/* analysis.html: the tab bar, plus the STAR offerings analyzer (star.js).
   styles.css supplies the site's color tokens and controls; this file adds
   the chart tokens (dataviz reference palette, validated light and dark --
   first three categorical slots all-pairs, blue sequential ramp) and layout. */

/* ---------- tabs ---------- */
.an-tabs { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.an-tab {
  font: inherit; font-size: 0.82rem; font-weight: 600; padding: 5px 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.an-tab:hover { color: var(--ink); }
.an-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.an-panel[hidden] { display: none; }

/* ---------- chart tokens ----------
   Also on the drawer and tooltip: star.js attaches those to <body>, outside
   .viz-root, and they draw with the same tokens. */
.viz-root, .st-drawer, .viz-tip {
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a;
  --seq-0: #f0efec; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5;
  --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --div-neg: #e34948; --div-pos: #2a78d6; --div-mid: #f0efec;
  --grid: #e1e0d9; --axis: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.viz-root, .st-drawer, .viz-tip) {
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70;
    --seq-0: #262624; --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #1c5cab;
    --seq-5: #2a78d6; --seq-6: #5598e7; --seq-7: #9ec5f4;
    --div-neg: #e66767; --div-pos: #3987e5; --div-mid: #383835;
    --grid: #2c2c2a; --axis: #383835;
  }
}
:root[data-theme="dark"] :is(.viz-root, .st-drawer, .viz-tip) {
  --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70;
  --seq-0: #262624; --seq-1: #0d366b; --seq-2: #104281; --seq-3: #184f95; --seq-4: #1c5cab;
  --seq-5: #2a78d6; --seq-6: #5598e7; --seq-7: #9ec5f4;
  --div-neg: #e66767; --div-pos: #3987e5; --div-mid: #383835;
  --grid: #2c2c2a; --axis: #383835;
}

/* ---------- layout ---------- */
.viz-root { padding: 0 16px 48px; }
.st-filters {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
  padding: 12px 0; background: var(--page); border-bottom: 1px solid var(--hairline); margin-bottom: 14px;
}
.st-filters .cmp-field { min-width: 0; }
.st-filters .year-select, .st-filters input[type="search"] { max-width: 220px; }
.st-filters input[type="search"] {
  font: inherit; font-size: 0.85rem; height: 34px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--ink); width: 200px;
}
.st-reset { font: inherit; font-size: 0.8rem; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.st-reset:hover { color: var(--accent); border-color: var(--accent); }
.st-active { flex: 1 1 100%; font-size: 0.78rem; color: var(--ink-muted); }
.st-active strong { color: var(--ink); font-weight: 600; }

.st-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: start; }
.st-card {
  grid-column: span 6; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 16px; min-width: 0;
}
.st-card.wide { grid-column: span 12; }
.st-card.third { grid-column: span 4; }
@media (max-width: 1100px) { .st-card, .st-card.third { grid-column: span 12; } }
.st-card h3 { font-family: var(--sans); font-size: 0.95rem; font-weight: 600; margin: 0 0 2px; color: var(--ink); }
.st-card .st-sub { font-size: 0.78rem; color: var(--ink-muted); margin: 0 0 10px; }
.st-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.st-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface-2); }
.st-seg button { font: inherit; font-size: 0.74rem; padding: 3px 10px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer; }
.st-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); font-weight: 600; }
.st-empty { color: var(--ink-muted); font-size: 0.85rem; padding: 18px 0; }
.st-section-title { grid-column: span 12; font-family: var(--serif); font-size: 1.15rem; margin: 18px 0 -4px; color: var(--ink); }

