/* =========================================================================
   Daniel Lew — Portfolio stylesheet
   Dark theme, amber accent. Edit the variables below to re-skin the site.
   ========================================================================= */

:root {
  /* Colours ------------------------------------------------------------- */
  --bg: #0d1117;            /* page background            */
  --surface: #161b22;       /* cards / panels             */
  --surface-2: #1c2430;     /* raised elements            */
  --border: #263041;        /* hairlines                  */
  --text: #e6edf3;          /* body text                  */
  --text-dim: #9aa7b4;      /* secondary text             */
  --accent: #f59e0b;        /* amber highlight            */
  --accent-soft: #f59e0b22; /* amber, translucent         */
  --accent-hover: #fbbf24;

  /* Type ---------------------------------------------------------------- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "Cascadia Code", "Consolas", "Liberation Mono", monospace;

  /* Layout -------------------------------------------------------------- */
  --maxw: 1080px;
  --radius: 12px;
  --gap: 1.5rem;
}

/* Reset-ish ------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }

code, .mono { font-family: var(--font-mono); }

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 1.25rem; }

/* Skip link (accessibility) -------------------------------------------- */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #000; padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* =========================================================================
   Header / footer
   ========================================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: .9rem; flex-wrap: wrap;
}
.brand { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-links { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .95rem; }
.nav-links a { color: var(--text-dim); }
.nav-links a:hover { color: var(--accent); text-decoration: none; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem; padding-block: 2rem;
  color: var(--text-dim); font-size: .9rem;
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer .nav-links a { color: var(--text-dim); }

/* =========================================================================
   Sections — each reads like a slide
   ========================================================================= */
section { padding-block: 4rem; border-bottom: 1px solid var(--border); }
section:last-of-type { border-bottom: 0; }

.section-eyebrow {
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
.section-title { font-size: clamp(1.5rem, 3.5vw, 2.1rem); margin: .3rem 0 1.75rem; }

/* Hero ------------------------------------------------------------------ */
.hero { padding-block: 5rem 4rem; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 0 0 .5rem; }
.hero .role {
  font-family: var(--font-mono); color: var(--accent);
  font-size: 1rem; letter-spacing: .04em;
}
.hero .tagline { font-size: clamp(1.1rem, 2.5vw, 1.4rem); color: var(--text-dim); max-width: 40ch; }
.hero-links { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.btn {
  display: inline-block; padding: .55rem 1.1rem; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); font-size: .95rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: #000; }

/* Card grids ------------------------------------------------------------ */
.card-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color .18s ease, transform .18s ease;
}
.card:hover { border-color: var(--accent); }

.pillar .pillar-icon { font-size: 1.8rem; line-height: 1; }
.pillar h3 { margin: .75rem 0 .5rem; font-size: 1.2rem; }
.pillar p { margin: 0; color: var(--text-dim); }

/* =========================================================================
   Algorithm diagrams (CSS-drawn — text comes from _data/algorithms.json)
   ========================================================================= */
.algo { margin-bottom: 3rem; }
.algo:last-child { margin-bottom: 0; }
.algo h3 { font-size: 1.35rem; margin: 0 0 .35rem; }
.algo .intro { color: var(--text-dim); margin: 0 0 1.25rem; max-width: 60ch; }

/* Cascading: horizontal flow with arrows */
.flow { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; }
.flow-node {
  flex: 1 1 160px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .9rem 1rem;
}
.flow-node .label { font-family: var(--font-mono); font-weight: 600; }
.flow-node .sub { font-size: .82rem; color: var(--text-dim); }
.flow-node.is-cheap { border-color: var(--accent); }
.flow-node.is-gate { border-style: dashed; }
.flow-arrow { align-self: center; color: var(--accent); font-size: 1.4rem; }

.algo-note {
  margin-top: 1.25rem; padding: .85rem 1.1rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.algo-note strong { color: var(--accent-hover); }
.algo-note .caption { display: block; font-size: .8rem; color: var(--text-dim); margin-top: .25rem; }

/* Desirepath: node graph */
.node-graph { display: flex; gap: .75rem; flex-wrap: wrap; }
.graph-node {
  flex: 1 1 160px; text-align: center; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1rem .75rem;
  position: relative;
}
.graph-node .label { font-family: var(--font-mono); font-weight: 600; font-size: .95rem; }
.graph-node .sub { font-size: .8rem; color: var(--text-dim); }
.graph-node::after {
  content: "→"; position: absolute; right: -0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--accent);
}
.graph-node:last-child::after { content: ""; }

/* =========================================================================
   Project cards
   ========================================================================= */
.project-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.project-card a.card-link { color: inherit; text-decoration: none; display: flex; flex-direction: column; height: 100%; }
.project-card a.card-link:hover { text-decoration: none; }
.project-thumb {
  aspect-ratio: 16 / 9; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-family: var(--font-mono); font-size: .85rem;
  border-bottom: 1px solid var(--border);
}
.project-body { padding: 1.35rem 1.5rem 1.5rem; display: flex; flex-direction: column; gap: .75rem; flex: 1; }
.project-body h3 { margin: 0; font-size: 1.25rem; }
.project-body .excerpt { margin: 0; color: var(--text-dim); font-size: .95rem; }
.project-body ul { margin: 0; padding-left: 1.1rem; color: var(--text-dim); font-size: .92rem; }
.project-body ul li { margin-bottom: .2rem; }
.tags { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; }
.tag {
  font-family: var(--font-mono); font-size: .72rem; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 6px; padding: .15rem .5rem;
}
.read-more { font-family: var(--font-mono); font-size: .85rem; color: var(--accent); }

/* =========================================================================
   Project page (case study)
   ========================================================================= */
.breadcrumb { font-size: .85rem; color: var(--text-dim); font-family: var(--font-mono); margin-bottom: 1rem; }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent); }

.article { max-width: 720px; }
.article h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: .25rem 0 1rem; }
.article h2 { margin-top: 2.25rem; font-size: 1.5rem; }
.article h3 { margin-top: 1.75rem; font-size: 1.2rem; }
.article p, .article li { color: var(--text); }
.article ul, .article ol { padding-left: 1.25rem; }
.article code {
  background: var(--surface-2); padding: .12rem .4rem; border-radius: 5px; font-size: .9em;
}
.article pre {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.25rem; overflow-x: auto;
}
.article pre code { background: none; padding: 0; }
.article .meta { color: var(--text-dim); font-family: var(--font-mono); font-size: .85rem; }
.article-links { margin: 1.5rem 0; display: flex; gap: .75rem; flex-wrap: wrap; }

/* =========================================================================
   Modal (progressive enhancement — hidden/no-op without JS)
   ========================================================================= */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(3, 6, 12, .72); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 3vh 1rem; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 800px; width: 100%; padding: 2rem clamp(1.25rem, 4vw, 2.5rem) 2.5rem;
  position: relative; margin-block: auto;
}
.modal-close {
  position: absolute; top: .75rem; right: .75rem;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 2.2rem; height: 2.2rem; border-radius: 8px; cursor: pointer; font-size: 1.1rem;
}
.modal-close:hover { border-color: var(--accent); color: var(--accent); }
body.modal-open { overflow: hidden; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 640px) {
  section { padding-block: 3rem; }
  .flow-arrow { transform: rotate(90deg); align-self: center; }
  .graph-node::after { content: ""; }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
