/* Peerscope. An observatory for U.S. higher education: a star chart of every institution,
   brass instrument accents, Public Sans (the federal government's own typeface) for the data. */
:root {
  color-scheme: light;
  --paper: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #eceef5;
  --ink: #141a35;
  --ink-2: #3d4462;
  --muted: #565d7a;
  --line: #d3d7e4;
  --line-strong: #8c93ad;
  --brass: #855f12;          /* text-safe brass */
  --brass-mark: #a6781c;     /* brass for marks (3:1+) */
  --brass-wash: #f4ead3;
  --teal: #136670;
  --teal-wash: #ddeef0;
  --focus: #2949c6;
  --danger: #a32635;
  --danger-wash: #fbe9eb;
  --sky-1: #121a44;          /* star chart night, light theme keeps it as an inset */
  --sky-2: #0b1030;
  --star: #f3e6c4;
  --star-dim: #8f9bd0;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 0 rgba(20, 26, 53, .06), 0 8px 24px -12px rgba(20, 26, 53, .18);
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0d1229; --surface: #151b3a; --surface-2: #1c2447; --ink: #eceef7; --ink-2: #c8cce0;
    --muted: #a3a9c6; --line: #2d3660; --line-strong: #5d6797; --brass: #e6bb62; --brass-mark: #d9a94a;
    --brass-wash: #2e2a26; --teal: #73cbd3; --teal-wash: #16324a; --focus: #9db3ff; --danger: #ff8f9c;
    --danger-wash: #3a1c2c; --sky-1: #0d1229; --sky-2: #080b1f;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d1229; --surface: #151b3a; --surface-2: #1c2447; --ink: #eceef7; --ink-2: #c8cce0;
  --muted: #a3a9c6; --line: #2d3660; --line-strong: #5d6797; --brass: #e6bb62; --brass-mark: #d9a94a;
  --brass-wash: #2e2a26; --teal: #73cbd3; --teal-wash: #16324a; --focus: #9db3ff; --danger: #ff8f9c;
  --danger-wash: #3a1c2c; --sky-1: #0d1229; --sky-2: #080b1f;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--font-body); font-feature-settings: "tnum" 1, "lnum" 1;
}
a { color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.015em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--surface); color: var(--ink); padding: 8px 12px; z-index: 50; border-radius: var(--radius-s); }
.skip:focus { top: 8px; }

/* ---------- frame ---------- */
.frame { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px; border-right: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { flex: none; }
.brand b { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brass-wash); color: var(--ink); box-shadow: inset 3px 0 0 var(--brass-mark); }
.nav svg { width: 18px; height: 18px; flex: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: .86rem; color: var(--muted); }
.rail-foot button { justify-content: flex-start; }
main { min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 80px; }
.page { max-width: 1180px; margin: 0 auto; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: .94rem; cursor: pointer; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 8px 14px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; line-height: 1.3;
}
button:hover, .btn:hover { border-color: var(--ink-2); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.primary:hover { background: var(--ink-2); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-s); padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; }
label { font-weight: 600; font-size: .92rem; color: var(--ink-2); display: block; margin-bottom: 5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 220px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: var(--teal-wash); color: var(--teal); }
.pill.warn { background: var(--brass-wash); color: var(--brass); }
.pill.bad { background: var(--danger-wash); color: var(--danger); }

