/* ============================================================
   ios-interview-kit — Premium theme (iOS Software Engineer pilot)
   Dark by default. Flip to light by setting:
     <html data-theme="light">   or   <body class="theme-light">
   ============================================================ */

/* ---------- Tokens: dark (default) ---------- */
:root {
  /* Surfaces */
  --bg:            #0b0e15;
  --bg-soft:       #0e1219;
  --surface:       #141925;
  --surface-2:     #1a2030;
  --surface-3:     #232a3d;
  --border:        #232a3a;
  --border-strong: #344057;

  /* Text */
  --ink:           #ecedf3;
  --ink-2:         #c1c7da;
  --muted:         #8a92ad;
  --faint:         #5e6680;

  /* Brand */
  --accent:        #a5b4fc;
  --accent-fg:     #0b0d22;
  --accent-soft:   rgba(165, 180, 252, 0.10);
  --accent-strong: #c7d2fe;

  /* Semantic */
  --good:          #6ee7b7;
  --good-soft:     rgba(110, 231, 183, 0.10);
  --strong:        #86efac;
  --strong-soft:   rgba(134, 239, 172, 0.10);
  --warn:          #fbbf24;
  --warn-soft:     rgba(251, 191, 36, 0.10);
  --weak:          #fb923c;
  --weak-soft:     rgba(251, 146, 60, 0.10);
  --bad:           #fca5a5;
  --bad-soft:      rgba(252, 165, 165, 0.10);

  /* Shadows */
  --shadow-sm:     0 1px 2px rgba(0,0,0,.30);
  --shadow:        0 4px 14px rgba(0,0,0,.28), 0 1px 2px rgba(0,0,0,.30);
  --shadow-lg:     0 12px 36px rgba(0,0,0,.40);

  /* Radius */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  /* Sizes */
  --container: 980px;
}

/* ---------- Tokens: light (opt-in) ---------- */
:root[data-theme="light"],
body.theme-light {
  --bg:            #f8f7f3;
  --bg-soft:       #fbfaf6;
  --surface:       #ffffff;
  --surface-2:     #f3f2ec;
  --surface-3:     #e9e7dc;
  --border:        #e6e4dc;
  --border-strong: #cfccc0;

  --ink:           #14182a;
  --ink-2:         #3a4061;
  --muted:         #6b7290;
  --faint:         #a3a8bf;

  --accent:        #4338ca;
  --accent-fg:     #ffffff;
  --accent-soft:   rgba(67, 56, 202, 0.08);
  --accent-strong: #3730a3;

  --good:          #047857;
  --good-soft:     rgba(4, 120, 87, 0.08);
  --strong:        #047857;
  --strong-soft:   rgba(4, 120, 87, 0.08);
  --warn:          #b45309;
  --warn-soft:     rgba(180, 83, 9, 0.08);
  --weak:          #c2410c;
  --weak-soft:     rgba(194, 65, 12, 0.08);
  --bad:           #b91c1c;
  --bad-soft:      rgba(185, 28, 28, 0.08);

  --shadow-sm:     0 1px 2px rgba(15,17,42,.04);
  --shadow:        0 2px 6px rgba(15,17,42,.05), 0 1px 2px rgba(15,17,42,.04);
  --shadow-lg:     0 12px 32px rgba(15,17,42,.10);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  font-feature-settings: "ss01", "cv11";   /* refined glyphs on supporting fonts */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.65;
  font-size: 16px;
  letter-spacing: -0.005em;
}

::selection { background: var(--accent-soft); color: var(--ink); }

.shell { max-width: var(--container); margin: 0 auto; padding: 32px 28px 96px; }

