/* ==========================================================================
   Interview Preparation — shared navigation shell
   Injected into every page. Uses high-specificity, scoped selectors so it
   never fights each page's own inline <style>. All chrome is prefixed .ipn*.
   ========================================================================== */

:root {
  --ipn-bar-h: 54px;
  --ipn-side-w: 300px;
  --ipn-accent: #10b981;
  --ipn-accent-strong: #0d9668;
  --ipn-bg: #ffffff;
  --ipn-fg: #1a1a1a;
  --ipn-muted: #667085;
  --ipn-faint: #98a2b3;
  --ipn-border: #e6e8eb;
  --ipn-surface: #f7f9fb;
  --ipn-side-bg: #fbfcfd;
  --ipn-hover: #f0fdf4;
  --ipn-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --ipn-shadow-lg: 0 10px 30px rgba(16,24,40,.14), 0 4px 8px rgba(16,24,40,.08);
  --ipn-radius: 10px;
  --ipn-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --ipn-bg: #0f1419;
  --ipn-fg: #e6eaf0;
  --ipn-muted: #9aa5b1;
  --ipn-faint: #6b7683;
  --ipn-border: #242b34;
  --ipn-surface: #161c24;
  --ipn-side-bg: #12171e;
  --ipn-hover: #14231d;
  --ipn-accent: #34d3a6;
  --ipn-accent-strong: #4ee0b6;
  --ipn-shadow: 0 1px 2px rgba(0,0,0,.4);
  --ipn-shadow-lg: 0 12px 34px rgba(0,0,0,.55);
}

/* ---- Reserve space for the fixed chrome ---------------------------------- */
html.ipn-on { scroll-padding-top: calc(var(--ipn-bar-h) + 16px); }
html.ipn-on body {
  padding-top: calc(var(--ipn-bar-h) + 18px) !important;
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.ipn-bar {
  position: fixed; inset: 0 0 auto 0; height: var(--ipn-bar-h);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 .85rem;
  background: var(--ipn-bg);
  background: color-mix(in srgb, var(--ipn-bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ipn-border);
  font-family: var(--ipn-font);
  z-index: 1000;
}
.ipn-menu {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--ipn-border); border-radius: 9px;
  background: var(--ipn-bg); color: var(--ipn-fg); cursor: pointer;
  font-size: 1.1rem; line-height: 1;
}
.ipn-menu:hover { background: var(--ipn-surface); }

.ipn-brand {
  display: inline-flex; align-items: center; gap: .55rem;
  text-decoration: none; color: var(--ipn-fg);
  font-weight: 700; font-size: 1rem; letter-spacing: -.01em;
  white-space: nowrap;
}
.ipn-brand:hover { color: var(--ipn-fg); }
.ipn-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--ipn-accent), var(--ipn-accent-strong));
  color: #fff; font-weight: 800; font-size: .82rem; letter-spacing: -.02em;
  box-shadow: 0 2px 6px rgba(16,185,129,.35);
}
.ipn-spacer { flex: 1 1 auto; }

.ipn-search {
  display: inline-flex; align-items: center; gap: .5rem;
  height: 38px; padding: 0 .7rem; min-width: 150px;
  border: 1px solid var(--ipn-border); border-radius: 9px;
  background: var(--ipn-surface); color: var(--ipn-muted);
  font-family: var(--ipn-font); font-size: .88rem; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ipn-search:hover { border-color: var(--ipn-accent); color: var(--ipn-fg); }
.ipn-search .ipn-mag { font-size: .95rem; }
.ipn-search .ipn-hint { margin-left: auto; padding-left: .6rem; }
.ipn-kbd {
  font: inherit; font-size: .72rem; line-height: 1;
  padding: .2rem .4rem; border-radius: 5px;
  border: 1px solid var(--ipn-border); background: var(--ipn-bg);
  color: var(--ipn-faint);
}
.ipn-theme {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--ipn-border); border-radius: 9px;
  background: var(--ipn-bg); color: var(--ipn-fg); cursor: pointer;
  font-size: 1.05rem; line-height: 1;
}
.ipn-theme:hover { background: var(--ipn-surface); }

/* ==========================================================================
   Sidebar (course lessons)
   ========================================================================== */
