/* ANVIL — Foundry Ledger aesthetic
   Palette: steel slate, bone, safety orange, verdigris, signal yellow
   Display: Abril Fatface · Body: Inter Tight · Mono: DM Mono
*/

:root {
  --ink: #0A0C0F;
  --slate: #232830;
  --slate-2: #363D47;
  --bone: #ECE6D8;
  --bone-2: #DAD2BF;
  --paper: #F4EFDF;
  --orange: #E04E1F;
  --orange-2: #C13F12;
  --yellow: #F4C42E;
  --verdigris: #4D6E6B;
  --steel: #6E7783;
  --rule: rgba(10,12,15,0.18);
  --shadow: 0 8px 24px rgba(10,12,15,0.18);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter Tight", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  background-image:
    /* paper grain (SVG inline noise) */
    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='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.04  0 0 0 0 0.05  0 0 0 0 0.06  0 0 0 0.07 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>"),
    /* rolled-steel scratch (faint diagonals) */
    repeating-linear-gradient(135deg, rgba(35,40,48,0.012) 0 2px, transparent 2px 7px);
  background-blend-mode: multiply, normal;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }

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

button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { font-family: "Abril Fatface", "Times New Roman", serif; font-weight: 400; line-height: 1.05; color: var(--ink); letter-spacing: 0; }
h1 { font-size: clamp(2.4rem, 6vw, 4.6rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.7rem); margin-bottom: 1rem; letter-spacing: -0.005em; }
h3 { font-size: clamp(1.3rem, 2.4vw, 1.85rem); margin-bottom: 0.75rem; }
h4 { font-size: 1.1rem; font-family: "Inter Tight", sans-serif; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.6rem; }

p { margin-bottom: 1rem; }
em { font-style: italic; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ============ MASTHEAD ============ */
.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--bone);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 0 var(--orange);
}
.masthead-inner {
  max-width: 1280px; margin: 0 auto; padding: 0.9rem 1.4rem;
  display: flex; align-items: center; gap: 1.2rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--ink); }
.brand-mark svg { width: 56px; height: auto; }
.brand-name { font-family: "Abril Fatface", serif; font-size: 1.95rem; letter-spacing: 0.01em; line-height: 1; }
.brand-tag { display: none; font-family: "DM Mono", monospace; font-size: 0.72rem; letter-spacing: 0.08em; color: var(--steel); padding-left: 0.7rem; border-left: 1px solid var(--rule); }
@media (min-width: 900px) { .brand-tag { display: inline-block; } }
.primary-nav { margin-left: auto; display: flex; gap: 1.5rem; align-items: center; }
.primary-nav a { color: var(--ink); font-weight: 500; font-size: 0.92rem; letter-spacing: 0.04em; text-transform: uppercase; }
.primary-nav a:hover { color: var(--orange); text-decoration: none; }
.hamburger { display: none; margin-left: auto; width: 42px; height: 42px; background: transparent; border: 1.5px solid var(--ink); padding: 0; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--ink); }

@media (max-width: 720px) {
  .primary-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 0; background: var(--bone); border-bottom: 2px solid var(--ink); padding: 0.4rem 1.4rem 1rem; }
  .primary-nav.open { display: flex; }
  .primary-nav a { padding: 0.7rem 0; border-bottom: 1px solid var(--rule); width: 100%; }
  .hamburger { display: flex; }
}

/* ============ AD SLOTS ============ */
.ad-slot { display: flex; justify-content: center; padding: 0.8rem 1.4rem; }
.ad-728 { background: rgba(35,40,48,0.04); }
.ad-frame {
  background: repeating-linear-gradient(45deg, rgba(35,40,48,0.04) 0 6px, transparent 6px 12px), var(--bone);
  border: 1.5px dashed var(--steel);
  display: flex; align-items: center; justify-content: center;
  color: var(--steel);
  font-family: "DM Mono", monospace; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  min-height: 90px;
}
.ad-728-frame { width: min(728px, 100%); height: 90px; }
.ad-336-frame { width: min(336px, 100%); min-height: 280px; }
.ad-300-frame { width: min(300px, 100%); }
.ad-half-page { height: 600px; }
.ad-native { width: 100%; min-height: 120px; margin: 1.5rem 0; }
.ad-native .ad-label { font-size: 0.65rem; }
.ad-label { padding: 0.3rem 0.6rem; background: var(--paper); border: 1px solid var(--steel); }