/* ---------- Hero ---------- */
header.hero {
  display: flex; flex-wrap: wrap; gap: 20px;
  align-items: flex-end; justify-content: space-between;
  padding: 28px 30px;
  border-radius: var(--r-lg);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
header.hero .title { display: flex; flex-direction: column; gap: 6px; }
header.hero .role-badge {
  display: inline-block;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  width: max-content;
}
header.hero h1 {
  margin: 6px 0 2px;
  font-size: 28px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}
header.hero .sub {
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 56ch;
}

.candidate {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-top: 22px; width: 100%;
}
.candidate input {
  width: 100%; padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  font: inherit; font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.candidate input::placeholder { color: var(--faint); }
.candidate input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  padding: 9px 14px; border-radius: var(--r-sm);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  text-decoration: none; line-height: 1; white-space: nowrap;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
a.btn { color: var(--ink); }
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.btn.primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: transparent; font-weight: 600;
}
a.btn.primary { color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  background: transparent;
}
.btn.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

/* ---------- Tabs ---------- */
nav.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin: 28px 0 18px;
  padding: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
nav.tabs button {
  background: transparent; color: var(--muted);
  border: 1px solid transparent;
  padding: 9px 14px; border-radius: var(--r-sm);
  cursor: pointer; font: inherit; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s ease, background .15s ease;
}
nav.tabs button:hover { color: var(--ink-2); }
nav.tabs button .pill {
  font-size: 11px; padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-weight: 600;
}
nav.tabs button.active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
nav.tabs button.active .pill {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Topic head ---------- */
.topic-head {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 12px; margin: 8px 4px 18px;
}
.topic-head h2 {
  margin: 0; font-size: 20px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--ink);
}
.topic-head .topic-meta {
  color: var(--muted); font-size: 13.5px;
}

/* ---------- Question card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 26px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease;
}
.card:hover { border-color: var(--border-strong); }

.q-header {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-bottom: 10px;
}
.q-num {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.10em; text-transform: uppercase;
  font-weight: 600;
}
.q-text {
  font-size: 18px; font-weight: 600; line-height: 1.5;
  letter-spacing: -0.01em;
  margin: 6px 0 14px;
  color: var(--ink);
}

/* ---------- Live-exercise tag + code snippet ---------- */
.q-tag {
  flex: none; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 3px 8px; border-radius: 999px;
}
.q-snippet-wrap { margin: 0 0 14px; }
.q-snippet-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.q-snippet {
  margin: 0; padding: 14px 16px; border-radius: var(--r);
  background: color-mix(in srgb, var(--ink) 5%, var(--surface));
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; color: var(--ink);
  white-space: pre; tab-size: 4;
}
.q-snippet code { font: inherit; background: none; padding: 0; color: inherit; }

/* ---------- Reveal panel ---------- */
details.reveal { margin: 6px 0 14px; }
details.reveal summary {
  cursor: pointer; user-select: none;
  color: var(--accent);
  font-size: 13px; font-weight: 600;
  padding: 6px 0;
  list-style: none;
}
details.reveal summary::-webkit-details-marker { display: none; }
details.reveal summary::before {
  content: "▸"; display: inline-block; margin-right: 6px;
  transition: transform .2s ease;
  color: var(--accent);
}
details.reveal[open] summary::before { transform: rotate(90deg); }
details.reveal .reveal-body {
  padding: 16px 18px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  margin-top: 8px;
  font-size: 15px; line-height: 1.7;
  color: var(--ink-2);
}
details.reveal .reveal-body ul {
  margin: 8px 0 0; padding-left: 22px;
}
details.reveal .reveal-body li {
  margin: 6px 0;
  color: var(--ink-2);
}
details.reveal .reveal-body li::marker { color: var(--accent); }
details.reveal .reveal-body .label {
  display: block;
  color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.10em;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- KB links ---------- */
.kb-link {
  display: inline-block; text-decoration: none;
  margin-left: 6px; opacity: .6; font-size: 13px;
  transition: opacity .15s ease, transform .15s ease;
}
.kb-link:hover { opacity: 1; transform: translateY(-1px); }
.kb-link-block {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 14px 0 0;
  padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent); font-size: 12.5px; font-weight: 600;
  opacity: 1;
}
.kb-link-block:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  transform: none;
}

/* ---------- Rubric ---------- */
.rubric {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 8px; margin: 16px 0 10px;
}
@media (max-width: 640px) { .rubric { grid-template-columns: repeat(2, 1fr); } }
.rubric label {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer; text-align: center;
  transition: all .15s ease;
}
.rubric label:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.rubric label .lvl {
  font-size: 11px; color: var(--muted);
  font-weight: 600; letter-spacing: 0.04em;
}
.rubric label .name {
  font-weight: 600; font-size: 12.5px;
  margin-top: 3px;
  color: var(--ink-2);
}
.rubric label input { position: absolute; opacity: 0; pointer-events: none; }

.rubric label.checked .name { color: var(--ink); }

.rubric label.no-signal.checked {
  border-color: var(--bad);
  background: var(--bad-soft);
  box-shadow: 0 0 0 1px var(--bad) inset;
}
.rubric label.no-signal.checked .lvl { color: var(--bad); }

.rubric label.below.checked {
  border-color: var(--weak);
  background: var(--weak-soft);
  box-shadow: 0 0 0 1px var(--weak) inset;
}
.rubric label.below.checked .lvl { color: var(--weak); }

.rubric label.meets.checked {
  border-color: var(--warn);
  background: var(--warn-soft);
  box-shadow: 0 0 0 1px var(--warn) inset;
}
.rubric label.meets.checked .lvl { color: var(--warn); }

.rubric label.strong.checked {
  border-color: var(--strong);
  background: var(--strong-soft);
  box-shadow: 0 0 0 1px var(--strong) inset;
}
.rubric label.strong.checked .lvl { color: var(--strong); }

.rubric label.exceeds.checked {
  border-color: var(--good);
  background: var(--good-soft);
  box-shadow: 0 0 0 1px var(--good) inset;
}
.rubric label.exceeds.checked .lvl { color: var(--good); }

