/*
 * SLP Nest design system. Tokens and rules: docs/product/Design_System.md.
 * One stylesheet for every Nest page; pages add only layout specific to them.
 */

/* Andika, self-hosted (SIL OFL, brand/fonts/OFL.txt). No third-party font
   request from pages that show student names. */
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/brand/fonts/andika-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/brand/fonts/andika-latin-700-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/brand/fonts/andika-latin-ext-400-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/brand/fonts/andika-latin-ext-700-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Brand */
  --nest-evergreen: #1e4a45;
  --nest-evergreen-tint: #e3ecea;
  --nest-evergreen-mid: #5f8a84;
  --nest-on-evergreen-muted: #d6e3e0;
  --pip-gold: #fcb82b; /* the wordmark dot only, never UI */
  --pip-ink: #2a241d;
  --pip-cream: #f6f4ef;

  /* Roles */
  --action-primary-bg: var(--nest-evergreen);
  --action-primary-fg: var(--pip-cream);
  --action-secondary-border: var(--pip-ink);
  --surface-page: var(--pip-cream);
  --surface-card: #ffffff;
  --surface-sunk: #efeadf;
  --nav-active-bg: var(--nest-evergreen-tint);
  --nav-active-fg: var(--nest-evergreen);
  --text-body: #1a1a1a;
  --text-muted: #3a352c;
  --text-subtle: #5b5348;
  --border-subtle: #d8d4c8;
  --divider: #efeadf;
  --dot-empty: #cfc9bb;
  --chart-cued: #8a8372; /* session bar with any cue; on own is evergreen */

  /* Shape */
  --radius-chip: 8px;
  --radius-nav: 10px;
  --radius-button: 12px;
  --radius-card: 16px;
  --radius-panel: 20px;
  --button-h: 46px;
  --sidebar-w: 240px;
  --touch-min: 44px;

  --font: "Andika", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (max-width: 720px) {
  :root { --button-h: 54px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

h1, h2, h3 { color: var(--pip-ink); line-height: 1.15; margin: 0; }
h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
a { color: var(--nest-evergreen); }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

.muted { color: var(--text-subtle); font-size: 0.875rem; }
.sub { color: var(--text-muted); margin-top: 0.4rem; }
[hidden] { display: none !important; }

/* ---------- Wordmark ---------- */
/* "SLP" bold, -0.02em; 0.26em gap; "Nest" regular; a gold full stop
   (0.17em, 0.07em after the t, on the baseline); the arc under "Nest"
   rising to the full stop. The arc takes evergreen on light, text color
   elsewhere; never gold. */
.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.26em;
  font-family: var(--font);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--pip-ink);
  text-decoration: none;
  --wm-arc: var(--nest-evergreen);
  --wm-dot: var(--pip-gold);
}
.wordmark b { font-weight: 700; letter-spacing: -0.02em; }
.wordmark .nest { position: relative; font-weight: 400; }
.wordmark .stop {
  display: inline-block;
  width: 0.17em;
  height: 0.17em;
  margin-left: 0.07em;
  border-radius: 50%;
  background: var(--wm-dot);
}
.wordmark .nest::after {
  /* the arc */
  content: "";
  position: absolute;
  left: 0.04em;
  right: 0.02em;
  top: 0.78em;
  height: 0.42em;
  background: var(--wm-arc);
  -webkit-mask: url(/brand/slp-nest-wordmark-arc.svg) no-repeat center / 100% 100%;
  mask: url(/brand/slp-nest-wordmark-arc.svg) no-repeat center / 100% 100%;
}
.wordmark.on-dark { color: var(--pip-cream); --wm-arc: var(--pip-cream); }
.wordmark.one-color { --wm-dot: currentColor; --wm-arc: currentColor; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--button-h);
  padding: 0 1.25rem;
  border-radius: var(--radius-button);
  border: 2px solid var(--action-secondary-border);
  background: transparent;
  color: var(--pip-ink);
  font: 700 1rem/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: rgba(42, 36, 29, 0.05); }
.btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible, .linkish:focus-visible {
  outline: 3px solid var(--nest-evergreen-mid);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--action-primary-bg);
  border-color: var(--action-primary-bg);
  color: var(--action-primary-fg);
}
.btn.primary:hover { filter: brightness(1.12); }
.btn.small { min-height: 36px; padding: 0 0.8rem; font-size: 0.875rem; border-width: 1.5px; border-radius: 10px; }
.btn.big { min-height: 64px; font-size: 1.25rem; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.linkish {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--nest-evergreen); font: 700 0.95rem var(--font);
}

