/* ═══════════════════════════════════════════════
   Meet Deshani — Learning Curve
   Editorial scroll layout · 7-section HUD
═══════════════════════════════════════════════ */

:root {
  --bg:        #f5f0e8;
  --bg-vivid:  #ede7d8;
  --surface:   #eee9df;
  --text:      #111;
  --muted:     #666;
  --border:    #ccc8be;
  --accent:    #7c5bf5;
  --acc-soft:  rgba(124,91,245,.1);
  --font-serif: 'DM Serif Display', ui-serif, Georgia, serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
  --hud-w:     416px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
}

a { color: inherit; }

/* ═══════════════════════════════════════════════
   MAIN GRID
═══════════════════════════════════════════════ */
.main-grid {
  display: grid;
  grid-template-columns: 130px 1fr var(--hud-w);
  grid-template-areas:
    "header header header"
    "toc    content hud";
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════ */
.site-nav {
  grid-area: header;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}
.nav-upper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-top: 8px;
}
.brand-link { text-decoration: none; }
.brand-link h1 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 400;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
  color: var(--text);
}
.brand-link h1::after {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  position: relative; top: -2px;
  transition: background .4s;
}
.top-links {
  display: flex; gap: 28px;
  font-size: .9rem; font-weight: 500;
  padding: 8px 0; align-items: center;
}
.top-links a { text-decoration: none; color: var(--muted); transition: color .15s; }
.top-links a:hover { color: var(--text); }
.about-btn {
  border: 1px solid var(--accent);
  color: var(--accent) !important;
  padding: 6px 14px; border-radius: 0;
  font-size: .82rem;
  background: transparent;
  transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.2, 1), background 0.3s, color 0.3s !important;
}
.about-btn:hover { 
  background: var(--accent) !important; 
  color: #fff !important; 
}
.nav-meta { padding: 5px 0 8px; }
.nav-authors { font-size: .82rem; color: var(--muted); }

/* ═══════════════════════════════════════════════
   TOC RAIL
═══════════════════════════════════════════════ */
.toc-rail {
  grid-area: toc;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  padding: 44px 0 0 16px;
}
.toc-nav { height: calc(100vh - 26px); }
.toc-dot { cursor: pointer; }

/* ═══════════════════════════════════════════════
   HUD PANEL
═══════════════════════════════════════════════ */
.hud-panel {
  grid-area: hud;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px 10px 8px;
  border-left: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: none;
  font-family: var(--font-mono);
}
.hud-panel::-webkit-scrollbar { display: none; }

