/* =========================================================
   Loreweaver — Design tokens + base theme
   Mood: mystical, premium, cinematic, modern editorial
   Dark-first, with refined gold/parchment/ink palette
   ========================================================= */

:root {
  /* ---- Ink (backgrounds, dark-first) ---- */
  --ink-000: #07060a;          /* deepest void */
  --ink-100: #0d0b08;          /* page bg */
  --ink-200: #15110c;          /* card bg */
  --ink-300: #1c1813;          /* elevated */
  --ink-400: #2a241c;          /* outline / hairline glow */
  --ink-500: #3a3127;
  --ink-600: #5a4d3e;

  /* ---- Gold (brand) ---- */
  --gold-50:  #f7ecd1;
  --gold-100: #ecd9aa;
  --gold-200: #dec488;
  --gold-300: #cfb072;        /* primary gold (foil) */
  --gold-400: #b8965a;        /* primary dark */
  --gold-500: #957543;
  --gold-600: #6e5631;

  /* ---- Parchment (light-mode bg, callouts) ---- */
  --parch-50:  #fbf6ea;
  --parch-100: #f5ecd6;
  --parch-200: #ecdfbf;
  --parch-300: #d9c89e;

  /* ---- Mana sigil colors (per archetype, more refined) ---- */
  --mana-w: #d9cf9b;            /* plains - bone */
  --mana-u: #5a83a6;            /* island - ink blue */
  --mana-b: #1a1714;            /* swamp - black */
  --mana-r: #b14d3c;            /* mountain - oxblood */
  --mana-g: #5e7a48;            /* forest - moss */

  /* ---- Accent / utility ---- */
  --oxblood:   #8a3a2f;
  --moss:      #5e7a48;
  --foil-blue: #5a83a6;
  --plum:      #5a3e6e;

  /* ---- Semantic (dark-first defaults) ---- */
  --bg:           var(--ink-100);
  --bg-alt:       var(--ink-200);
  --bg-elev:      var(--ink-300);
  --rule:         #2a241c;
  --rule-strong:  #3a3127;

  --text:         #e8dec8;
  --text-soft:    #aea189;
  --text-mute:    #7c715f;
  --text-faint:   #4a4337;

  --gold:         var(--gold-300);
  --gold-strong:  var(--gold-200);
  --gold-deep:    var(--gold-500);

  --link:         var(--gold-200);
  --link-hover:   var(--gold-50);

  /* ---- Typography ---- */
  --f-display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --f-serif:   "EB Garamond", "Cormorant Garamond", Georgia, serif;
  --f-ui:      "Inter Tight", "Inter", system-ui, sans-serif;
  --f-mono:    "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  /* Type scale (display, fluid) */
  --t-overline: 0.72rem;     /* eyebrow / label */
  --t-meta:     0.78rem;
  --t-small:    0.875rem;
  --t-body:     1.0625rem;   /* 17px reading */
  --t-lead:     1.25rem;
  --t-h6:       1.125rem;
  --t-h5:       1.375rem;
  --t-h4:       1.75rem;
  --t-h3:       2.25rem;
  --t-h2:       clamp(2rem, 4vw, 3.25rem);
  --t-h1:       clamp(2.75rem, 7vw, 5.5rem);
  --t-display:  clamp(3.5rem, 10vw, 8rem);

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;

  /* Radii — very subtle. We're going editorial, not "card UI". */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 8px;
  --r-pill: 999px;

  /* Shadows — soft, golden-tinted glow */
  --shadow-1: 0 1px 0 rgba(207, 176, 114, 0.05);
  --shadow-2: 0 12px 32px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(207, 176, 114, 0.06);
  --shadow-3: 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(207, 176, 114, 0.08);
  --glow-gold: 0 0 0 1px rgba(207, 176, 114, 0.18), 0 0 40px -10px rgba(207, 176, 114, 0.25);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 180ms;
  --dur-2: 320ms;
  --dur-3: 600ms;
  --dur-4: 1200ms;

  /* Layout */
  --container: 1280px;
  --container-narrow: 880px;
  --container-prose: 680px;
}

/* Light theme override */
[data-theme="light"] {
  --bg:          var(--parch-50);
  --bg-alt:      var(--parch-100);
  --bg-elev:     #ffffff;
  --rule:        #e2d5b4;
  --rule-strong: #c9b48a;

  --text:        #1f1812;
  --text-soft:   #4a3f33;
  --text-mute:   #7c715f;
  --text-faint:  #b09f82;

  --gold:        var(--gold-500);
  --gold-strong: var(--gold-600);
  --gold-deep:   var(--gold-600);

  --link:        var(--gold-600);
  --link-hover:  var(--ink-100);
}

/* ---------------- RESET ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--f-serif);
  font-size: var(--t-body);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "onum" 1;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--link); text-decoration: none; transition: color var(--dur-1) var(--ease); }
a:hover { color: var(--link-hover); }
input, textarea, select { font: inherit; color: inherit; }

/* Default: subtle paper grain on the body */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0.7  0 0 0 0 0.6  0 0 0 0 0.4  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------------- TYPOGRAPHY ---------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-display);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
h1 { font-size: var(--t-h1); font-weight: 500; letter-spacing: -0.02em; }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }
h4 { font-size: var(--t-h4); font-weight: 600; }
h5 { font-size: var(--t-h5); }

.display {
  font-family: var(--f-display);
  font-size: var(--t-display);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.92;
}
.display em, em.display-em {
  font-style: italic;
  color: var(--gold-strong);
  font-weight: 400;
}

