/* =============================================================
   OLD FORGE · LETTERPRESS DESIGN SYSTEM
   Shared tokens, base typography, and primitives.
   Typeset in Fraunces (display) and JetBrains Mono (technical).
   ============================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }

:root {
  /* Ink & Paper */
  --ink:        #14110D;
  --ink-soft:   #1E1A14;
  --ink-deep:   #0A0805;
  --paper:      #F0E7D2;
  --paper-warm: #EADEC0;
  --paper-deep: #DCCFA8;
  --paper-edge: #B9A77C;

  /* Fire & Metal */
  --ember:      #C8441C;
  --ember-hot:  #E85D2B;
  --ember-deep: #8C2E12;
  --ember-glow: rgba(200, 68, 28, .28);
  --copper:     #B87333;
  --steel:      #3D5568;
  --ash:        #7A6F5E;
  --rust:       #8E3A1E;

  /* Ink on paper */
  --text:       #181511;
  --text-muted: #5B5140;
  --text-faint: #8B7F66;
  --rule:       #2E2A22;
  --rule-soft:  rgba(20, 17, 13, .18);

  /* Typography */
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Measure */
  --measure: 62ch;
  --gutter:  clamp(1.25rem, 4vw, 3rem);
  --page:    clamp(1.25rem, 4vw, 4rem);
}

/* ------------------------------------------------------------
   BASE TYPOGRAPHY
   ------------------------------------------------------------ */
html, body { background: var(--paper); color: var(--text); }
body {
  font-family: var(--serif);
  font-variation-settings: "opsz" 14, "SOFT" 30, "wght" 400;
  font-feature-settings: "ss01", "onum", "liga", "calt";
  font-size: clamp(16px, .95rem + .15vw, 18px);
  line-height: 1.55;
  overflow-x: hidden;
  position: relative;
}

/* Global grain — SVG fractal noise multiplied onto the page */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08  0 0 0 0 0.07  0 0 0 0 0.05  0 0 0 0.42 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 240px 240px;
  opacity: .55;
  mix-blend-mode: multiply;
}

/* Dark sections invert the grain */
.ink-bg::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.9  0 0 0 0 0.75  0 0 0 0.10 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: screen;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 420;
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--text);
}

a { color: inherit; }
a:focus-visible { outline: 2px solid var(--ember); outline-offset: 4px; border-radius: 2px; }

::selection { background: var(--ember); color: var(--paper); }

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

/* ------------------------------------------------------------
   PRIMITIVES
   ------------------------------------------------------------ */

/* Small-caps mono label — section kickers, table headers, metadata */
.kicker {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ember);
}
.kicker--ink   { color: var(--paper-deep); }
.kicker--muted { color: var(--text-muted); }

.mono { font-family: var(--mono); font-weight: 400; letter-spacing: -.01em; }

/* Screen-reader-only text */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Hair rules */
.hair         { display: block; width: 100%; height: 1px; background: var(--rule); opacity: .55; }
.hair--ember  { background: var(--ember); opacity: 1; height: 2px; }
.hair--paper  { background: var(--paper-deep); opacity: .35; }

/* Ornamental dingbat — a small forged mark */
.dingbat {
  display: inline-block; width: 18px; height: 18px; vertical-align: middle;
  color: var(--ember);
}
.dingbat--center { display: block; margin: 2rem auto; width: 28px; height: 28px; }

/* Page frame */
.page {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--page);
}

/* ------------------------------------------------------------
   MASTHEAD — thin, letterpress, always-on publication bar
   ------------------------------------------------------------ */
.masthead {
  position: sticky; top: 0; z-index: 80;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: saturate(1.05);
}
.masthead__inner {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "mark nav" "meta meta";
  align-items: center;
  gap: .4rem 1rem;
  padding: .75rem var(--page);
  max-width: 1400px; margin: 0 auto;
}
.masthead__mark { grid-area: mark; }
.masthead__nav  { grid-area: nav; }
.masthead__mark {
  font-family: var(--serif);
  font-variation-settings: "opsz" 144, "SOFT" 50, "wght" 640;
  font-size: clamp(1.5rem, 1.2rem + .9vw, 2rem);
  letter-spacing: -.025em;
  line-height: .9;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.masthead__mark em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "wght" 380;
  color: var(--ember);
  font-feature-settings: "ss01";
  margin-left: .05em;
}
.masthead__mark-tag {
  display: inline-block;
  margin-left: .55em;
  font-family: var(--mono); font-style: normal;
  font-size: .48em; font-weight: 500;
  letter-spacing: .24em; text-transform: uppercase;
  color: var(--text-muted);
  vertical-align: .35em;
}
@media (max-width: 520px) {
  .masthead__mark-tag { display: none; }
}
.masthead__meta {
  grid-area: meta; justify-self: center;
  padding-top: .5rem; margin-top: .25rem;
  border-top: 1px solid var(--rule-soft);
  width: max-content; max-width: 100%;
  display: flex; gap: 1.5rem; align-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--text-muted);
  justify-content: center;
}
.masthead__meta span { position: relative; }
.masthead__meta span + span::before {
  content: ""; position: absolute; left: -.75rem; top: 50%;
  width: 4px; height: 4px; background: var(--ember);
  border-radius: 50%; transform: translateY(-50%);
}
.masthead__nav {
  display: flex; gap: 1.25rem; justify-content: flex-end;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
}
.masthead__nav a {
  text-decoration: none; color: var(--text); position: relative; padding: 2px 0;
  transition: color .18s ease;
}
.masthead__nav a:hover,
.masthead__nav a[aria-current="page"] { color: var(--ember); }
.masthead__nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: var(--ember); transform: scaleX(0); transform-origin: left;
  transition: transform .22s ease;
}
.masthead__nav a:hover::after,
.masthead__nav a[aria-current="page"]::after { transform: scaleX(1); }

@media (max-width: 860px) {
  .masthead__inner { grid-template-areas: "mark nav"; gap: .5rem; }
  .masthead__meta  { display: none; }
  .masthead__nav   { gap: .9rem; font-size: 11px; }
}
@media (max-width: 520px) {
  .masthead__nav a:not([aria-current]):not(.masthead__cta):not(.masthead__auth) { display: none; }
}

/* Auth link — identity slot, styled as a bordered plate with a leading
   diamond mark. Empty diamond = signed-out, filled diamond = signed-in. */
.masthead__auth {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-left: .9rem;
  padding: .38rem .7rem .38rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-warm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  transition: border-color .2s ease, background .18s ease, color .18s ease;
}
.masthead__auth::before {
  content: "";
  width: 7px; height: 7px;
  border: 1px solid var(--ember);
  background: transparent;
  transform: rotate(45deg);
  flex: 0 0 auto;
  transition: background .2s ease;
}
.masthead__auth[data-auth-state="signed-in"]::before {
  background: var(--ember);
}
.masthead__auth:hover {
  border-color: var(--ember);
  background: var(--paper-deep);
  color: var(--ember);
}
.masthead__auth:hover::before {
  background: var(--ember);
}
/* Masthead nav underline rule shouldn't draw on the plated auth link */
.masthead__nav a.masthead__auth::after { display: none; }
