/* How a Machine Thinks / Cómo piensa una máquina
   One shared stylesheet. No build step.
   Palette nods to the Valley: ruby-red grapefruit, marigold, river teal, night navy. */

:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #e8eef4;
  --ink: #13203a;
  --ink-soft: #3d4a60;
  --muted: #5b677b;
  --line: #cfd8e3;
  --ruby: #c8364d;          /* grapefruit red, text-safe on light */
  --ruby-bg: #fbe3e7;
  --marigold: #f0a500;
  --marigold-bg: #fff1cc;
  --teal: #0b6e72;
  --teal-bg: #dcf1f1;
  --good: #1f7a3d;
  --good-bg: #dff3e5;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --bar-track: #e3e9f0;
  --bar-fill: #f0a500;
  --bar-top: #c8364d;
  --shadow: 0 1px 2px rgba(19, 32, 58, .06), 0 6px 18px rgba(19, 32, 58, .07);
  --radius: 18px;
  --radius-sm: 12px;
  --focus: #0b6e72;

  --f-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-head: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --f-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: clamp(1rem, .96rem + .2vw, 1.0625rem);
  --step-0: clamp(1.125rem, 1.06rem + .3vw, 1.25rem);
  --step-1: clamp(1.3rem, 1.18rem + .6vw, 1.55rem);
  --step-2: clamp(1.6rem, 1.38rem + 1.1vw, 2.05rem);
  --step-3: clamp(2.1rem, 1.7rem + 2vw, 3rem);
  --step-4: clamp(2.5rem, 1.9rem + 3.2vw, 4rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1522;
    --surface: #152034;
    --surface-2: #1c2a42;
    --ink: #eef2f8;
    --ink-soft: #c9d3e2;
    --muted: #9fadc2;
    --line: #2b3b56;
    --ruby: #ff7a8c;
    --ruby-bg: #3a1d27;
    --marigold: #ffc43d;
    --marigold-bg: #3a3014;
    --teal: #5fd3d6;
    --teal-bg: #12343a;
    --good: #6fdc93;
    --good-bg: #133022;
    --bad: #ff8a80;
    --bad-bg: #3b1a1a;
    --bar-track: #22314b;
    --bar-fill: #ffc43d;
    --bar-top: #ff7a8c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    --focus: #5fd3d6;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- language switching ----------
   Every translatable bit exists twice, as <x lang="en"> and <x lang="es">.
   The <html data-ui> attribute decides which one shows. */
html[data-ui="en"] body [lang="es"] { display: none !important; }
html[data-ui="es"] body [lang="en"] { display: none !important; }

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

a { color: var(--teal); text-underline-offset: .18em; text-decoration-thickness: .08em; }
a:hover { text-decoration-thickness: .14em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.skip {
  position: absolute; left: 16px; top: -100px;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; z-index: 10;
}
.skip:focus { top: 12px; }

.wrap { width: 100%; max-width: 46rem; margin: 0 auto; padding: 0 16px; }
.wrap-wide { width: 100%; max-width: 64rem; margin: 0 auto; padding: 0 16px; }
@media (min-width: 700px) { .wrap, .wrap-wide { padding: 0 28px; } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 14px; padding-bottom: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--ink); text-decoration: none; font-family: var(--f-head); font-weight: 700;
  font-size: 1.02rem; line-height: 1.15; min-height: 48px;
}
.brand .mark { width: 34px; height: 34px; flex: none; }
.brand span { max-width: 13ch; }
@media (min-width: 560px) { .brand span { max-width: none; } }

.lang-toggle {
  display: inline-flex; flex: none; background: var(--surface-2); border-radius: 999px; padding: 4px;
  border: 1px solid var(--line);
}
.lang-toggle button {
  font: inherit; font-size: 1rem; font-weight: 700; border: 0; background: transparent; color: var(--ink-soft);
  min-height: 44px; min-width: 44px; padding: 0 .9rem; border-radius: 999px; cursor: pointer;
}
.lang-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lang-toggle .long { display: none; }
@media (min-width: 420px) { .lang-toggle .long { display: inline; } .lang-toggle .short { display: none; } }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--f-head); line-height: 1.12; letter-spacing: -.015em; margin: 0 0 .5em; font-weight: 750; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); margin-top: 1.6em; }
h3 { font-size: var(--step-1); margin-top: 1.2em; }
p { margin: 0 0 1em; }
.lede { font-size: var(--step-1); line-height: 1.45; color: var(--ink-soft); }
.kicker {
  font-family: var(--f-mono); font-size: .95rem; letter-spacing: .04em; color: var(--teal);
  text-transform: uppercase; margin: 0 0 .6rem; font-weight: 600;
}
.small { font-size: var(--step--1); color: var(--muted); }
strong { font-weight: 700; }
.mono { font-family: var(--f-mono); }

