/* ============================================================
   React Interview Tutorial — shared styles
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg:            #fdf2f5;   /* soft violet paper */
  --surface:       #ffffff;
  --surface-2:     #fdf1f4;
  --surface-3:     #fffcfd;   /* sidebar */
  --border:        #f2d9e1;
  --text:          #26161c;
  --text-soft:     #6b4d57;
  --text-faint:    #a08b93;

  --accent:        #9f1239;
  --accent-soft:   #fce7ee;
  --react:         #be123c;   /* brand accent (kept name for shared components) */
  --react-soft:    #fdeef3;

  --ok:            #10795a;
  --ok-soft:       #e0f5ec;
  --warn:          #9a5f04;
  --warn-soft:     #fdf0da;
  --danger:        #c02b3e;
  --danger-soft:   #fdeaee;
  --tip:           #1d6fa5;
  --tip-soft:      #e4f0fa;

  --code-bg:       #2a1720;
  --code-text:     #ece8f7;

  --hero-grad:     linear-gradient(135deg, #fde8ef 0%, #fceaea 55%, #f8e9f0 100%);

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 2px rgba(50,30,92,.05), 0 2px 6px rgba(50,30,92,.07);
  --sidebar-w:     260px;

  --mono: "JetBrains Mono", "Cascadia Mono", "Fira Code", Consolas, "Courier New", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg:            #1a1216;
  --surface:       #231a1e;
  --surface-2:     #2d2126;
  --surface-3:     #1e1519;
  --border:        #3e2c34;
  --text:          #f2e8ec;
  --text-soft:     #c6adb6;
  --text-faint:    #957d86;

  --accent:        #f472a0;
  --accent-soft:   #3a1826;
  --react:         #fb9dc0;
  --react-soft:    #341521;
  --hero-grad:     linear-gradient(135deg, #34202a 0%, #38222c 55%, #2c1c24 100%);

  --ok:            #6ed39b;
  --ok-soft:       #15291f;
  --warn:          #e9b872;
  --warn-soft:     #2c2317;
  --danger:        #f08c8c;
  --danger-soft:   #2e1b1c;
  --tip:           #7cc2ee;
  --tip-soft:      #172633;

  --code-bg:       #170f13;
  --code-text:     #e4e0ee;
  --shadow:        0 1px 2px rgba(0,0,0,.45);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 20px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.28; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; margin-top: 2.2rem; }
h3 { font-size: 1.05rem; margin-top: 1.6rem; }
p  { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.3rem; }
li { margin-bottom: .35rem; }
strong { font-weight: 640; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-3);
  border-right: 1px solid var(--border);
  padding: 18px 14px 40px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1rem; letter-spacing: -.02em;
  color: var(--text); margin-bottom: 4px; padding: 0 6px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--react); color: #fff;
  display: grid; place-items: center; font-size: .82rem; font-weight: 700;
}
.brand-sub { font-size: .74rem; color: var(--text-faint); padding: 0 6px 14px; font-weight: 500; }

.side-search {
  width: 100%; padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-family: var(--sans); font-size: .85rem;
}
.side-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.side-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); font-weight: 700;
  padding: 16px 6px 6px;
}

.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-size: .875rem; font-weight: 500;
  line-height: 1.3;
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 620; }
.side-link .num {
  font-family: var(--mono); font-size: .7rem; color: var(--text-faint);
  min-width: 17px; font-weight: 600;
}
.side-link.active .num { color: var(--accent); }
.side-link .tick { margin-left: auto; color: var(--ok); font-size: .8rem; }

.search-results { padding: 2px 0 6px; }
.search-results .side-link { font-size: .8rem; }
.search-empty { padding: 8px 10px; font-size: .8rem; color: var(--text-faint); }

.content { flex: 1; min-width: 0; }
.content-inner { max-width: 880px; margin: 0 auto; padding: 30px 30px 90px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: .82rem; color: var(--text-faint); font-weight: 500; }
.topbar .spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-soft);
  border-radius: var(--radius-sm); padding: 5px 11px; cursor: pointer;
  font-size: .8rem; font-family: var(--sans); font-weight: 550;
}
.icon-btn:hover { background: var(--border); color: var(--text); }