.ipn-side {
  position: fixed; top: var(--ipn-bar-h); bottom: 0; left: 0;
  width: var(--ipn-side-w);
  display: flex; flex-direction: column;
  background: var(--ipn-side-bg);
  border-right: 1px solid var(--ipn-border);
  font-family: var(--ipn-font);
  transform: translateX(-100%);
  transition: transform .22s ease;
  z-index: 900;
}
.ipn-side-head {
  padding: 1rem 1.1rem .7rem;
  border-bottom: 1px solid var(--ipn-border);
}
.ipn-eyebrow {
  display: block; font-size: .68rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ipn-accent); margin-bottom: .3rem;
}
.ipn-course-title {
  display: block; text-decoration: none;
  color: var(--ipn-fg); font-weight: 700; font-size: 1.02rem; line-height: 1.3;
}
.ipn-course-title:hover { color: var(--ipn-accent); }
.ipn-count { display: block; margin-top: .3rem; font-size: .78rem; color: var(--ipn-muted); }

.ipn-lessons {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: .5rem .5rem 2rem;
}
.ipn-lesson {
  display: flex; gap: .55rem; align-items: baseline;
  padding: .42rem .6rem; margin: .1rem 0;
  border-radius: 7px; text-decoration: none;
  color: var(--ipn-muted); font-size: .86rem; line-height: 1.35;
  border-left: 2px solid transparent;
}
.ipn-lesson:hover { background: var(--ipn-hover); color: var(--ipn-fg); }
.ipn-lesson .ipn-num {
  flex: 0 0 auto; min-width: 1.6em; text-align: right;
  font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--ipn-faint);
}
.ipn-lesson.is-active {
  background: var(--ipn-hover); color: var(--ipn-accent-strong);
  font-weight: 600; border-left-color: var(--ipn-accent);
}
html[data-theme="dark"] .ipn-lesson.is-active { color: var(--ipn-accent-strong); }
.ipn-lesson.is-active .ipn-num { color: var(--ipn-accent); }

/* ---- Collapsible chapters -------------------------------------------- */
.ipn-chap { margin: .05rem 0; }
.ipn-chap-head {
  width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .5rem .55rem; border: none; background: none; cursor: pointer;
  font-family: var(--ipn-font); font-size: .85rem; font-weight: 600;
  color: var(--ipn-fg); text-align: left; border-radius: 7px;
}
.ipn-chap-head:hover { background: var(--ipn-hover); }
.ipn-chap-caret {
  flex: 0 0 auto; width: .8em; font-size: .7rem; color: var(--ipn-faint);
  transition: transform .18s ease;
}
.ipn-chap.is-open > .ipn-chap-head .ipn-chap-caret { transform: rotate(90deg); }
.ipn-chap-name { flex: 1 1 auto; }
.ipn-chap-count {
  flex: 0 0 auto; font-size: .7rem; font-weight: 700; color: var(--ipn-faint);
  background: var(--ipn-surface); border-radius: 20px; padding: .05rem .45rem;
}
.ipn-chap-body {
  display: none;
  margin: .1rem 0 .35rem .95rem; padding-left: .35rem;
  border-left: 1px solid var(--ipn-border);
}
.ipn-chap.is-open > .ipn-chap-body { display: block; }

/* ---- Grouped outline on the course landing page ---------------------- */
.ipn-toc { font-family: var(--ipn-font); margin: 1.5rem 0 1rem; }
.ipn-toc .ipn-chap {
  border: 1px solid var(--ipn-border); border-radius: 12px;
  margin-bottom: .7rem; overflow: hidden; background: var(--ipn-bg);
}
.ipn-toc .ipn-chap-head { padding: .85rem 1rem; font-size: 1rem; border-radius: 0; background: var(--ipn-surface); }
.ipn-toc .ipn-chap-body { margin: 0; padding: .4rem .7rem .6rem; border-left: none; }
.ipn-toc .ipn-lesson { font-size: .93rem; padding: .5rem .6rem; }
.ipn-toc .ipn-lesson .ipn-num { min-width: 2em; }

.ipn-backdrop {
  position: fixed; inset: var(--ipn-bar-h) 0 0 0;
  background: rgba(16,24,40,.42); opacity: 0; visibility: hidden;
  transition: opacity .2s; z-index: 850;
}

/* ==========================================================================
   Prev / next footer (rebuilt)
   ========================================================================== */
