/* ===========================================================
   PingLabz CCNA study apps - "Patch Panel" visual identity
   Engineering / terminal / blueprint. Shared by the quiz
   (CCNA Flashcards) and learn (CCNA Key Terms) apps.
   Fonts loaded via <link> in each index.html:
     Space Grotesk (display) + IBM Plex Mono (mono/body).
   =========================================================== */

:root {
  --bg:        #0E1110;   /* warm near-black, not navy */
  --bg-grid:   #171C1A;   /* faint graph-paper lines */
  --surface:   #161A18;
  --surface-2: #1E2422;
  --surface-3: #232a27;
  --ink:       #D7E0DA;   /* cool bone */
  --text-dim:  #A4B0A8;
  --muted:     #7E8C84;
  --border:    #2C3530;
  --border-hi: #3C4842;
  --prompt:    #F2A93B;   /* amber CLI accent - eyebrows, primary, active */
  --prompt-ink:#0E1110;
  --signal:    #7FE3A0;   /* phosphor green - correct / progress (LED) */
  --good:      #7FE3A0;
  --good-bg:   rgba(127,227,160,.12);
  --bad:       #E5616B;   /* incorrect */
  --bad-bg:    rgba(229,97,107,.12);
  --warn:      #F2A93B;
  --radius:    3px;
  --maxw:      880px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

[data-theme="light"] {
  --bg:        #EAE6DB;   /* warm drafting paper */
  --bg-grid:   #DCD6C7;
  --surface:   #F4F1E8;
  --surface-2: #ECE8DC;
  --surface-3: #E3DECE;
  --ink:       #1A1E1C;
  --text-dim:  #3D453F;
  --muted:     #6B746E;
  --border:    #CEC8B8;
  --border-hi: #ADA593;
  --prompt:    #A86512;   /* darker amber for contrast on paper */
  --prompt-ink:#FFFFFF;
  --signal:    #1E8E54;
  --good:      #1E8E54;
  --good-bg:   rgba(30,142,84,.12);
  --bad:       #C23A43;
  --bad-bg:    rgba(194,58,67,.10);
  --warn:      #A86512;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.22rem; letter-spacing: -.02em; }
.brand-accent { color: var(--prompt); }
.header-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink); width: 36px; height: 36px; border-radius: var(--radius); cursor: pointer; font-size: 1rem; }
.icon-btn:hover { border-color: var(--prompt); }
.badge { font-family: var(--font-mono); font-size: .68rem; font-weight: 600; padding: 5px 9px; border-radius: var(--radius); text-transform: uppercase; letter-spacing: .08em; border: 1px solid var(--border); }
.badge-free { color: var(--prompt); border-color: color-mix(in srgb, var(--prompt) 50%, var(--border)); }
.badge-full { color: var(--signal); border-color: color-mix(in srgb, var(--signal) 50%, var(--border)); }

.site-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 20px 0; color: var(--muted); font-size: .8rem; background: var(--surface); }
.site-footer a { color: var(--prompt); }

/* ---------- screens / hero ---------- */
main.wrap { padding-top: 28px; padding-bottom: 48px; flex: 1; }
.screen { display: none; animation: fade .2s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero { margin-bottom: 22px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 0 0 10px; letter-spacing: -.02em; line-height: 1.08; }
.lede { color: var(--text-dim); max-width: 640px; margin: 0; font-size: .98rem; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.card h2 { font-family: var(--font-display); font-size: 1rem; margin: 0 0 13px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: "▍"; color: var(--prompt); }
.topic-block, .length-block { margin-top: 24px; }

/* ---------- grids (mode / topic / deck / length) ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-btn { display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; color: var(--ink); transition: border-color .12s, background .12s; font-family: var(--font-mono); }
.mode-btn:hover { border-color: var(--border-hi); }
.mode-btn.active { border-color: var(--prompt); background: color-mix(in srgb, var(--prompt) 8%, var(--surface)); }
.mode-title { font-weight: 600; }
.mode-sub { font-size: .78rem; color: var(--muted); }

.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.topic-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; color: var(--ink); text-align: left; transition: border-color .12s, background .12s; font-family: var(--font-mono); }
.topic-btn:hover { border-color: var(--border-hi); }
.topic-btn.active { border-color: var(--prompt); background: color-mix(in srgb, var(--prompt) 8%, var(--surface)); }
.topic-btn .t-name { font-weight: 500; font-size: .92rem; }
.topic-btn .t-meta { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.topic-btn .t-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 6px currentColor; }
.topic-btn .t-prog { color: var(--signal); }

.length-grid { display: flex; gap: 9px; flex-wrap: wrap; }
.len-btn { min-width: 62px; padding: 10px 15px; border-radius: var(--radius); cursor: pointer; background: var(--surface-2); border: 1px solid var(--border); color: var(--ink); font-weight: 600; font-family: var(--font-mono); }
.len-btn.active { border-color: var(--prompt); background: color-mix(in srgb, var(--prompt) 8%, var(--surface)); }

.checkbox-row { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--text-dim); font-size: .88rem; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--prompt); }

.setup-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .82rem; margin: 0; }
.fineprint { color: var(--muted); font-size: .8rem; margin-top: 16px; }

/* ---------- buttons ---------- */
.btn { font-family: var(--font-mono); font-weight: 500; letter-spacing: .01em; border-radius: var(--radius); cursor: pointer; border: 1px solid var(--border); padding: 11px 18px; font-size: .9rem; transition: border-color .12s, background .12s; color: var(--ink); background: var(--surface-2); }
.btn:hover:not(:disabled) { border-color: var(--border-hi); background: var(--surface-3); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--prompt); color: var(--prompt-ink); border-color: var(--prompt); font-weight: 600; }
.btn-primary:not(:disabled):hover { filter: brightness(1.07); background: var(--prompt); border-color: var(--prompt); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 13px 26px; font-size: .98rem; }
.btn-sm { padding: 8px 13px; font-size: .82rem; }
.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; margin: 14px 0; }