.menu-btn { display: none; }

/* ---------- page head ---------- */
.page-head { border-bottom: 2px solid var(--accent-soft); padding-bottom: 18px; margin-bottom: 8px; }
.eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--react); font-weight: 700; margin-bottom: 6px;
}
.page-head p { color: var(--text-soft); margin: 0; font-size: .97rem; }

/* ---------- question block ---------- */
.q {
  scroll-margin-top: 70px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  margin-top: 30px;
}
.q:first-of-type { border-top: 0; }

.q-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.q-num {
  font-family: var(--mono); font-size: .72rem; font-weight: 700;
  color: var(--react); background: var(--react-soft);
  padding: 3px 7px; border-radius: 5px; white-space: nowrap;
}
.q-head h2 { margin: 0; font-size: 1.22rem; }

/* ---------- callouts ---------- */
.box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin: 0 0 1rem;
}
.box p:last-child, .box ul:last-child { margin-bottom: 0; }
.box-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; margin-bottom: 5px; display: block;
}

.one-line { border-left-color: var(--accent); background: var(--accent-soft); }
.one-line .box-title { color: var(--accent); }
.one-line p { font-size: 1.02rem; }

.trap { border-left-color: var(--danger); background: var(--danger-soft); }
.trap .box-title { color: var(--danger); }

.tip { border-left-color: var(--tip); background: var(--tip-soft); }
.tip .box-title { color: var(--tip); }

.note { border-left-color: var(--warn); background: var(--warn-soft); }
.note .box-title { color: var(--warn); }

.interview { border-left-color: var(--ok); background: var(--ok-soft); }
.interview .box-title { color: var(--ok); }
.interview p { font-style: normal; }
.interview q { quotes: "\201C" "\201D"; }

/* ---------- tables ---------- */
table {
  width: 100%; border-collapse: collapse; margin: 0 0 1.2rem;
  font-size: .9rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

/* ---------- code ---------- */
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--react-soft); border: 1px solid transparent;
  color: color-mix(in srgb, var(--text) 82%, var(--react));
  padding: 1px 5px; border-radius: 4px;
}

pre.code {
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius); padding: 14px 16px;
  overflow-x: auto; margin: 0 0 1.1rem;
  font-family: var(--mono); font-size: .845rem; line-height: 1.6;
  border: 1px solid var(--border);
}
pre.code code { background: none; border: 0; padding: 0; font-size: 1em; color: inherit; }

.diagram {
  background: var(--surface-2); border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 1.1rem;
  font-family: var(--mono); font-size: .8rem; line-height: 1.5;
  color: var(--text-soft); overflow-x: auto; white-space: pre;
}

.bad, .good { font-weight: 650; }
.bad  { color: var(--danger); }
.good { color: var(--ok); }

/* ---------- prev / next ---------- */
.pager { display: flex; gap: 12px; margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--border); }
.pager a {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 15px; background: var(--surface); box-shadow: var(--shadow);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); font-weight: 700; }
.pager .name { display: block; color: var(--text); font-weight: 600; font-size: .92rem; }
.pager .next { text-align: right; }

/* ---------- home ---------- */
.hero {
  background: var(--hero-grad); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 30px; margin-bottom: 26px;
  box-shadow: var(--shadow);
}
.hero h1 { margin-bottom: 8px; }
.hero p { color: var(--text-soft); margin-bottom: 0; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  font-weight: 600; font-size: .9rem; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 13px; }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 15px 16px; box-shadow: var(--shadow);
  display: block; color: var(--text);
}
.card { transition: border-color .15s, transform .15s, box-shadow .15s; }
.card:hover {
  border-color: var(--accent); text-decoration: none; transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(23,48,92,.12);
}
.card .card-num { font-family: var(--mono); font-size: .7rem; color: var(--text-faint); font-weight: 700; }
.card h3 { margin: 3px 0 5px; font-size: 1rem; }
.card p { margin: 0; font-size: .82rem; color: var(--text-soft); line-height: 1.5; }
.card .card-meta { margin-top: 9px; font-size: .72rem; color: var(--text-faint); font-family: var(--mono); }
.card.done { border-left: 3px solid var(--ok); }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin: 18px 0 26px; }
.progress-bar { flex: 1; height: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--ok); width: 0; transition: width .3s; }
.progress-text { font-size: .8rem; color: var(--text-soft); font-weight: 600; white-space: nowrap; }