/* ---------- Notes ---------- */
textarea.notes {
  width: 100%; min-height: 72px; resize: vertical;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  font: inherit; font-size: 14.5px; line-height: 1.6;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea.notes::placeholder { color: var(--faint); }
textarea.notes:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Report tab ---------- */
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
@media (max-width: 900px) { .report-grid { grid-template-columns: 1fr; } }

.radar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 20px 14px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; justify-content: center;
}
.radar-wrap svg {
  width: 100%; height: auto; display: block;
  max-width: 540px; margin: 0 auto;
  overflow: visible;
}
.radar-wrap .legend {
  display: flex; gap: 16px; margin-top: 14px;
  color: var(--muted); font-size: 12px;
  justify-content: center; flex-wrap: wrap;
}
.radar-wrap .legend .dot {
  width: 10px; height: 10px; border-radius: 999px;
  display: inline-block; margin-right: 6px; vertical-align: middle;
}

.topic-bars {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.topic-bars-title {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.10em; text-transform: uppercase;
  font-weight: 600;
  margin: 0 0 16px;
}
.topic-bars .bars {
  display: flex; flex-direction: column;
  justify-content: space-between;
  flex: 1; gap: 6px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 170px) 1fr 56px;
  gap: 14px; align-items: center;
  padding: 8px 0;
}
.bar-row .label {
  font-size: 14px; color: var(--ink); font-weight: 500;
}
.bar-row .label .sub {
  color: var(--muted); font-size: 11px;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.bar-row .track {
  background: var(--surface-2);
  border-radius: 999px;
  height: 10px; overflow: hidden;
}
.bar-row .fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--good));
  transition: width .4s cubic-bezier(.2,.7,.3,1);
}
.bar-row .val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 14px; color: var(--ink); font-weight: 600;
}

/* ---------- Summary / verdict ---------- */
.summary {
  margin-top: 22px;
  padding: 26px 28px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.summary h3 {
  margin: 0 0 8px;
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.10em; text-transform: uppercase;
  font-weight: 600;
}
.summary .verdict {
  font-size: 30px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
}
.summary .verdict.strong-hire { color: var(--good); }
.summary .verdict.hire        { color: var(--accent-strong); }
.summary .verdict.lean-no     { color: var(--warn); }
.summary .verdict.no-hire     { color: var(--bad); }
.summary .verdict.incomplete  { color: var(--muted); }

.summary .meta {
  color: var(--ink-2); font-size: 13.5px;
  margin-top: 10px;
}
.summary .meta b { color: var(--ink); }

/* ---------- Notes digest ---------- */
.note-list { margin-top: 18px; }
.note-list .note-item {
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.note-list .note-item .who {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- Footer ---------- */
footer.foot {
  margin-top: 36px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- Print ---------- */
@media print {
  :root {
    --bg: #ffffff;
    --bg-soft: #ffffff;
    --surface: #ffffff;
    --surface-2: #f6f5f0;
    --surface-3: #ebe9e0;
    --border: #d4d1c6;
    --ink: #14182a;
    --ink-2: #3a4061;
    --muted: #6b7290;
    --shadow: none;
    --shadow-sm: none;
    --shadow-lg: none;
  }
  body { background: #ffffff; color: #14182a; }
  nav.tabs, .actions, header.hero .role-badge { display: none !important; }
  .topic-pane { display: block !important; page-break-inside: avoid; }
  details.reveal { display: none; }
  .card, .radar-wrap, .topic-bars, .summary { box-shadow: none; border-color: #d4d1c6; background: #ffffff; }
}

/* ============ interaction polish (iOS-0017) ============ */

/* score click pop */
.rubric label.pop { animation: iv-pop .28s cubic-bezier(.3,1.6,.5,1) 1; }
@keyframes iv-pop { 0% { transform: scale(1); } 45% { transform: scale(1.09); } 100% { transform: scale(1); } }

/* live progress pill — green when the topic is fully scored */
nav.tabs button .pill.done { background: var(--good-soft, rgba(91,227,192,.15)); color: var(--good, #5be3c0); border-color: var(--good, #5be3c0); }

/* report entrance */
.radar-wrap svg .radar-data { animation: iv-radar .8s cubic-bezier(.2,.9,.3,1) 1; }
@keyframes iv-radar { from { transform: scale(.05); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bar-row .fill { animation: iv-bar .7s ease-out 1; }
@keyframes iv-bar { from { width: 0; } }
.summary .verdict { animation: iv-verdict .45s cubic-bezier(.3,1.5,.5,1) 1; }
@keyframes iv-verdict { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* confetti */
.iv-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.iv-confetti span { position: absolute; width: 8px; height: 11px; border-radius: 2px; opacity: 0; animation: iv-confetti 1.2s cubic-bezier(.21,.61,.35,1) forwards; }
@keyframes iv-confetti { 0% { opacity: 1; transform: translate(0,0) rotate(0); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); } }

@media (prefers-reduced-motion: reduce) {
  .rubric label.pop, .radar-wrap svg .radar-data, .bar-row .fill, .summary .verdict { animation: none; }
}
