/* ── Design tokens ─────────────────────────────────────────────────────────── */
/* Midnight — dark by default (chosen palette). */
:root {
  --bg:      #0f1216;
  --layer:   #171b21;
  --layer-2: #232a33;
  --text:    #e6edf3;
  --dim:     #8b97a6;
  --line:    #262d36;
  --blue:    #58a6ff;
}

/* ── Reset / base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--blue); }

img { display: block; max-width: 100%; }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: 1.25rem; margin-bottom: 1rem; }
h3 { font-size: 1rem; }

/* ── Focus ring ────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ── Layout wrapper ────────────────────────────────────────────────────────── */
.wrap {
  max-width: 960px;
  margin-inline: auto;
  padding-inline: 24px;
}

/* ── Masthead ──────────────────────────────────────────────────────────────── */
.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--layer);
  padding-block: 2rem;
}

.masthead .wrap {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.id { flex: 1 1 auto; min-width: 0; }

/* ── Role / tagline ────────────────────────────────────────────────────────── */
.role {
  color: var(--dim);
  margin-top: 0.35rem;
}

.tagline {
  color: var(--dim);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}

/* ── Links nav ─────────────────────────────────────────────────────────────── */
.links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  padding-top: 0.25rem;
}

.links a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8125rem;
  color: var(--dim);
  transition: color 0.15s ease;
}

.links a:hover { color: var(--blue); }

/* ── Main sections ─────────────────────────────────────────────────────────── */
main.wrap > section {
  padding-block: 2.5rem;
  border-bottom: 1px solid var(--line);
}

main.wrap > section:last-child { border-bottom: none; }

/* ── About / stats ─────────────────────────────────────────────────────────── */
#about-body {
  max-width: 68ch;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.stats > * {
  background: var(--layer);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stats .stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
}

.stats .stat-label {
  font-size: 0.75rem;
  color: var(--dim);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Currently reading ─────────────────────────────────────────────────────── */
#cr {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.cr-card {
  background: var(--layer);
  display: flex;
  gap: 1rem;
  padding: 1rem;
}

/* Cover = monogram tile with the real image layered on top (see coverHTML in main.js).
   If the <img> fails to load it removes itself and the monogram shows through. */
.cover {
  position: relative;
  overflow: hidden;
  background: var(--layer-2);
  border: 1px solid var(--line);
}
.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-mono {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 0.85rem;
  font-weight: 500;
}

.cr-card .cover {
  flex-shrink: 0;
  width: 60px;
  height: 88px;
}
.cr-card .cover-mono { font-size: 1rem; }

.cr-card h3 { font-size: 0.9rem; margin-bottom: 0.2rem; }

.cr-card .dim { font-size: 0.8rem; color: var(--dim); margin-bottom: 0.5rem; }

.cr-card .note {
  font-size: 0.8rem;
  color: var(--dim);
  margin-top: 0.4rem;
  font-style: italic;
}

.progress {
  height: 4px;
  background: var(--layer-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
}

/* ── Section head (graph) ──────────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h2 { margin-bottom: 0; }

/* ── Segmented tab toggle ──────────────────────────────────────────────────── */
.toggle {
  display: flex;
  border: 1px solid var(--line);
  background: var(--layer-2);
  border-radius: 2px;
  overflow: hidden;
}

.toggle button {
  background: none;
  border: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8125rem;
  color: var(--dim);
  padding: 0.4rem 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toggle button:hover { color: var(--text); }

.toggle button[aria-pressed="true"],
.toggle button.is-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  background: var(--layer);
}

/* ── Graph canvas ──────────────────────────────────────────────────────────── */
#graph-view {
  position: relative;
  border: 1px solid var(--line);
  background: var(--layer);
}

#graph-canvas {
  width: 100%;
  height: min(70vh, 620px);
  display: block;
}

/* ── Mode note ─────────────────────────────────────────────────────────────── */
.mode-note {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--dim);
  pointer-events: none;
}

/* ── Tooltip ───────────────────────────────────────────────────────────────── */
.tooltip {
  position: absolute;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  background: var(--layer);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

/* ── Card grid / book cards (list view) ────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.book-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--layer);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-card:hover,
.book-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.book-card .cover {
  width: 56px;
  aspect-ratio: 2/3;
}

.book-card .cover-mono { font-size: 0.875rem; }

.book-card h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.15rem; }
.book-card .dim { font-size: 0.75rem; color: var(--dim); margin-bottom: 0.25rem; }

.rating {
  color: var(--blue);
  letter-spacing: 2px;
  font-size: 0.8rem;
}

.book-card .review {
  font-size: 0.75rem;
  color: var(--dim);
  font-style: italic;
  margin-top: 0.25rem;
}

.group { margin-bottom: 2rem; }

.group-h {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 0.75rem;
}

/* ── List view ─────────────────────────────────────────────────────────────── */
#list-view {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 1rem;
}

