/* site.css — page shell (base type, app header, footer, flash, error and
   start pages), shared controls, the Admin page and the drawer. Colours
   come from tokens.css, and User type colours from /usertypes.css (--ut on
   the ut-N classes). */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; line-height: 1.45;
	min-height: 100vh; display: flex; flex-direction: column;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--brand); }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

.wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.wrap { flex: 1; padding-block: 16px; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; z-index: 20; background: var(--card); padding: 6px 10px; border-radius: var(--radius); }

/* App header */
.apphead { background: var(--brand); color: var(--brand-fg); }
.apphead .wrap { display: flex; align-items: center; gap: 16px; padding-block: 12px; flex-wrap: wrap; }
.org { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; color: var(--brand-fg); text-decoration: none; }
.org-logo { height: 32px; width: auto; max-width: 120px; object-fit: contain; border-radius: 4px; }
.landing-logo { display: block; max-height: 96px; max-width: 100%; width: auto; margin-bottom: 12px; }
.apphead nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.apphead nav a { color: var(--brand-fg); opacity: .8; text-decoration: none; padding: 4px 10px; border-radius: var(--radius); font-size: 13px; }
.apphead nav a[aria-current] { opacity: 1; background: rgba(255, 255, 255, .12); }
.who { font-size: 13px; opacity: .9; display: flex; align-items: center; gap: 8px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.site-footer p { margin: 0; padding-block: 12px; }

/* Flash messages */
.flash { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); background: var(--card); padding: 10px 14px; margin-bottom: 16px; }
.flash-error { border-left-color: var(--error); }
.flash-success { border-left-color: var(--success); }
/* The Admins' stale-extender warning, under the app header on every page. */
.sysbanner { background: var(--card); border-bottom: 1px solid var(--border); border-left: 4px solid var(--error); padding: 10px 0; font-weight: 600; }

/* Start and error pages */
.landing, .error, .no-access, .dev-identity { max-width: 560px; margin: 48px auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.landing h1, .error h1, .no-access h1, .dev-identity h1 { margin-top: 0; font-size: 22px; }
.error h1 { color: var(--error); }

.who-meta { opacity: .75; }

/* The one primary action button (Sign in, the dev switcher's Use) */
.button { display: inline-block; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: var(--radius); padding: 8px 16px; text-decoration: none; font-weight: 600; }
.button:disabled { opacity: .5; cursor: default; }

/* Dev identity switcher (deployDev / deployLocal only) */
.dev-identity { max-width: 760px; }
.dev-identity ul { list-style: none; margin: 0; padding: 0; }
.dev-identity li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 10px; border-top: 1px solid var(--border); }
.dev-identity li > div { flex: 1; min-width: 200px; }
.dev-identity .muted { color: var(--muted); font-size: 13px; }

/* Shared controls */
.btn { display: inline-block; border: 1px solid var(--border); background: var(--card); color: var(--fg); border-radius: var(--radius); padding: 7px 14px; font-weight: 600; text-decoration: none; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.icon { padding: 3px 9px; font-weight: 400; }
.button.danger { background: var(--error); color: var(--card); }
a.danger { color: var(--error); }
.note, .hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.empty { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.row > * { flex: 1; min-width: 120px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }

/* Admin page: tabs, then the active tab's panel */
.admin { max-width: 880px; }
.admin h1 { font-size: 22px; margin: 0 0 12px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; margin: 0; margin-right: auto; }
.tabpanel .flash { margin-bottom: 0; }
.admintable { width: 100%; border-collapse: collapse; }
.admintable th, .admintable td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); }
.admintable thead th { border-top: 0; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.admintable td a { font-weight: 600; text-decoration: none; }
.admintable td a:hover { text-decoration: underline; }
.admintable .order { text-align: right; white-space: nowrap; width: 1%; }
.admintable .order form { display: inline-flex; gap: 4px; margin: 0; }
.tablewrap { overflow-x: auto; }
/* My bookings: a Series' line under its Event, and its listed dates. */
.mylist td { vertical-align: top; }
.mylist td.num { white-space: nowrap; }
.mylist .series-line { margin-top: 2px; font-size: 13px; }
.mylist .series-line a { font-weight: 400; margin-left: 6px; }
.mylist tr.occurrence td { border-top-style: dashed; }
.mylist tr.occurrence td:first-child { padding-left: 22px; }
/* Admin › Bookings: the filter form, and Cancelled rows. */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px 14px; align-items: end; margin: 12px 0; }
.filters .field.check { align-self: center; }
.filters .actions { display: flex; gap: 12px; align-items: center; }
.adminbookings .series-mark { margin-left: 4px; cursor: help; }
.adminbookings tr.cancelled td { color: var(--muted); }
.adminbookings tr.cancelled td a { text-decoration: line-through; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); font-size: 12px; font-weight: 400; }
.archived { margin-top: 20px; }
.archived summary { cursor: pointer; color: var(--muted); }
.archived ul { margin: 8px 0 0; padding-left: 20px; }
.archived .note { margin-top: 6px; }
.muted { color: var(--muted); }

