/* TExES 242 Prep — RUN 4 rebuild.
 * Linear-inspired dark UI. Tokens below are the DOX plan's hard spec.
 * Mobile-first at 390px; desktop centers content at 720px.
 * Zero external assets; system font stacks only.
 */

:root {
  --bg: #0b0c0e; --surface: #141518; --surface-2: #1a1c20;
  --border: #23262b; --border-strong: #2e3238;
  --text: #e8eaed; --text-2: #9ba1a8; --text-3: #7d838b;
  --accent: #5f6ad0; --accent-hover: #7681da; --accent-bg: rgba(95,106,208,.12);
  --green: #3fb37f; --red: #e05555; --amber: #d9a03f;
  --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.25);
}

/* Domain hues (RUN 5): left stripes on domain cards, weight-bar segments,
 * legend dots. I reuses the accent; IV is a muted blue from the palette. */
.dom-i { --dom: var(--accent); }
.dom-ii { --dom: var(--green); }
.dom-iii { --dom: var(--amber); }
.dom-iv { --dom: #5b8fd6; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- type scale (12 / 13 / 14-15 / 17 / 22 / 28) ---------- */

h1, h2, h3 { margin: 0; font-weight: 600; }

.hero-title { font-size: 28px; line-height: 1.2; }

.view-title { font-size: 22px; margin: 24px 0 16px; }

.card-title { font-size: 17px; line-height: 1.35; }

.kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.muted { font-size: 13px; color: var(--text-2); }
.dim { color: var(--text-3); }

.small { font-size: 13px; }

p { margin: 0 0 12px; }

/* ---------- app shell ---------- */

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 96px;
}

.topbar { padding: 16px 0; border-bottom: 1px solid var(--border); }

.brand-name { margin: 0; font-size: 17px; font-weight: 600; }

.brand-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }

.load-status {
  margin: 24px 0 0;
  padding: 16px;
  border: 1px solid var(--red);
  border-radius: var(--radius-lg);
  color: var(--red);
  font-size: 14px;
}

/* ---------- cards & surfaces (elevation via surface steps) ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-grid { display: grid; gap: 12px; }

/* Domain differentiation: 3px left accent stripe, hue per domain (RUN 5 item 7). */
.dom-card { border-left: 3px solid var(--dom); }

@media (min-width: 560px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.hero {
  background:
    linear-gradient(160deg, rgba(95,106,208,.14), rgba(95,106,208,0) 55%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin: 16px 0 32px;
}

.hero-meta { margin: 8px 0 16px; font-size: 13px; color: var(--text-2); }

.hero-status { margin: 8px 0 0; }

/* Domain-weight visual: one stacked bar, segments sized by weight,
 * tiny legend beneath. No prose percentages (RUN 5 item 1). */
.weights { margin: 12px 0 16px; }

.weights-bar {
  display: flex;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.weights-seg { height: 100%; background: var(--dom); }

.weights-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-2);
}

.weights-item { display: inline-flex; align-items: center; gap: 6px; }

.weights-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--dom); }

.hero-chiprow { margin: 0 0 16px; }

.bank-stats { margin: 16px 0 0; }

.dash-footer {
  margin: 32px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 24px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out,
              color 150ms ease-out;
}

/* Secondary/ghost hover: accent border + accent text + accent tint fill,
 * so outline buttons read as tappable (RUN 5 item 5). */
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

.btn:focus-visible,
.choice:focus-visible,
.tabbar button:focus-visible,
.study-head:focus-visible,
.navgrid button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-block { width: 100%; }

.btn-small { padding: 8px 16px; font-size: 13px; }

.btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn-danger:hover { border-color: var(--red); color: var(--red); background: rgba(224,85,85,.12); }

.btn-ghost { background: transparent; color: var(--text-2); }

/* ---------- chips & badges ---------- */

.chiprow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.chip-accent { color: var(--accent-hover); border-color: var(--accent); }

.chip-timer { font-size: 15px; font-weight: 400; }
.chip-timer.low { color: var(--amber); border-color: var(--amber); }
.chip-timer.critical { color: var(--red); border-color: var(--red); }

.tab-badge {
  min-width: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

/* ---------- question & choices ---------- */

.question { font-size: 17px; font-weight: 600; line-height: 1.45; margin: 0 0 16px; }

.choices { display: grid; gap: 8px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.choice:hover { border-color: var(--accent); background: var(--accent-bg); }

.choice .badge {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
}

.choice-text { flex: 1 1 auto; }

.choice.selected { border-color: var(--accent); background: var(--accent-bg); }
.choice.selected .badge { border-color: var(--accent); color: var(--accent-hover); }

.choice.correct { border-color: var(--green); background: rgba(63,179,127,.10); }
.choice.correct .badge { background: var(--green); border-color: var(--green); color: #0b0c0e; }

.choice.wrong { border-color: var(--red); background: rgba(224,85,85,.10); }
.choice.wrong .badge { background: var(--red); border-color: var(--red); color: #0b0c0e; }

.rationale {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-2);
}

.rationale .rationale-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.verdict-line { margin: 12px 0 0; font-size: 13px; font-weight: 600; }
.verdict-good { color: var(--green); }
.verdict-bad { color: var(--red); }

/* ---------- progress bars (6px track, accent fill, green at >=80%) ---------- */

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 200ms ease-out;
}

.bar-fill.good { background: var(--green); }

.bar-label { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }

/* ---------- question grid navigator ---------- */

.grid-toggle { margin-top: 16px; }

.navgrid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.navgrid button {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}

.navgrid button.answered {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--text);
}

.navgrid button.here { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--text); }

@media (min-width: 560px) {
  .navgrid { grid-template-columns: repeat(10, 1fr); }
}

/* ---------- results ---------- */

.score-big { margin: 16px 0 4px; font-size: 28px; font-weight: 600; }
.score-big .dim { font-size: 17px; font-weight: 600; }

.verdict-pill {
  display: inline-block;
  margin: 8px 0 16px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.verdict-pill.pass { background: rgba(63,179,127,.14); color: var(--green); border: 1px solid var(--green); }
.verdict-pill.fail { background: rgba(224,85,85,.14); color: var(--red); border: 1px solid var(--red); }

.domain-rows { display: grid; gap: 16px; margin: 16px 0 0; }

.domain-row .row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.domain-row .row-name { font-size: 14px; font-weight: 600; }
.domain-row .row-count { font-size: 12px; color: var(--text-3); }

.review-item {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.review-item .q { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.review-item .a { font-size: 14px; margin: 0 0 4px; color: var(--text-2); }
.review-item .a strong { color: var(--text); font-weight: 600; }

/* ---------- study cards ---------- */

.study-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
}

.study-card + .study-card { margin-top: 12px; }

.study-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.caret {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg);
  transition: transform 200ms ease-out;
}

.study-card.open .caret { transform: rotate(225deg); }

.study-body {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
}

.study-body p { margin: 0; }

.study-card.open .study-body { display: block; }

/* ---------- empty states ---------- */

.empty {
  padding: 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

.qnav { display: flex; gap: 12px; margin-top: 16px; }
.qnav .btn { flex: 1 1 auto; }

.inline-confirm {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: rgba(224,85,85,.08);
  font-size: 14px;
}

.inline-confirm .qnav { margin-top: 12px; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  display: flex;
  gap: 4px;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.tabbar button {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 4px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-3);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease-out;
}

.tabbar svg { display: block; flex: 0 0 auto; }

.tabbar button.active { color: var(--accent-hover); }
.tabbar button:hover { color: var(--accent-hover); }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none;
    animation: none;
  }
}