.in-content { width: 100%; max-width: 700px; margin: 1.5rem auto; min-height: 140px; }

.ad-slot.ad-300.sticky {
  display: none;
}
@media (min-width: 1180px) {
  .ad-slot.ad-300.sticky {
    display: block; position: absolute; top: 80px; right: 1.4rem; width: 300px; padding: 0; height: auto;
  }
}

/* ============ HERO ============ */
.hero { position: relative; padding: 3.2rem 1.4rem 0; }
.hero-frame {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr; gap: 2rem;
  border: 2px solid var(--ink); background: var(--bone);
  padding: 2.2rem 1.6rem; position: relative;
  box-shadow: 8px 8px 0 var(--ink);
}
@media (min-width: 900px) { .hero-frame { grid-template-columns: 1.45fr 1fr; padding: 3.2rem 3rem; gap: 3rem; } }
.hero-frame::before {
  content: "FORM W-AC · §15"; position: absolute; top: -14px; right: 24px;
  background: var(--paper); color: var(--ink); padding: 0.2rem 0.7rem;
  font-family: "DM Mono", monospace; font-size: 0.7rem; letter-spacing: 0.18em;
  border: 1.5px solid var(--ink);
}

.hero-text { position: relative; }
.hero-stamp { display: inline-block; margin-bottom: 1.2rem; }
.hero-stamp span {
  display: inline-block;
  padding: 0.32rem 0.85rem;
  border: 2px solid var(--orange);
  color: var(--orange);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem; letter-spacing: 0.22em; font-weight: 500;
  transform: rotate(-2deg);
  background: rgba(224,78,31,0.06);
}
.hero h1 { margin-bottom: 1.2rem; }
.hero h1 em { color: var(--orange); font-style: italic; }
.hero-deck { font-size: 1.18rem; line-height: 1.5; color: var(--slate); max-width: 56ch; margin-bottom: 1.8rem; }

.hero-stats { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 1.8rem; padding-top: 1.2rem; border-top: 1.5px dashed var(--ink); }
@media (min-width: 600px) { .hero-stats { grid-template-columns: repeat(3, 1fr); } }
.stat { font-family: "DM Mono", monospace; }
.stat-num { display: block; font-family: "Abril Fatface", serif; font-size: 2.4rem; color: var(--orange); line-height: 1; margin-bottom: 0.3rem; }
.stat-lbl { display: block; font-size: 0.78rem; color: var(--slate); line-height: 1.4; }

.cta {
  display: inline-block; padding: 1rem 1.7rem;
  background: var(--ink); color: var(--bone) !important;
  font-family: "DM Mono", monospace; font-size: 0.95rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  border: 2px solid var(--ink); position: relative; transition: transform 0.15s ease;
}
.cta::after { content: ""; position: absolute; inset: 6px -6px -6px 6px; background: var(--orange); z-index: -1; }
.cta:hover { transform: translate(-3px, -3px); text-decoration: none; }
.cta:hover::after { inset: 9px -9px -9px 9px; }

.hero-art { display: none; }
@media (min-width: 900px) { .hero-art { display: block; align-self: center; } }
.hero-svg { width: 100%; height: auto; }

.warn-stripe {
  height: 18px; margin-top: 3.2rem;
  background: repeating-linear-gradient(45deg, var(--yellow) 0 24px, var(--ink) 24px 48px);
}

