@layer reset, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, figure, blockquote, dl, dd { margin: 0; }
  button, input { font: inherit; }
  img, svg { display: block; max-width: 100%; }
}

@layer base {
  :root {
    --paper: #f4efe5;
    --paper-2: #fbf8f1;
    --ink: #171713;
    --muted: #666257;
    --rule: #c9c0ae;
    --rule-dark: #8d8578;
    --signal: #e0462f;
    --signal-dark: #a42718;
    --yellow: #f4c95d;
    --green: #226d5b;
    --blue: #285b83;
    --shadow: 0 20px 60px rgb(38 32 23 / 10%);
    --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  html { background: var(--paper); color: var(--ink); font-family: var(--sans); }
  body {
    min-width: 320px;
    background:
      linear-gradient(90deg, transparent 0 47px, rgb(224 70 47 / 15%) 47px 48px, transparent 48px),
      repeating-linear-gradient(0deg, transparent 0 31px, rgb(23 23 19 / 4%) 31px 32px),
      var(--paper);
    font-size: 17px;
    line-height: 1.55;
    text-rendering: optimizeLegibility;
  }
  a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: .08em; }
  a:hover { color: var(--signal-dark); }
  button, input { color: inherit; }
  button { cursor: pointer; }
  :focus-visible { outline: 3px solid var(--signal); outline-offset: 3px; }
  ::selection { background: var(--yellow); color: var(--ink); }
}

