/* ============================================================
   React Interview Tutorial — shared styles
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg:            #eef3fb;   /* soft blue paper */
  --surface:       #ffffff;
  --surface-2:     #f2f6fd;
  --surface-3:     #fbfcff;   /* sidebar */
  --border:        #d8e3f2;
  --text:          #15202f;
  --text-soft:     #4d5b72;
  --text-faint:    #8090a8;

  --accent:        #1f6fd0;
  --accent-soft:   #e3eefc;
  --react:         #0b8ba8;
  --react-soft:    #def3f7;

  --ok:            #10795a;
  --ok-soft:       #e0f5ec;
  --warn:          #9a5f04;
  --warn-soft:     #fdf0da;
  --danger:        #c02b3e;
  --danger-soft:   #fdeaee;
  --tip:           #6a45b8;
  --tip-soft:      #efe9fc;

  --code-bg:       #1b2333;
  --code-text:     #e7ecf5;

  --hero-grad:     linear-gradient(135deg, #e8f0ff 0%, #f3ebff 55%, #e2f5f8 100%);

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 2px rgba(23,48,92,.05), 0 2px 6px rgba(23,48,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:            #12161d;
  --surface:       #1a1f28;
  --surface-2:     #222834;
  --surface-3:     #171c24;
  --border:        #2d3541;
  --text:          #e7eaef;
  --text-soft:     #a8b0bb;
  --text-faint:    #79828f;

  --accent:        #63a6f0;
  --accent-soft:   #17283c;
  --react:         #5bc8e8;
  --react-soft:    #12303a;
  --hero-grad:     linear-gradient(135deg, #1c2634 0%, #241f38 55%, #16303a 100%);

  --ok:            #6ed39b;
  --ok-soft:       #15291f;
  --warn:          #e9b872;
  --warn-soft:     #2c2317;
  --danger:        #f08c8c;
  --danger-soft:   #2e1b1c;
  --tip:           #c3a5ee;
  --tip-soft:      #241d33;

  --code-bg:       #10141b;
  --code-text:     #dfe4ec;
  --shadow:        0 1px 2px rgba(0,0,0,.4);
}

/* ---------- 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); }

/* ---------- playground ---------- */
.playground {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 0 0 1.2rem; background: var(--surface);
  box-shadow: var(--shadow);
}
.pg-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.pg-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 700; color: var(--text-faint);
}
.pg-bar .spacer { flex: 1; }
.pg-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  border-radius: 5px; padding: 3px 10px; cursor: pointer;
  font-size: .76rem; font-family: var(--sans); font-weight: 600;
}
.pg-btn:hover { background: var(--border); color: var(--text); }
.pg-btn.run { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg-btn.run:hover { filter: brightness(1.08); }

.pg-body { display: flex; align-items: stretch; }
.pg-editor {
  flex: 1 1 58%; min-width: 0;
  background: var(--code-bg); color: var(--code-text);
  border: 0; resize: vertical; display: block;
  padding: 13px 15px; margin: 0;
  font-family: var(--mono); font-size: .83rem; line-height: 1.6;
  tab-size: 2;
}
.pg-editor:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.pg-out {
  flex: 1 1 42%; min-width: 0;
  border-left: 1px solid var(--border);
  padding: 14px 16px; background: var(--surface);
  font-size: .92rem; overflow-x: auto;
}
.pg-out-label {
  font-size: .64rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-faint); font-weight: 700; margin-bottom: 8px;
}
.pg-error {
  color: var(--danger); background: var(--danger-soft);
  border: 1px solid var(--danger); border-radius: var(--radius-sm);
  padding: 9px 11px; font-family: var(--mono); font-size: .78rem;
  white-space: pre-wrap; word-break: break-word;
}
.pg-offline {
  padding: 9px 12px; font-size: .78rem; color: var(--warn);
  background: var(--warn-soft); border-top: 1px solid var(--border);
}

/* elements rendered inside the output pane get sane default looks */
.pg-out button {
  font: inherit; padding: 6px 13px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; margin: 0 6px 6px 0;
}
.pg-out button:hover { filter: brightness(1.08); }
.pg-out input, .pg-out select, .pg-out textarea {
  font: inherit; padding: 6px 9px; margin: 0 6px 6px 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text);
}
.pg-out ul { padding-left: 1.2rem; }
.pg-out p { margin: 0 0 .5rem; }

/* ---------- 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; }