/* ---------- the observatory (front page) ---------- */
.observatory {
  position: relative; border-radius: 16px; overflow: hidden; color: #eef0fa;
  background: radial-gradient(120% 90% at 70% 0%, var(--sky-1), var(--sky-2));
  min-height: 380px; margin-bottom: 26px; isolation: isolate;
}
.observatory canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.observatory .lede { padding: clamp(22px, 4vw, 40px); max-width: min(44%, 520px); position: relative; }
@media (max-width: 760px) { .observatory .lede { max-width: none; } }
.observatory h1 { font-size: clamp(2.3rem, 6vw, 4.2rem); font-weight: 700; letter-spacing: -0.035em; color: #fff; }
.observatory .lede p { color: #d3d8ef; font-size: 1.08rem; max-width: 34em; margin-top: 12px; }
.observatory .count { font-variant-numeric: tabular-nums; color: #f3e6c4; font-weight: 600; }
.star-tip {
  position: absolute; pointer-events: none; background: rgba(8, 11, 31, .92); color: #fff; padding: 6px 10px;
  border-radius: 6px; font-size: .84rem; border: 1px solid #3a4478; white-space: nowrap; transform: translate(-50%, -130%);
}
.askbox {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px; margin: -64px clamp(10px, 3vw, 28px) 18px; position: relative; z-index: 2;
}
.askbox textarea { border: none; font-size: 1.18rem; padding: 6px 4px; min-height: 58px; background: transparent; }
.askbox textarea:focus-visible { outline: none; }
.askbox:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.askbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.askbar select { width: auto; max-width: 100%; }
.askbar .primary { margin-left: auto; padding: 10px 20px; }
.prompts { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 26px; }
.prompts button { font-weight: 500; font-size: .9rem; border-radius: 99px; background: var(--surface); color: var(--ink-2); border-color: var(--line); text-align: left; }
.prompts button:hover { border-color: var(--brass-mark); color: var(--ink); }

/* ---------- answers ---------- */
.answer { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(18px, 3vw, 28px); margin-bottom: 22px; }
.answer h2 { margin-bottom: 12px; }
.answer .prose { font-size: 1.12rem; line-height: 1.6; max-width: 70ch; }
.answer .prose mark { background: var(--danger-wash); color: var(--danger); padding: 0 3px; border-radius: 3px; }
.flag { border-left: 4px solid var(--danger); background: var(--danger-wash); padding: 10px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 12px 0; color: var(--ink); }
.note { color: var(--ink-2); font-size: .94rem; max-width: 75ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.thinking { display: flex; gap: 12px; align-items: center; padding: 22px; color: var(--ink-2); }
.orbit { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brass-mark); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orbit { animation: none; } }
details.sql summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 6px 0; }
pre.code { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-s); overflow: auto; font-size: .85rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }

/* citation strip: the brass rule under every figure */
.cite { border-top: 2px solid var(--brass-mark); margin-top: 18px; padding-top: 10px; font-size: .88rem; color: var(--ink-2); display: grid; gap: 4px; }
.cite b { color: var(--ink); font-weight: 600; }

/* ---------- tables ---------- */
.tablewrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: var(--radius-s); margin-top: 14px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 650; z-index: 1; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.anchor td { background: var(--brass-wash); font-weight: 600; }
td.null { color: var(--muted); }

/* ---------- charts ---------- */
.chart { margin-top: 18px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text, .chart .lbl { fill: var(--muted); font-size: 12px; font-family: var(--font-body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-strong); stroke-width: 1; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .86rem; color: var(--ink-2); margin-bottom: 6px; }
.chart .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: .84rem; padding: 6px 9px; border-radius: 6px; white-space: nowrap; z-index: 5; transform: translate(-50%, calc(-100% - 10px)); box-shadow: var(--shadow); }
.tip b { font-weight: 700; }

/* ---------- institution profile ---------- */
.inst-head { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.inst-head .meta { color: var(--ink-2); margin-top: 8px; }
.inst-head .meta span + span::before { content: ", "; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.group-title { margin: 26px 0 10px; font-size: 1.05rem; color: var(--ink-2); font-family: var(--font-display); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.tile .label { color: var(--ink-2); font-size: .9rem; font-weight: 500; }
.tile .value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.tile .yr { color: var(--muted); font-size: .82rem; }
.tile .delta { font-size: .84rem; color: var(--ink-2); }
.tile svg { margin-top: 4px; }

/* ---------- compare ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 99px; padding: 3px 4px 3px 11px; font-size: .88rem; }
.chip button { padding: 2px 7px; border: none; background: transparent; border-radius: 99px; font-size: .95rem; line-height: 1; }
.chip button:hover { background: var(--line); }
.chip.anchor { background: var(--brass-wash); }
.typeahead { position: relative; }
.typeahead ul { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s); list-style: none; margin: 0; padding: 4px; z-index: 20; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.typeahead li { padding: 7px 9px; border-radius: 4px; cursor: pointer; }
.typeahead li[aria-selected="true"], .typeahead li:hover { background: var(--surface-2); }
.strip-row { display: grid; grid-template-columns: minmax(150px, 230px) 110px 110px minmax(160px, 1fr); gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.strip-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.strip-head { font-weight: 650; font-size: .86rem; color: var(--ink-2); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(16px, 3vw, 24px); margin-bottom: 20px; }

/* ---------- sources & dictionary ---------- */
.sources { display: grid; gap: 14px; }
.source { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; }
.source header { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.source dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 12px 0 0; font-size: .92rem; }
.source dt { color: var(--muted); }
.source dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.source, .panel, .answer { min-width: 0; overflow-wrap: break-word; }
.row > * { min-width: 0; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 6px 0 22px; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.9rem; font-weight: 650; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
.view-block { margin: 18px 0 26px; }
.view-block code, code { font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.empty { text-align: center; padding: 50px 20px; color: var(--ink-2); }
.err { background: var(--danger-wash); color: var(--ink); border-left: 4px solid var(--danger); padding: 12px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 8px; z-index: 60; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list a, .list button.link { display: block; padding: 10px 4px; text-decoration: none; color: var(--ink); width: 100%; text-align: left; border: none; background: none; border-radius: 0; font-weight: 500; }
.list a:hover, .list button.link:hover { background: var(--surface-2); }
.list .sub { color: var(--muted); font-size: .86rem; font-weight: 400; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(120% 90% at 70% 0%, #121a44, #080b1f); }
.login form { background: var(--surface); color: var(--ink); width: min(380px, 100%); padding: 28px; border-radius: 16px; box-shadow: 0 20px 60px -20px #000; display: grid; gap: 14px; }

@media (max-width: 860px) {
  .frame { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--line); gap: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 6px 9px; }
  .rail-foot { margin-top: 0; flex-direction: row; align-items: center; margin-left: auto; }
  .rail-foot .muted { display: none; }
  .strip-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .strip-row .strip { grid-column: 1 / -1; }
  .askbox { margin: -48px 8px 16px; }
  .source dl { grid-template-columns: minmax(0, 1fr); }
  .source dt { margin-top: 6px; }
  .grow { flex-basis: 100%; }
}
@media print {
  .rail, .askbox, .prompts, .actions { display: none; }
  .frame { display: block; }
}
