/* Neobrutalist component layer. */

/* ---------- nav + shell ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--paper);
  border-bottom: var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 8px 0;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 6px 12px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.logo .dot {
  width: 10px;
  height: 10px;
  background: var(--ink);
  border-radius: 50%;
}
.nav-links { display: flex; flex-wrap: wrap; gap: 6px; }
.nav-link {
  min-height: 36px;
  padding: 6px 10px;
  border: var(--border-thin);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
}
.nav-link:hover { background: var(--accent); }
.nav-link[aria-current="page"] { background: var(--accent); box-shadow: var(--shadow-sm); }
.nav-spacer { flex: 1; }

.footer {
  border-top: var(--border);
  background: var(--paper-2);
  padding: 18px 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer .wrap { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }

/* ---------- typography helpers ---------- */
.kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  border: var(--border-thin);
  padding: 2px 8px;
  margin-bottom: 10px;
}
.lede { font-size: 1.05rem; color: var(--muted); max-width: 62ch; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.section-title h2 { margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.flat { box-shadow: none; }
.card.accent { border-top: 10px solid var(--accent); }
.card.tight { padding: 14px; }
.card-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-title h3 { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
}
.btn:hover { transform: translate(4px, 4px); box-shadow: none; }
.btn:active { transform: translate(5px, 5px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn.primary { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); }
.btn.good { background: var(--green); }
.btn.sm { padding: 7px 11px; font-size: 0.75rem; min-height: 34px; }
.btn.lg { padding: 13px 22px; font-size: 0.95rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- badges + stats ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: var(--border-thin);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge.accent { background: var(--accent); }
.badge.good { background: var(--green); }
.badge.bad { background: var(--red); }
.badge.warn { background: var(--orange); }
.badge.mono { font-family: var(--font-mono); text-transform: none; letter-spacing: 0; }

.stat {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
}
.stat .v { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; }
.stat .l { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }

/* ---------- progress ---------- */
.progress {
  height: 16px;
  border: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-right: var(--border-thin);
  transition: width 0.2s ease;
}
.progress.thin { height: 10px; box-shadow: none; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: var(--border);
  background: var(--surface);
  box-shadow: inset 2px 2px 0 rgba(18, 18, 18, 0.08);
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.input.good { background: #e6f7e6; border-color: var(--good); }
.input.bad { background: #ffe9e9; border-color: var(--bad); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: var(--border-thin);
  background: var(--surface);
  cursor: pointer;
}
.check:hover { background: var(--surface-2); }
.check input { width: 32px; height: 32px; margin-top: 0; accent-color: var(--accent); }

/* ---------- tabs + chips ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab {
  padding: 8px 13px;
  border: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tab:hover { transform: translate(2px, 2px); box-shadow: none; }
.tab[aria-selected="true"], .tab[aria-pressed="true"] { background: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px;
  padding: 6px 12px;
  border: var(--border-thin);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--accent); box-shadow: var(--shadow-sm); border-color: var(--ink); }
.chip:disabled { opacity: 0.55; cursor: not-allowed; background: var(--surface-2); }
.chip .n { color: var(--muted); font-weight: 700; margin-left: 4px; }

/* ---------- option list (quiz) ---------- */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
}
.option:hover { transform: translate(2px, 2px); box-shadow: none; }
.option:focus,
.option:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: var(--shadow-sm);
}
.option .letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  height: 28px;
  border: var(--border-thin);
  background: var(--paper-2);
  font-family: var(--font-display);
  font-size: 0.8rem;
}
.option .txt { flex: 1; }
.option.selected { background: var(--accent); }
.option.selected .letter { background: var(--ink); color: var(--surface); }
.option.correct { background: var(--green); }
.option.wrong { background: var(--red); }
.option.locked { cursor: default; }
.option.locked:hover { transform: none; box-shadow: var(--shadow-sm); }

/* ---------- feedback + results ---------- */
.feedback {
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-top: 14px;
}
.feedback.good { background: #e6f7e6; }
.feedback.bad { background: #ffe9e9; }
.feedback.warn { background: #fff4dd; }
.feedback .verdict { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 6px; }
.feedback.good .verdict { color: var(--good); }
.feedback.bad .verdict { color: var(--bad); }
.feedback .answer { font-weight: 800; margin-bottom: 6px; }

.score-big {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 5rem);
  line-height: 1;
  letter-spacing: -0.04em;
}
.score-big small { font-family: var(--font-body); font-size: 1rem; font-weight: 700; color: var(--muted); }

.breakdown {
  border: var(--border);
  background: var(--surface-2);
  padding: 14px;
}
.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(18, 18, 18, 0.25);
}
.breakdown-row:last-child { border-bottom: 0; }

.miss-item {
  border: var(--border);
  border-left: 8px solid var(--bad);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 10px;
}
.miss-item .q { font-weight: 800; margin: 6px 0 8px; }
.miss-item .you { color: var(--bad); font-size: 0.9rem; }
.miss-item .cor { color: var(--good); font-size: 0.9rem; }
.miss-item .exp { color: var(--muted); font-size: 0.9rem; margin-top: 8px; border-top: 1px dashed rgba(18,18,18,.25); padding-top: 8px; }

/* ---------- exam cards / dashboard ---------- */
.exam-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.exam-card:hover { transform: translate(-3px, -3px); box-shadow: var(--shadow-lg); }
.exam-card .stripe { height: 12px; background: var(--accent); border-bottom: var(--border); }
.exam-card .body { padding: 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.exam-card .name { font-family: var(--font-display); font-size: 1.4rem; }
.exam-card .code { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.exam-card .desc { color: var(--muted); font-size: 0.9rem; flex: 1; }
.exam-card .meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- section list ---------- */
.section-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: var(--border-thin);
  background: var(--surface);
  cursor: pointer;
}
.section-row:hover { background: var(--surface-2); }
.section-row.selected { background: var(--accent); }
.section-row .name { flex: 1; font-weight: 700; font-size: 0.92rem; }
.section-row .count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }

/* ---------- mock ---------- */
/* Task screens keep the nav in flow so it cannot cover a terminal or question. */
[data-view="study"] .nav,
[data-view="mock"] .nav,
[data-view="pbq-scenario"] .nav,
[data-view="lesson"] .nav { position: static; }
[data-view="mock"] .mock-bar { top: 0; }

.mock-bar {
  position: sticky;
  top: 68px;
  z-index: 10;
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.timer {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.15rem;
  background: var(--surface);
  border: var(--border-thin);
  padding: 4px 10px;
}
.timer.low { background: var(--red); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.65; } }

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.palette button {
  height: 40px;
  border: var(--border-thin);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
}
.palette button.answered { background: var(--green); }
.palette button.flagged { background: var(--orange); }
.palette button.current { outline: 3px solid var(--focus); outline-offset: 1px; }
.palette button.pbq { border-style: dashed; }

/* ---------- PBQ shell ---------- */
.pbq-head { border-bottom: var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.pbq-goal {
  border: var(--border-thin);
  border-left: 8px solid var(--accent);
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 0.9rem;
}
.pbq-top-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.pbq-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 0;
  border-top: var(--border);
  background: var(--surface);
}
.pbq-debrief {
  margin-top: 14px;
  border: var(--border);
  background: var(--surface-2);
  padding: 14px;
  font-size: 0.92rem;
}
.pbq-debrief h3 { margin-bottom: 6px; }
.pbq-debrief p { white-space: pre-wrap; }
.hints { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.hint {
  border: var(--border-thin);
  border-left: 8px solid var(--orange);
  background: #fff4dd;
  padding: 8px 12px;
  font-size: 0.88rem;
}

/* match */
.match-list { display: flex; flex-direction: column; gap: 10px; }
.match-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.8fr);
  gap: 10px;
  align-items: center;
  border: var(--border-thin);
  background: var(--surface);
  padding: 10px;
}
.match-row.correct { background: #e6f7e6; }
.match-row.wrong { background: #ffe9e9; }
.match-left { font-size: 0.9rem; }
.match-fix { grid-column: 1 / -1; font-size: 0.82rem; color: var(--good); font-weight: 700; }
@media (max-width: 640px) { .match-row { grid-template-columns: 1fr; } }

/* order */
.order-list { display: flex; flex-direction: column; gap: 8px; list-style: none; padding: 0; margin: 0; }
.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: var(--border-thin);
  background: var(--surface);
  padding: 8px 10px;
}
.order-item.dragging { opacity: 0.5; }
.order-item .handle { font-family: var(--font-mono); color: var(--muted); cursor: grab; }
.order-item .txt { flex: 1; font-size: 0.9rem; }
.order-item .controls { display: flex; gap: 4px; }
.order-item .controls button {
  width: 36px; height: 36px;
  border: var(--border-thin);
  background: var(--surface-2);
  cursor: pointer;
}
.order-item.correct { background: #e6f7e6; }
.order-item.wrong { background: #ffe9e9; }

/* fill */
.fill-list { display: flex; flex-direction: column; gap: 12px; }
.fill-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 0.8fr); gap: 10px; align-items: center; }
.fill-field .lbl { font-size: 0.9rem; font-weight: 700; }
@media (max-width: 640px) { .fill-field { grid-template-columns: 1fr; } }

/* stages */
.stage {
  border: var(--border);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 12px;
}
.stage.correct { border-color: var(--good); }
.stage.wrong { border-color: var(--bad); }
.stage .sn { font-size: 0.75rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stage .sp { font-weight: 800; margin: 6px 0 10px; }
.stage .sopts { display: flex; flex-direction: column; gap: 8px; }
.stage .sopt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: var(--border-thin);
  background: var(--surface-2);
  padding: 8px 10px;
  cursor: pointer;
}
.stage .sopt.sel { background: var(--accent); }
.stage .snote { margin-top: 10px; font-size: 0.85rem; color: var(--good); font-weight: 700; }

/* table */
.dtable { width: 100%; border-collapse: collapse; background: var(--surface); }
.dtable th, .dtable td { border: var(--border-thin); padding: 8px; text-align: left; vertical-align: top; font-size: 0.88rem; }
.dtable th { background: var(--paper-2); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.dtable tr.correct td { background: #e6f7e6; }
.dtable tr.wrong td { background: #ffe9e9; }
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dtable { min-width: 640px; }
.dcards { display: none; }

/* terminal */
.terminal {
  background: #0c1117;
  color: #d7e2d9;
  border: var(--border);
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 12px 14px;
  height: 340px;
  overflow-y: auto;
  cursor: text;
}
.term-line { white-space: pre-wrap; word-break: break-word; margin: 0; }
.term-line.echo { color: #8fb7ff; }
.term-line.err { color: #ff9b8a; }
.term-line.ok { color: #7ee787; font-weight: 700; }
.term-input-row { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.term-prompt { color: #7ee787; white-space: pre; }
.term-input {
  flex: 1;
  min-height: 32px;
  background: transparent;
  border: 0;
  outline: 0;
  color: #d7e2d9;
  font-family: inherit;
  font-size: inherit;
  padding: 2px 0;
}
.term-input:focus-visible { outline: 1px dashed #7ee787; outline-offset: 2px; }

/* triage */
.triage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.host-card { border: var(--border); background: var(--surface); padding: 12px; }
.host-card.correct { border-color: var(--good); }
.host-card.wrong { border-color: var(--bad); }
.host-card .hname { font-weight: 900; }
.hlog {
  background: #0c1117;
  color: #d7e2d9;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  padding: 10px;
  border: var(--border-thin);
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-overflow-scrolling: touch;
}
.host-card .hlog { max-height: 190px; }
.host-card .states { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.host-card .states button {
  border: var(--border-thin);
  background: var(--surface-2);
  padding: 6px 10px;
  min-height: 32px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}
.host-card .states button.sel { background: var(--accent); }

/* visible check marks after a PBQ check (colour is reinforcement, not the only cue) */
.match-row.correct .match-left::after,
.order-item.correct .txt::after,
.stage.correct .sp::after,
.host-card.correct .hname::after,
.dtable tr.correct td:first-child::after {
  content: " ✓";
  color: var(--good);
  font-weight: 900;
}
.match-row.wrong .match-left::after,
.order-item.wrong .txt::after,
.stage.wrong .sp::after,
.host-card.wrong .hname::after,
.dtable tr.wrong td:first-child::after {
  content: " ✗";
  color: var(--bad);
  font-weight: 900;
}

/* ---------- dialog + toast ---------- */
dialog {
  border: var(--border);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  padding: 0;
  width: min(560px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(18, 18, 18, 0.5); }
.dialog-body { padding: 20px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: var(--border); background: var(--surface-2); }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100% - 32px));
}
.toast {
  background: var(--surface);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.88rem;
  animation: toast-in 0.15s ease;
}
.toast.good { background: var(--green); }
.toast.bad { background: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 760px) {
  .nav { position: static; }
  .nav-inner { flex-wrap: wrap; gap: 8px; padding: 8px 0; }
  .nav-inner > .badge { display: none; }
  .nav-spacer { display: none; }
  .mock-bar { position: sticky; top: 0; z-index: 10; }
  .review-label { white-space: normal; }
}

.review-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.btn:disabled,
.btn.primary:disabled,
.btn.danger:disabled,
.btn.good:disabled,
.btn[aria-disabled="true"] {
  opacity: 1;
  background: var(--surface-2);
  color: var(--muted);
  border-style: dashed;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 640px) {
  .btn, .btn.sm { min-height: 44px; }
  .nav-link, .chip, .tab { min-height: 40px; display: inline-flex; align-items: center; }
  .palette button { height: 44px; }
}

.pbq, .pbq-body { min-width: 0; max-width: 100%; }

@media (max-width: 640px) {
  .order-item .controls button { width: 40px; height: 40px; }
  .host-card .states button { min-height: 40px; }
}

@media (max-width: 640px) {
  .check input { width: 32px; height: 32px; }
}

@media (max-width: 640px) {
  .domain-row { flex-wrap: wrap; }
  .domain-row .nm { flex: 1 1 100%; }
  .domain-row .bar { display: none; }
  .domain-row .w { order: 1; }
  .domain-row .badge { order: 2; margin-left: auto; }
}

@media (max-width: 640px) {
  .nav-link, .chip, .tab, .logo { min-height: 44px; }
  .review-item { min-height: 44px; }
  .term-input { min-height: 44px; }
  .dtable-wrap { display: none; }
  .dcards { display: flex; flex-direction: column; gap: 10px; }
  .dcard { border: var(--border); background: var(--surface); padding: 10px; }
  .dcard.correct { border-color: var(--good); background: #e6f7e6; }
  .dcard.wrong { border-color: var(--bad); background: #ffe9e9; }
  .dcell { padding: 4px 0; }
  .dlabel {
    display: block;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .dcard.correct .dcell:first-child::after { content: " ✓"; color: var(--good); font-weight: 900; }
  .dcard.wrong .dcell:first-child::after { content: " ✗"; color: var(--bad); font-weight: 900; }
}
