/* Carpool — visual identity.
   Palette sampled from The Howard School's own colours (deep teal / bright cyan
   / pale sky) so the app feels of-a-piece with the school, on a warm neutral
   ground so it reads friendly rather than clinical. We use the COLOURS only —
   no school logo, no implied endorsement: this is a parent-run tool.

   Accessibility rules held throughout:
   - body text >= 4.5:1 on its background (WCAG AA)
   - selected vs unselected NEVER relies on hue alone — a selected cell also
     carries a check glyph and a solid (not dashed) border, so the grids work
     for colour-blind parents and in bright sun at 7:25am.
   - tap targets >= 44px. */

:root {
  --teal-900: #0a5169;   /* darkest — high-contrast type */
  --teal-700: #006585;   /* deep — headers, active tab, primary text accent */
  --cyan-500: #06a8e1;   /* bright — primary actions, selected toggles */
  --sky-200:  #95ddee;   /* pale — subtle fills, info surfaces */
  --sky-050:  #e8f6fb;   /* barely-there tint for selected cell backgrounds */

  --ink:      #22303a;   /* body text */
  --ink-soft: #5a6b76;   /* secondary text */
  --paper:    #fbf9f5;   /* warm neutral page */
  --card:     #ffffff;
  --line:     #e3ded4;   /* warm hairline */
  --line-firm:#cfc7b8;

  /* semantic — deliberately outside the brand ramp so status never reads as
     decoration. Green/amber/red keep their conventional meaning. */
  --ok:    #1f7a4d;
  --ok-bg: #e7f4ec;
  --warn:  #8a5a00;
  --warn-bg:#fdf1dc;
  --bad:   #a32c1e;
  --bad-bg:#fbeae7;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 81, 105, .06), 0 4px 14px rgba(10, 81, 105, .07);
  --shadow-lift: 0 2px 6px rgba(10, 81, 105, .10), 0 10px 26px rgba(10, 81, 105, .10);
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));  /* clear the tab bar */
}
[hidden] { display: none !important; }

/* ── typographic scale ───────────────────────────────────────────────────── */
h1 { font-size: 1.5rem;  line-height: 1.25; margin: 0 0 .2rem; color: var(--teal-900); letter-spacing: -.01em; }
h2 { font-size: 1.15rem; line-height: 1.3;  margin: 1.4rem 0 .5rem; color: var(--teal-700); }
h3 { font-size: .95rem;  margin: 0 0 .35rem; color: var(--teal-900); }
.sub  { color: var(--ink-soft); font-size: .9rem; }
.tiny { color: var(--ink-soft); font-size: .8rem; }
.dim  { color: var(--ink-soft); }
a { color: var(--teal-700); }

/* ── shell ───────────────────────────────────────────────────────────────── */
#app, .wrap { max-width: 780px; margin: 0 auto; padding: 14px 14px 24px; }

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--teal-700), var(--teal-900));
  color: #fff; box-shadow: var(--shadow);
}
.appbar img.avatar { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex: none;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.appbar .who { font-weight: 650; font-size: 1rem; line-height: 1.15; }
.appbar .role { font-size: .72rem; opacity: .85; letter-spacing: .03em; text-transform: uppercase; }
.appbar .spacer { flex: 1; }
.appbar button, .appbar select {
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.28);
  border-radius: 9px; padding: 7px 11px; font-size: .82rem; min-height: 36px; max-width: 190px;
}
.appbar select option { color: var(--ink); }

/* hero — the school building, with a teal scrim so type stays legible */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
        margin: 0 0 4px; }