@layer layout {
  .shell { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
  .site-header {
    position: relative;
    z-index: 20;
    border-bottom: 1px solid var(--rule);
    background: rgb(244 239 229 / 90%);
    backdrop-filter: blur(12px);
  }
  .site-header__inner {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
  .brand { font-weight: 760; text-decoration: none; letter-spacing: -.02em; }
  .nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
  .nav a { text-decoration: none; }
  .hero {
    min-height: 760px;
    display: grid;
    grid-template-columns: minmax(0, .93fr) minmax(440px, 1.07fr);
    gap: clamp(44px, 7vw, 104px);
    align-items: center;
    padding-block: 76px 86px;
  }
  .section { padding-block: 96px; border-top: 1px solid var(--rule); }
  .section--dark { background: var(--ink); color: var(--paper-2); }
  .section--plain { background: var(--paper-2); }
  .section-grid { display: grid; grid-template-columns: minmax(260px, .72fr) minmax(0, 1.28fr); gap: clamp(42px, 7vw, 104px); align-items: start; }
  .footer { border-top: 1px solid var(--rule); padding-block: 42px 56px; }
  .footer__inner { display: flex; justify-content: space-between; gap: 30px; align-items: flex-end; }

  @media (max-width: 860px) {
    body { background-position-x: -8px, 0, 0; }
    .shell { width: min(100% - 30px, 720px); }
    .hero { min-height: auto; grid-template-columns: 1fr; padding-block: 54px 70px; gap: 56px; }
    .section { padding-block: 72px; }
    .section-grid { grid-template-columns: 1fr; gap: 38px; }
    .nav .nav__section { display: none; }
  }

  @media (max-width: 520px) {
    .shell { width: min(100% - 24px, 720px); }
    .site-header__inner { min-height: 58px; }
    .brand { font-size: 14px; }
    .nav { gap: 10px; }
    .hero { padding-block: 42px 58px; }
    .section { padding-block: 60px; }
    .footer__inner { align-items: flex-start; flex-direction: column; }
  }
}

@layer components {
  .sr-only-anchor { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .sr-only-anchor:focus { top: 0; left: 12px; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; background: var(--ink); color: var(--paper-2); padding: 8px 10px; z-index: 1000; }
  .skip-link { position: fixed; top: 12px; left: 12px; transform: translateY(-150%); z-index: 999; background: var(--ink); color: white; padding: 10px 14px; }
  .skip-link:focus { transform: none; }
  .lang-switch { border: 1px solid var(--ink); padding: 6px 10px; font-family: var(--mono); font-weight: 700; }
  .eyebrow { font-family: var(--mono); font-size: 13px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; color: var(--signal-dark); }
  .section--dark .eyebrow { color: #ff866f; }
  h1 { margin-top: 18px; max-width: 9ch; font-size: clamp(64px, 8.6vw, 126px); line-height: .87; letter-spacing: -.075em; font-weight: 860; }
  h2 { max-width: 16ch; font-size: clamp(39px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; font-weight: 820; }
  h3 { font-size: 22px; line-height: 1.15; letter-spacing: -.025em; }
  .dek { margin-top: 30px; max-width: 690px; font-size: clamp(21px, 2.1vw, 30px); line-height: 1.35; letter-spacing: -.025em; }
  .hero-note { margin-top: 22px; max-width: 650px; color: var(--muted); }
  .hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 34px; }
  .button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper-2); padding: 11px 16px; font-weight: 760; text-decoration: none; box-shadow: 5px 5px 0 var(--signal); transition: transform .18s ease, box-shadow .18s ease; }
  .button:hover { color: var(--paper-2); transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--signal); }
  .button--ghost { background: transparent; color: var(--ink); box-shadow: none; }
  .button--ghost:hover { color: var(--ink); box-shadow: none; }

  .hero-meter { position: relative; min-height: 550px; display: grid; place-items: center; }
  .hero-meter::before { content: ""; position: absolute; inset: 5% 3%; border: 1px solid var(--rule); background: var(--paper-2); box-shadow: var(--shadow); transform: rotate(1.6deg); }
  .hero-meter__sheet { position: relative; width: min(100%, 590px); padding: clamp(28px, 5vw, 54px); transform: rotate(-1.25deg); }
  .hero-meter__label { display: flex; justify-content: space-between; gap: 20px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  .hero-number { margin-top: 24px; font-family: var(--mono); font-size: clamp(52px, 7.2vw, 94px); line-height: 1; letter-spacing: -.08em; font-weight: 850; white-space: nowrap; }
  .hero-number small { font-family: var(--sans); font-size: .18em; letter-spacing: .03em; }
  .micro-ruler { position: relative; height: 126px; margin-top: 32px; border-top: 5px solid var(--ink); background: repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 20px); background-size: 20px 18px; background-repeat: repeat-x; }
  .micro-ruler::after { content: ""; position: absolute; left: 82%; top: -20px; width: 4px; height: 106px; background: var(--signal); box-shadow: 0 0 0 7px rgb(224 70 47 / 12%); }
  .micro-ruler__amount { position: absolute; left: 66%; top: 28px; transform: translateX(-50%); font-family: var(--mono); font-size: 12px; font-weight: 800; white-space: nowrap; }
  .micro-ruler__ceiling { position: absolute; left: 82%; top: 90px; transform: translateX(-65%); color: var(--signal-dark); font-family: var(--mono); font-size: 12px; font-weight: 800; white-space: nowrap; }
  .hero-punch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 20px; }
  .hero-punch div { border-top: 1px solid var(--rule-dark); padding-top: 10px; }
  .hero-punch strong { display: block; font-family: var(--mono); font-size: clamp(20px, 2.7vw, 31px); line-height: 1; }
  .hero-punch span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

  .intro-copy { max-width: 540px; color: var(--muted); margin-top: 22px; font-size: 18px; }
  .tool-card { background: var(--paper-2); border: 1px solid var(--rule-dark); padding: clamp(20px, 4vw, 40px); box-shadow: 10px 10px 0 rgb(23 23 19 / 8%); }
  .segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); }
  .segmented button { min-height: 48px; border: 0; background: transparent; padding: 10px 12px; font-weight: 760; }
  .segmented button + button { border-left: 1px solid var(--ink); }
  .segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper-2); }
  .amount-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-top: 24px; }
  .field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 760; text-transform: uppercase; letter-spacing: .06em; }
  .amount-input { width: 100%; min-width: 0; min-height: 58px; border: 1px solid var(--ink); background: white; padding: 8px 12px; font-family: var(--mono); font-size: clamp(24px, 4vw, 38px); font-weight: 800; letter-spacing: -.04em; }
  .unit { min-height: 58px; display: grid; place-items: center; border: 1px solid var(--ink); padding: 8px 12px; font-family: var(--mono); font-weight: 760; }
  .slider { width: 100%; margin-top: 20px; accent-color: var(--signal); }
  .presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
  .preset { border: 1px solid var(--rule-dark); background: transparent; padding: 7px 9px; font-family: var(--mono); font-size: 12px; }
  .preset:hover { border-color: var(--signal); color: var(--signal-dark); }

  .ruler { position: relative; margin-top: 34px; padding-top: 42px; }
  .ruler__track { height: 28px; display: flex; border: 1px solid var(--ink); overflow: hidden; }
  .ruler__segment { min-width: 2px; height: 100%; border-right: 1px solid rgb(23 23 19 / 40%); }
  .ruler__segment:nth-child(1) { background: #e7cf85; }
  .ruler__segment:nth-child(2) { background: #d6c79f; }
  .ruler__segment:nth-child(3) { background: #a7c3ba; }
  .ruler__segment:nth-child(4) { background: #8ab4c5; }
  .ruler__segment:nth-child(5) { background: #d9a08e; }
  .ruler__marker { position: absolute; top: 30px; width: 3px; height: 52px; background: var(--signal); transform: translateX(-50%); transition: left .22s ease; }
  .ruler__marker::before { content: ""; position: absolute; top: -11px; left: 50%; transform: translateX(-50%); border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 11px solid var(--signal); }
  .ruler__labels { position: relative; height: 32px; font-family: var(--mono); font-size: 10px; color: var(--muted); }
  .ruler__label { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
  .ruler__label:first-child { transform: none; }
  .ruler__label:last-child { transform: translateX(-100%); }
  .result { margin-top: 26px; border-top: 4px solid var(--signal); padding-top: 20px; }
  .result__kicker { font-family: var(--mono); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--signal-dark); }
  .result__title { margin-top: 8px; font-size: clamp(24px, 3vw, 36px); line-height: 1.15; font-weight: 820; letter-spacing: -.035em; }
  .result__detail { margin-top: 10px; color: var(--muted); }
  .result__distance { margin-top: 14px; font-family: var(--mono); font-weight: 750; }
  .legal-note { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }

  .trace-controls { margin-top: 30px; max-width: 500px; }
  .trace-panel { margin-top: 42px; }
  .trace-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .trace-card { border: 1px solid #4f4d47; padding: 18px; background: #211f1b; }
  .trace-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
  .trace-card__amount { font-family: var(--mono); font-size: clamp(24px, 3vw, 36px); font-weight: 850; letter-spacing: -.05em; }
  .trace-card__share { color: #ff9c89; font-family: var(--mono); font-size: 12px; text-align: right; }
  .bars { height: 210px; margin-top: 22px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 10px; border-bottom: 1px solid #777168; }
  .bar-wrap { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 7px; }
  .bar-value { font-family: var(--mono); font-size: 12px; text-align: center; }
  .bar { min-height: 3px; background: #9b958b; transition: height .3s ease; }
  .bar--exact { background: #ff745c; }
  .bar-label { padding-top: 7px; font-family: var(--mono); font-size: 10px; color: #b8b2a8; text-align: center; white-space: nowrap; }
  .trace-card__law { min-height: 72px; margin-top: 18px; color: #d7d1c7; font-size: 14px; }
  .trace-foot { margin-top: 24px; max-width: 860px; color: #bcb6ac; }

  .threshold-switch { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; margin-top: 40px; }
  .threshold-side { border: 1px solid var(--rule-dark); padding: clamp(22px, 4vw, 44px); background: var(--paper-2); }
  .threshold-side strong { display: block; font-family: var(--mono); font-size: clamp(29px, 4vw, 50px); letter-spacing: -.06em; }
  .threshold-side span { display: block; margin-top: 13px; color: var(--muted); }
  .threshold-side--stop { border-color: var(--signal); background: #fff3ef; }
  .threshold-arrow { display: grid; place-items: center; min-width: 72px; font-size: 40px; color: var(--signal); }
  .threshold-toggle { margin-top: 24px; max-width: 520px; }

  .caveats { display: grid; gap: 20px; }
  .caveat { border-top: 1px solid var(--rule-dark); padding-top: 18px; }
  .caveat__num { font-family: var(--mono); color: var(--signal-dark); font-size: 13px; font-weight: 800; }
  .caveat h3 { margin-top: 8px; }
  .caveat p { margin-top: 10px; color: var(--muted); }
  .sources { margin-top: 42px; border: 1px solid var(--rule-dark); padding: 22px; }
  .sources h3 { font-size: 16px; }
  .sources ul { margin: 12px 0 0; padding-left: 20px; }
  .sources li + li { margin-top: 8px; }
  .sources a { overflow-wrap: anywhere; }

  .timeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; }
  .timeline__item { border: 1px solid var(--rule); background: rgb(251 248 241 / 65%); padding: 18px; }
  .timeline__year { font-family: var(--mono); font-size: 13px; color: var(--muted); }
  .timeline__count { display: block; margin-top: 8px; font-family: var(--mono); font-size: clamp(30px, 4vw, 46px); line-height: 1; font-weight: 850; letter-spacing: -.05em; }
  .timeline__item small { display: block; margin-top: 8px; color: var(--muted); }

  .footer p { color: var(--muted); max-width: 630px; }
  .footer .footer-mark { font-family: var(--mono); font-weight: 850; color: var(--signal-dark); }
  .back-to-top { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--ink); background: var(--paper-2); text-decoration: none; }
  .js .back-to-top { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .18s ease, visibility .18s ease; }
  .js .back-to-top.is-enhanced { position: fixed; right: 16px; bottom: 16px; z-index: 30; opacity: 1; visibility: visible; pointer-events: auto; background: var(--yellow); box-shadow: 6px 6px 0 var(--ink); }
  .noscript { margin: 0; padding: 12px 20px; background: var(--yellow); color: var(--ink); text-align: center; font-weight: 700; }

  @media (max-width: 960px) {
    .trace-grid { grid-template-columns: 1fr; }
    .trace-card__law { min-height: auto; }
    .bars { height: 165px; }
  }
  @media (max-width: 680px) {
    .hero-meter { min-height: 470px; }
    .hero-meter__sheet { padding-inline: 14px; }
    .hero-number { font-size: clamp(46px, 14vw, 70px); }
    .hero-punch { grid-template-columns: 1fr; }
    .hero-punch div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: baseline; }
    .amount-row { grid-template-columns: minmax(0, 1fr); }
    .unit { min-height: 40px; width: max-content; }
    .threshold-switch { grid-template-columns: 1fr; }
    .threshold-arrow { min-height: 60px; transform: rotate(90deg); }
    .timeline { grid-template-columns: 1fr; }
    .ruler__label { font-size: 9px; }
  }
}

@layer utilities {
  .sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
  .muted { color: var(--muted); }
  [hidden] { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .js .back-to-top { transition: none; }
}