/* Drawer: a side panel, a bottom sheet under 600px (the booking panel's shape) */
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 30, .35); z-index: 40; }
.drawer {
	position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--card); z-index: 41; box-shadow: var(--shadow);
	padding: calc(18px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) 20px;
	overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
@media (max-width: 600px) {
	.drawer { top: auto; left: 0; width: 100%; max-height: 88%; border-radius: 14px 14px 0 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
@media (prefers-reduced-motion: no-preference) {
	.drawer { animation: drawer-in .16s ease-out; }
	@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } }
}
.drawer-head { display: flex; align-items: baseline; gap: 12px; }
.drawer-head h2 { margin: 0; font-size: 18px; margin-right: auto; text-wrap: balance; }
.drawer-close { font-size: 13px; }
.drawer-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.drawer-form p { margin: 0; }
.drawer-foot { margin: 0; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; }
.field input { border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius); padding: 7px 9px; width: 100%; }
.field input[aria-invalid] { border-color: var(--error); }
.field textarea, .field select { border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius); padding: 7px 9px; width: 100%; }
.field textarea { resize: vertical; min-height: 6em; }
.field textarea[aria-invalid], .field select[aria-invalid] { border-color: var(--error); }
.field.check label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.field.check input { width: auto; margin: 0; }
.field-error { color: var(--error); font-size: 13px; margin: 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.field input[type="file"] { padding: 6px; }
.image-preview { display: block; max-width: 100%; max-height: 160px; width: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.resource-photo { display: block; max-width: 100%; max-height: 320px; width: auto; border-radius: var(--radius); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.preline { white-space: pre-line; overflow-wrap: anywhere; margin: 0; }

/* Calendar day grid (the approved prototype's variant A). Rows are
   Resources, columns Periods; the first column sticks and the grid scrolls
   sideways on a phone. */
.calendar { display: flex; flex-direction: column; gap: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding-bottom: 14px; }
.datenav { display: flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }
.iconbtn { display: inline-block; border: 1px solid var(--border); background: var(--card); color: var(--fg); border-radius: var(--radius); padding: 5px 10px; min-width: 34px; text-align: center; text-decoration: none; line-height: 1.45; }
.iconbtn[aria-current] { border-color: var(--accent); color: var(--accent); }
.datepick { border: 1px solid var(--border); background: var(--card); border-radius: var(--radius); padding: 4px 8px; }
.datelabel { font-weight: 650; font-size: 16px; margin: 0; min-width: 0; text-wrap: balance; flex: 1 1 14em; }
.grouptabs { display: flex; gap: 4px; flex-wrap: wrap; }
.grouptabs a { border: 1px solid transparent; padding: 5px 12px; border-radius: var(--radius-pill); font-size: 13px; color: var(--muted); text-decoration: none; }
.grouptabs a[aria-current] { border-color: var(--border); background: var(--card); color: var(--fg); font-weight: 600; }
.grouptabs .count { color: var(--muted); font-weight: 400; margin-left: 4px; }

.gridwrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 560px; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 4px; vertical-align: top; }
.grid tr > *:last-child { border-right: 0; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid thead th { background: var(--bg); text-align: left; font-weight: 600; padding: 8px 10px; font-size: 13px; }
.grid th small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.grid tbody th { text-align: left; font-weight: 600; padding: 8px 10px; position: sticky; left: 0; background: var(--card); z-index: 1; width: 170px; }
.grid thead th:first-child { position: sticky; left: 0; z-index: 2; }
.grid tbody th a { color: var(--fg); text-decoration: none; }
.grid tbody th a:hover, .grid tbody th a:focus-visible { color: var(--accent); text-decoration: underline; }
.grid td { height: 58px; min-width: 120px; }

/* Cells. A booked cell's colours derive from its User type's --ut. */
.bk {
	display: flex; flex-direction: column; gap: 1px; border-radius: 4px; padding: 6px 8px; font-size: 12.5px; line-height: 1.3; min-height: 100%;
	background: color-mix(in srgb, var(--ut, var(--accent)) var(--ut-fill), var(--card));
	color: color-mix(in srgb, var(--ut, var(--accent)) var(--ut-text), var(--fg));
	border-left: 3px solid var(--ut, var(--accent));
}
.bk .nm { font-weight: 650; overflow-wrap: anywhere; }
.bk .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk .rep { font-size: 11px; }
.bk.mine { box-shadow: inset 0 0 0 2px currentColor; }
a.bk { text-decoration: none; }
a.bk:hover .nm, a.bk:focus-visible .nm { text-decoration: underline; }
.free { display: block; min-height: 100%; border: 1px dashed transparent; border-radius: 4px; color: var(--muted); font-size: 12.5px; padding: 6px 8px; text-decoration: none; }
a.free:hover, a.free:focus-visible { border-color: var(--accent); color: var(--accent); background: var(--card); }
.na { display: flex; align-items: center; min-height: 100%; border-radius: 4px; padding: 6px 8px; font-size: 12px; color: var(--muted); background: repeating-linear-gradient(45deg, var(--hatch) 0 5px, transparent 5px 10px); }

/* Legend */
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 12px 0 0; margin: 0; list-style: none; align-items: center; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: color-mix(in srgb, var(--ut, var(--accent)) var(--ut-fill), var(--card)); border: 1px solid var(--ut, var(--accent)); }
.sw.free { background: var(--card); border-color: var(--border); }
.sw.hatch { background: repeating-linear-gradient(45deg, var(--hatch) 0 4px, var(--card) 4px 8px); border-color: var(--border); }
.sw.mine { background: transparent; border: 0; box-shadow: inset 0 0 0 2px var(--fg); }

/* Booking panel */
.drawer-sub { color: var(--muted); margin: -8px 0 0; font-size: 13px; }
.chip {
	display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--radius-pill); font-size: 12px; margin-left: 4px;
	background: color-mix(in srgb, var(--ut, var(--accent)) var(--ut-fill), var(--card));
	color: color-mix(in srgb, var(--ut, var(--accent)) var(--ut-text), var(--fg));
}

/* Toast: a short result over a refreshed grid; calendar.js hides it. */
.toast {
	position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60;
	background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: var(--radius); font-size: 13px; max-width: calc(100% - 32px);
	box-shadow: var(--shadow);
}
.toast-error { border-left: 4px solid var(--error); }

/* Repeat: the weekly and end controls show only for the patterns that use
   them (CSS alone; the panel has no script). */
.repeat:has(#f-freq option[value="none"]:checked) .repeat-weekly,
.repeat:has(#f-freq option[value="none"]:checked) .repeat-end,
.repeat:has(#f-freq option[value="daily"]:checked) .repeat-weekly { display: none; }
.repeat .inline, .scope .inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.repeat .inline input[type="radio"], .scope .inline input[type="radio"], .repeat .inline input[type="checkbox"] { margin: 0; }
.repeat .num-in { width: 4.5em; border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius); padding: 4px 6px; }
.repeat input[type="date"] { border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius); padding: 4px 6px; }
.repeat-weekly, .repeat-end { display: flex; flex-direction: column; gap: 8px; }
.days { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.days label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.series-preview { display: flex; flex-direction: column; gap: 6px; }
.series-preview:empty { display: none; }
.preview { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 260px; overflow-y: auto; }
.preview li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.preview li:last-child { border-bottom: 0; }
.preview .ok, .preview .more { color: var(--muted); }
.preview .more { font-style: italic; }
.preview .clash { color: var(--error); }
.preview label.clash { font-size: 13px; }