.hero img { display: block; width: 100%; max-height: 190px; object-fit: cover; }
.hero .scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,101,133,.10) 0%, rgba(10,81,105,.84) 100%);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 14px 16px;
}
.hero h1 { color: #fff; }
.hero .sub { color: #fff; opacity: .93; }

/* ── cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 12px 0; box-shadow: var(--shadow);
}
.card.flush { padding: 0; overflow: hidden; }
.card h3 { display: flex; align-items: center; gap: 8px; }

.banner {
  border-radius: var(--radius); padding: 12px 14px; margin: 12px 0;
  background: var(--sky-050); border: 1px solid var(--sky-200); color: var(--teal-900);
  display: flex; gap: 10px; align-items: flex-start; font-size: .93rem;
}
.banner.ok   { background: var(--ok-bg);   border-color: #b9dfc9; color: var(--ok); }
.banner.warn { background: var(--warn-bg); border-color: #f0d5a0; color: var(--warn); }
.banner.bad  { background: var(--bad-bg);  border-color: #f0c2ba; color: var(--bad); }

/* status pill — a text label is always present, never colour alone */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 10px; font-size: .74rem; font-weight: 650;
  letter-spacing: .02em; text-transform: uppercase;
  background: var(--sky-050); color: var(--teal-700); border: 1px solid var(--sky-200);
}
.pill.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: #b9dfc9; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d5a0; }
.pill.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: #f0c2ba; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
button, .btn {
  font: inherit; border-radius: 11px; border: 1px solid var(--line-firm);
  background: var(--card); color: var(--ink); padding: 10px 14px; min-height: var(--tap);
  cursor: pointer; transition: background .12s, box-shadow .12s, transform .04s;
}
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: 3px solid var(--cyan-500); outline-offset: 2px; }
.primary, .btn-primary {
  background: var(--cyan-500); border-color: var(--cyan-500); color: #fff; font-weight: 650;
}
.primary:hover, .btn-primary:hover { background: #0596c9; }
.ghost, .btn-quiet { background: transparent; border-color: transparent; color: var(--teal-700); padding: 8px 10px; }
.btn-sm { min-height: 36px; padding: 6px 10px; font-size: .85rem; border-radius: 9px; }
.btn-danger { color: var(--bad); border-color: #f0c2ba; background: var(--bad-bg); }

input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line-firm); border-radius: 10px; padding: 10px 12px;
  min-height: var(--tap); width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--sky-200); outline-offset: 1px; border-color: var(--cyan-500); }
label.field { display: block; margin: 10px 0 0; }
label.field > span { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: 4px; }
label.check { display: flex; align-items: center; gap: 9px; min-height: var(--tap); font-size: .93rem; }
label.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--cyan-500); }
.err { color: var(--bad); font-size: .88rem; }

/* sign-in / claim screen */
#login, #enroll { max-width: 460px; margin: 0 auto; }
#pin, #enrollPin, #enrollPin2 { letter-spacing: 4px; text-align: center; font-size: 1.15rem; }

/* ── week selector ───────────────────────────────────────────────────────── */
.weekbar {
  display: flex; align-items: center; gap: 6px; margin: 12px 0 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px; box-shadow: var(--shadow);
}
.weekbar button { min-width: var(--tap); min-height: var(--tap); border: none; background: transparent;
  color: var(--teal-700); font-size: 1.15rem; border-radius: 10px; padding: 0; }
.weekbar button:disabled { color: var(--line-firm); cursor: default; }
.weekbar .label { flex: 1; text-align: center; line-height: 1.2; }
.weekbar .label strong { display: block; color: var(--teal-900); font-size: .98rem; }
.weekbar .label small { color: var(--ink-soft); font-size: .78rem; }

/* ── the ride / drive grid — the heart of the app ────────────────────────── */
.gridwrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: separate; border-spacing: 6px; }
.grid th {
  font-size: .76rem; font-weight: 650; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .04em; padding-bottom: 2px; text-align: center;
}
.grid th.rowhead, .grid td.rowhead {
  text-align: left; font-size: .92rem; color: var(--teal-900); font-weight: 650;
  white-space: nowrap; padding-right: 4px; text-transform: none; letter-spacing: 0;
}
.cell {
  width: 100%; min-height: var(--tap); height: 46px; padding: 0;
  border: 2px dashed var(--line-firm); border-radius: 12px;
  background: var(--card); color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 700;
}
.cell::after { content: "+"; font-weight: 400; font-size: 1.15rem; opacity: .5; }
.cell[aria-pressed="true"] {
  border-style: solid; border-color: var(--cyan-500);
  background: var(--sky-050); color: var(--teal-700);
  box-shadow: inset 0 0 0 1px var(--cyan-500);
}
.cell[aria-pressed="true"]::after { content: "✓"; opacity: 1; font-weight: 800; }
.cell:disabled { opacity: .5; cursor: not-allowed; }
.cell.locked { border-style: solid; border-color: var(--line); background: #f6f3ee; }
.gridnote { font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--line); font-size: .9rem; }