.eyebrow {
  font-family: var(--f-ui);
  font-size: var(--t-overline);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.meta, .ui {
  font-family: var(--f-ui);
  font-size: var(--t-meta);
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.lead {
  font-family: var(--f-serif);
  font-size: var(--t-lead);
  line-height: 1.55;
  color: var(--text-soft);
  font-style: italic;
}

/* Drop cap for article intros */
.dropcap > p:first-of-type::first-letter,
p.dropcap::first-letter {
  font-family: var(--f-display);
  font-size: 5.5em;
  font-weight: 500;
  line-height: 0.85;
  float: left;
  padding: 0.04em 0.12em 0 0;
  margin-top: 0.05em;
  color: var(--gold);
  font-feature-settings: "ss01" 1;
}

/* Roman numerals helper */
.numeral {
  font-family: var(--f-display);
  font-style: italic;
  color: var(--gold-deep);
  font-feature-settings: "onum" 1;
}

/* ---------------- LAYOUT ---------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--s-6);
}
.container--narrow { max-width: var(--container-narrow); }
.container--prose  { max-width: var(--container-prose); }

@media (max-width: 720px) {
  .container { padding: 0 var(--s-4); }
}

/* ---------------- SECTION HEADER (used everywhere) ---------------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-5);
  margin-bottom: var(--s-7);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--rule);
}
.section-head__num {
  font-family: var(--f-display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--gold-deep);
  flex: 0 0 auto;
}
.section-head__title {
  font-family: var(--f-display);
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  flex: 1;
  letter-spacing: -0.01em;
}
.section-head__kicker {
  font-family: var(--f-ui);
  font-size: var(--t-overline);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
  flex: 0 0 auto;
}

/* ---------------- FLEURON / DIVIDER ---------------- */
.fleuron {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  margin: var(--s-8) 0;
  color: var(--gold-deep);
}
.fleuron::before, .fleuron::after {
  content: "";
  flex: 1;
  height: 1px;
  max-width: 240px;
  background: linear-gradient(to var(--dir, right), transparent, var(--rule-strong), transparent);
}
.fleuron::after { --dir: left; }
.fleuron svg { width: 28px; height: 28px; flex: 0 0 auto; }

/* ---------------- BUTTON ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  font-family: var(--f-ui);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--r-1);
  transition: all var(--dur-2) var(--ease);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.btn--primary {
  background: linear-gradient(180deg, var(--gold-200) 0%, var(--gold-400) 100%);
  color: var(--ink-100);
  box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 0 0 1px var(--gold-500), 0 12px 28px -16px rgba(207,176,114,0.5);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 0 0 1px var(--gold-300), 0 16px 32px -14px rgba(207,176,114,0.6);
  color: var(--ink-100);
}
.btn--ghost {
  border: 1px solid var(--rule-strong);
  color: var(--text);
}
.btn--ghost:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.btn--text {
  padding: 6px 0;
  color: var(--gold);
  letter-spacing: 0.16em;
}
.btn--text::after {
  content: "→";
  transition: transform var(--dur-2) var(--ease);
}
.btn--text:hover::after { transform: translateX(4px); }

/* ---------------- TAG (wax-seal sigil) ---------------- */
.sigil {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  font-family: var(--f-ui);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gold-50);
  background: var(--ink-300);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-pill);
  position: relative;
  transition: all var(--dur-1) var(--ease);
}
.sigil::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sigil-color, var(--gold));
  box-shadow: 0 0 0 2px var(--ink-100), 0 0 0 3px var(--sigil-color, var(--gold));
}
.sigil:hover {
  border-color: var(--sigil-color, var(--gold));
  color: var(--gold-50);
}
.sigil--commander       { --sigil-color: var(--mana-r); }
.sigil--commander-theory{ --sigil-color: var(--gold-300); }
.sigil--deck-techs      { --sigil-color: var(--foil-blue); }
.sigil--narrative       { --sigil-color: var(--gold-400); }
.sigil--flavor          { --sigil-color: var(--moss); }
.sigil--lorecraft       { --sigil-color: var(--plum); }
.sigil--philosophy      { --sigil-color: #5a7fb8; }
.sigil--art             { --sigil-color: var(--mana-w); }
.sigil--news            { --sigil-color: var(--gold-200); }

/* ---------------- INPUTS ---------------- */
.field {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-2);
  font-family: var(--f-ui);
  font-size: 0.95rem;
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.field:focus {
  outline: 0;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(207,176,114,0.15);
}
.field::placeholder { color: var(--text-faint); }

/* ---------------- UTILITY ---------------- */
.stack-1 > * + * { margin-top: var(--s-1); }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-5 > * + * { margin-top: var(--s-5); }
.stack-6 > * + * { margin-top: var(--s-6); }

.cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.cluster--end { justify-content: flex-end; }

.muted { color: var(--text-mute); }
.gold  { color: var(--gold); }

/* Scroll-reveal helper */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--dur-4) var(--ease-out), transform var(--dur-4) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-in {
  opacity: 1;
  transform: none;
}
.reveal--scale {
  opacity: 0;
  transform: scale(0.96);
}
.reveal--scale.is-in { opacity: 1; transform: none; }
.reveal--blur {
  opacity: 0;
  filter: blur(12px);
  transition: opacity var(--dur-4) var(--ease-out), filter var(--dur-4) var(--ease-out);
}
.reveal--blur.is-in { opacity: 1; filter: blur(0); }

/* Hide the .field native scrollbar styling subtly */
::selection { background: var(--gold); color: var(--ink-100); }