/* ---------- cheat sheet ---------- */
.sheet-group { margin-bottom: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.sheet-head {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 10px 14px; background: var(--surface-2); border: 0; width: 100%;
  font-family: var(--sans); font-size: .9rem; font-weight: 650; color: var(--text); text-align: left;
}
.sheet-head .count { margin-left: auto; font-size: .74rem; color: var(--text-faint); font-family: var(--mono); }
.sheet-head .caret { color: var(--text-faint); font-size: .75rem; transition: transform .15s; }
.sheet-group.collapsed .caret { transform: rotate(-90deg); }
.sheet-group.collapsed .sheet-body { display: none; }
.sheet-body { padding: 4px 0; }
.sheet-row { display: flex; gap: 11px; padding: 7px 14px; border-bottom: 1px solid var(--border); font-size: .875rem; }
.sheet-row:last-child { border-bottom: 0; }
.sheet-row .sid { font-family: var(--mono); font-size: .72rem; color: var(--text-faint); font-weight: 700; min-width: 30px; padding-top: 3px; }
.sheet-row .sq { font-weight: 620; color: var(--text); }
.sheet-row .sa { color: var(--text-soft); }
.sheet-row .sa code { font-size: .8rem; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }

/* ---------- flashcards ---------- */
.fc-stage { max-width: 640px; margin: 0 auto; }
.fc-card {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow); padding: 34px 30px; min-height: 250px;
  display: flex; flex-direction: column; justify-content: center; cursor: pointer;
}
.fc-tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); font-weight: 700; margin-bottom: 12px; }
.fc-q { font-size: 1.3rem; font-weight: 640; line-height: 1.4; }
.fc-a { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-soft); font-size: 1rem; }
.fc-a .fc-recap { margin-top: 9px; font-family: var(--mono); font-size: .8rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.fc-hint { margin-top: 20px; font-size: .78rem; color: var(--text-faint); }
.fc-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.fc-actions .btn { min-width: 128px; text-align: center; cursor: pointer; }
.fc-actions .know { border-color: var(--ok); color: var(--ok); }
.fc-actions .again { border-color: var(--danger); color: var(--danger); }
.fc-meta { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 20px; font-size: .82rem; color: var(--text-soft); }
.fc-done { text-align: center; padding: 40px 20px; }
.fc-done h2 { margin-top: 0; }

select.filter {
  padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--sans); font-size: .85rem;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .2s;
    box-shadow: 0 0 30px rgba(0,0,0,.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30;
  }
  .menu-btn { display: inline-block; }
  .content-inner { padding: 22px 16px 70px; }
  .pg-body { flex-direction: column; }
  .pg-out { border-left: 0; border-top: 1px solid var(--border); }
  .pg-editor { min-height: 190px; }
  h1 { font-size: 1.55rem; }
  .pager { flex-direction: column; }
}

