/* ---------- Fonts (self-hosted, SIL OFL) ---------- */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("/fonts/instrument-sans-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #fbfaf7;
  --surface: rgba(255, 255, 255, 0.6);
  --text: #16171b;
  --muted: #62666e;
  --rule: #e3dfd7;
  --accent: #f0502a;          /* brand / CTA: vivid vermilion */
  --accent-ink: #c43d1a;      /* accent dark enough for body-size text */
  --accent-soft: rgba(240, 80, 42, 0.08);
  --code-bg: rgba(22, 23, 27, 0.045);
  --mark: rgba(255, 196, 0, 0.35);
  --glow-1: rgba(255, 112, 67, 0.20);
  --glow-2: rgba(136, 92, 255, 0.14);
  --glow-3: rgba(0, 184, 196, 0.10);
  --measure: 40rem;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  /* SVG line work, used as masks so they take any color */
  --swoosh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8.5C22 3 48 2.5 70 5.5s34 3.5 48-1' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 16' preserveAspectRatio='none'%3E%3Cpath d='M0 8h296c6 0 8-6 12-6s6 12 12 12 6-6 12-6h308' fill='none' stroke='%23000' stroke-width='1.2' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215;
    --surface: rgba(255, 255, 255, 0.03);
    --text: #ece9e2;
    --muted: #9a9ea6;
    --rule: #2a2d33;
    --accent: #ff6a3d;
    --accent-ink: #ff8a63;
    --accent-soft: rgba(255, 106, 61, 0.10);
    --code-bg: rgba(255, 255, 255, 0.05);
    --mark: rgba(255, 196, 0, 0.28);
    --glow-1: rgba(255, 106, 61, 0.14);
    --glow-2: rgba(136, 92, 255, 0.14);
    --glow-3: rgba(0, 184, 196, 0.08);
  }
}

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

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0 auto;
  max-width: calc(var(--measure) + 2rem);
  padding: 0 1rem;
  color: var(--text);
  font: 1.0625rem/1.72 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Ambient background: layered, muted gradients + a whisper of grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(48rem 32rem at 92% -8%, var(--glow-1), transparent 62%),
    radial-gradient(40rem 30rem at -12% 6%, var(--glow-2), transparent 60%),
    radial-gradient(44rem 28rem at 60% 108%, var(--glow-3), transparent 62%),
    linear-gradient(160deg, transparent 40%, var(--accent-soft) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: var(--accent-ink);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.15s, text-decoration-thickness 0.15s;
}
a:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* Reusable SVG line work */
.divider {
  height: 16px;
  margin: 2.5rem 0;
  border: 0;
  background: var(--rule);
  -webkit-mask: var(--divider) center / 100% 100% no-repeat;
          mask: var(--divider) center / 100% 100% no-repeat;
}

/* ---------- Header / footer ---------- */
.site-header, .site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 0.95rem;
}
.site-header { padding: 2rem 0 4rem; }
.site-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}
.site-title span { color: var(--accent); }
.site-header nav { display: flex; gap: 1.5rem; }
.site-header nav a { position: relative; color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--text); }
.site-header nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.55em;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--accent);
}

