/* Vandegrift HS colors: black, white, silver. Data ink stays monochrome; the only hues
   are reserved status colors (missing work, grade deltas), always paired with a glyph. */
:root {
  color-scheme: light;
  --page: #f4f4f2;
  --surface: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --silver: #a7a9ac;
  --header-bg: #0b0b0b;
  --header-ink: #ffffff;
  --data: #1f1f1f;
  --data-wash: rgba(31, 31, 31, 0.06);
  --good: #006300;
  --bad: #b42323;
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.08);
  --fail-band: rgba(208, 59, 59, 0.09);
  --ring: rgba(11, 11, 11, 0.10);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --axis: #383835;
    --silver: #c0c2c5;
    --header-bg: #000000;
    --data: #e8e8e6;
    --data-wash: rgba(232, 232, 230, 0.07);
    --good: #0ca30c;
    --bad: #e66767;
    --critical-wash: rgba(208, 59, 59, 0.16);
    --fail-band: rgba(230, 103, 103, 0.10);
    --ring: rgba(255, 255, 255, 0.10);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.secondary { color: var(--ink-2); }

/* Header: black bar with a silver rule, like the school's athletics marks. */
header.site { background: var(--header-bg); color: var(--header-ink); border-bottom: 3px solid var(--silver); }
header.site .inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none; display: flex; align-items: baseline; gap: 10px; }
.brand .v { font-size: 22px; }
.brand .sub { font-size: 12px; color: var(--silver); letter-spacing: 0.14em; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a { text-decoration: none; padding: 6px 12px; border-radius: 6px; color: #d6d7d9; font-weight: 500; }
nav.tabs a:hover { background: rgba(255,255,255,0.08); }
nav.tabs a[aria-current="page"] { color: #fff; background: rgba(255,255,255,0.14); }
.status { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #c9cacc; }
.status .err { color: #ff9a9a; }
.status button { font: inherit; font-weight: 600; color: #0b0b0b; background: var(--silver); border: 0; border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.status button:hover { background: #d4d5d7; }
.status button:disabled { opacity: 0.6; cursor: default; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-2); margin: 36px 0 12px; display: flex; align-items: center; gap: 12px; }
h2::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.lede { color: var(--ink-2); margin: 0 0 8px; }
.narrow { display: none; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); }

/* Class cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.class-card { padding: 14px 16px 10px; text-decoration: none; display: flex; flex-direction: column; gap: 2px; transition: box-shadow 120ms; }
.class-card:hover { box-shadow: 0 0 0 1px var(--silver), 0 2px 8px rgba(0,0,0,0.06); }
.class-card .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.class-card .row { display: flex; align-items: baseline; gap: 10px; }
.class-card .avg { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.class-card .sub { font-size: 13px; min-height: 19px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.class-card .avg.none { font-size: 15px; font-weight: 500; color: var(--muted); padding: 12px 0; }
.class-card .meta { font-size: 12px; color: var(--muted); }
.class-card .spark { margin-top: 6px; }

.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

.chip-missing { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--critical); background: var(--critical-wash); border-radius: 999px; padding: 1px 8px; }

/* Segmented preset control */
.filters { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.seg { display: inline-flex; background: var(--surface); box-shadow: 0 0 0 1px var(--ring); border-radius: 8px; padding: 2px; }
.seg a { text-decoration: none; padding: 3px 12px; border-radius: 6px; color: var(--ink-2); font-weight: 500; }
.seg a:hover { background: var(--data-wash); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--surface); }

/* Change feed */
.feed { padding: 4px 0; }
.day { padding: 10px 16px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.change { display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; padding: 8px 16px; align-items: baseline; border-top: 1px solid var(--hairline); }
.day + .change { border-top: 0; }
.kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.kind.new { color: var(--ink); }
.kind.removed { color: var(--muted); text-decoration: line-through; }
.change .what { min-width: 0; }
.change .what .course { font-size: 12px; color: var(--muted); }
.change .what .detail { font-size: 13px; color: var(--ink-2); }
.change .score { font-weight: 650; text-align: right; white-space: nowrap; }
.empty { padding: 20px 16px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px 6px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid var(--hairline); vertical-align: baseline; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.missing td { background: var(--critical-wash); }
tr.ungraded td { color: var(--muted); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--silver); outline-offset: 4px; border-radius: 4px; }
.chart .grid-line { stroke: var(--hairline); stroke-width: 1; }
.chart .grid-label, .chart .x-label, .chart .seg-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .seg-label { font-weight: 600; letter-spacing: 0.06em; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .seg-divider { stroke: var(--hairline); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--data); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--data-wash); }
.chart .dot { fill: var(--data); stroke: var(--surface); stroke-width: 2; }
.chart .line.below { stroke: var(--bad); }
.chart .dot.below { fill: var(--bad); }
.chart .fail-band { fill: var(--fail-band); }
.chart .threshold { stroke: var(--bad); stroke-width: 1; opacity: 0.55; }
.chart .threshold-label { fill: var(--ink-2); font-weight: 650; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); box-shadow: 0 0 0 1px var(--ring), 0 6px 20px rgba(0,0,0,0.14); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 160px; max-width: 280px; }
.tooltip .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tooltip .d { color: var(--muted); }
.tooltip ul { margin: 6px 0 0; padding: 6px 0 0; list-style: none; border-top: 1px solid var(--hairline); }
.tooltip li { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-2); }
.tooltip li b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tooltip[hidden] { display: none; }

.big-chart { padding: 16px 16px 8px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.multiple { padding: 12px 14px 6px; }
.multiple .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.multiple .head a { font-weight: 600; text-decoration: none; }
.multiple .head a:hover { text-decoration: underline; }

.course-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.hero { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 12px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }

@media (max-width: 640px) {
  .wide { display: none; }
  .narrow { display: inline; }

  /* One-line header. */
  header.site .inner { padding: 8px 12px; gap: 12px; flex-wrap: nowrap; }
  .brand .v { font-size: 19px; }
  .brand .sub { display: none; }
  nav.tabs a { padding: 5px 9px; }
  .status { gap: 8px; font-size: 12px; white-space: nowrap; }
  .status button { padding: 3px 9px; font-size: 14px; }
  main { padding-top: 12px; }

  /* Name and period on one line. */
  .title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
  .title-row h1 { font-size: 18px; margin: 0; }
  .title-row .lede { font-size: 13px; margin: 0; }
  .lede .explain { display: none; }

  /* Class cards collapse into one list: name and status left, sparkline, average right. */
  .grid { display: block; background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); }
  .class-card { display: grid; grid-template-columns: minmax(0, 1fr) 76px 78px; grid-template-areas: "name spark avg" "sub spark avg";
                column-gap: 10px; row-gap: 0; align-items: center; padding: 8px 14px; box-shadow: none; border-radius: 0; border-top: 1px solid var(--hairline); }
  .class-card:first-child { border-top: 0; }
  .class-card:hover { box-shadow: none; background: var(--data-wash); }
  .class-card .name { grid-area: name; }
  .class-card .sub { grid-area: sub; font-size: 12px; min-height: 18px; gap: 6px; flex-wrap: nowrap; }
  .class-card .sub .sfx { display: none; }
  .class-card .sub .delta, .class-card .chip-missing { font-size: 12px; }
  .class-card .spark { grid-area: spark; margin: 0; }
  .class-card .avg { grid-area: avg; font-size: 21px; text-align: right; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .class-card .avg.none { grid-column: 2 / -1; font-size: 13px; padding: 0; }
  .class-card .meta { display: none; }

  .hero { font-size: 44px; }
  .change { grid-template-columns: 1fr auto; }
  .change .kind { grid-column: 1 / -1; }
}

/* Login */
.login { max-width: 360px; margin: 48px auto 0; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login .lede { margin: 0; }
.login-err { margin: 0; color: var(--bad); font-weight: 600; font-size: 14px; }
.login input[type="password"] { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 8px; border: 0; box-shadow: 0 0 0 1px var(--ring); background: var(--page); color: var(--ink); }
.login button { font: inherit; font-weight: 600; padding: 10px 12px; border: 0; border-radius: 8px; background: var(--ink); color: var(--surface); cursor: pointer; }