/* ---------- Cards, chips, tables ---------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 1.5rem;
}
.card > h2 { margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }

.panel {
  background: var(--nest-evergreen);
  color: var(--pip-cream);
  border-radius: var(--radius-panel);
  padding: 1.75rem 2rem;
}

.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-chip);
  background: var(--surface-sunk);
  color: var(--pip-ink);
  font-size: 0.85rem;
  white-space: nowrap;
}
.chip.target { background: var(--nest-evergreen-tint); color: var(--nest-evergreen); font-weight: 700; }

table.data { border-collapse: collapse; width: 100%; }
table.data th {
  text-align: left; font-weight: 400; color: var(--text-subtle); font-size: 0.875rem;
  padding: 0 0.75rem 0.6rem 0; border-bottom: 1px solid var(--border-subtle);
}
table.data td { padding: 0.8rem 0.75rem 0.8rem 0; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.data td.name { font-weight: 700; }
table.data .num { text-align: center; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions .btn + .btn { margin-left: 0.4rem; }
.table-wrap { overflow-x: auto; }

textarea, select, input[type="date"], input[type="text"], input[type="number"], input[type="time"] {
  font: inherit;
  color: var(--text-body);
  background: var(--surface-card);
  border: 1.5px solid var(--pip-ink);
  border-radius: var(--radius-button);
  padding: 0.6rem 0.8rem;
  min-height: var(--button-h);
}
input[type="number"] { width: 6rem; }
textarea { width: 100%; font-family: var(--mono); font-size: 0.85rem; line-height: 1.6; resize: vertical; }

/* Segmented control (cue level). */
.seg {
  display: flex; gap: 2px; padding: 4px;
  background: var(--surface-sunk); border-radius: var(--radius-button);
}
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent;
  font: 400 0.9rem var(--font); color: var(--text-muted); cursor: pointer;
}
.seg button.on { background: var(--surface-card); color: var(--pip-ink); font-weight: 700; box-shadow: 0 1px 2px rgba(42, 36, 29, 0.12); }

/* Home-practice dots. */
.dots { display: inline-flex; gap: 4px; }
.dot { width: 13px; height: 13px; border-radius: 50%; background: var(--nest-evergreen); display: inline-block; }
.dot.off { background: transparent; border: 1.5px solid var(--dot-empty); }

.bar { height: 6px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--nest-evergreen); }

/* A number in a report paragraph: it traces to a source. */
mark.n { background: var(--nest-evergreen-tint); color: inherit; font-weight: 700; padding: 0 0.2em; border-radius: 4px; }

.status { color: var(--text-subtle); font-size: 0.875rem; margin: 0.5rem 0 0; }
.status:empty { display: none; }

/* Score reminders (Today, This week): public/js/reminders.mjs */
#unscoredRows, #syncPendingRows { list-style: none; margin: 0; padding: 0; }
#unscoredRows li, #syncPendingRows li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--divider); }
#unscoredRows li:last-child, #syncPendingRows li:last-child { border-bottom: 0; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.75rem 1rem 1.5rem;
  border-right: 1px solid var(--divider);
  background: var(--surface-page);
}
.side .wordmark { margin: 0 0.75rem 2rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; min-height: var(--touch-min);
  padding: 0 0.75rem; border-radius: var(--radius-nav);
  color: var(--pip-ink); text-decoration: none; font-size: 1.05rem;
}
.nav a:hover { background: rgba(42, 36, 29, 0.05); }
.nav a[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-fg); font-weight: 700; }
.side .privacy {
  margin-top: auto; padding: 1rem 0.75rem 0;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem; color: var(--text-muted);
}
.main { padding: 2.25rem 2.5rem 3rem; max-width: 1240px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.page-head .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1.25rem; }
.grid > * { min-width: 0; }
.stack > * + * { margin-top: 1.25rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 0.5rem 1rem; padding: 0.9rem 1rem; border-right: 0; border-bottom: 1px solid var(--divider);
  }
  .side .wordmark { margin: 0 0.5rem 0 0.25rem; font-size: 1.35rem; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .nav a { font-size: 0.95rem; padding: 0 0.6rem; }
  .side .privacy { display: none; }
  .main { padding: 1.5rem 1rem 2.5rem; }
  h1 { font-size: 1.8rem; }
  .card { padding: 1.15rem; }
}

/* "Allow a new device?" (approvals.mjs): on top of whatever page is open. */
.approval {
  position: fixed; z-index: 50; top: 1rem; left: 50%; transform: translateX(-50%);
  width: min(34rem, calc(100vw - 2rem)); display: grid; gap: 0.75rem;
  background: var(--surface-card); border: 2px solid var(--nest-evergreen); border-radius: var(--radius-card);
  padding: 1rem 1.15rem; box-shadow: 0 10px 30px rgba(42, 36, 29, 0.18);
}
.approval p { margin: 0.25rem 0 0; }
.approval-number { font: 700 1.35rem var(--mono); letter-spacing: 0.08em; color: var(--pip-ink); }
.approval-actions { display: flex; gap: 0.6rem; }

/* Phone: the nav is one scrolling row, so the page starts near the top. */
@media (max-width: 600px) {
  .side { flex-wrap: nowrap; padding: 0.5rem 0.75rem; gap: 0.25rem; }
  .side .wordmark { flex: none; font-size: 1.15rem; }
  .nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; font-size: 0.9rem; padding: 0 0.5rem; }
  .main { padding: 1rem 0.85rem 2rem; }
}

@media print {
  body { background: #fff; }
  .shell { display: block; }
  .side, .noprint { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { border-color: #000; break-inside: avoid; }
  mark.n { background: none; padding: 0; }
}