/* ── lists / directory ───────────────────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.listrow {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 12px 14px; background: transparent; border: none; border-radius: 0; min-height: 60px;
}
.listrow:hover { background: var(--sky-050); }
a.listrow { text-decoration: none; color: inherit; }
.avatar-sm { width: 44px; height: 44px; border-radius: 11px; object-fit: cover; flex: none;
  background: var(--sky-050); border: 1px solid var(--line); }
.avatar-sm.placeholder { display: flex; align-items: center; justify-content: center;
  color: var(--teal-700); font-weight: 700; font-size: 1rem; }
.listrow .grow { flex: 1; min-width: 0; }
.listrow .name { font-weight: 650; color: var(--teal-900); }
.listrow .meta { font-size: .84rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--line-firm); font-size: 1.2rem; flex: none; }

.photostrip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; }
.photostrip figure { margin: 0; flex: none; width: 96px; }
.photostrip img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); display: block; }
.photostrip figcaption { font-size: .7rem; color: var(--ink-soft); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── self-explaining UI ──────────────────────────────────────────────────────
   A phone has no hover, so every tab opens with a "What is this?" button that
   toggles the same sentence the desktop shows on hover. Neither is a modal:
   nothing ever stands between a parent and the grid. */
.whatis {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 5px 11px; margin: 2px 0 0;
  font-size: .82rem; color: var(--teal-700);
  background: var(--sky-050); border: 1px solid var(--sky-200); border-radius: 999px;
}
.explainer { margin-top: 8px; }
[data-tip] { position: relative; }

@media (hover: hover) and (min-width: 900px) {
  .whatis { display: none; }              /* desktop hovers instead */
  [data-tip] { cursor: help; }
  [data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
    width: max-content; max-width: 320px; padding: 9px 11px;
    background: var(--teal-900); color: #fff; border-radius: 10px;
    font-size: .8rem; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: 0;
    box-shadow: var(--shadow-lift);
    opacity: 0; visibility: hidden; transition: opacity .12s;
  }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; }
}

/* ── icons ───────────────────────────────────────────────────────────────────
   One shared line-icon style. Everything inherits currentColor so an icon in a
   warning banner is amber and the same icon in a card is teal, with no extra
   markup. */
svg.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.banner svg.ico { margin-top: 1px; }

/* ── empty states that teach ─────────────────────────────────────────────── */
.empty { text-align: center; padding: 22px 16px; }
.empty .icon { line-height: 1; margin-bottom: 10px; color: var(--sky-200); }
.empty .icon svg.ico { width: 34px; height: 34px; stroke-width: 1.5; }
.empty p { margin: 0 0 12px; color: var(--ink-soft); max-width: 34ch;
  margin-left: auto; margin-right: auto; }

/* ── coach marks — per tab, non-blocking, dismissible ────────────────────── */
.coach {
  position: fixed; left: 10px; right: 10px; bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 30; background: var(--teal-900); color: #fff; border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow-lift); display: flex; gap: 10px; align-items: flex-start;
}
.coach p { margin: 0; font-size: .9rem; flex: 1; }
.coach button { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.3);
  min-height: 34px; padding: 5px 10px; font-size: .82rem; }