.site-footer {
  margin-top: 5rem;
  padding: 0 0 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .divider { flex-basis: 100%; margin: 0 0 1.25rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ---------- Home ---------- */
.intro h1 {
  font: 700 clamp(2.4rem, 7vw, 3.25rem)/1.05 var(--font-display);
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}
.scribble { position: relative; white-space: nowrap; }
.scribble svg {
  position: absolute;
  left: -2%;
  bottom: -0.18em;
  width: 104%;
  height: 0.3em;
  overflow: visible;
  color: var(--accent);
}
.intro p { color: var(--muted); font-size: 1.15rem; margin: 0 0 1.5rem; max-width: 32rem; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.85rem 0.35rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(6px);
  font: 500 0.85rem/1.3 var(--font-display);
  color: var(--text);
  text-decoration: none;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.status:hover { border-color: var(--accent); }

.section-label {
  font: 600 0.75rem/1 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 4rem 0 0.5rem;
}

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { position: relative; padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.post-list li > a {
  font: 600 1.25rem/1.3 var(--font-display);
  letter-spacing: -0.015em;
  color: var(--text);
  text-decoration: none;
}
.post-list li > a::after { content: " →"; color: var(--accent); opacity: 0; transition: opacity 0.15s, margin 0.15s; }
.post-list li > a:hover::after { opacity: 1; margin-left: 0.15em; }
.post-list time { display: block; font: 0.82rem var(--font-display); color: var(--muted); margin-top: 0.2rem; }
.post-list p { margin: 0.4rem 0 0; font-size: 0.98rem; color: var(--muted); }

/* ---------- Post ---------- */
.post-header h1 {
  font: 700 clamp(2rem, 6vw, 2.75rem)/1.1 var(--font-display);
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}
.post-header h1::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 0.6rem;
  margin-top: 0.9rem;
  background: var(--accent);
  -webkit-mask: var(--swoosh) center / 100% 100% no-repeat;
          mask: var(--swoosh) center / 100% 100% no-repeat;
}
.post-meta { font: 0.88rem var(--font-display); color: var(--muted); margin: 0 0 2.5rem; }
.draft-badge { color: var(--accent-ink); }

.post-footer { margin-top: 3rem; font-size: 1rem; color: var(--muted); }
.post-footer .divider { margin: 0 0 1.75rem; }
.cta {
  display: inline-block;
  margin: 0.25rem 0 1.25rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: 600 0.95rem/1.2 var(--font-display);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 6px 18px -8px var(--accent); }
.back { font-family: var(--font-display); font-size: 0.9rem; }

/* ---------- Prose ---------- */
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 2.75rem 0 0.75rem;
}
.prose h1 { font-size: 2.5rem; letter-spacing: -0.03em; }
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.prose h2 a, .prose h3 a, .prose h4 a { color: inherit; text-decoration: none; }
.prose h2 a:hover::after, .prose h3 a:hover::after, .prose h4 a:hover::after {
  content: " #"; color: var(--accent); font-weight: 400;
}

.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre, .prose figure, .prose details { margin: 0 0 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose li::marker { color: var(--accent); }
.prose ol > li::marker { font-family: var(--font-display); font-weight: 600; font-size: 0.92em; }
.prose li > ul, .prose li > ol { margin: 0.3rem 0 0; }
.prose .task-list-item { list-style: none; margin-left: -1.4em; }
.prose .task-list-item-checkbox { margin-right: 0.5em; accent-color: var(--accent); }

.prose blockquote {
  position: relative;
  margin-left: 0;
  padding: 0.1rem 0 0.1rem 1.5rem;
  color: var(--muted);
  font-style: italic;
}
.prose blockquote::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4em;
  bottom: 0.4em;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 10%, transparent));
}
.prose blockquote p:last-child { margin-bottom: 0; }

.callout {
  display: block;
  margin: 0 0 1.4rem;
  padding: 1rem 1.25rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 10px;
}
.callout strong { color: var(--accent-ink); }

.prose hr {
  height: 16px;
  margin: 2.75rem 0;
  border: 0;
  background: var(--rule);
  -webkit-mask: var(--divider) center / 100% 100% no-repeat;
          mask: var(--divider) center / 100% 100% no-repeat;
}
.prose mark { background: linear-gradient(transparent 35%, var(--mark) 35%, var(--mark) 90%, transparent 90%); color: inherit; padding: 0 0.1em; }
.prose kbd {
  font: 0.8em var(--font-mono);
  padding: 0.1em 0.4em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
}

.prose code { font-family: var(--font-mono); font-size: 0.86em; }
.prose :not(pre) > code { background: var(--code-bg); padding: 0.12em 0.35em; border-radius: 4px; }
.prose pre {
  overflow-x: auto;
  padding: 1rem 1.15rem;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); }
.prose th { font-family: var(--font-display); font-weight: 600; border-bottom: 1.5px solid var(--text); }

.prose img, .prose svg { max-width: 100%; height: auto; }
.prose figure { margin-left: 0; margin-right: 0; }
.prose figcaption { margin-top: 0.6rem; font: 0.85rem var(--font-display); color: var(--muted); text-align: center; }

.prose details { border: 1px solid var(--rule); border-radius: 10px; padding: 0.8rem 1rem; background: var(--surface); }
.prose summary { cursor: pointer; font-family: var(--font-display); font-weight: 600; }
.prose summary::marker { color: var(--accent); }
.prose details[open] summary { margin-bottom: 0.75rem; }

.prose .footnotes { font-size: 0.92rem; color: var(--muted); }
.prose .footnotes-sep { margin-top: 3rem; }
.prose .footnote-ref a { text-decoration: none; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