/* ── ① Top badge + headline ── */
.hud-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 7px;
}
.hud-toggle-btn {
  display: none;
}
.hud-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #111;
  color: white;
  border-radius: 0;
  padding: 4px 9px;
  white-space: nowrap;
  flex-shrink: 0;
}
.date-ch { font-size: 8px; opacity: .55; }
.date-yr { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hud-headline {
  font-family: var(--font-sans);
  font-size: 9px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
  transition: color .4s;
  flex: 1;
  padding-top: 3px;
}

/* ── ② Life Pulse chart ── */
.hud-chart-wrap {
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 4px;
  margin-top: 4px;
}
.leg-item {
  font-size: 8.5px;
  color: var(--lc);
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── ③ Project counter (like agent copies) ── */
.hud-proj-counter {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.proj-counter-text {
  font-size: 10px;
  margin-bottom: 5px;
  line-height: 1.4;
}
.proj-bold { font-weight: 700; color: var(--text); font-size: 11px; }
.proj-plain { color: var(--muted); font-size: 9.5px; }

.proj-squares-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.proj-sq {
  width: 20px; height: 20px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 1.5px solid transparent;
}
.proj-sq:hover { transform: scale(1.15); }
.proj-sq--active {
  border-color: #111;
  box-shadow: 0 0 0 2px var(--accent);
}
.proj-sq-icon { font-size: 10px; line-height: 1; }

/* ── ④ Stats grid ── */
.hud-stats-band {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}
.stats-divider {
  height: 1px;
  background: var(--border);
  margin: 5px 0;
}
.stats-cell {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 3px 4px;
}
.stats-icon {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  padding-top: 1px;
}
.stats-label {
  font-size: 7px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.2;
}
.stats-val {
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.2;
  transition: color .3s;
}

/* ── ⑤ Skills (like AI capability bars) ── */
.hud-skills-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 4px;
}
.skills-vert-label {
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: .12em;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 2px;
  align-self: flex-start;
}

/* 2-column flex wrap layout (like caps-bars) */
.skills-grid {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  height: 100px; /* 6 rows × ~16px + gaps */
  gap: 2px;
  flex: 1;
}
.skill-row {
  width: 50%;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 15px;
  transition: opacity .35s;
}
.sk-icon { font-size: 9px; flex-shrink: 0; line-height: 1; }
.sk-name {
  font-size: 7px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 0 44px;
}
.sk-squares {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.sk-sq {
  width: 9px; height: 9px;
  border-radius: 0;
  background: var(--bg-vivid);
  transition: background .5s;
}
.sk-sq.filled { /* background set by JS */ }

/* ── ⑥ Projects Donut ── */
.hud-proj-donut-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-proj-legend { font-size: 8px; color: var(--muted); line-height: 1.5; }
.proj-legend-label { font-weight: 700; font-size: 9px; color: var(--text); margin-bottom: 2px; }

/* Project tooltip */
.proj-tooltip {
  background: #111;
  color: white;
  border-radius: 0;
  padding: 10px 12px;
  margin: 4px 0 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.5;
  border-left: 3px solid var(--accent);
  transition: border-color .3s;
}
.proj-tooltip.hidden { display: none; }

.tt-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.tt-icon-big { font-size: 14px; flex-shrink: 0; }
.tt-proj-name { font-weight: 700; font-size: 11px; }
.tt-proj-year { font-size: 9px; color: rgba(255,255,255,.5); font-family: var(--font-mono); }
.tt-desc {
  font-size: 10px;
  line-height: 1.5;
  opacity: .85;
  margin-bottom: 6px;
}
.tt-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.tt-tag {
  font-size: 8px;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: 1px 6px;
  font-family: var(--font-mono);
}
.tt-footer {
  font-size: 9px;
  opacity: .6;
  font-family: var(--font-mono);
}

/* ── ⑦ Achievements ── */
.hud-achievements {
  padding: 6px 0 10px;
}
.section-micro-label {
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 5px;
}

/* Grid of achievement icons (like tech buckets) */
.achieve-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ach-dot {
  width: 26px; height: 26px;
  border-radius: 0;
  border: 1.5px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  background: var(--bg);
  transition: transform 0.1s linear, opacity 0.3s;
  transform-origin: bottom center;
  will-change: transform;
}

/* Achievement tooltip */
.achieve-tooltip {
  background: #111;
  color: white;
  border-radius: 0;
  padding: 10px 12px;
  margin-top: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  line-height: 1.5;
  position: relative;
  z-index: 10;
}
.achieve-tooltip.hidden { display: none; }

/* ═══════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════ */
.main-content {
  grid-area: content;
  padding: 24px 48px 200px 16px;
  max-width: 680px;
}
.content-section { margin-bottom: 0; }
.chart-anchor { height: 0; overflow: hidden; scroll-margin-top: 50vh; }
.scroll-mt { scroll-margin-top: 54vh; }

/* Typography */
.main-content p {
  font-size: 1rem;
  line-height: 1.78;
  margin-bottom: 1.3rem;
  color: #222;
}
.main-content h2.chapter-heading {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin: 4rem 0 .3rem;
  scroll-margin-top: 54vh;
  display: flex; flex-direction: column; gap: 4px;
}
.chapter-number {
  font-family: var(--font-mono);
  font-size: .65rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--chapter-color, var(--accent));
}
.chapter-years {
  font-family: var(--font-mono);
  font-size: .75rem; color: var(--muted);
}
.chapter-tagline {
  font-family: var(--font-serif) !important;
  font-size: 1.05rem !important;
  font-style: italic;
  color: var(--muted) !important;
  margin: .4rem 0 1.4rem !important;
  line-height: 1.5 !important;
}

/* Stat cards */
.stat-cards { display: flex; gap: 10px; flex-wrap: wrap; margin: 1.2rem 0; }
.stat-card {
  background: white; border: 1px solid var(--border);
  border-radius: 0; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--card-color, var(--accent));
}
.stat-card-value {
  font-family: var(--font-mono); font-size: 1.15rem;
  font-weight: 700; color: var(--card-color, var(--accent));
}
.stat-card-label {
  font-family: var(--font-mono); font-size: .6rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}

/* Pull quote */
.pull-quote {
  border-left: 3px solid var(--quote-color, var(--accent));
  margin: 1.5rem 0; padding: 6px 0 6px 16px;
  font-family: var(--font-serif); font-size: 1.1rem;
  font-style: italic; color: var(--quote-color, var(--accent));
  line-height: 1.55; opacity: .85;
}

.main-content a { text-decoration: underline; text-underline-offset: 3px; }

/* Pub meta */
.pub-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--muted); margin-top: 3rem; margin-bottom: 2rem;
  opacity: .6;
}
.pub-action { cursor: pointer; text-decoration: none; transition: opacity .15s; }
.pub-action:hover { opacity: 1; }
.meta-sep {
  display: inline-block; width: 1px; height: 11px;
  background: currentColor; vertical-align: middle;
}