.list-card {
  background: var(--layer);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.list-card h3 { font-size: 0.875rem; }
.list-card .dim { font-size: 0.75rem; color: var(--dim); }

.tag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: var(--dim);
  background: var(--layer-2);
  border: 1px solid var(--line);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

/* ── Side panel ────────────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(420px, 90vw);
  background: var(--layer);
  border-inline-start: 1px solid var(--line);
  overflow-y: auto;
  padding: 1.5rem;
  z-index: 100;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.panel[hidden] {
  display: none !important;
}

.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--dim);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  transition: color 0.15s ease;
}

.panel-close:hover { color: var(--text); }

.panel-cover {
  width: 96px;
  aspect-ratio: 2 / 3;
  height: auto;
  margin-bottom: 1rem;
}

.panel-review {
  font-size: 0.875rem;
  color: var(--dim);
  font-style: italic;
  margin-block: 0.5rem;
}

.panel-link {
  display: inline-block;
  margin-top: 1rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8125rem;
  color: var(--blue);
}

.panel-link:hover { text-decoration: underline; }

/* ── Category chips ────────────────────────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-block: 0.5rem;
}

.chip {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--dim);
  background: var(--layer-2);
  border: 1px solid var(--line);
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
}

/* ── Reduced motion: disable panel slide ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.footer {
  padding-block: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--dim);
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.dim { color: var(--dim); }
.mono { font-family: 'IBM Plex Mono', monospace; }

[hidden] { display: none !important; }

/* ══ Three-view layout: top nav (Work · FLUX · Reading) + per-view blocks ══════ */
.skip { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--blue); color: var(--bg); padding: 0.5rem 1rem; }
.skip:focus { left: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 960px; margin-inline: auto; padding: 0.85rem 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.topbar::after { content: ''; position: absolute; left: 24px; right: 24px; bottom: 0; height: 1px; background: var(--line); }
.brand { font-weight: 600; font-size: 0.95rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--blue); }
.mainnav { display: flex; gap: 1.25rem; }
.mainnav a {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.8rem; letter-spacing: 0.04em;
  color: var(--dim); text-decoration: none; padding-bottom: 2px; border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.mainnav a:hover { color: var(--text); }
.mainnav a.is-active { color: var(--text); border-bottom-color: var(--blue); }

.view { animation: viewIn 0.28s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view > .wrap { padding-block: 2.5rem 4rem; }
.view-head { margin-bottom: 2rem; }
.view-head h1 { margin-bottom: 0.4rem; }

/* Work — hero + blocks */
.hero { padding-block: 1rem 2.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); letter-spacing: -0.02em; }
.hero .links { padding-top: 1.25rem; }
.block { padding-block: 2rem 0; }
.block + .block { border-top: 1px solid var(--line); margin-top: 2rem; }

/* Experience */
.xp-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.xp { background: var(--layer); padding: 1.25rem 1.5rem; }
.xp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.xp-head h3 { font-size: 1rem; font-weight: 500; }
.xp-period { font-size: 0.75rem; color: var(--dim); white-space: nowrap; }
.xp-summary { color: var(--text); line-height: 1.65; margin: 0.5rem 0 0.75rem; max-width: 70ch; }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.proj { display: block; background: var(--layer); padding: 1.25rem 1.5rem; text-decoration: none; color: inherit; transition: background 0.15s ease; }
a.proj:hover { background: var(--layer-2); }
.proj-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.proj-head h3 { font-size: 0.95rem; font-weight: 500; }
.proj-blurb { color: var(--dim); font-size: 0.85rem; line-height: 1.6; margin: 0.5rem 0 0.75rem; }

/* FLUX post list */
.post-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.post { display: block; background: var(--layer); padding: 1.5rem; text-decoration: none; color: inherit; transition: background 0.15s ease; }
.post:hover { background: var(--layer-2); }
.post:hover .post-more { color: var(--blue); }
.post .post-meta { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 0.6rem; }
.post .post-tags { color: var(--blue); }
.post h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.post-excerpt { font-size: 0.9rem; line-height: 1.65; max-width: 72ch; }
.post-more { display: inline-block; margin-top: 0.9rem; font-family: 'IBM Plex Mono', monospace; font-size: 0.75rem; color: var(--dim); }

/* Nav "Let's talk" CTA */
.mainnav a.btn-talk { color: var(--blue); border: 1px solid var(--blue); border-radius: 2px; padding: 0.28rem 0.8rem; }
.mainnav a.btn-talk:hover { background: var(--blue); color: var(--bg); }

/* Stack chips under the hero */
.stack-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.1rem; }

/* Where I can help */
.cap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.cap { background: var(--layer); padding: 1.25rem 1.4rem; }
.cap h3 { font-size: 0.95rem; font-weight: 500; margin-bottom: 0.4rem; }
.cap p { font-size: 0.85rem; line-height: 1.6; }

/* Contact CTA */
.contact { margin-top: 2.5rem; padding: 2rem 1.75rem; background: var(--layer); border: 1px solid var(--line); }
#cta-headline { font-size: clamp(1.4rem, 3.5vw, 2rem); }
.cta-line { margin-top: 0.8rem; font-size: clamp(1.05rem, 2.4vw, 1.35rem); line-height: 1.5; max-width: 46ch; color: var(--text); }
.cta-line .accent { color: var(--blue); font-weight: 600; }
#cta-sub { max-width: 58ch; margin-top: 0.75rem; font-size: 0.95rem; line-height: 1.7; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.cta-btn { font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; letter-spacing: 0.02em; padding: 0.7rem 1.3rem; border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease; }
.cta-btn:hover { border-color: var(--blue); color: var(--blue); }
.cta-btn--primary { background: var(--blue); color: var(--bg); border-color: var(--blue); }
.cta-btn--primary:hover { background: var(--blue); color: var(--bg); opacity: 0.88; }

/* ── Reduced motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
