/* =========================================================
   Desira Wijesundara - portfolio design system
   One stylesheet for every page. Light + dark themes.
   All text/background pairs meet WCAG AA (4.5:1 or better).
   ========================================================= */

:root {
  --bg: #f6f4ef;
  --bg-2: #ebe8df;
  --surface: #fffdf9;
  --ink: #15171c;
  --muted: #575c55;
  --line: rgba(21, 23, 28, .11);
  --line-strong: rgba(21, 23, 28, .22);
  --accent: #a4442a;
  --accent-soft: rgba(164, 68, 42, .09);
  --on-accent: #ffffff;
  --ok: #1d6b45;
  --ok-bg: #e6f4ea;
  --code-bg: #17191d;
  --code-bg-2: #1f2126;
  --code-line: rgba(255, 255, 255, .08);
  --shadow: 0 1px 2px rgba(21, 23, 28, .04), 0 18px 40px -22px rgba(21, 23, 28, .28);
  --shadow-lift: 0 2px 4px rgba(21, 23, 28, .05), 0 26px 50px -24px rgba(21, 23, 28, .36);
  --nav-bg: rgba(246, 244, 239, .82);

  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --bg-2: #1a1b1e;
    --surface: #16171a;
    --ink: #ecebe6;
    --muted: #a4a8a0;
    --line: rgba(255, 255, 255, .09);
    --line-strong: rgba(255, 255, 255, .2);
    --accent: #f0875f;
    --accent-soft: rgba(240, 135, 95, .12);
    --on-accent: #111214;
    --ok: #7fd6a2;
    --ok-bg: rgba(127, 214, 162, .1);
    --code-bg: #0b0c0e;
    --code-bg-2: #141518;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -22px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 26px 50px -24px rgba(0, 0, 0, .8);
    --nav-bg: rgba(17, 18, 20, .8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111214;
  --bg-2: #1a1b1e;
  --surface: #16171a;
  --ink: #ecebe6;
  --muted: #a4a8a0;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .2);
  --accent: #f0875f;
  --accent-soft: rgba(240, 135, 95, .12);
  --on-accent: #111214;
  --ok: #7fd6a2;
  --ok-bg: rgba(127, 214, 162, .1);
  --code-bg: #0b0c0e;
  --code-bg-2: #141518;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -22px rgba(0, 0, 0, .7);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 26px 50px -24px rgba(0, 0, 0, .8);
  --nav-bg: rgba(17, 18, 20, .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
ul, ol { padding-left: 1.25em; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: var(--on-accent); }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  padding: 10px 16px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-weight: 600;
}
.skip-link:focus { top: 12px; text-decoration: none; }

h1, h2, h3 { color: var(--ink); text-wrap: balance; }

h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.3rem, 4.2vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -.015em;
  margin-bottom: 14px;
}

h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.35;
  letter-spacing: -.01em;
}

p { text-wrap: pretty; }
.dim { color: var(--muted); }

/* ---------- Method pills (GET / POST) ---------- */

.method {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: .66rem; font-weight: 500;
  letter-spacing: .04em; line-height: 1;
  padding: 4px 6px; border-radius: 5px;
  min-width: 38px;
}
.method.get  { background: var(--accent-soft); color: var(--accent); }
.method.post { background: var(--ok-bg); color: var(--ok); }

/* ---------- Top navigation ---------- */