/* Tab boxes */
.tab-boxes { margin: 1.5rem 0 2rem; }
.tab-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tab-btn {
  padding: 5px 12px; border: 1.5px solid var(--border); border-radius: 0;
  background: transparent; cursor: pointer; font-family: var(--font-sans);
  font-size: .82rem; font-weight: 500; color: var(--muted); 
  transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.2, 1), background 0.3s, border-color 0.3s, color 0.3s;
}
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
.tab-content {
  border: 1.5px solid var(--border); border-radius: 0;
  padding: 12px 14px;
}
.tab-content p {
  font-size: .9rem; line-height: 1.65; margin-bottom: .7rem; color: #333;
}
.tab-content p:last-child { margin-bottom: 0; }
.hidden { display: none; }
.phase-hidden { display: none !important; }

/* Phase filters */
.phase-filters {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 1.5rem;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(245, 240, 232, 0.96), rgba(245, 240, 232, 0.82)),
    linear-gradient(135deg, rgba(124, 91, 245, 0.08), rgba(0, 119, 182, 0.06));
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.phase-btn {
  appearance: none;
  border: 1.5px solid var(--border);
  background: rgba(255,255,255,0.55);
  color: var(--muted);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .25s, color .25s, background .25s, transform .25s, box-shadow .25s;
}
.phase-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.phase-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.1);
}