/* ============ WIZARD ============ */
.wizard { position: relative; padding: 3rem 1.4rem; }
.wizard-frame {
  max-width: 1080px; margin: 0 auto;
  background: var(--bone); border: 2px solid var(--ink); padding: 2rem 1.6rem;
  box-shadow: var(--shadow);
}
@media (min-width: 720px) { .wizard-frame { padding: 2.6rem 2.4rem; } }
.wizard-header { margin-bottom: 2rem; }
.wizard-tab {
  display: inline-block; padding: 0.28rem 0.8rem;
  background: var(--ink); color: var(--bone);
  font-family: "DM Mono", monospace; font-size: 0.7rem; letter-spacing: 0.2em;
  margin-bottom: 1rem;
}
.muted { color: var(--steel); font-size: 0.95rem; }

.step-rail { list-style: none; display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 2rem; padding-bottom: 1.4rem; border-bottom: 1.5px dashed var(--ink); }
.step-rail li {
  flex: 1; min-width: 100px; padding: 0.7rem 0.6rem;
  border: 1.5px solid var(--rule); background: var(--paper);
  font-family: "DM Mono", monospace; font-size: 0.72rem; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 0.5rem;
  transition: all 0.2s;
}
.step-rail li span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: 1.5px solid var(--ink);
  font-family: "Abril Fatface", serif; font-size: 0.95rem;
  background: var(--bone);
}
.step-rail li em { font-style: normal; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--steel); }
.step-rail li.active { background: var(--ink); color: var(--bone); border-color: var(--ink); }
.step-rail li.active em { color: var(--orange); }
.step-rail li.active span { background: var(--orange); color: var(--bone); border-color: var(--orange); }
.step-rail li.done { background: var(--verdigris); color: var(--bone); border-color: var(--verdigris); }
.step-rail li.done em { color: var(--bone); }
.step-rail li.done span { background: var(--bone); color: var(--ink); border-color: var(--bone); }

.step { animation: stampIn 0.4s ease-out; }
.step h3 { margin-bottom: 0.5rem; }
.step-help { font-size: 0.97rem; color: var(--slate); margin-bottom: 1.4rem; }

select, input[type="number"], input[type="range"] {
  font-family: "Inter Tight", sans-serif; font-size: 1rem;
  background: var(--paper); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 0;
  padding: 0.8rem 0.9rem; width: 100%;
}
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%230A0C0F' d='M6 8 0 0h12z'/></svg>"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
select:focus, input:focus { outline: 3px solid var(--orange); outline-offset: 2px; }

.choice-grid { display: grid; grid-template-columns: 1fr; gap: 0.8rem; }
@media (min-width: 720px) { .choice-grid { grid-template-columns: repeat(2, 1fr); } }
.choice {
  display: flex; flex-direction: column; gap: 0.4rem; text-align: left;
  padding: 1.2rem 1.2rem; background: var(--paper); border: 1.5px solid var(--ink);
  color: var(--ink); transition: all 0.15s;
}
.choice:hover { background: var(--ink); color: var(--bone); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--orange); }
.choice.selected { background: var(--ink); color: var(--bone); }
.choice.selected .choice-sub { color: var(--bone-2); }
.choice-title { font-family: "Abril Fatface", serif; font-size: 1.15rem; }
.choice-sub { font-size: 0.85rem; line-height: 1.4; color: var(--slate); }

.state-note { margin-top: 1rem; padding: 0.9rem 1rem; background: var(--paper); border-left: 4px solid var(--verdigris); font-size: 0.92rem; color: var(--slate); font-family: "DM Mono", monospace; line-height: 1.5; }

.schedule-readout { margin-top: 1rem; padding: 1rem 1.2rem; background: var(--paper); border: 1.5px solid var(--ink); font-family: "DM Mono", monospace; font-size: 0.85rem; }
.schedule-readout strong { color: var(--orange); }

.field { margin-bottom: 1.4rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.5rem; font-size: 0.97rem; }
.field-help { display: block; font-weight: 400; font-size: 0.8rem; color: var(--steel); margin-top: 0.2rem; }
.optional { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.45rem; background: var(--bone-2); color: var(--slate); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }

