/* ────────────────────────────────────────────────────────────────────────────
 * @forge/grain — ported to forge-website/grain.css
 *
 * Source: foundry-hearth/commercialization/web/grain.css
 * Ported: 2026-05-06
 *
 * Three voices:
 *   Newsreader (serif)     — Hearth voice. Warm, narrative, human.
 *   Inter Tight (sans)     — Workbench voice. Precise, functional, clear.
 *   JetBrains Mono (mono)  — Anvil voice. Raw, honest, unadorned.
 *
 * Color discipline:
 *   --forge-blue  primary brand accent (for system, structure, data, links)
 *   --forge-warmth/ember/gold  reserved for DELIGHT moments only
 *   --sage        success / active / live indicators
 *   --amber       warning / in-progress / caution
 *   --danger-red  alert / error
 * ──────────────────────────────────────────────────────────────────────── */

:root {
  /* ── Surfaces ────────────────────────────────────────── */
  --background: #F9F9F8;
  --background-sunken: #F2F2F0;
  --background-deep: #F4EFE6;
  --surface: #FFFFFF;
  --surface-sunken: #FAF7F1;
  --surface-elevated: #FFFFFF;

  /* ── Text / Ink ──────────────────────────────────────── */
  --ink: rgba(15, 23, 42, 0.9);
  --ink-secondary: #475569;
  --ink-tertiary: #94A3B8;
  --ink-emphasis: rgba(15, 23, 42, 0.95);
  --text-main: rgba(15, 23, 42, 0.9);
  --text-muted: #475569;
  --text-faint: #94A3B8;

  /* ── Surface Layers ──────────────────────────────────── */
  --surface-overlay: rgba(255, 255, 255, 0.5);
  --bg-gradient: linear-gradient(145deg, #FDFBF7 0%, #F4EFE6 100%);

  /* ── Borders ─────────────────────────────────────────── */
  --border: rgba(15, 23, 42, 0.08);
  --border-light: rgba(15, 23, 42, 0.04);
  --border-hairline: rgba(15, 23, 42, 0.08);
  --border-faint: rgba(15, 23, 42, 0.04);

  /* ── Forge Blue (primary accent) ─────────────────────── */
  --forge-blue: #0151AF;
  --forge-blue-bg: rgba(1, 81, 175, 0.06);
  --forge-blue-border: rgba(1, 81, 175, 0.15);
  --forge-blue-vivid: #0A55FF;

  /* ── Sage (active / positive) ────────────────────────── */
  --sage: #1A8A4A;
  --sage-bg: rgba(26, 138, 74, 0.06);
  --sage-border: rgba(26, 138, 74, 0.15);
  --sage-vivid: #059669;

  /* ── Amber (warning / in-progress) ───────────────────── */
  --amber: #C47D00;
  --amber-bg: rgba(196, 125, 0, 0.06);
  --amber-border: rgba(196, 125, 0, 0.15);
  --amber-vivid: #D97706;

  /* ── Danger / Alert ──────────────────────────────────── */
  --danger-red: #CC2222;
  --danger-red-bg: rgba(204, 34, 34, 0.06);
  --danger-red-border: rgba(204, 34, 34, 0.15);

  /* ── Forge Warmth (DELIGHT moments only) ─────────────── */
  --forge-warmth: rgba(245, 158, 11, 0.08);
  --forge-warmth-glow: rgba(245, 158, 11, 0.15);
  --forge-warmth-border: rgba(217, 119, 6, 0.2);
  --forge-ember: #92400E;
  --forge-gold: #FFD700;
  --forge-white-hot: #FFF7E0;

  /* ── Shadows ─────────────────────────────────────────── */
  --shadow-sunken: inset 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-elevated: 0 1px 3px rgba(146, 64, 14, 0.03), 0 12px 40px rgba(15, 23, 42, 0.05);
  --shadow-float: 0 4px 24px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(146, 64, 14, 0.04);
  --shadow-subtle: 0 2px 8px rgba(15, 23, 42, 0.04);

  /* ── Border Radius ───────────────────────────────────── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-panel: 12px;
  --radius-card: 12px;
  --radius-input: 6px;
  --radius-pill: 99px;

  /* ── Typography ──────────────────────────────────────── */
  --font-sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --font-size-base: 15px;
  --line-height-base: 1.5;
  --letter-spacing-base: -0.01em;

  --tracking-tight: -0.02em;
  --tracking-normal: -0.01em;
  --tracking-wide: 0.06em;
  --tracking-caps: 0.12em;

  --weight-body: 400;
  --weight-label: 500;
  --weight-heading: 600;

  /* ── Spacing Scale (4pt base) ────────────────────────── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  /* ── Elevation ───────────────────────────────────────── */
  --elevation-0: none;
  --elevation-1: 0 1px 2px rgba(15, 23, 42, 0.04);
  --elevation-2: 0 2px 8px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(146, 64, 14, 0.02);
  --elevation-3: 0 4px 16px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(146, 64, 14, 0.03);
  --elevation-4: 0 8px 32px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(146, 64, 14, 0.04);

  /* ── Motion ──────────────────────────────────────────── */
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
  --ease-default: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-decelerate: cubic-bezier(0.0, 0.0, 0.2, 1);
}

/* ── Dark theme override (apply with data-theme="dark") ──── */
[data-theme="dark"] {
  --background: #0F172A;
  --background-sunken: #0B1120;
  --background-deep: #080E1A;
  --surface: #1E293B;
  --surface-sunken: #0B1222;
  --surface-elevated: #1E293B;

  --ink: #F8FAFC;
  --ink-secondary: #CBD5E1;
  --ink-tertiary: #8494A7;
  --ink-emphasis: rgba(248, 250, 252, 0.95);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-faint: #8494A7;

  --surface-overlay: rgba(30, 41, 59, 0.5);
  --bg-gradient: linear-gradient(145deg, #0F172A 0%, #0B1120 100%);

  --border: rgba(248, 250, 252, 0.08);
  --border-light: rgba(248, 250, 252, 0.04);
  --border-hairline: rgba(248, 250, 252, 0.08);
  --border-faint: rgba(248, 250, 252, 0.04);

  --forge-blue: #6B9FE8;
  --forge-blue-bg: rgba(107, 159, 232, 0.1);
  --forge-blue-border: rgba(107, 159, 232, 0.25);
  --forge-blue-vivid: #3B82F6;

  --sage: #5CB888;
  --sage-bg: rgba(92, 184, 136, 0.1);
  --sage-border: rgba(92, 184, 136, 0.25);
  --sage-vivid: #34D399;

  --amber: #E0A840;
  --amber-bg: rgba(224, 168, 64, 0.1);
  --amber-border: rgba(224, 168, 64, 0.25);
  --amber-vivid: #FBBF24;

  --danger-red: #E85C5C;
  --danger-red-bg: rgba(232, 92, 92, 0.1);
  --danger-red-border: rgba(232, 92, 92, 0.25);

  --shadow-sunken: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-elevated: 0 1px 3px rgba(0, 0, 0, 0.2), 0 12px 40px rgba(0, 0, 0, 0.3);
  --shadow-float: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.15);

  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.2);
  --elevation-2: 0 2px 8px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --elevation-3: 0 4px 16px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
  --elevation-4: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ── Base typography ─────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  letter-spacing: var(--letter-spacing-base);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.display-serif,
.hearth-voice {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.hearth-emphasis {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}

.small-caps {
  font-variant-caps: all-small-caps;
  font-weight: var(--weight-heading);
  letter-spacing: var(--tracking-wide);
  font-size: 0.75rem;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-secondary { color: var(--ink-secondary); }
.text-tertiary { color: var(--ink-tertiary); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-heading);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-tertiary);
}

/* ── Animations (canonical Grain keyframes) ──────────────── */

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}
@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes breathe {
  0%, 100% { box-shadow: var(--shadow-elevated); }
  50% { box-shadow: var(--shadow-float); }
}
@keyframes idle-breathe {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
@keyframes ember-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 6px 2px rgba(245, 158, 11, 0.2); }
}
@keyframes forge-rise {
  from { opacity: 0; transform: translateY(12px); filter: brightness(1.02); }
  to { opacity: 1; transform: translateY(0); filter: brightness(1); }
}
@keyframes forge-temper {
  0% { transform: scale(0.9); opacity: 0; }
  40% { transform: scale(1.03); opacity: 1; }
  60% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.15); }
  100% { transform: scale(1); box-shadow: none; }
}
@keyframes molten-seal {
  0% { stroke-dashoffset: 24; opacity: 0; }
  20% { opacity: 1; filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6)); }
  60% { stroke-dashoffset: 0; filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.4)); }
  100% { stroke-dashoffset: 0; filter: none; }
}
@keyframes molten-shimmer {
  0% { transform: translateX(-200%); }
  100% { transform: translateX(200%); }
}
@keyframes heat-flow {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 200%; }
}