.ipn-prevnext {
  display: grid; grid-template-columns: 1fr 1fr; gap: .8rem;
  margin: 3rem 0 1rem; font-family: var(--ipn-font);
}
.ipn-pn {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .85rem 1rem; text-decoration: none;
  border: 1px solid var(--ipn-border); border-radius: var(--ipn-radius);
  background: var(--ipn-bg); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.ipn-pn:hover { border-color: var(--ipn-accent); box-shadow: var(--ipn-shadow); transform: translateY(-1px); }
.ipn-pn.next { text-align: right; }
.ipn-pn-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ipn-faint); }
.ipn-pn-title { font-size: .95rem; font-weight: 600; color: var(--ipn-fg); }
.ipn-pn:hover .ipn-pn-title { color: var(--ipn-accent-strong); }
.ipn-pn.spacer { border: none; background: none; pointer-events: none; }

/* ==========================================================================
   Search modal
   ========================================================================== */
.ipn-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 1rem 1rem;
  background: rgba(16,24,40,.5);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.ipn-modal[hidden] { display: none; }
.ipn-modal-box {
  width: 100%; max-width: 640px; max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--ipn-bg); color: var(--ipn-fg);
  border: 1px solid var(--ipn-border); border-radius: 14px;
  box-shadow: var(--ipn-shadow-lg); overflow: hidden;
  font-family: var(--ipn-font);
}
.ipn-modal-input {
  border: none; outline: none; width: 100%;
  padding: 1.05rem 1.2rem; font-size: 1.05rem;
  background: var(--ipn-bg); color: var(--ipn-fg);
  border-bottom: 1px solid var(--ipn-border);
}
.ipn-modal-input::placeholder { color: var(--ipn-faint); }
.ipn-results { overflow-y: auto; padding: .4rem; }
.ipn-res {
  display: block; text-decoration: none; padding: .55rem .7rem;
  border-radius: 8px; color: var(--ipn-fg);
}
.ipn-res:hover, .ipn-res.is-sel { background: var(--ipn-hover); }
.ipn-res-title { font-size: .95rem; font-weight: 600; }
.ipn-res.is-sel .ipn-res-title, .ipn-res:hover .ipn-res-title { color: var(--ipn-accent-strong); }
.ipn-res-course { font-size: .76rem; color: var(--ipn-muted); margin-top: .1rem; }
.ipn-res mark { background: rgba(16,185,129,.22); background: color-mix(in srgb, var(--ipn-accent) 32%, transparent); color: inherit; padding: 0 .05em; border-radius: 3px; }
.ipn-empty { padding: 1.4rem 1.2rem; color: var(--ipn-muted); font-size: .9rem; text-align: center; }
.ipn-res-foot {
  display: flex; gap: 1rem; justify-content: flex-end;
  padding: .5rem .9rem; border-top: 1px solid var(--ipn-border);
  font-size: .74rem; color: var(--ipn-faint);
}
.ipn-res-foot kbd { font: inherit; border: 1px solid var(--ipn-border); border-radius: 4px; padding: .05rem .35rem; }

/* ==========================================================================
   Open / responsive states
   ========================================================================== */
@media (max-width: 1199px) {
  html.ipn-on .ipn-menu { display: inline-flex; }
  html.ipn-side-open .ipn-side { transform: translateX(0); box-shadow: var(--ipn-shadow-lg); }
  html.ipn-side-open .ipn-backdrop { opacity: 1; visibility: visible; }
  html.ipn-side-open { overflow: hidden; }
}
@media (min-width: 1200px) {
  html.ipn-course .ipn-side { transform: none; }
  html.ipn-course.ipn-on body {
    margin-left: calc(var(--ipn-side-w) + 16px) !important;
    margin-right: auto !important;
  }
  .ipn-backdrop { display: none; }
}