/* ---------- quiz/learn topbar + progress ---------- */
.quiz-topbar { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "quit meta" "bar bar"; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
#quitBtn { grid-area: quit; justify-self: start; }
.progress-meta { grid-area: meta; justify-self: end; color: var(--text-dim); font-size: .82rem; font-family: var(--font-mono); }
.progress-meta .dot { color: var(--border-hi); margin: 0 6px; }
.progress-track { grid-area: bar; height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--prompt); transition: width .3s ease; }

/* ---------- quiz card ---------- */
.q-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.tag { font-family: var(--font-mono); font-size: .66rem; font-weight: 500; padding: 4px 8px; border-radius: var(--radius); text-transform: uppercase; letter-spacing: .08em; border: 1px solid var(--border); color: var(--muted); }
.tag-domain { color: var(--prompt); }
.tag-diff { color: var(--warn); }
.q-text { font-family: var(--font-display); font-size: 1.22rem; line-height: 1.4; margin: 0 0 6px; letter-spacing: -.01em; }
.q-hint { color: var(--muted); font-size: .82rem; margin: 0 0 15px; }
.q-text code, .explanation code, .opt-text code, .flash-text code { font-family: var(--font-mono); background: var(--surface-3); padding: 1px 6px; border-radius: var(--radius); font-size: .9em; color: var(--ink); }