.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-nav-inner {
  max-width: 1320px; margin: 0 auto;
  min-height: 68px;
  padding: 12px clamp(20px, 4vw, 48px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px 32px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 600; letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font-family: var(--display); font-size: 1.05rem; letter-spacing: 0;
  transition: background-color .25s ease, transform .25s var(--ease);
}
.brand:hover .brand-mark { background: var(--accent); color: var(--on-accent); transform: rotate(-6deg); }

.nav-links { display: flex; gap: 4px; justify-content: center; }
.nav-links a {
  position: relative;
  padding: 8px 12px; border-radius: 8px;
  color: var(--muted); font-size: .9rem; font-weight: 500;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--ink); background: var(--bg-2); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--accent);
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  transition: background-color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { background: var(--bg-2); border-color: var(--line-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.scroll-progress {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%;
  background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(var(--progress, 0));
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px;
  font-family: var(--sans); font-size: .92rem; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease,
              transform .2s var(--ease), box-shadow .2s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .arrow { transition: transform .2s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn:hover .arrow.down { transform: translateY(2px); }

.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 24px -12px var(--accent); }
.btn.ghost { color: var(--ink); border-color: var(--line-strong); background: transparent; }
.btn.ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 9px 16px; font-size: .85rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Page shell: sidebar + main ---------- */

.shell {
  max-width: 1320px; margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 72px);
}

.sidebar {
  position: sticky; top: var(--nav-h);
  align-self: start;
  height: calc(100vh - var(--nav-h));
  padding: 48px 0 32px;
  overflow-y: auto;
}
.sidebar-title {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 14px; padding-left: 12px;
}
.sidebar ul { list-style: none; padding: 0; position: relative; }
.sidebar ul::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 1px; background: var(--line);
}
.sidebar li a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-family: var(--mono); font-size: .8rem; color: var(--muted);
  transition: color .2s ease;
}
.sidebar li a::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px; background: transparent;
  transition: background-color .2s ease;
}
.sidebar li a:hover { color: var(--ink); text-decoration: none; }
.sidebar li a.active { color: var(--ink); }
.sidebar li a.active::before { background: var(--accent); }

main { min-width: 0; padding: 48px 0 96px; }

main > section { padding-top: 0; }
main > section + section,
main > .stats + section { margin-top: clamp(76px, 8vw, 108px); }

/* Section labels like "GET /experience" */
.endpoint-label {
  display: inline-flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  font-family: var(--mono); font-size: .8rem; color: var(--muted);
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: clamp(32px, 4.5vw, 64px);
  align-items: center;
  padding-top: clamp(8px, 2vw, 24px);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 22px;
  font-family: var(--mono); font-size: .78rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.eyebrow strong { color: var(--ink); font-weight: 500; }

.pulse {
  position: relative; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
}
.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--ok); opacity: 0;
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.6); opacity: .7; }
  100% { transform: scale(1.8); opacity: 0; }
}

.hero h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.2rem, 6.6vw, 5.9rem);
  line-height: .98;
  letter-spacing: -.025em;
  margin-bottom: 26px;
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero .tagline {
  max-width: 54ch;
  margin-bottom: 26px;
  font-size: 1.06rem; line-height: 1.75; color: var(--muted);
}

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: .8rem; font-weight: 500; color: var(--ink);
}
.badge.status { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.badge.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}

/* API response window */
.api-window {
  position: relative;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: #e6e8ee;
  border: 1px solid var(--code-line);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  transform: perspective(1600px) rotateY(-4deg) rotateX(2deg);
  transition: transform .6s var(--ease);
}
.api-window:hover { transform: perspective(1600px) rotateY(0) rotateX(0); }
.api-window::before {
  content: ""; position: absolute; inset: -40% -20% auto auto;
  width: 70%; height: 80%;
  background: radial-gradient(closest-side, rgba(240, 135, 95, .22), transparent);
  pointer-events: none;
}