/* ---------- print (cheat sheet) ---------- */
@media print {
  :root { --surface: #fff; --surface-2: #fff; --bg: #fff; --text: #000; --text-soft: #333; --border: #bbb; }
  .sidebar, .topbar, .toolbar, .pager, .no-print { display: none !important; }
  .layout { display: block; }
  .content-inner { max-width: none; padding: 0; }
  body { font-size: 10.5pt; line-height: 1.38; }
  .sheet-group { break-inside: avoid; border: 0; margin-bottom: 10px; }
  .sheet-group.collapsed .sheet-body { display: block; }
  .sheet-head { background: #eee; padding: 4px 6px; font-size: 10.5pt; border-bottom: 1px solid #999; }
  .sheet-head .caret { display: none; }
  .sheet-row { padding: 2px 6px; font-size: 9.5pt; border-bottom: 0; break-inside: avoid; }
  .sheet-row .sa { color: #000; }
  a { color: #000; text-decoration: none; }
  h1 { font-size: 15pt; }
}

/* anchors for questions that share a section */
.sub-anchor { display: block; height: 0; scroll-margin-top: 70px; }

/* ---------- collapsible areas in the sidebar ---------- */
.area { margin-bottom: 2px; }
.area-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); cursor: pointer;
  font-family: var(--sans); font-size: .8rem; font-weight: 700;
  letter-spacing: .02em; text-align: left;
}
.area-head:hover { background: var(--surface-2); }
.area-head .caret { color: var(--text-faint); font-size: .66rem; transition: transform .15s; }
.area.collapsed .caret { transform: rotate(-90deg); }
.area.collapsed .area-body { display: none; }
.area-head .letter {
  width: 18px; height: 18px; border-radius: 5px; flex: 0 0 18px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .66rem; font-weight: 800;
}
.area-head .count { margin-left: auto; font-family: var(--mono); font-size: .66rem; color: var(--text-faint); font-weight: 600; }
.area.has-active .area-head { color: var(--accent); }
.area-body { padding: 2px 0 6px 6px; border-left: 1px solid var(--border); margin-left: 17px; }
.area-body .side-link { font-size: .83rem; padding: 6px 9px; }

/* ---------- compact question row ---------- */
.q-compact {
  border: 1px solid var(--border); border-left: 3px solid var(--react);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px 15px; margin: 0 0 10px; scroll-margin-top: 70px;
  box-shadow: var(--shadow);
}
.q-compact .qc-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 6px; }
.q-compact .qc-num {
  font-family: var(--mono); font-size: .68rem; font-weight: 700;
  color: var(--react); background: var(--react-soft);
  padding: 2px 6px; border-radius: 4px; white-space: nowrap;
}
.q-compact .qc-q { font-weight: 650; font-size: .98rem; line-height: 1.35; }
.q-compact p { margin: 0 0 .5rem; font-size: .93rem; color: var(--text-soft); }
.q-compact p:last-child { margin-bottom: 0; }
.q-compact strong { color: var(--text); }
.q-compact pre.code { margin: 8px 0 0; font-size: .8rem; padding: 10px 13px; }
.q-compact table { margin: 8px 0 0; font-size: .85rem; }
.q-compact ul { margin: 6px 0 0; font-size: .92rem; color: var(--text-soft); }

/* ---------- reveal ("predict the output") ---------- */
.reveal {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin: 0 0 1.1rem; overflow: hidden;
  box-shadow: var(--shadow);
}
.reveal-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; color: var(--text-faint);
}
.reveal pre.code { margin: 0; border-radius: 0; border: 0; }
.reveal-btn {
  display: block; width: 100%; border: 0; border-top: 1px solid var(--border);
  background: var(--accent-soft); color: var(--accent);
  padding: 9px 12px; cursor: pointer;
  font-family: var(--sans); font-size: .82rem; font-weight: 650;
}
.reveal-btn:hover { filter: brightness(.97); }
.reveal-answer { padding: 13px 16px; border-top: 1px solid var(--border); font-size: .93rem; }
.reveal-answer p:last-child { margin-bottom: 0; }
.reveal-answer .out {
  font-family: var(--mono); font-size: .84rem; background: var(--code-bg); color: var(--code-text);
  padding: 9px 12px; border-radius: var(--radius-sm); margin: 0 0 10px; white-space: pre-wrap;
}

/* ---------- copy button on code blocks ---------- */
.code-wrap { position: relative; }
.copy-btn {
  position: absolute; top: 7px; right: 7px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #cdd3e1; border-radius: 5px; padding: 2px 9px; cursor: pointer;
  font-family: var(--sans); font-size: .7rem; font-weight: 600;
  opacity: 0; transition: opacity .15s;
}
.code-wrap:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.copy-btn.done { color: #8ee5b4; border-color: #8ee5b4; opacity: 1; }

/* ---------- area chips on the home page ---------- */
.area-block { margin-bottom: 30px; }
.area-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.area-title .letter {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: .78rem; font-weight: 800;
}
.area-title h2 { margin: 0; font-size: 1.1rem; }
.area-title .meta { margin-left: auto; font-size: .75rem; color: var(--text-faint); font-family: var(--mono); }