.fade-in-up { animation: fade-in-up var(--duration-normal) var(--ease-out) both; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

.forge-rise { animation: forge-rise var(--duration-normal) var(--ease-decelerate) both; }
.forge-rise.delay-1 { animation-delay: 0.08s; }
.forge-rise.delay-2 { animation-delay: 0.16s; }
.forge-rise.delay-3 { animation-delay: 0.24s; }
.forge-rise.delay-4 { animation-delay: 0.32s; }

.forge-temper { animation: forge-temper var(--duration-normal) var(--ease-decelerate) both; }
.idle-breathe { animation: idle-breathe 4s ease-in-out infinite; }
.ember-breathe { animation: ember-breathe 3s ease-in-out infinite; }

.breathe { animation: breathe 4s ease-in-out infinite; }

.shimmer { position: relative; overflow: hidden; }
.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer-sweep 2s ease-in-out infinite;
}

/* ── Atmospheric surface ─────────────────────────────────── */

.bg-textured {
  background: var(--bg-gradient);
  position: relative;
}
.bg-textured::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ── Reveal helper (intersection-observer-driven) ────────── */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}
.reveal.in {
  opacity: 1;
  transform: translateY(0);
}
.reveal.delay-1 { transition-delay: 0.08s; }
.reveal.delay-2 { transition-delay: 0.16s; }
.reveal.delay-3 { transition-delay: 0.24s; }
.reveal.delay-4 { transition-delay: 0.32s; }

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

/* ── Selection ───────────────────────────────────────────── */
::selection {
  background: var(--forge-blue);
  color: var(--surface);
}

/* ── Brand mark (canonical nav wordmark) ────────────────────
   Used by every public page's top nav: <a class="logo">
     <span class="brand-name">FOUNDRY</span>
     <span class="brand-tagline">— Go Forge It</span>
   </a>
   The brand-name is the load-bearing wordmark; the tagline ties
   the brand back to the goforgeit.com URL. */
.brand-name {
  font-family: 'Newsreader', Georgia, serif;
  font-weight: 600;
  font-size: 1.05em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink, #0F172A);
}
.brand-tagline {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7em;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink-tertiary, #94A3B8);
  margin-left: 0.5em;
  white-space: nowrap;
}
@media (max-width: 540px) {
  .brand-tagline { display: none; }
}