/* ── tab bar (phone) ─────────────────────────────────────────────────────── */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 14px rgba(10,81,105,.06);
}
#tabbar button {
  position: relative; flex: 1; border: none; background: transparent; border-radius: 0;
  padding: 7px 2px 8px; min-height: 58px; color: var(--ink-soft);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .66rem; font-weight: 600; letter-spacing: .01em;
}
#tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#tabbar button[aria-selected="true"] { color: var(--teal-700); }
#tabbar button[aria-selected="true"] svg { stroke: var(--cyan-500); }
#tabbar button[aria-selected="true"]::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--cyan-500);
}
.badge {
  position: absolute; top: 5px; left: 50%; transform: translateX(6px);
  min-width: 17px; height: 17px; border-radius: 999px; background: var(--cyan-500); color: #fff;
  font-size: .64rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ── desktop: sidebar + two columns, not a stretched phone ───────────────── */
@media (min-width: 900px) {
  /* The grid goes on #main, NOT on body: body's children are the signed-out
     screens and the app shell, so a grid there put the whole shell in one
     column and left the sidebar rendering full-width inside it. */
  body { padding-bottom: 0; }
  #main { display: grid; grid-template-columns: 236px 1fr; grid-template-rows: auto 1fr;
          min-height: 100vh; align-content: start; }
  .appbar { grid-column: 1 / -1; }
  #content { min-width: 0; }
  #tabbar {
    position: sticky; top: 0; align-self: start; height: auto;
    flex-direction: column; border-top: none; border-right: 1px solid var(--line);
    padding: 12px 10px; gap: 4px; box-shadow: none; background: transparent;
  }
  #tabbar button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 11px;
    padding: 11px 13px; border-radius: 11px; font-size: .92rem; min-height: var(--tap);
    text-align: left; letter-spacing: 0;
  }
  #tabbar button[aria-selected="true"] { background: var(--sky-050); }
  #tabbar button[aria-selected="true"]::before { display: none; }
  #tabbar button svg { width: 20px; height: 20px; }
  .badge { position: static; transform: none; margin-left: auto; }
  #app { max-width: 1040px; padding: 20px 26px 40px; }
  .wrap { max-width: 900px; margin: 0; padding: 20px 26px 40px; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  .cols > .card { margin-top: 0; }
  .hero img { max-height: 230px; }
  .coach { left: auto; right: 24px; bottom: 24px; max-width: 380px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ═══ shared vocabulary for the standalone consoles ══════════════════════════
   czar.html, pickup.html and admin.html are separate pages that link this same
   stylesheet and have always relied on it for their layout primitives. They are
   NOT part of the tab-shell rewrite, so these classes keep their original
   semantics — only the colours move to the school palette. Deleting them once
   silently flattened all three consoles into unstyled text. */
.wrap { max-width: 780px; margin: 0 auto; padding: 14px 14px 40px; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.2rem; margin: 0; }
.back { color: var(--ink-soft); text-decoration: none; font-size: .88rem; }
.note, .muted { color: var(--ink-soft); font-size: .82rem; }
.h2 { font-weight: 700; font-size: .95rem; color: var(--teal-900); }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

/* .row here is a LIST row (a line of a schedule), not a flex form row — the
   consoles stack their content. Form rows in the tab shell use .formrow. */
.row { padding: 5px 0; font-size: .95rem; }
.row.struck { text-decoration: line-through; color: var(--ink-soft); }
.row.spread, .row .spread, .spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.formrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn.wide { width: 100%; }
.btn.on { border-color: var(--cyan-500); background: var(--sky-050); font-weight: 650; }
.mini { min-height: 34px; padding: 5px 10px; font-size: .78rem; border-radius: 9px; }
.danger { color: var(--bad); border-color: #f0c2ba; background: var(--bad-bg); }

.rider {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px;
  background: var(--card); border: 1px solid var(--line-firm); border-radius: 12px;
  font-size: 1rem; text-align: left; min-height: var(--tap);
}
.rider.on { background: var(--ok-bg); border-color: var(--ok); }
.rider.struck { opacity: .5; text-decoration: line-through; }
.rider .check { font-size: 1.25rem; width: 24px; color: var(--ok); }

.preview {
  background: var(--sky-050); border: 1px solid var(--sky-200); border-radius: 10px;
  padding: 10px 12px; white-space: pre-wrap; font-size: .82rem; margin: 8px 0; font-family: inherit;
}
.lbl { font-weight: 650; font-size: .88rem; display: block; margin-bottom: 6px; }
textarea { min-height: 88px; }
.compact #shiftList { max-height: 96px; overflow: auto; }
