/* =====================================================================
   AUH Attendance — shared design system
   Type: Atkinson Hyperlegible Next (built for character disambiguation —
   PINs and enrolment numbers read correctly from the back of a classroom)
   with Archivo (expanded width) for headings and the projector PIN.
   ===================================================================== */
@font-face { font-family: 'Atkinson Next'; src: url(fonts/atkinson-hyperlegible-next-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url(fonts/atkinson-hyperlegible-next-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Archivo'; src: url(fonts/archivo-latin-wdth-normal.woff2) format('woff2-variations'); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }

:root {
  --ink: #10264a;          /* Amity navy — text & brand */
  --blue: #1e4fa3;         /* actions */
  --blue-weak: #e7eefb;
  --gold: #f2b227;         /* marigold accent — used sparingly */
  --gold-ink: #6b4a00;
  --paper: #f5f6f9;
  --surface: #ffffff;
  --line: #dde2ec;
  --line-strong: #c3cbda;
  --muted: #5b6780;
  --present: #1f8a4c; --present-bg: #e3f4ea;
  --late: #a8660b;    --late-bg: #fdf1dc;
  --absent: #c2382f;  --absent-bg: #fbe6e4;
  --excused: #4f55c4; --excused-bg: #e9eafb;
  --focus: #f2b227;
  --radius-s: 6px; --radius-m: 10px; --radius-l: 16px;
  --shadow: 0 1px 2px rgba(16, 38, 74, .06), 0 8px 24px -12px rgba(16, 38, 74, .18);
  --font: 'Atkinson Next', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Archivo', 'Atkinson Next', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7ecf6; --blue: #7aa7ff; --blue-weak: #1b2b4d; --gold: #f5c04a; --gold-ink: #f5c04a;
    --paper: #0d1526; --surface: #141f36; --line: #26334f; --line-strong: #34446a; --muted: #9aa8c4;
    --present: #5fd08f; --present-bg: #12351f; --late: #f0b45a; --late-bg: #3a2a0f;
    --absent: #ff8a80; --absent-bg: #3d1716; --excused: #a9adff; --excused-bg: #24264d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink);
  background: var(--paper); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--display); font-stretch: 112%; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .75em; }
a { color: var(--blue); }
small, .muted { color: var(--muted); }
.muted { font-size: .92em; }
code, .code { font-family: var(--font); font-weight: 700; letter-spacing: .02em; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: inherit; font-weight: 700; font-size: .95rem; line-height: 1; min-height: 42px; padding: 0 1.05em;
  border-radius: var(--radius-s); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--blue); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2b1d00; }
.btn.danger { color: var(--absent); border-color: color-mix(in srgb, var(--absent) 45%, var(--line)); }
.btn.danger:hover { background: var(--absent-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--blue-weak); }
.btn.small { min-height: 32px; padding: 0 .7em; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 1.1rem; border-radius: var(--radius-m); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
label.field > small { display: block; margin-top: .25rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%; min-height: 42px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: .5rem .7rem;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent); outline-offset: 0; border-color: var(--blue); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--blue); }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .75rem; }
.check input { margin-top: .3rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-error { background: var(--absent-bg); color: var(--absent); border-radius: var(--radius-s); padding: .6rem .8rem; margin-bottom: .9rem; font-weight: 700; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.1rem 1.2rem; }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: .3em; font-size: .8rem; font-weight: 700; padding: .15em .6em; border-radius: 999px; background: var(--blue-weak); color: var(--blue); white-space: nowrap; }
.pill.present { background: var(--present-bg); color: var(--present); }
.pill.late { background: var(--late-bg); color: var(--late); }
.pill.absent { background: var(--absent-bg); color: var(--absent); }
.pill.excused { background: var(--excused-bg); color: var(--excused); }
.pill.live { background: var(--gold); color: #2b1d00; }
.pill.live::before { content: ''; width: .5em; height: .5em; border-radius: 50%; background: #c2382f; animation: blink 1.4s infinite; }
.pill.flag { background: var(--late-bg); color: var(--late); }
.pill.neutral { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 700; padding: .65rem .8rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 60%, var(--surface)); position: sticky; top: 0; z-index: 1; }
table.data td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--blue-weak); }
table.data td.num, table.data th.num { text-align: right; }
table.data td.actions { text-align: right; white-space: nowrap; }

/* ---------- Attendance bar with threshold tick ---------- */
.meter { position: relative; height: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; overflow: visible; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--present); }
.meter.warning > i { background: var(--late); }
.meter.shortage > i { background: var(--absent); }
.meter > b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); opacity: .7; }

/* ---------- Toasts & modals ---------- */
#toasts { position: fixed; z-index: 1000; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: .8rem 1rem; border-radius: var(--radius-m); box-shadow: var(--shadow); font-weight: 700; pointer-events: auto; animation: toast-in .2s ease-out; }
.toast.error { background: var(--absent); color: #fff; }
.toast.success { background: var(--present); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(9, 18, 36, .55); z-index: 900; display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-l); width: min(100%, 520px); max-height: calc(100vh - 2rem); overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(100%, 860px); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem .4rem; }
.modal header h2 { margin: 0; font-size: 1.2rem; }
.modal .body { padding: .6rem 1.25rem 1rem; }
.modal footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem 1.2rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Brand mark (text-based; drop your official logo at /assets/brand/logo.svg) ---------- */
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brand .mark { min-width: 34px; padding: 0 7px; height: 34px; border-radius: 8px; background: #10264a; color: var(--gold); display: grid; place-items: center; font-family: var(--display); font-stretch: 100%; font-weight: 800; font-size: .78rem; letter-spacing: .03em; flex: none; }
.brand .name { font-family: var(--display); font-stretch: 105%; font-weight: 700; line-height: 1.1; }
.brand .name small { display: block; font-family: var(--font); font-weight: 400; font-size: .78rem; color: var(--muted); }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 3rem; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.kbd { font-weight: 700; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; }