/* Chapter tab extractor */
.chapter-tabs {
  margin: 1.4rem 0 3rem;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.45)),
    linear-gradient(135deg, rgba(124, 91, 245, 0.03), rgba(0, 119, 182, 0.03));
}
.ch-tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.02);
}
.ch-tab-tgl {
  appearance: none;
  border: 1.5px solid transparent;
  border-bottom-color: var(--border);
  background: transparent;
  color: var(--muted);
  padding: 6px 0;
  min-width: 76px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .25s, border-color .25s, transform .25s;
}
.ch-tab-tgl:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ch-tab-tgl.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.ch-tab-panes {
  padding: 16px 16px 18px;
}
.ch-pane > *:last-child {
  margin-bottom: 0;
}
.clean-list {
  list-style: none;
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
}
.clean-list li {
  position: relative;
  padding-left: 16px;
  color: #222;
  line-height: 1.75;
}
.clean-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: .75em;
  width: 6px;
  height: 6px;
  background: var(--accent);
}
.ref-links {
  display: grid;
  gap: 10px;
}
.ref-link {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  text-decoration: none !important;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: #222;
  background: rgba(255,255,255,0.58);
  transition: transform .2s, border-color .2s, color .2s, background .2s;
}
.ref-link:hover {
  transform: translateX(2px);
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255,255,255,0.9);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 1280px) {
  :root { --hud-w: 360px; }
  .main-grid { grid-template-columns: 0px 1fr var(--hud-w); }
  .toc-rail { display: none; }
}
@media (max-width: 960px) {
  .nav-upper {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .top-links > div {
    flex-wrap: wrap;
  }
  .main-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "content";
  }
  .main-content { padding: 16px 20px 180px; max-width: 100%; }
  .phase-filters {
    top: 0;
    margin-bottom: 1.25rem;
    margin-left: -4px;
    margin-right: -4px;
    padding: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .phase-filters::-webkit-scrollbar { display: none; }
  .phase-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: .78rem;
    padding: 8px 10px;
  }
  .chapter-tabs {
    margin: 1.2rem 0 2.4rem;
  }
  .ch-tab-nav {
    gap: 10px 12px;
    padding: 12px 12px 8px;
  }
  .ch-tab-tgl {
    min-width: auto;
    font-size: .68rem;
    padding: 4px 0;
  }
  .ch-tab-panes {
    padding: 14px 12px 16px;
  }
  .clean-list li {
    padding-left: 14px;
  }
  
  .hud-panel { 
    position: fixed; 
    top: auto;
    bottom: 12px; 
    left: 12px; 
    right: 12px; 
    width: auto;
    height: auto; 
    border-left: none; 
    border: 1.5px solid var(--border); 
    border-radius: 0;
    background: var(--bg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    cursor: pointer;
  }
  
  .hud-panel:not(.expanded) .hud-chart-wrap {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }
  
  .hud-panel:not(.expanded) .hud-proj-counter,
  .hud-panel:not(.expanded) .hud-stats-band,
  .hud-panel:not(.expanded) .hud-skills-section,
  .hud-panel:not(.expanded) .hud-proj-donut-section,
  .hud-panel:not(.expanded) .hud-achievements,
  .hud-panel:not(.expanded) .chart-legend {
    display: none;
  }
  
  .hud-panel.expanded {
    bottom: 0; left: 0; right: 0; top: 0;
    max-height: 100vh !important;
    border: none;
    box-shadow: none;
    cursor: default;
    overflow-y: auto;
    padding: 16px 16px 40px;
  }
  
  .hud-toggle-btn {
    display: flex;
    align-items: center; justify-content: center;
    width: 26px; height: 26px;
    background: #111; color: white;
    cursor: pointer;
    flex-shrink: 0;
  }
  .hud-panel.expanded .hud-toggle-btn {
    background: transparent; color: #111; border: 1.5px solid var(--border);
  }
  .icon-close { display: none; }
  .hud-panel.expanded .icon-expand { display: none; }
  .hud-panel.expanded .icon-close { display: block; }

  .skills-grid { height: 100px; }
}
@media (max-width: 560px) {
  .main-content {
    padding: 14px 14px 176px;
  }
  .main-content h2.chapter-heading {
    font-size: 1.55rem;
    margin-top: 3.2rem;
  }
  .chapter-tagline {
    font-size: .98rem !important;
  }
  .tab-btn {
    font-size: .78rem;
    padding: 5px 10px;
  }
  .tab-content {
    padding: 12px;
  }
  .stat-cards {
    gap: 8px;
  }
  .stat-card {
    width: 100%;
  }
  .pub-meta {
    flex-wrap: wrap;
    row-gap: 6px;
  }
}

/* ═══════════════════════════════════════════════
   MAGNETIC BUTTONS
═══════════════════════════════════════════════ */
.magnetic {
  display: inline-block;
  will-change: transform;
  transition: transform 0.5s cubic-bezier(0.3, 1.3, 0.2, 1), background 0.3s, border-color 0.3s, color 0.3s !important;
}
.magnetic:hover {
  transition: transform 0.1s linear, background 0.2s, color 0.2s, border-color 0.2s !important;
}