/* ---------- stat tiles ---------- */
.st-kpis { grid-column: span 12; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.st-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.st-kpi .label { font-size: 0.76rem; color: var(--ink-2); }
.st-kpi .value { font-family: var(--sans); font-size: 1.6rem; font-weight: 600; color: var(--ink); line-height: 1.2; margin-top: 2px; }
.st-kpi .delta { font-size: 0.74rem; color: var(--ink-muted); margin-top: 2px; }
.st-kpi .delta .chg { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.st-kpi.hero { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.st-kpi.hero .value { font-size: 2rem; }

/* ---------- charts ---------- */
.viz { width: 100%; display: block; overflow: visible; }
.viz text { font-family: var(--sans); font-size: 11px; fill: var(--ink-muted); }
.viz .val { fill: var(--ink-2); font-weight: 600; }
.viz .lab { fill: var(--ink-2); }
.viz .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz .hit { fill: transparent; cursor: pointer; }
.viz .mark { transition: opacity 0.12s ease; }
.viz .hit:hover + .mark, .viz .mark.hover { opacity: 0.75; }
.viz .cross { stroke: var(--axis); stroke-width: 1; }
.viz .cell { stroke: var(--surface); stroke-width: 2; }
.viz .cell:hover { stroke: var(--ink); stroke-width: 1.5; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.76rem; color: var(--ink-2); margin: 0 0 8px; }
.viz-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.viz-legend .ln { width: 14px; height: 2px; border-radius: 1px; flex: 0 0 auto; }
.viz-legend .num { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-scale { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--ink-muted); margin-top: 6px; }
.viz-scale .ramp { display: flex; height: 8px; border-radius: 2px; overflow: hidden; }
.viz-scale .ramp span { width: 18px; }

.viz-tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 280px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16); padding: 8px 10px; font-size: 0.78rem; line-height: 1.35;
}
.viz-tip[hidden] { display: none; }
.viz-tip .t { font-weight: 600; margin-bottom: 3px; color: var(--ink); }
.viz-tip .r { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.viz-tip .r strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.viz-tip .k { width: 12px; height: 2px; border-radius: 1px; flex: 0 0 auto; }
.viz-tip .m { color: var(--ink-muted); margin-top: 3px; }

/* ---------- tables ---------- */
.st-table-wrap { overflow-x: auto; }
.st-table { border-collapse: collapse; width: 100%; font-size: 0.8rem; }
.st-table th {
  text-align: left; font-weight: 600; color: var(--ink-2); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--hairline);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
.st-table th.sortable { cursor: pointer; user-select: none; }
.st-table th.sortable:hover { color: var(--accent); }
.st-table th .arrow { color: var(--accent); margin-left: 3px; }
.st-table td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--hairline); color: var(--ink-2); vertical-align: middle; }
.st-table td.num, .st-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.st-table td.code { font-family: var(--mono); font-weight: 600; color: var(--accent); white-space: nowrap; }
.st-table td.title { color: var(--ink); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-table tr.clickable { cursor: pointer; }
.st-table tr.clickable:hover td { background: var(--surface-2); }
.st-table tr.dim td { opacity: 0.55; }
.st-pager { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 10px; font-size: 0.78rem; color: var(--ink-muted); flex-wrap: wrap; }
.st-pager button, .st-link-btn {
  font: inherit; font-size: 0.78rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.st-pager button:disabled { opacity: 0.4; cursor: default; }
.st-pager button:not(:disabled):hover, .st-link-btn:hover { color: var(--accent); border-color: var(--accent); }
.fillbar { display: inline-block; vertical-align: middle; width: 70px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-right: 6px; }
.fillbar > span { display: block; height: 100%; background: var(--viz-1); }
.fillbar.full > span { background: var(--status-warning); }
.st-pill { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.st-pill.offer-fall, .st-pill.offer-spring, .st-pill.offer-irregular { border-color: color-mix(in srgb, var(--status-warning) 60%, transparent); background: color-mix(in srgb, var(--status-warning) 12%, transparent); }
.st-pill.offer-none { border-color: color-mix(in srgb, var(--status-critical) 60%, transparent); background: color-mix(in srgb, var(--status-critical) 10%, transparent); }
.spark { display: inline-block; vertical-align: middle; }
.spark path { fill: none; stroke: var(--viz-1); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--viz-1); }

/* ---------- offering calendar ---------- */
.st-cal { border-collapse: separate; border-spacing: 2px; font-size: 0.74rem; }
.st-cal th { font-weight: 600; color: var(--ink-muted); padding: 2px 4px; white-space: nowrap; text-align: center; }
.st-cal th.rowhead { text-align: left; font-family: var(--mono); color: var(--accent); cursor: pointer; }
.st-cal th.rowhead:hover { text-decoration: underline; }
.st-cal td { width: 54px; height: 22px; border-radius: 4px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); }
.st-cal td.off { background: transparent; color: var(--ink-muted); }
.st-cal td.on-dark { color: #fff; }

/* ---------- insights lists ---------- */
.st-list { list-style: none; margin: 0; padding: 0; }
.st-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--hairline); font-size: 0.8rem; cursor: pointer; }
.st-list li:hover { background: var(--surface-2); }
.st-list .code { font-family: var(--mono); font-weight: 600; color: var(--accent); flex: 0 0 auto; min-width: 82px; }
.st-list .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.st-list .stat { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.78rem; }