.slider-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
.slider-row output { font-family: "Abril Fatface", serif; font-size: 1.8rem; color: var(--orange); min-width: 80px; text-align: right; }
input[type="range"] { padding: 0; height: 8px; background: var(--ink); accent-color: var(--orange); }

.dollar-row { display: flex; align-items: stretch; border: 1.5px solid var(--ink); background: var(--paper); }
.dollar-row .prefix, .dollar-row .suffix { display: flex; align-items: center; padding: 0 0.9rem; background: var(--ink); color: var(--bone); font-family: "DM Mono", monospace; }
.dollar-row input { border: none; width: 100%; }

.step-nav { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 2rem; flex-wrap: wrap; }
.btn-back, .btn-next, .btn-calc {
  padding: 0.9rem 1.3rem; font-family: "DM Mono", monospace; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  background: var(--bone); color: var(--ink); border: 1.5px solid var(--ink);
}
.btn-next, .btn-calc { background: var(--ink); color: var(--bone); }
.btn-calc { background: var(--orange); border-color: var(--ink); color: var(--bone); position: relative; }
.btn-calc::after { content: ""; position: absolute; inset: 5px -5px -5px 5px; background: var(--ink); z-index: -1; }
.btn-next:disabled, .btn-calc:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-back:hover, .btn-next:hover:not(:disabled), .btn-calc:hover:not(:disabled) { transform: translate(-2px, -2px); }

/* ============ LOADING ============ */
.loading { padding: 2rem 0; text-align: center; }
.spin {
  width: 64px; height: 64px; margin: 0 auto 1.4rem;
  border: 4px solid var(--rule); border-top-color: var(--orange);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.loading-line { font-family: "DM Mono", monospace; font-size: 0.85rem; color: var(--steel); margin-bottom: 0.3rem; opacity: 0; animation: fadeUp 0.6s forwards; }
.loading-line:nth-child(2) { animation-delay: 0.4s; }
.loading-line:nth-child(3) { animation-delay: 0.9s; }
.loading-line:nth-child(4) { animation-delay: 1.4s; }
.loading .ad-frame { margin: 1.6rem auto 0; }

/* ============ RESULT ============ */
.result { animation: stampIn 0.5s ease-out; }
.result-header { position: relative; margin-bottom: 2rem; padding-bottom: 1.4rem; border-bottom: 1.5px dashed var(--ink); }
.stamp-mark {
  position: absolute; top: -10px; right: 0;
  font-family: "Abril Fatface", serif; font-size: 2.4rem;
  color: var(--orange);
  border: 4px solid var(--orange); padding: 0.1rem 1rem;
  transform: rotate(-6deg); letter-spacing: 0.06em;
  opacity: 0.7;
}
.result-summary { font-size: 1.05rem; color: var(--slate); margin-top: 0.8rem; max-width: 70ch; }

.result-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-bottom: 2rem; }
@media (min-width: 720px) { .result-grid { grid-template-columns: 2fr 1fr 1fr; } }
.result-card {
  background: var(--paper); border: 1.5px solid var(--ink); padding: 1.4rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.4rem; position: relative;
}
.result-card.big { background: var(--ink); color: var(--bone); border-color: var(--ink); }
.result-card.big .card-formula { color: var(--bone-2); }
.card-label { font-family: "DM Mono", monospace; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--steel); }
.result-card.big .card-label { color: var(--orange); }
.card-figure { font-family: "Abril Fatface", serif; font-size: 2.6rem; line-height: 1; }
.result-card.big .card-figure { font-size: 3.4rem; color: var(--bone); }
.card-formula { font-family: "DM Mono", monospace; font-size: 0.78rem; color: var(--steel); line-height: 1.5; }

.ledger-table { margin: 2rem 0 1.4rem; }
.ledger-table table { width: 100%; border-collapse: collapse; font-family: "DM Mono", monospace; font-size: 0.9rem; }
.ledger-table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger-table td:first-child { color: var(--steel); width: 55%; }
.ledger-table td:last-child { text-align: right; color: var(--ink); font-weight: 500; }
.ledger-table tr.total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); padding-top: 0.8rem; padding-bottom: 0.8rem; color: var(--ink); background: var(--bone); }