.api-window-bar {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
  font-family: var(--mono); font-size: .78rem;
}
.api-window-bar .dots { display: flex; gap: 6px; }
.api-window-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a3d45; }
.api-window-bar .dots i:nth-child(1) { background: #ef6a5e; }
.api-window-bar .dots i:nth-child(2) { background: #f4bf4f; }
.api-window-bar .dots i:nth-child(3) { background: #61c454; }
.api-url {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 7px;
  background: rgba(255, 255, 255, .05);
  color: #c4c8d2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.api-url .method { background: rgba(242, 165, 127, .14); color: #f2a57f; min-width: 0; padding: 3px 5px; }
.api-status {
  display: inline-flex; align-items: center; gap: 6px;
  color: #7fe0a8; white-space: nowrap;
}
.api-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.json {
  position: relative;
  counter-reset: ln;
  padding: 18px 20px 20px 0;
  font-family: var(--mono); font-size: .76rem; line-height: 1.7;
}
.json .ln {
  position: relative; display: block;
  white-space: pre-wrap; overflow-wrap: anywhere;
  padding-left: 52px;
}
.json .ln.i { padding-left: calc(52px + 4ch); text-indent: -2ch; }
.json .ln::before {
  counter-increment: ln; content: counter(ln);
  position: absolute; left: 0; width: 34px; text-align: right;
  color: #5d626d; text-indent: 0;
}
.json .k { color: #f2a57f; }
.json .s { color: #b9d98c; }
.json .p, .json .a { color: #8b909a; }
.json .cursor {
  display: inline-block; width: .55em; height: 1.05em; vertical-align: -.15em;
  background: #f2a57f; margin-left: 2px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Stats strip ---------- */

.stats {
  margin-top: clamp(56px, 7vw, 88px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat {
  padding: 24px 22px;
  border-left: 1px solid var(--line);
}
.stat:first-child { border-left: 0; }
.stat-num {
  display: block;
  font-family: var(--display); font-size: clamp(2.4rem, 3.4vw, 3.1rem);
  line-height: 1; letter-spacing: -.02em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-num .plus { color: var(--accent); }
.stat-label {
  display: block; margin-top: 10px;
  font-size: .84rem; line-height: 1.45; color: var(--muted);
}

/* ---------- Overview ---------- */

.prose { max-width: 68ch; }
.prose p { color: var(--muted); font-size: 1.02rem; line-height: 1.8; }
.prose p + p { margin-top: 18px; }
.prose p.lead { color: var(--ink); font-size: 1.2rem; line-height: 1.7; }

/* ---------- Experience timeline ---------- */

.timeline { list-style: none; padding: 0; margin-top: 30px; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px;
  width: 1px; background: var(--line-strong);
}

.role { position: relative; padding: 0 0 40px 40px; }
.role:last-child { padding-bottom: 0; }
.role::before {
  content: ""; position: absolute; left: 0; top: 6px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line-strong);
}
.role.current::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }

.role-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px 20px; flex-wrap: wrap;
}
.role-head h3 { font-size: 1.2rem; }
.role-head .org { display: block; margin-top: 2px; font-size: .95rem; font-weight: 500; color: var(--accent); }
.role-head .org-note { display: inline; color: var(--muted); font-weight: 400; }
.role-meta {
  font-family: var(--mono); font-size: .76rem; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  white-space: nowrap;
}
.role ul { margin-top: 14px; color: var(--muted); max-width: 72ch; list-style: disc; }
.role li { margin-bottom: 7px; padding-left: 4px; }
.role li::marker { color: var(--accent); }

/* ---------- Case studies & writing cards ---------- */

.case-grid { display: grid; gap: 20px; margin-top: 26px; }
.case-grid > .case-card { min-width: 0; }

.case-group-label,
.skill-group-label {
  display: flex; align-items: center; gap: 12px;
  margin-top: 22px;
  font-family: var(--mono); font-size: .74rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.case-group-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.case-group-label:first-child { margin-top: 0; }
.subsection-label { margin-top: 56px; line-height: 1.4; }
.subsection-label + .timeline { margin-top: 24px; }

.case-card {
  position: relative;
  padding: clamp(22px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s var(--ease);
}
.case-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); }

.case-card .tag {
  display: inline-block; margin-bottom: 12px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--mono); font-size: .7rem; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
}
.case-card h3 { font-size: 1.3rem; margin-bottom: 4px; }
.case-card > p { color: var(--muted); font-size: .97rem; margin: 10px 0 0; max-width: 75ch; }
.case-card > p strong { color: var(--ink); font-weight: 600; }
.case-card > a {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 16px;
  font-weight: 600; font-size: .92rem;
}

/* Featured case study */
.case-card.featured {
  padding: clamp(26px, 4vw, 44px);
  border-color: transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), var(--line-strong) 45%, var(--line)) border-box;
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-lift);
}
.case-card.featured::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(600px 220px at 100% 0%, var(--accent-soft), transparent 70%);
}
.case-card.featured > * { position: relative; }
.case-card.featured h3 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.08; letter-spacing: -.01em;
  max-width: 24ch; margin-bottom: 12px;
}
.case-card.featured .featured-lead { color: var(--ink); font-size: 1.08rem; max-width: 62ch; }

.feature-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 28px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.feature-stat { padding: 20px 20px 20px 0; }
.feature-stat + .feature-stat { padding-left: 20px; border-left: 1px solid var(--line); }
.fs-num {
  display: block; font-family: var(--display); font-size: clamp(2.2rem, 3.4vw, 2.9rem);
  line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums;
}
.fs-num .plus { color: var(--accent); }
.fs-num .of { font-size: .5em; color: var(--muted); font-family: var(--sans); vertical-align: .35em; }
.fs-label { display: block; margin-top: 8px; font-size: .84rem; line-height: 1.45; color: var(--muted); }

.flow {
  list-style: none; padding: 0; margin-top: 28px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  counter-reset: none;
}
.flow li {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line);
  font-size: .86rem; line-height: 1.5; color: var(--muted);
}
.flow li strong { color: var(--ink); font-size: .95rem; font-weight: 600; }
.flow-n { font-family: var(--mono); font-size: .72rem; color: var(--accent); }
.flow li:not(:last-child)::after {
  content: "→"; position: absolute; right: -11px; top: 16px; z-index: 1;
  width: 10px; text-align: center; color: var(--muted); font-size: .8rem;
}

.sample-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.case-card > .sample-links a { margin-top: 0; }
.case-card .sample-links .btn.primary { color: var(--bg); }
.case-card .sample-links .btn.primary:hover { color: var(--on-accent); }
.case-card .sample-links .btn.ghost { color: var(--ink); }

/* Writing grid: three Medium cards, thesis full width */
.writing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.writing-grid .case-card { display: flex; flex-direction: column; align-items: flex-start; }
.writing-grid .case-card > * { max-width: 100%; }
.writing-grid .case-card .excerpt { align-self: stretch; }
.writing-grid .case-card > a { margin-top: auto; padding-top: 16px; }
.writing-grid .case-card.wide { grid-column: 1 / -1; }
.read-stats {
  font-family: var(--mono); font-size: .78rem !important; color: var(--muted);
}

/* Expandable excerpts */
.excerpt {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color .2s ease;
}
.excerpt + .excerpt { margin-top: 10px; }
.excerpt[open] { border-color: var(--line-strong); }
.excerpt > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px;
  list-style: none; cursor: pointer;
  font-size: .94rem; font-weight: 500; color: var(--ink);
  border-radius: var(--radius-sm);
}
.excerpt > summary::-webkit-details-marker { display: none; }
.excerpt > summary:hover { color: var(--accent); }
.excerpt > summary::after {
  content: ""; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 50%;
  background:
    linear-gradient(currentColor, currentColor) center / 10px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.5px 10px no-repeat,
    var(--bg-2);
  transition: transform .25s var(--ease), background-color .2s ease;
}
.excerpt[open] > summary::after {
  transform: rotate(45deg);
}