main { padding-bottom: 3rem; }

.page-head { padding: 1.2rem 0 .6rem; }
.page-head h1 { max-width: 18ch; }

section { margin: 0 0 1.5rem; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem; box-shadow: var(--shadow); margin: 1.25rem 0;
}
@media (min-width: 700px) { .panel { padding: 1.6rem 1.75rem; } }

.note {
  border-left: 6px solid var(--marigold); background: var(--marigold-bg);
  padding: .9rem 1.1rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1.2rem 0;
}
.note p:last-child { margin-bottom: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 700; font-size: 1.08rem; line-height: 1.2;
  min-height: 52px; padding: .7rem 1.25rem; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--ink); background: var(--ink); color: var(--bg); text-decoration: none;
  text-align: center;
}
.btn:hover { filter: brightness(1.12); }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.ruby { background: var(--ruby); border-color: var(--ruby); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.ruby { color: #1a0d12; } }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1rem 0 0; }

/* ---------- site footer ---------- */
.site-foot { border-top: 1px solid var(--line); padding: 1.6rem 0 2.4rem; color: var(--muted); font-size: var(--step--1); }
.site-foot p { margin: 0 0 .5rem; }
.site-foot a { color: inherit; }

.next-page {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 2rem 0 0; box-shadow: var(--shadow);
}
.next-page:hover { border-color: var(--teal); }
.next-page .small { display: block; margin-bottom: .2rem; }
.next-page strong { font-family: var(--f-head); font-size: var(--step-1); }

/* ---------- probability bars (shared by home illustration and demo) ---------- */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.bar {
  position: relative; display: grid; align-items: center; column-gap: .6rem; row-gap: .3rem;
  grid-template-columns: 1fr auto; grid-template-areas: "word pct" "track track";
  min-height: 48px; width: 100%; padding: .45rem .75rem .55rem; border-radius: 12px; border: 2px solid transparent;
  background: var(--surface-2); color: var(--ink); font: inherit; text-align: left;
}
.bar .word { grid-area: word; }
.bar .track { grid-area: track; }
.bar .pct { grid-area: pct; }
@media (min-width: 600px) {
  .bar { grid-template-columns: minmax(7rem, 32%) 1fr auto; grid-template-areas: "word track pct"; padding: .35rem .75rem; }
}
button.bar { cursor: pointer; }
button.bar:hover { border-color: var(--teal); }
.bar .word { font-family: var(--f-mono); font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; line-height: 1.25; }
.bar .word .join { color: var(--muted); font-weight: 400; }
.bar .track { height: 14px; background: var(--bar-track); border-radius: 999px; overflow: hidden; }
.bar .fill { display: block; height: 100%; width: 0; background: var(--bar-fill); border-radius: 999px; transition: width .45s cubic-bezier(.2, .8, .2, 1); }
.bar.top .fill, li.bar:first-child .fill { background: var(--bar-top); }
.bar.top { border-color: color-mix(in srgb, var(--bar-top) 35%, transparent); }
.bar .pct { font-family: var(--f-mono); font-size: 1rem; min-width: 3.6ch; text-align: right; color: var(--ink-soft); }

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

/* ---------- print (used by the fridge card on the scam page) ---------- */
@media print {
  .topbar, .site-foot, .no-print, .next-page { display: none !important; }
  body { background: #fff; color: #000; }
}