/* ---------- course drawer ---------- */
.st-drawer-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 40; }
.st-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 41; overflow-y: auto;
  background: var(--page); border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0, 0, 0, 0.18); padding: 18px 20px 40px;
}
.st-drawer[hidden], .st-drawer-back[hidden] { display: none; }
.st-drawer .close { float: right; font: inherit; font-size: 1.2rem; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.st-drawer .code { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.st-drawer h2 { font-size: 1.3rem; margin: 2px 0 6px; }
.st-drawer .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 12px; font-size: 0.8rem; color: var(--ink-2); }
.st-drawer .st-card { margin-bottom: 12px; }

.st-foot { font-size: 0.76rem; color: var(--ink-muted); margin-top: 22px; line-height: 1.5; }
@media (max-width: 640px) {
  .viz-root { padding: 0 10px 40px; }
  .st-filters { position: static; }
  .st-filters .year-select, .st-filters input[type="search"] { max-width: none; width: 100%; }
  .st-filters .cmp-field { flex: 1 1 44%; }
}

/* ---------- EE degree tab (ee.js) ---------- */
.ee-check { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); align-self: center; }
.ee-code { font-family: var(--mono); font-weight: 600; color: var(--accent); text-decoration: none; }
.ee-code:hover { text-decoration: underline; }
.ee-taken { color: var(--accent); font-weight: 700; }
.ee-warn { font-size: 0.8rem; color: var(--ink); background: color-mix(in srgb, var(--status-warning) 14%, transparent); border-radius: 6px; padding: 6px 10px; margin: 6px 0; }

/* status icons: distinct glyphs, so color is never the only signal */
.ee-st { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; font-size: 0.66rem; font-weight: 700; flex: 0 0 auto; }
.ee-st.ok { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ee-st.done { background: var(--accent); color: var(--accent-ink); }
.ee-st.warn { background: color-mix(in srgb, var(--status-warning) 22%, transparent); color: var(--ink); }
.ee-st.bad { background: var(--status-critical); color: #fff; }
.ee-st.unk { border: 1px solid var(--border); color: var(--ink-muted); }

/* check sheet grid */
.ee-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.ee-grid-col { border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--surface-2); min-width: 0; }
.ee-grid-head { display: flex; flex-direction: column; margin-bottom: 6px; }
.ee-grid-head strong { font-size: 0.8rem; color: var(--ink); }
.ee-grid-head span { font-size: 0.72rem; color: var(--ink-muted); }
.ee-grid-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px; border-radius: 6px; font-size: 0.76rem; color: var(--ink-2); background: var(--surface); margin-bottom: 3px; cursor: default; }
.ee-grid-row .lab { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ee-grid-row .lab .slot { color: var(--ink-muted); font-size: 0.7rem; }
.ee-grid-row .cr { font-family: var(--mono); color: var(--ink-muted); font-size: 0.7rem; }
.ee-grid-row.bad { box-shadow: inset 0 0 0 1.5px var(--status-critical); }
.ee-grid-row.warn { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--status-warning) 70%, transparent); }
.ee-grid-total { text-align: right; font-size: 0.7rem; color: var(--ink-muted); font-family: var(--mono); margin-top: 4px; }
.ee-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.74rem; color: var(--ink-2); margin: 10px 0 4px; }
.ee-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ee-issues { margin: 10px 0 0; padding-left: 18px; font-size: 0.8rem; color: var(--ink-2); }
.ee-issues li { margin: 3px 0; }
.ee-issues li.bad { color: var(--ink); }
.ee-issues li.bad strong { color: var(--status-critical); }

