/* ===========================================================
   Deep Neural Networks — Course Site
   Shared design system for all lecture pages
   =========================================================== */

:root{
  --bg:            #f6f7fb;
  --bg-alt:        #ffffff;
  --surface:       #ffffff;
  --surface-2:     #eef1fb;
  --border:        #e0e3ee;
  --text:          #1b1f2b;
  --text-dim:      #565b6e;
  --text-faint:    #8a8fa3;

  --brand:         #4338ca;   /* indigo */
  --brand-2:       #7c3aed;   /* violet */
  --brand-3:       #0891b2;   /* cyan */
  --accent-warm:   #ea580c;   /* orange, for "pitfall/warning" callouts */
  --accent-good:   #059669;   /* emerald, for "insight/result" callouts */
  --accent-pink:   #db2777;

  --brand-grad: linear-gradient(120deg, var(--brand), var(--brand-2));

  --code-bg:       #1e1e2e;
  --code-text:     #e4e4f0;
  --code-accent:   #7dd3fc;

  --shadow-sm: 0 1px 2px rgba(20,20,50,.06), 0 1px 1px rgba(20,20,50,.04);
  --shadow-md: 0 6px 20px rgba(30,30,70,.08), 0 2px 6px rgba(30,30,70,.06);
  --shadow-lg: 0 20px 50px rgba(30,30,70,.16);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --content-w: 880px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:            #0f1117;
    --bg-alt:        #161925;
    --surface:       #171a26;
    --surface-2:     #1d2133;
    --border:        #2a2f42;
    --text:          #e9eaf3;
    --text-dim:      #b0b4c9;
    --text-faint:    #7d8199;

    --brand:         #818cf8;
    --brand-2:       #c084fc;
    --brand-3:       #22d3ee;
    --accent-warm:   #fb923c;
    --accent-good:   #34d399;
    --accent-pink:   #f472b6;

    --code-bg:       #0c0e16;
    --code-text:     #e4e4f0;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 6px 24px rgba(0,0,0,.45);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
  }
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

img{ max-width:100%; display:block; }
a{ color: var(--brand); text-decoration: none; }
a:hover{ text-decoration: underline; }