.options { display: flex; flex-direction: column; gap: 9px; }
.opt { display: flex; align-items: flex-start; gap: 12px; width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; color: var(--ink); transition: border-color .1s, background .1s; font-size: .96rem; font-family: var(--font-mono); text-align: left; }
.opt:hover:not(.locked) { border-color: var(--border-hi); }
.opt .opt-key { flex: 0 0 auto; width: 25px; height: 25px; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .82rem; color: var(--muted); }
.opt.selected { border-color: var(--prompt); }
.opt.selected .opt-key { background: var(--prompt); color: var(--prompt-ink); border-color: var(--prompt); }
.opt.locked { cursor: default; }
.opt.correct { border-color: var(--good); background: var(--good-bg); }
.opt.correct .opt-key { background: var(--good); color: var(--prompt-ink); border-color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .opt-key { background: var(--bad); color: #fff; border-color: var(--bad); }

.answer-panel { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 15px; animation: fade .15s; }
.verdict { font-family: var(--font-display); font-weight: 700; margin-bottom: 8px; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.explanation h3 { margin: 0 0 4px; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--prompt); font-family: var(--font-mono); }
.explanation h3::before { content: "$ "; color: var(--muted); }
.explanation p { margin: 0; color: var(--text-dim); }
.quiz-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- results ---------- */
.results-card { text-align: center; }
.results-card h1 { font-family: var(--font-display); margin: 0 0 18px; letter-spacing: -.02em; }
.score-ring { width: 144px; height: 144px; margin: 6px auto 10px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: conic-gradient(var(--signal) var(--ring,0%), var(--surface-2) 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); }
.score-ring > * { position: relative; z-index: 1; }
#scorePct, #sumPct { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.score-frac { color: var(--muted); font-size: .85rem; }
.score-verdict { color: var(--text-dim); margin: 4px 0 22px; font-size: 1rem; }

table.breakdown { width: 100%; border-collapse: collapse; margin: 6px 0 20px; font-size: .9rem; font-family: var(--font-mono); }
table.breakdown th, table.breakdown td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.breakdown th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
table.breakdown td:nth-child(2), table.breakdown td:nth-child(3),
table.breakdown th:nth-child(2), table.breakdown th:nth-child(3) { text-align: right; }
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.review-block { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
.review-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.review-item.ri-wrong { border-left: 3px solid var(--bad); }
.review-item.ri-ok { border-left: 3px solid var(--good); }
.review-item .ri-q { font-weight: 600; margin: 0 0 8px; }
.review-item .ri-line { font-size: .88rem; margin: 3px 0; color: var(--text-dim); }
.review-item .ri-correct { color: var(--good); }
.review-item .ri-your { color: var(--bad); }
.review-item .ri-exp { color: var(--muted); font-size: .86rem; margin-top: 8px; }

/* ---------- flashcard (learn app) ---------- */
.flashwrap { perspective: 1600px; margin: 8px 0 22px; }
.flashcard { width: 100%; min-height: 320px; cursor: pointer; outline: none; }
.flashcard:focus-visible .flash-inner { box-shadow: 0 0 0 2px var(--prompt); border-radius: var(--radius); }
.flash-inner { position: relative; width: 100%; min-height: 320px; transition: transform .5s cubic-bezier(.4,.2,.2,1); transform-style: preserve-3d; }
.flash-inner.flipped { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 34px 28px; min-height: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.flash-back { transform: rotateY(180deg); background: var(--surface-2); }
.flash-side { position: absolute; top: 15px; left: 18px; font-family: var(--font-mono); font-size: .68rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.flash-front .flash-side { color: var(--prompt); }
.flash-side::before { content: "$ "; color: var(--muted); }
.flash-text { font-family: var(--font-mono); font-size: clamp(1.3rem, 3.2vw, 1.95rem); font-weight: 600; line-height: 1.35; margin: 0; color: var(--ink); }
.flash-back .flash-text { font-family: var(--font-display); font-size: clamp(1.02rem, 2.2vw, 1.25rem); font-weight: 500; line-height: 1.5; color: var(--text-dim); }
.flash-tap { position: absolute; bottom: 13px; right: 16px; font-family: var(--font-mono); font-size: .68rem; color: var(--muted); }

.learn-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.nav-mid { display: flex; gap: 8px; justify-content: center; }
.btn-still { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); justify-self: start; }
.btn-still:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn-know { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--border)); justify-self: end; }
.btn-know:hover { border-color: var(--good); background: var(--good-bg); }
.kbd-hint { text-align: center; color: var(--muted); font-size: .76rem; margin: 16px 0 0; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,10,9,.8); display: grid; place-items: center; z-index: 50; padding: 18px; }
.modal { background: var(--surface); border: 1px solid var(--border-hi); border-radius: var(--radius); padding: 28px; max-width: 480px; width: 100%; position: relative; }
.modal h2 { font-family: var(--font-display); margin: 0 0 12px; font-size: 1.25rem; letter-spacing: -.01em; }
.modal p { color: var(--text-dim); margin: 0 0 14px; font-size: .92rem; }
.gate-steps { color: var(--text-dim); padding-left: 20px; margin: 0 0 6px; font-size: .9rem; }
.gate-steps li { margin: 6px 0; }
.gate-note { font-size: .82rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin: 0 0 12px; }
.unlock-row { display: flex; gap: 8px; margin-top: 8px; }
.unlock-row input { flex: 1; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); font-size: .92rem; font-family: var(--font-mono); }
.unlock-row input:focus { outline: none; border-color: var(--prompt); }
.unlock-msg { font-size: .86rem; margin: 10px 0 0; min-height: 1.1em; font-family: var(--font-mono); }
.unlock-msg.ok { color: var(--good); }
.unlock-msg.no { color: var(--bad); }
.modal-close { position: absolute; top: 10px; right: 13px; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 620px) {
  .mode-grid { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.65rem; }
  .card { padding: 18px; }
  .setup-footer { flex-direction: column; align-items: stretch; }
  .setup-footer .btn { width: 100%; }
  .learn-controls { grid-template-columns: 1fr 1fr; }
  .nav-mid { grid-column: 1 / -1; order: 3; margin-top: 4px; }
  .btn-still, .btn-know { justify-self: stretch; }
}