/* planner timeline */
.ee-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.ee-chip-btn { font: inherit; font-size: 0.74rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; font-family: var(--mono); }
.ee-chip-btn.on { background: var(--accent-wash); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); font-weight: 600; }
.ee-timeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.ee-sem { flex: 0 0 158px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--surface-2); }
.ee-sem.summer { flex-basis: 130px; background: var(--surface); border-style: dashed; }
.ee-sem-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 0.78rem; }
.ee-sem-head span { font-family: var(--mono); color: var(--ink-muted); font-size: 0.72rem; }
.ee-sem-head span.over { color: var(--status-critical); font-weight: 700; }
.ee-chip { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; font-size: 0.74rem; }
.ee-chip .top { display: flex; justify-content: space-between; gap: 6px; }
.ee-chip .ph { color: var(--ink-2); font-style: italic; }
.ee-chip .cr { font-family: var(--mono); color: var(--ink-muted); }
.ee-chip .flags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.ee-chip .f { font-size: 0.64rem; padding: 0 5px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); }
.ee-chip .f.warn { border-color: color-mix(in srgb, var(--status-warning) 70%, transparent); background: color-mix(in srgb, var(--status-warning) 12%, transparent); }
.ee-chip .f.bad { border-color: var(--status-critical); color: var(--ink); }

/* track comparison */
.ee-stats { list-style: none; margin: 0 0 8px; padding: 0; font-size: 0.8rem; }
.ee-stats li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--hairline); color: var(--ink-2); }
.ee-stats li strong { color: var(--ink); text-align: right; }
.ee-stats li.bad strong { color: var(--status-critical); }
.ee-stats li.ok strong { color: var(--accent); }

/* gen-ed needs */
.ee-needs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ee-need { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface-2); }
.ee-need strong { font-size: 0.82rem; color: var(--ink); }
.ee-need .num { font-size: 1.1rem; font-weight: 600; color: var(--ink); }
.ee-need .note { font-size: 0.72rem; color: var(--ink-muted); }
.ee-need.met { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.ee-need.met .num { color: var(--accent); }
.ee-dd-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; }
.st-pill.ee-need-pill { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-wash); color: var(--accent); }
.st-pill.ee-ok { border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent); }
.st-pill.ee-arranged { border-style: dashed; color: var(--ink-muted); }
.st-cal tr.ee-group th { text-align: left; padding: 10px 4px 4px; color: var(--ink); font-weight: 600; font-size: 0.78rem; }

/* advising notes */
.ee-notes { list-style: none; margin: 0; padding: 0; }
.ee-notes li { position: relative; padding: 7px 10px 7px 30px; border-bottom: 1px solid var(--hairline); font-size: 0.84rem; color: var(--ink); }
.ee-notes li::before { position: absolute; left: 6px; top: 7px; width: 16px; height: 16px; border-radius: 50%; font-size: 0.66rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ee-notes li.bad::before { content: "✕"; background: var(--status-critical); color: #fff; }
.ee-notes li.warn::before { content: "!"; background: color-mix(in srgb, var(--status-warning) 30%, transparent); color: var(--ink); }
.ee-notes li.ok::before { content: "✓"; background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.ee-notes li.info::before { content: "i"; border: 1px solid var(--border); color: var(--ink-muted); }

/* EE tab: conflicts in past terms */
.ee-feas { list-style: none; margin: 4px 0 10px; padding: 0; }
.ee-feas li { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--hairline); font-size: 0.82rem; color: var(--ink-2); }
.ee-feas li .ee-st { align-self: center; }
.ee-feas li strong { color: var(--ink); white-space: nowrap; }
.ee-frac { font-size: 0.72rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ee-pairs td { white-space: nowrap; }
.ee-tt .ee-blk { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.ee-tt .ee-blk.pick { fill: var(--accent-wash); stroke: var(--accent); stroke-width: 1.5; }
.ee-tt .ee-blk.clash { stroke: var(--status-critical); stroke-width: 2; }
.ee-tt .ee-blk:hover { stroke: var(--ink); }
.ee-tt .ee-blk-t { font-family: var(--mono); font-size: 10px; font-weight: 600; fill: var(--ink); pointer-events: none; }
.viz-legend .ee-sw { background: var(--surface-2); border: 1px solid var(--border); }
.viz-legend .ee-sw.pick { background: var(--accent-wash); border: 1.5px solid var(--accent); }
.viz-legend .ee-sw.clash { background: var(--surface-2); border: 2px solid var(--status-critical); }