::selection{ background: var(--brand-2); color:#fff; }

/* ---------- Layout shell ---------- */
.site-header{
  position: sticky; top:0; z-index: 50;
  display:flex; align-items:center; gap:14px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg-alt) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .brand{
  font-weight: 800; letter-spacing:.2px; font-size: 1.05rem;
  background: var(--brand-grad); -webkit-background-clip:text; background-clip:text; color:transparent;
  white-space:nowrap;
}
.site-header nav{ display:flex; gap:4px; margin-left:auto; flex-wrap:wrap; }
.site-header nav a{
  color: var(--text-dim); font-size:.86rem; font-weight:600;
  padding:7px 12px; border-radius: 999px;
}
.site-header nav a:hover, .site-header nav a.active{ background: var(--surface-2); color: var(--brand); text-decoration:none; }
.menu-btn{ display:none; }

.page-shell{
  display:grid;
  grid-template-columns: 268px minmax(0,1fr);
  gap: 0;
  max-width: 1360px;
  margin: 0 auto;
}
.sidebar{
  position: sticky; top: 58px; align-self:start;
  height: calc(100vh - 58px);
  overflow-y:auto;
  padding: 22px 14px 60px 22px;
  border-right: 1px solid var(--border);
  font-size:.86rem;
}
.sidebar::-webkit-scrollbar{ width:6px; }
.sidebar::-webkit-scrollbar-thumb{ background: var(--border); border-radius:4px; }
.sidebar h4{
  font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; color: var(--text-faint);
  margin: 18px 0 6px; padding-left:10px;
}
.sidebar h4:first-child{ margin-top:0; }
.sidebar ol,.sidebar ul{ list-style:none; margin:0; padding:0; }
.sidebar li a{
  display:flex; gap:8px; align-items:flex-start;
  padding:7px 10px; border-radius:9px; color: var(--text-dim);
  font-size:.85rem; line-height:1.35;
}
.sidebar li a .n{
  flex:0 0 auto; width:20px; height:20px; border-radius:6px;
  background: var(--surface-2); color:var(--text-faint);
  display:flex; align-items:center; justify-content:center;
  font-size:.68rem; font-weight:700; margin-top:1px;
}
.sidebar li a:hover{ background: var(--surface-2); text-decoration:none; color:var(--text); }
.sidebar li a.active{ background: var(--brand-grad); color:#fff; }
.sidebar li a.active .n{ background: rgba(255,255,255,.25); color:#fff; }

main.content{ min-width:0; padding: 0 0 80px; }
.content-inner{ max-width: var(--content-w); margin:0 auto; padding: 40px 28px 0; }

@media (max-width: 980px){
  .page-shell{ grid-template-columns: 1fr; }
  .sidebar{
    position:fixed; inset: 58px 0 0 auto; right:0; width:300px; max-width:82vw;
    background: var(--bg-alt); z-index:60; box-shadow: var(--shadow-lg);
    transform: translateX(100%); transition: transform .25s ease; height:calc(100vh - 58px);
  }
  .sidebar.open{ transform:none; }
  .menu-btn{
    display:inline-flex; align-items:center; justify-content:center;
    width:36px; height:36px; border-radius:9px; border:1px solid var(--border);
    background:var(--surface); color:var(--text); cursor:pointer; font-size:1.1rem;
  }
  .site-header nav{ display:none; }
}

/* ---------- Typography ---------- */
h1.lecture-title{ font-size: clamp(1.7rem, 3.4vw, 2.5rem); line-height:1.15; margin: 4px 0 10px; letter-spacing:-.01em; }
h2{ font-size: 1.5rem; margin: 48px 0 14px; padding-top:6px; letter-spacing:-.01em; scroll-margin-top: 80px;}
h2 .sec-no{ color:var(--brand); margin-right:8px; font-variant-numeric: tabular-nums; }
h3{ font-size: 1.15rem; margin: 30px 0 10px; color: var(--text); scroll-margin-top: 80px;}
p{ margin: 0 0 16px; color: var(--text); }
strong{ color: var(--text); }
.lede{ font-size:1.12rem; color: var(--text-dim); margin-bottom: 20px; }
hr.sep{ border:none; border-top:1px solid var(--border); margin: 46px 0; }

ul.std, ol.std{ padding-left: 1.3em; margin: 0 0 16px; }
ul.std li, ol.std li{ margin-bottom:7px; }

.kicker{
  display:inline-flex; align-items:center; gap:8px;
  font-size:.74rem; font-weight:800; letter-spacing:.09em; text-transform:uppercase;
  color: var(--brand); margin-bottom: 10px;
}
.kicker::before{ content:""; width:7px; height:7px; border-radius:50%; background: var(--brand-grad); }

.meta-row{ display:flex; gap:18px; flex-wrap:wrap; color:var(--text-faint); font-size:.82rem; margin: 6px 0 28px; }
.meta-row span{ display:inline-flex; align-items:center; gap:6px; }

/* ---------- Callout boxes ---------- */
.box{
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin: 22px 0;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.box > .box-title{
  font-weight:800; font-size:.82rem; text-transform:uppercase; letter-spacing:.06em;
  display:flex; align-items:center; gap:8px; margin-bottom:8px;
}
.box > :last-child{ margin-bottom:0; }
.box.def{ border-left:4px solid var(--brand); }
.box.def > .box-title{ color: var(--brand); }
.box.example{ border-left:4px solid var(--brand-3); background: color-mix(in srgb, var(--brand-3) 6%, var(--surface)); }
.box.example > .box-title{ color: var(--brand-3); }
.box.insight{ border-left:4px solid var(--accent-good); background: color-mix(in srgb, var(--accent-good) 6%, var(--surface)); }
.box.insight > .box-title{ color: var(--accent-good); }
.box.warn{ border-left:4px solid var(--accent-warm); background: color-mix(in srgb, var(--accent-warm) 7%, var(--surface)); }
.box.warn > .box-title{ color: var(--accent-warm); }
.box.quote{ border-left:4px solid var(--accent-pink); font-style:italic; color:var(--text-dim); }
.box.bridge{
  border-left:4px solid var(--brand-3);
  background: color-mix(in srgb, var(--brand-3) 5%, var(--surface));
}
.box.bridge > .box-title{ color: var(--brand-3); }

/* ---------- Collapsible beginner primers ---------- */
details.primer{
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  margin: 20px 0;
  overflow: hidden;
}
details.primer > summary{
  cursor: pointer;
  list-style: none;
  padding: 13px 18px;
  font-weight: 700;
  font-size: .87rem;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
details.primer > summary::-webkit-details-marker{ display:none; }
details.primer > summary::before{
  content: "▶";
  font-size: .65rem;
  color: var(--text-faint);
  transition: transform .18s ease;
  flex: 0 0 auto;
}
details.primer[open] > summary::before{ transform: rotate(90deg); }
details.primer > summary .tag{
  font-size: .65rem; background: var(--surface); border:1px solid var(--border); color: var(--text-faint);
  padding: 2px 9px; border-radius: 999px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}
details.primer > .primer-body{
  padding: 2px 18px 18px;
  border-top: 1.5px dashed var(--border);
  margin-top: 4px;
}
details.primer > .primer-body > :first-child{ margin-top: 14px; }
details.primer > .primer-body > :last-child{ margin-bottom: 0; }

/* ---------- Math ---------- */
.katex-display{ overflow-x:auto; overflow-y:hidden; padding: 6px 0; }
.katex{ font-size: 1.05em; }

/* ---------- Code ---------- */
pre{
  background: var(--code-bg); color: var(--code-text);
  padding: 16px 18px; border-radius: var(--radius-md);
  overflow-x:auto; font-size:.86rem; line-height:1.6;
  margin: 16px 0; position:relative; box-shadow: var(--shadow-sm);
}
pre code{ font-family: var(--font-mono); background:none; padding:0; }
code{
  font-family: var(--font-mono); background: var(--surface-2);
  padding: .15em .4em; border-radius:5px; font-size:.88em; color: var(--brand-2);
}
.code-file{
  display:flex; align-items:center; justify-content:space-between;
  background: var(--surface-2); border:1px solid var(--border); border-bottom:none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 8px 14px; font-size:.78rem; color: var(--text-faint); font-family: var(--font-mono);
  margin-top:16px;
}
.code-file + pre{ margin-top:0; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.copy-btn{
  border:1px solid var(--border); background: var(--surface); color: var(--text-dim);
  font-size:.72rem; padding:4px 10px; border-radius:7px; cursor:pointer; font-family: var(--font-body);
}
.copy-btn:hover{ color: var(--text); }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; margin: 18px 0; border-radius: var(--radius-md); border:1px solid var(--border); }
table{ border-collapse:collapse; width:100%; font-size:.9rem; }
th,td{ padding:9px 14px; text-align:left; border-bottom:1px solid var(--border); white-space:nowrap; }
thead th{ background: var(--surface-2); font-size:.72rem; text-transform:uppercase; letter-spacing:.05em; color:var(--text-faint); }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background: var(--surface-2); }
td.num, th.num{ font-variant-numeric: tabular-nums; text-align:right; }

/* ---------- Figures / viz containers ---------- */
figure{ margin: 26px 0; }
figure.viz{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
}
figcaption{ color: var(--text-faint); font-size:.82rem; margin-top:12px; text-align:center; }
.viz-canvas-wrap{ display:flex; justify-content:center; overflow-x:auto; }
svg.diagram text{ font-family: var(--font-body); fill: var(--text); }
svg.diagram{ max-width:100%; height:auto; }

.controls{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:center; margin-top:16px; }
.controls button{
  border:1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 8px 16px; border-radius:999px; font-size:.82rem; font-weight:600; cursor:pointer;
  font-family: var(--font-body); transition: .15s;
}
.controls button:hover{ background: var(--brand); color:#fff; border-color: var(--brand); }
.controls button:disabled{ opacity:.4; cursor:not-allowed; }
.controls button.primary{ background: var(--brand-grad); color:#fff; border:none; }
.controls .step-label{ font-size:.8rem; color: var(--text-faint); min-width:120px; text-align:center; }
.controls input[type=range]{ width:160px; accent-color: var(--brand); }

/* ---------- Grid / value cells (for matrices, one-hot, attention heatmaps) ---------- */
.grid-cells{ display:inline-grid; gap:4px; }
.cell{
  display:flex; align-items:center; justify-content:center;
  min-width:38px; min-height:34px; border-radius:6px;
  font-size:.78rem; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border:1px solid var(--border); color:var(--text-dim);
  transition: background .3s, color .3s, transform .2s;
}
.cell.hl{ background: var(--brand); color:#fff; border-color: var(--brand); transform: scale(1.06); }
.cell.hl2{ background: var(--accent-warm); color:#fff; border-color: var(--accent-warm); }
.cell.out{ background: var(--accent-good); color:#fff; border-color: var(--accent-good); }
.cell.label{ background:transparent; border:none; color:var(--text-faint); font-weight:700; }

/* ---------- Cards (index page) ---------- */
.hero{
  padding: 64px 28px 40px; text-align:center;
  background:
    radial-gradient(60% 60% at 50% 0%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%);
}
.hero h1{
  font-size: clamp(2rem, 5vw, 3.2rem); margin:0 0 14px; letter-spacing:-.02em;
  background: var(--brand-grad); -webkit-background-clip:text; background-clip:text; color:transparent;
}
.hero p{ max-width:680px; margin:0 auto 26px; color: var(--text-dim); font-size:1.08rem; }
.hero .pill-row{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:22px; }
.pill{
  border:1px solid var(--border); background: var(--surface); padding:6px 14px; border-radius:999px;
  font-size:.78rem; color:var(--text-dim); font-weight:600;
}

.module-group{ max-width: 1180px; margin: 0 auto; padding: 10px 28px 60px; }
.module-group h2{ font-size:1.3rem; margin: 46px 0 18px; display:flex; align-items:center; gap:10px; }
.module-group h2 .tag{
  font-size:.68rem; padding:3px 10px; border-radius:999px; background: var(--surface-2); color:var(--text-faint);
  font-weight:700; letter-spacing:.03em;
}
.card-grid{ display:grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap:16px; }
.card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s; position:relative; overflow:hidden;
}
.card:hover{ transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration:none; }
.card .lec-no{
  font-size:.72rem; font-weight:800; color: var(--brand); letter-spacing:.05em; text-transform:uppercase;
  margin-bottom:8px; display:block;
}
.card h3{ margin:0 0 8px; font-size:1.02rem; color:var(--text); }
.card p{ font-size:.85rem; color: var(--text-faint); margin:0; }
.card .badges{ display:flex; gap:6px; margin-top:12px; flex-wrap:wrap; }
.card .badges span{ font-size:.66rem; background:var(--surface-2); color:var(--text-faint); padding:3px 8px; border-radius:6px; font-weight:700; }

/* ---------- Lecture footer nav ---------- */
.lecture-nav{
  display:flex; justify-content:space-between; gap:16px; margin-top:60px; padding-top:26px; border-top:1px solid var(--border);
}
.lecture-nav a{
  flex:1; max-width:48%; padding:16px 18px; border:1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color:var(--text); box-shadow: var(--shadow-sm);
}
.lecture-nav a:hover{ text-decoration:none; border-color: var(--brand); }
.lecture-nav a.next{ text-align:right; margin-left:auto; }
.lecture-nav .dir{ font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; color:var(--text-faint); display:block; margin-bottom:4px; }
.lecture-nav .ttl{ font-weight:700; font-size:.92rem; }

/* ---------- Objectives list ---------- */
.obj-list{ display:grid; gap:10px; margin: 18px 0 26px; }
.obj-list li{
  list-style:none; display:flex; gap:10px; align-items:flex-start;
  background: var(--surface); border:1px solid var(--border); border-radius:12px; padding:12px 14px;
  font-size:.92rem; color:var(--text-dim);
}
.obj-list li::before{ content:"✓"; color:#fff; background:var(--accent-good); border-radius:50%; width:20px; height:20px; flex:0 0 auto; display:flex; align-items:center; justify-content:center; font-size:.7rem; font-weight:900; }

/* ---------- Footer ---------- */
.site-footer{ text-align:center; padding: 40px 20px 60px; color: var(--text-faint); font-size:.82rem; }

/* toc chip nav inside article (mobile jumps) */
.badge-row{ display:flex; gap:8px; flex-wrap:wrap; margin: 4px 0 30px; }
.badge-row a{
  font-size:.75rem; font-weight:700; background: var(--surface-2); color:var(--text-dim);
  padding:6px 12px; border-radius:999px; border:1px solid var(--border);
}
.badge-row a:hover{ background:var(--brand); color:#fff; text-decoration:none; }

/* download button */
.btn-download{
  display:inline-flex; align-items:center; gap:8px; background: var(--brand-grad); color:#fff !important;
  padding:10px 18px; border-radius:999px; font-weight:700; font-size:.86rem; box-shadow: var(--shadow-sm);
}
.btn-download:hover{ text-decoration:none; filter:brightness(1.08); }
.btn-secondary{
  display:inline-flex; align-items:center; gap:8px; background: var(--surface); border:1px solid var(--border);
  color:var(--text) !important; padding:10px 18px; border-radius:999px; font-weight:700; font-size:.86rem;
}
.btn-secondary:hover{ text-decoration:none; border-color:var(--brand); }