/* Search button collapses to an icon on small screens */
@media (max-width: 680px) {
  .ipn-search .ipn-label, .ipn-search .ipn-hint { display: none; }
  .ipn-search { min-width: 0; padding: 0; width: 38px; height: 38px; justify-content: center; }
  .ipn-brand .ipn-brand-text { display: none; }
}
@media (max-width: 520px) {
  .ipn-prevnext { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Dark-mode overrides for existing per-page content
   (scoped so nav chrome — which carries classes — is never affected)
   ========================================================================== */
html[data-theme="dark"] body { background: var(--ipn-bg) !important; color: var(--ipn-fg) !important; }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] strong { color: var(--ipn-fg) !important; }
html[data-theme="dark"] a:not([class]) { color: var(--ipn-accent-strong) !important; }
html[data-theme="dark"] p,
html[data-theme="dark"] li,
html[data-theme="dark"] td,
html[data-theme="dark"] span:not([class]) { color: var(--ipn-fg); }
html[data-theme="dark"] pre,
html[data-theme="dark"] code { background: var(--ipn-surface) !important; color: #e6eaf0 !important; }
html[data-theme="dark"] pre code { background: none !important; }
html[data-theme="dark"] blockquote { background: var(--ipn-surface) !important; border-left-color: var(--ipn-accent) !important; }
html[data-theme="dark"] th { background: var(--ipn-surface) !important; }
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color: var(--ipn-border) !important; }
html[data-theme="dark"] hr { border-top-color: var(--ipn-border) !important; }
html[data-theme="dark"] .breadcrumb,
html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .tagline { color: var(--ipn-muted) !important; }
html[data-theme="dark"] .course-card { background: var(--ipn-surface) !important; border-color: var(--ipn-border) !important; }
html[data-theme="dark"] ol li { background: var(--ipn-surface) !important; border-color: var(--ipn-border) !important; }
html[data-theme="dark"] ol li:hover { background: var(--ipn-hover) !important; }
html[data-theme="dark"] ol li a { color: var(--ipn-fg) !important; }

/* Lesson diagrams are drawn for a light background (white fill or transparent
   with dark strokes), so on a dark page they glare or vanish. Give content
   images a clean white plate; pad the vector diagrams so they don't touch the
   edges. Opaque photos/screenshots simply cover the plate, so this is safe. */
html[data-theme="dark"] img {
  background: #fff;
  border-radius: 8px;
}
html[data-theme="dark"] figure img,
html[data-theme="dark"] img[src$=".svg"] {
  padding: 12px;
}

/* ==========================================================================
   Code language tabs (Python / C++ / Java)
   ========================================================================== */
.code-tabs {
  margin: 1.2rem 0; border: 1px solid var(--ipn-border); border-radius: 12px;
  overflow: hidden; background: var(--ipn-bg); font-family: var(--ipn-font);
}
.code-tabs .tabbar {
  display: flex; align-items: stretch; gap: .15rem; flex-wrap: wrap;
  padding: .4rem .4rem 0; background: var(--ipn-surface);
  border-bottom: 1px solid var(--ipn-border);
}
.code-tabs .tab {
  border: none; background: none; cursor: pointer;
  font-family: var(--ipn-font); font-size: .84rem; font-weight: 600;
  color: var(--ipn-muted); padding: .5rem .85rem; border-radius: 8px 8px 0 0;
  display: inline-flex; align-items: center; gap: .45rem;
}
.code-tabs .tab:hover { color: var(--ipn-fg); }
.code-tabs .tab.active { background: var(--ipn-bg); color: var(--ipn-fg); box-shadow: inset 0 2px 0 var(--ipn-accent); }
.code-tabs .tab .dot { width: .62rem; height: .62rem; border-radius: 50%; display: inline-block; }
.code-tabs .tab .dot.py { background: #3776ab; }
.code-tabs .tab .dot.cpp { background: #00599c; }
.code-tabs .tab .dot.java { background: #e76f00; }
.code-tabs .copy {
  margin-left: auto; align-self: center; cursor: pointer;
  border: 1px solid var(--ipn-border); background: var(--ipn-bg); color: var(--ipn-muted);
  font-family: var(--ipn-font); font-size: .74rem; font-weight: 600;
  padding: .3rem .6rem; border-radius: 7px;
}
.code-tabs .copy:hover { color: var(--ipn-fg); border-color: var(--ipn-accent); }
.code-tabs .code-panel { display: none; }
.code-tabs .code-panel.active { display: block; }
.code-tabs .code-panel pre { margin: 0 !important; border-radius: 0 !important; }

@media print {
  .ipn-bar, .ipn-side, .ipn-backdrop, .ipn-modal { display: none !important; }
  html.ipn-on body { padding-top: 0 !important; margin-left: auto !important; }
}