.next-steps { background: var(--paper); border: 1.5px solid var(--ink); padding: 1.4rem 1.4rem; margin-bottom: 1.4rem; }
.next-steps ul { padding-left: 1.2rem; margin-top: 0.6rem; }
.next-steps li { margin-bottom: 0.4rem; font-size: 0.94rem; }

.callout { background: var(--ink); color: var(--bone); padding: 1.6rem 1.4rem; margin-bottom: 1.4rem; border-left: 6px solid var(--orange); }
.callout h4 { color: var(--orange); margin-bottom: 0.5rem; }
.callout p { margin-bottom: 0; font-size: 0.97rem; }

/* ============ ARTICLE WRAPPER ============ */
.content { max-width: 780px; margin: 3rem auto 4rem; padding: 0 1.4rem; }
.content section { margin-bottom: 2.6rem; }
.content h2 { padding-bottom: 0.5rem; border-bottom: 1.5px solid var(--ink); position: relative; }
.content h2::before {
  content: ""; position: absolute; bottom: -4px; left: 0;
  width: 80px; height: 6px; background: var(--orange);
}
.content p, .content li { font-size: 1.04rem; line-height: 1.68; color: var(--slate); }
.content strong { color: var(--ink); }
.content ul, .content ol { padding-left: 1.4rem; margin-bottom: 1.2rem; }
.content li { margin-bottom: 0.55rem; }
.content em { color: var(--ink); }

details { background: var(--bone); border: 1.5px solid var(--ink); margin-bottom: 0.7rem; }
details summary { padding: 0.95rem 1.1rem; cursor: pointer; font-weight: 600; font-family: "Inter Tight", sans-serif; font-size: 1rem; list-style: none; position: relative; padding-right: 2.4rem; }
details summary::after { content: "+"; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-family: "Abril Fatface", serif; font-size: 1.5rem; color: var(--orange); line-height: 1; }
details[open] summary::after { content: "−"; }
details p { padding: 0 1.1rem 1.1rem; margin-bottom: 0; font-size: 0.96rem; }

.disclaimer { background: var(--bone-2); padding: 1.6rem 1.4rem; border: 1.5px solid var(--ink); }
.disclaimer p { font-size: 0.97rem; }

.sources ol { font-family: "DM Mono", monospace; font-size: 0.85rem; }
.sources li { color: var(--steel); }

/* ============ FOOTER ============ */
.footer {
  margin-top: 4rem;
  background: var(--ink); color: var(--bone-2);
  padding: 2.4rem 1.4rem 1.4rem;
  border-top: 12px solid var(--orange);
}
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.6rem; justify-content: space-between; align-items: flex-start; }
@media (min-width: 720px) { .footer-inner { flex-direction: row; align-items: center; } }
.footer-brand .brand-name { color: var(--bone); display: block; font-size: 2.4rem; margin-bottom: 0.3rem; }
.footer-brand .brand-tag { color: var(--bone-2); display: block; font-family: "Inter Tight", sans-serif; font-size: 0.9rem; padding: 0; border: none; letter-spacing: 0; max-width: 38ch; line-height: 1.5; }
.footer-brand a { color: var(--orange); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; }
.footer-nav a { color: var(--bone-2); font-family: "DM Mono", monospace; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
.footer-nav a:hover { color: var(--orange); }
.footer-credit { max-width: 1280px; margin: 1.6rem auto 0; padding-top: 1.2rem; border-top: 1px solid rgba(236,230,216,0.18); font-family: "DM Mono", monospace; font-size: 0.72rem; color: var(--steel); letter-spacing: 0.06em; }

/* ============ ANIMATIONS ============ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes stampIn {
  0% { opacity: 0; transform: scale(0.96) translateY(8px); }
  60% { opacity: 1; transform: scale(1.01) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