.excerpt-body {
  padding: 4px 22px 22px;
  font-size: .94rem; line-height: 1.75; color: var(--ink);
  animation: fadeDown .35s var(--ease);
}
@keyframes fadeDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.excerpt-body p { margin-bottom: 12px; }
.excerpt-body ol, .excerpt-body ul { margin: 8px 0 12px; }
.excerpt-body li { margin-bottom: 7px; }
.excerpt-body li::marker { color: var(--muted); }
.excerpt-body .field {
  font-family: var(--mono); font-size: .84em;
  padding: 1px 6px; border-radius: 5px;
  background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.excerpt-body blockquote {
  margin: 10px 0; padding: 10px 14px;
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  background: var(--accent-soft); color: var(--ink); font-size: .9rem;
}
.excerpt-body details {
  margin: 10px 0; padding: 10px 14px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
}
.excerpt-body details > summary {
  cursor: pointer; list-style: none;
  font-weight: 600; font-size: .9rem; color: var(--accent);
}
.excerpt-body details > summary::-webkit-details-marker { display: none; }
.excerpt-body details > summary::before { content: "+ "; font-family: var(--mono); }
.excerpt-body details[open] > summary::before { content: "\2212  "; }
.excerpt-body details[open] > summary { margin-bottom: 8px; }

.excerpt-body pre.code {
  margin: 10px 0 14px; padding: 14px 16px;
  border-radius: 10px;
  background: var(--code-bg); color: #e6e8ee;
  border: 1px solid var(--code-line);
  font-family: var(--mono); font-size: .8rem; line-height: 1.65;
  overflow-x: auto; white-space: pre;
}

.excerpt-body.email {
  margin: 6px 22px 22px; padding: 18px 20px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
}
.excerpt-body.email ol, .excerpt-body.email li { color: var(--ink); }

.excerpt-body .endpoint-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.excerpt-body table.params {
  display: block; width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 10px 0 16px;
  font-size: .86rem;
}
.excerpt-body table.params th,
.excerpt-body table.params td {
  text-align: left; vertical-align: top;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.excerpt-body table.params thead th {
  font-family: var(--mono); font-size: .72rem; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: var(--bg-2);
}
.excerpt-body table.params tbody tr:hover { background: var(--accent-soft); }
.excerpt-body table.params td:first-child,
.excerpt-body table.params td:nth-child(2) {
  font-family: var(--mono); font-size: .8rem; white-space: nowrap;
}
.excerpt-body table.params.errors td:nth-child(2) { font-family: inherit; font-size: .86rem; white-space: normal; }

.excerpt-body .marker {
  display: inline-block; margin-left: 6px; vertical-align: 1px;
  padding: 1px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: .64rem; font-weight: 500;
}
.excerpt-body .marker.req { background: var(--accent-soft); color: var(--accent); }
.excerpt-body .marker.opt { background: var(--bg-2); color: var(--muted); }
.excerpt-body .marker.ro  { background: var(--ok-bg); color: var(--ok); }

.excerpt-note {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 16px;
  font-size: .82rem; color: var(--muted);
}
.excerpt-note::before { content: "\24D8"; font-size: .95rem; line-height: 1.3; }

.excerpt-screenshot {
  margin-top: 16px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.excerpt-screenshot img { width: 100%; height: auto; }
.excerpt-screenshot-label {
  padding: 8px 12px;
  border-top: 1px solid var(--line); background: var(--bg-2);
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
}

/* ---------- Toolchain ---------- */

.tool-groups { display: grid; gap: 0; margin-top: 26px; border-top: 1px solid var(--line); }
.tool-group {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px 32px;
  padding: 22px 0; border-bottom: 1px solid var(--line);
}
.tool-group .skill-group-label { margin: 6px 0 0; }
.skills-grid { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.skill-chip {
  padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: .88rem; font-weight: 500; color: var(--ink);
  transition: border-color .2s ease, color .2s ease, transform .2s var(--ease);
}
.skill-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ---------- Contact ---------- */

.contact-card {
  position: relative; overflow: hidden;
  padding: clamp(32px, 5vw, 64px);
  border-radius: calc(var(--radius) + 8px);
  background: var(--code-bg); color: #e6e8ee;
  border: 1px solid var(--code-line);
  box-shadow: var(--shadow-lift);
}
.contact-card::before {
  content: ""; position: absolute; right: -10%; top: -60%;
  width: 60%; height: 160%;
  background: radial-gradient(closest-side, rgba(240, 135, 95, .25), transparent);
  pointer-events: none;
}
.contact-card > * { position: relative; }
.contact-card .endpoint-label { color: #a7acb6; }
.contact-card .method.post { background: rgba(127, 224, 168, .14); color: #7fe0a8; }
.contact-card h2 { color: #f4f2ec; font-size: clamp(2.6rem, 5.4vw, 4.2rem); }
.contact-card p { color: #b9bdc6; max-width: 58ch; margin-top: 8px; font-size: 1.05rem; }
.contact-card .cta-row { margin-top: 28px; }
.contact-card .btn.primary { background: #f0875f; color: #111214; }
.contact-card .btn.primary:hover { background: #f6a283; color: #111214; box-shadow: 0 10px 28px -12px #f0875f; }
.contact-card .btn.ghost { color: #e6e8ee; border-color: rgba(255, 255, 255, .22); }
.contact-card .btn.ghost:hover { border-color: #e6e8ee; }
.contact-email {
  margin-top: 22px;
  font-family: var(--mono); font-size: .85rem; color: #a7acb6;
}
.contact-email .copied { color: #7fe0a8; margin-left: 8px; opacity: 0; transition: opacity .2s ease; }
.contact-email .copied.show { opacity: 1; }

/* ---------- Footer ---------- */

.site-footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 72px; padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: .76rem; color: var(--muted);
}

/* ---------- Scroll reveal (only when JS is running) ---------- */

.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .writing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .flow li { display: grid; grid-template-columns: 34px 150px minmax(0, 1fr); align-items: baseline; gap: 4px 12px; padding: 12px 16px; }
  .flow li:not(:last-child)::after { display: none; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }

  /* Sidebar becomes a sticky, swipeable jump bar */
  .sidebar {
    position: sticky; top: var(--nav-h); z-index: 40;
    height: auto; padding: 10px 0;
    margin: 0 calc(-1 * clamp(20px, 4vw, 48px));
    padding-inline: clamp(20px, 4vw, 48px);
    background: var(--nav-bg);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-title { display: none; }
  .sidebar ul { display: flex; gap: 6px; }
  .sidebar ul::before { display: none; }
  .sidebar li a {
    padding: 6px 12px 6px 6px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    white-space: nowrap;
  }
  .sidebar li a::before { display: none; }
  .sidebar li a.active { border-color: var(--accent); }

  main { padding-top: 36px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .api-window { transform: none; }
  .tool-group { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 720px) {
  .site-nav-inner {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand actions" "links links";
    gap: 10px 12px; padding-bottom: 8px;
  }
  .brand { grid-area: brand; }
  .nav-actions { grid-area: actions; }
  .nav-links { grid-area: links; justify-content: flex-start; margin: 0 -12px; overflow-x: auto; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:first-child, .stat:nth-child(2) { border-top: 0; }
  .stat:last-child { grid-column: 1 / -1; border-left: 0; }

  .writing-grid { grid-template-columns: minmax(0, 1fr); }

  .feature-stats { grid-template-columns: minmax(0, 1fr); }
  .feature-stat, .feature-stat + .feature-stat { padding: 16px 0; border-left: 0; }
  .feature-stat + .feature-stat { border-top: 1px solid var(--line); }
  .flow li { grid-template-columns: 28px minmax(0, 1fr); }
  .flow li > span:last-child { grid-column: 2; }

  /* Eyebrow: name on one line, role on the next */
  .eyebrow .sep { display: none; }
  .eyebrow .role-line { flex-basis: 100%; padding-left: 18px; }

  /* Profile response: show the top, scroll for the rest */
  .json {
    max-height: 460px; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: #3a3d45 transparent;
  }

  /* Wide reference tables scroll sideways instead of crushing the description */
  .excerpt-body table.params td:last-child { min-width: 230px; }

  .excerpt-body { padding: 4px 16px 18px; }
  .excerpt-body.email { margin: 4px 12px 16px; padding: 16px; }
  .excerpt > summary { padding: 13px 14px; }
  .role { padding-left: 32px; }
  .site-footer { flex-direction: column; }
}

@media (max-width: 420px) {
  .brand { gap: 8px; font-size: .92rem; }
  .theme-toggle { width: 34px; height: 34px; }
  .hero h1 { font-size: 2.9rem; }
}

@media (max-width: 350px) {
  .brand-name { display: none; }
  .cta-row .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .api-window { transform: none; }
}

@media print {
  .site-nav, .sidebar, .theme-toggle, .scroll-progress { display: none !important; }
  .shell { display: block; }
  .api-window, .contact-card { box-shadow: none; transform: none; }
  details { display: block; }
  .js .reveal { opacity: 1; transform: none; }
}
