/* Clean and minimal: neutral greys, one green accent, Geist.
   Radius rule: 16px panels, 10px controls, pill for the toggle. */
@font-face {
  font-family: "Geist";
  src: url("/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #6b6b73;
  --line: #e7e7ea;
  --subtle: #f4f4f5;
  --accent: #047857;
  --accent-soft: #e7f5ee;
  --shadow: 0 1px 2px rgb(24 24 27 / 0.04), 0 8px 24px rgb(24 24 27 / 0.05);
  color-scheme: light dark;
  font: 17px/1.65 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f10;
    --surface: #18181a;
    --ink: #ededee;
    --muted: #a0a0a8;
    --line: #2a2a2d;
    --subtle: #212124;
    --accent: #34d399;
    --accent-soft: #143326;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); text-decoration-thickness: 1.5px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
main.wrap > :not(.tool):not(table) { max-width: 68ch; }

/* Header */
header.site { position: relative; border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { font-weight: 650; font-size: 1.02rem; letter-spacing: -0.01em; text-decoration: none; }
.brand span { color: var(--accent); }
nav.site { display: flex; gap: 24px; font-size: 0.92rem; }
nav.site a { text-decoration: none; color: var(--muted); }
nav.site a:hover { color: var(--ink); }

/* Mobile menu: hidden on desktop, replaces the inline nav below 760px */
.menu { display: none; }
.menu summary { list-style: none; cursor: pointer; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; }
.menu summary::-webkit-details-marker { display: none; }
.bars, .bars::before, .bars::after { display: block; width: 18px; height: 1.5px; background: var(--ink); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.bars { position: relative; }
.bars::before, .bars::after { content: ""; position: absolute; left: 0; }
.bars::before { top: -6px; }
.bars::after { top: 6px; }
.menu[open] .bars { background: transparent; }
.menu[open] .bars::before { transform: translateY(6px) rotate(45deg); }
.menu[open] .bars::after { transform: translateY(-6px) rotate(-45deg); }
.menu nav { position: absolute; left: 0; right: 0; top: 60px; z-index: 2; display: grid; max-height: calc(100dvh - 60px); overflow-y: auto; padding: 4px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.menu nav a { padding: 12px 0; text-decoration: none; border-bottom: 1px solid var(--line); }
.menu nav a:last-child { border-bottom: 0; }

/* Type */
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); font-weight: 680; letter-spacing: -0.035em; line-height: 1.1; margin: 48px 0 10px; }
h2 { font-size: 1.45rem; font-weight: 640; letter-spacing: -0.02em; line-height: 1.25; margin: 56px 0 10px; }
h3 { font-size: 1.08rem; font-weight: 620; letter-spacing: -0.01em; margin: 28px 0 4px; }
.lede { color: var(--muted); font-size: 1.08rem; margin: 0 0 28px; }

/* Calculator */
.tool { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; margin-bottom: 16px; }
.sheet { grid-column: 1; grid-row: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }

.result { grid-column: 2; grid-row: 1; position: sticky; top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.result small { display: block; color: var(--muted); font-size: 0.9rem; }
.result b.empty { color: var(--muted); }
.result b { display: block; margin: 6px 0 10px; font-size: 3.6rem; font-weight: 650; line-height: 1; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.result .detail { display: inline-block; margin: 0; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.88rem; font-weight: 550; }

.toggle { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--subtle); margin-bottom: 20px; }
.toggle button { border: 0; background: none; color: var(--muted); padding: 6px 16px; border-radius: 999px; font: inherit; font-size: 0.9rem; cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(24 24 27 / 0.12); }

.rows { display: grid; gap: 8px; }
.rows:empty { min-height: 208px; } /* reserve 4 rows until app.js renders them, so the page does not jump */
.row, .heads { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: center; }
.tool.weighted .row, .tool.weighted .heads { grid-template-columns: 1fr 1fr 1fr 44px; }
.level, .level-head { display: none; }
.tool.weighted .level, .tool.weighted .level-head { display: block; }
.heads { font-size: 0.82rem; color: var(--muted); margin-bottom: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

input, select { width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-size: 1rem; color: var(--ink); background-color: var(--surface); border: 1px solid var(--line); border-radius: 10px; transition: border-color 0.15s ease; }
input:hover, select:hover { border-color: var(--muted); }
input::placeholder { color: var(--muted); opacity: 0.85; }
/* Own chevron instead of the native arrow: same look on iOS, Android and desktop, and a known text width */
select {
  appearance: none; padding-right: 30px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 17px center, right 12px center; background-size: 5px 5px; background-repeat: no-repeat;
}
select[data-field="grade"] { font-weight: 600; }
.remove { height: 46px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.remove:hover { background: var(--subtle); color: var(--ink); }

.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 8px 16px; border-radius: 10px; font: inherit; font-size: 0.92rem; font-weight: 550; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn:hover { background: var(--subtle); }
.btn:active, .toggle button:active { transform: scale(0.98); }
.btn.link { border-color: transparent; background: none; color: var(--muted); }

details.prev { margin-top: 20px; padding-top: 6px; border-top: 1px solid var(--line); }
details.prev summary { padding: 10px 0; cursor: pointer; color: var(--muted); font-size: 0.95rem; }
details.prev summary:hover { color: var(--ink); }
.prev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.prev-grid label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
/* On the cumulative page the previous-GPA block sits above the rows */
.sheet > details.prev:not(:last-child) { margin: -10px 0 20px; padding: 0 0 16px; border-top: 0; border-bottom: 1px solid var(--line); }

/* Converter */
.tool.converter { grid-template-columns: 1fr 1fr; }
.tool.converter .sheet { grid-row: auto; grid-column: auto; }
.tool.converter label { display: block; font-weight: 600; margin-bottom: 8px; }
.conv-out { margin: 14px 0 0; color: var(--muted); }
.conv-out.ok { color: var(--ink); font-weight: 550; }

/* Honors data table */
.table-scroll { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
main.wrap > div.table-scroll { max-width: none; }
table.honors { max-width: none; min-width: 900px; margin: 0; font-size: 0.9rem; }
table.honors td.note { color: var(--muted); font-size: 0.85rem; }
table.honors { table-layout: fixed; }
table.honors th:nth-child(1) { width: 18%; }
table.honors th:nth-child(2) { width: 11%; }
table.honors th:nth-child(n+3):nth-child(-n+5) { width: 13%; }
table.honors th:nth-child(6) { width: 32%; }
.muted { color: var(--muted); font-size: 0.85em; }
.filter-label { display: block; font-weight: 600; margin: 20px 0 6px; }
#honors-filter { max-width: 360px; }

/* Content */
table { border-collapse: collapse; width: 100%; max-width: 68ch; margin: 14px 0; font-variant-numeric: tabular-nums; font-size: 0.96rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { font-weight: 550; color: var(--muted); font-size: 0.86rem; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody th { font-weight: 600; }
p strong { font-weight: 620; }
ol, ul { padding-left: 1.3em; }
li { margin: 6px 0; }

footer.site { margin-top: 88px; border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.9rem; }
footer.site .wrap { padding-block: 36px 28px; }
.footer-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.footer-cols h2 { font-size: 0.9rem; font-weight: 600; letter-spacing: 0; margin: 0 0 8px; color: var(--ink); }
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin: 6px 0; }
.footer-cols a { text-decoration: none; }
.footer-cols a:hover { color: var(--ink); }

/* Mobile: result becomes a compact bar pinned to the top */
@media (max-width: 760px) {
  :root { font-size: 16px; }
  /* Keep focused fields (and the native picker's scroll-into-view) clear of the sticky result bar */
  html { scroll-padding-top: 80px; }
  .brand { padding: 10px 0; }
  nav.site { display: none; }
  .menu { display: block; }
  h1 { margin-top: 24px; }
  .lede { margin-bottom: 20px; }
  h2 { margin-top: 44px; }
  .tool { grid-template-columns: 1fr; gap: 12px; }
  /* Fixed height whether the detail takes one line or two, so content below never jumps */
  .result { grid-column: 1; grid-row: 1; z-index: 1; top: 0; display: flex; align-items: center; gap: 14px; height: 68px; padding: 0 16px; margin: 0 -20px; border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  .result small { display: none; }
  .result b { margin: 0; min-width: 3.3ch; font-size: 2.2rem; }
  .result .detail { padding: 4px 10px; border-radius: 12px; font-size: 0.84rem; line-height: 1.3; }
  .sheet { grid-row: 2; padding: 18px 14px; }
  .toggle button { min-height: 44px; padding-inline: 18px; }
  .row, .heads { gap: 6px; }
  /* Weighted: 4 columns need a narrow credits field so grade and class type stay readable */
  .tool.weighted .row, .tool.weighted .heads { grid-template-columns: minmax(0, 1fr) 3rem minmax(0, 1.1fr) 44px; }
  .tool.weighted [data-field="credits"] { padding-inline: 8px; text-align: center; }
  .tool.weighted select { padding: 10px 24px 10px 10px; background-position: right 15px center, right 10px center; }
  th, td { padding: 8px 6px; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .tool.converter { grid-template-columns: 1fr; }
}

/* Very narrow phones: class type moves to its own line instead of being cut off */
@media (max-width: 359px) {
  .rows { gap: 14px; }
  .tool.weighted .row, .tool.weighted .heads { grid-template-columns: 1fr 1fr 44px; }
  .tool.weighted .level { grid-column: 1 / 3; }
  .tool.weighted .level-head { display: none; }
  .tool.weighted [data-field="credits"] { text-align: left; padding-inline: 12px; }
  table { font-size: 0.86rem; }
  th, td { padding: 8px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active, .toggle button:active { transform: none; }
  .bars, .bars::before, .bars::after, input, select { transition: none; }
}
