/* ============================================================
   LetterSift — original design system
   Warm paper / ink / ember. Editorial serif + grotesk tiles.
   No frameworks. All motion respects prefers-reduced-motion.
   ============================================================ */

:root {
  --paper: #faf6ee;
  --paper-2: #f3ecdd;
  --paper-3: #ece1cd;
  --ink: #1b1611;
  --ink-soft: #57503f;
  --ink-faint: #6b5f4a;
  --line: #e3d7bf;
  --ember: #e4572e;
  --ember-deep: #c2431f;
  --ember-soft: #fbe9e0;
  --sage: #6f7d5c;
  --gold: #b98a1f;
  --dark: #171310;
  --dark-2: #221c16;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 24px 60px -24px rgba(27, 22, 17, .28);
  --shadow-s: 0 10px 28px -12px rgba(27, 22, 17, .22);
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-tile: 'Space Grotesk', 'Inter', sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1;
  opacity: .5;
  background-image: radial-gradient(rgba(27,22,17,.055) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 70%);
}

::selection { background: var(--ember); color: #fff; }

a { color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 2; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-name {
  font-family: var(--font-display); font-size: 26px; letter-spacing: .2px;
}
.brand-name em { font-style: italic; color: var(--ember); }
.nav { display: flex; gap: 6px; align-items: center; }
.nav a {
  text-decoration: none; font-size: 14.5px; font-weight: 500;
  padding: 9px 15px; border-radius: 999px; color: var(--ink-soft);
  transition: background .25s var(--ease), color .25s var(--ease);
}
.nav a:hover { background: var(--paper-2); color: var(--ink); }
.nav a.cta {
  background: var(--ink); color: var(--paper); font-weight: 600;
}
.nav a.cta:hover { background: var(--ember); color: #fff; }

/* ---------------- hero ---------------- */
.hero { padding: 88px 0 30px; position: relative; overflow: clip; }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--ember-deep); margin-bottom: 22px;
}
.hero-kicker::before {
  content: ""; width: 34px; height: 2px; background: var(--ember); border-radius: 2px;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(46px, 7.2vw, 92px);
  line-height: 1.02; letter-spacing: -1px;
  max-width: 16ch;
}
.hero h1 em { font-style: italic; color: var(--ember); }
.hero-sub {
  margin-top: 20px; max-width: 56ch;
  font-size: 17.5px; color: var(--ink-soft);
}
/* floating background letters */
.float-letters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float-letters span {
  position: absolute; font-family: var(--font-tile); font-weight: 700;
  color: var(--ink); opacity: .05; user-select: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translateY(-14px) rotate(-4deg); }
  to   { transform: translateY(16px) rotate(5deg); }
}

/* ---------------- solver ---------------- */
.solver-card {
  margin-top: 44px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 44px);
  position: relative; overflow: hidden;
}
.solver-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--ember), var(--gold), var(--sage));
}
.solver-title {
  font-family: var(--font-display); font-size: 30px; margin-bottom: 6px;
}
.solver-hint { color: var(--ink-soft); font-size: 15px; margin-bottom: 24px; }
.solver-hint code {
  font-family: var(--font-tile); background: var(--paper-2);
  padding: 2px 8px; border-radius: 6px; font-size: 13.5px;
}
.tile-row { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.tile-input {
  width: 62px; height: 72px; text-align: center;
  font-family: var(--font-tile); font-size: 34px; font-weight: 700; text-transform: uppercase;
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius-s);
  color: var(--ink); outline: none;
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
  caret-color: var(--ember);
}
.tile-input:focus {
  border-color: var(--ember); transform: translateY(-3px);
  box-shadow: 0 10px 22px -10px rgba(228, 87, 46, .55);
}
.tile-input.filled { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.solver-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.field label {
  display: block; font-size: 13px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px;
}
.field input {
  width: 100%; padding: 14px 16px; font-size: 16px; font-family: var(--font-tile);
  letter-spacing: 3px; text-transform: uppercase;
  border: 2px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink); outline: none;
  transition: border-color .2s var(--ease);
}
.field input:focus { border-color: var(--ember); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn {
  appearance: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: 16px;
  padding: 15px 34px; border-radius: 999px;
  background: var(--ember-deep); color: #fff;
  transition: transform .22s var(--ease), background .22s var(--ease), box-shadow .22s var(--ease);
  box-shadow: 0 14px 30px -12px rgba(194, 67, 31, .6);
}
.btn:hover { background: var(--ember-deep); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.ghost {
  background: transparent; color: var(--ink-soft); box-shadow: none;
  border: 2px solid var(--line);
}
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); background: transparent; }
.result-meta {
  display: flex; align-items: baseline; gap: 14px;
  margin: 30px 0 16px; padding-top: 24px; border-top: 1px dashed var(--line);
}
.result-count {
  font-family: var(--font-tile); font-weight: 700; font-size: 30px; color: var(--ember-deep);
}
.result-label { color: var(--ink-soft); font-size: 15px; }
.results { display: flex; flex-wrap: wrap; gap: 9px; min-height: 60px; }
.word-list { display: flex; flex-wrap: wrap; gap: 9px; margin: 0; padding: 0; list-style: none; content-visibility: auto; contain-intrinsic-size: auto 4000px; }
.word-chip {
  font-family: var(--font-tile); font-weight: 600; font-size: 15.5px; letter-spacing: 1.5px;
  text-transform: uppercase; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px;
  transition: background .2s, border-color .2s, transform .2s var(--ease);
}
/* Only the first 40 chips animate; the rest render statically (perf). */
.word-chip.anim {
  opacity: 0; transform: translateY(14px) scale(.94);
  animation: chipIn .45s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.word-chip:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); transform: translateY(-2px); }
@keyframes chipIn { to { opacity: 1; transform: none; } }
.no-results { color: var(--ink-soft); font-size: 15.5px; padding: 12px 0; }

/* ---------------- stats band ---------------- */
.stats-band {
  margin: 70px 0 0; background: var(--dark); color: var(--paper);
  border-radius: var(--radius); padding: clamp(30px, 5vw, 56px);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px;
  position: relative; overflow: hidden;
}
.stats-band::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 200px at 15% 0%, rgba(228,87,46,.22), transparent 70%);
}
.stat { position: relative; z-index: 1; }
.stat-num {
  font-family: var(--font-tile); font-weight: 700;
  font-size: clamp(34px, 4.6vw, 54px); color: #fff; line-height: 1;
}
.stat-num small { font-size: .5em; color: var(--ember); }
.stat-label { margin-top: 10px; color: #b9ac93; font-size: 14.5px; }

/* ---------------- sections ---------------- */
.section { padding: 84px 0 8px; }
.section-head { max-width: 720px; margin-bottom: 40px; }
.eyebrow {
  font-size: 13px; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--ember-deep); margin-bottom: 14px; display: block;
}
.section-head h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(34px, 4.6vw, 54px); line-height: 1.08; letter-spacing: -.5px;
}
.section-head h2 em { font-style: italic; color: var(--ember); }
.section-head p { margin-top: 14px; color: var(--ink-soft); font-size: 16.5px; }

/* sieve divider motif */
.sieve { display: flex; gap: 8px; align-items: center; margin: 0 0 34px; }
.sieve i { display: block; height: 2px; background: var(--line); border-radius: 2px; }
.sieve i:nth-child(1) { width: 64px; } .sieve i:nth-child(2) { width: 34px; }
.sieve i:nth-child(3) { width: 16px; background: var(--ember); }
.sieve i:nth-child(4) { width: 34px; } .sieve i:nth-child(5) { width: 64px; }

/* pattern cards */
.pattern-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.pattern-card {
  display: block; text-decoration: none;
  background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 24px; position: relative; overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.pattern-card::after {
  content: "→"; position: absolute; right: 22px; top: 24px;
  font-family: var(--font-tile); font-size: 20px; color: var(--ember);
  opacity: 0; transform: translateX(-10px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.pattern-card:hover {
  transform: translateY(-6px); box-shadow: var(--shadow-s); border-color: var(--ember);
}
.pattern-card:hover::after { opacity: 1; transform: none; }
.pattern-card h3 {
  font-family: var(--font-display); font-weight: 400; font-size: 23px;
  line-height: 1.25; margin-bottom: 10px; padding-right: 28px;
}
.pattern-card .count {
  font-family: var(--font-tile); font-size: 13.5px; font-weight: 600;
  color: var(--ember-deep); letter-spacing: 1px; text-transform: uppercase;
}
.pattern-card p { font-size: 14.5px; color: var(--ink-soft); margin-top: 8px; }

/* ---------------- pattern page ---------------- */
.page-hero { padding: 70px 0 10px; }
.page-hero h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(38px, 5.6vw, 68px); line-height: 1.05; letter-spacing: -.5px;
  max-width: 20ch;
}
.page-hero h1 em { font-style: italic; color: var(--ember); }
.page-hero .lede { margin-top: 18px; max-width: 62ch; font-size: 17px; color: var(--ink-soft); }
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 38px 0 10px; }
.mini-stat {
  background: #fffdf8; border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 20px 18px;
}
.mini-stat b {
  display: block; font-family: var(--font-tile); font-size: 27px; font-weight: 700;
  color: var(--ink); line-height: 1.1;
}
.mini-stat b.accent { color: var(--ember-deep); }
.mini-stat span { font-size: 13px; color: var(--ink-faint); font-weight: 500; }
.wordlist-section { margin: 40px 0 20px; }
.wordlist-section h2 {
  font-family: var(--font-display); font-size: 30px; font-weight: 400; margin-bottom: 18px;
}
.method-note {
  margin-top: 44px; background: var(--paper-2); border: 1px dashed var(--line);
  border-radius: var(--radius-s); padding: 22px 24px; font-size: 14.5px; color: var(--ink-soft);
}
.method-note strong { color: var(--ink); }
.related { margin: 60px 0 90px; }
.related h2 { font-family: var(--font-display); font-size: 30px; font-weight: 400; margin-bottom: 20px; }

/* prose (legal pages, about) */
.prose { max-width: 760px; padding: 70px 0 90px; }
.prose h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(36px, 5vw, 58px); margin-bottom: 24px; line-height: 1.08;
}
.prose h2 { font-family: var(--font-display); font-size: 27px; font-weight: 400; margin: 40px 0 12px; }
.prose p { margin-bottom: 16px; color: var(--ink-soft); font-size: 16.5px; }
.prose p strong, .prose li strong { color: var(--ink); }
.prose ul { margin: 0 0 16px 22px; color: var(--ink-soft); font-size: 16.5px; }
.prose li { margin-bottom: 8px; }
.prose a { color: var(--ember-deep); }

/* ---------------- footer ---------------- */
.site-footer { background: var(--dark); color: #cfc3ab; margin-top: 40px; }
.footer-inner { padding: 64px 0 34px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 40px; margin-bottom: 50px; }
.footer-brand { font-family: var(--font-display); font-size: 34px; color: #fff; margin-bottom: 12px; }
.footer-brand em { font-style: italic; color: var(--ember); }
.footer-grid p { font-size: 14.5px; max-width: 36ch; }
.footer-grid h4 {
  font-size: 12.5px; letter-spacing: 2px; text-transform: uppercase;
  color: #8f8268; margin-bottom: 16px; font-weight: 700;
}
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: 10px; }
.footer-grid ul a { text-decoration: none; font-size: 15px; transition: color .2s; }
.footer-grid ul a:hover { color: #fff; }
.footer-bottom {
  border-top: 1px solid #2e2620; padding-top: 26px;
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 13.5px; color: #8f8268;
}

/* ---------------- accessibility ---------------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 12px 20px;
  border-radius: 0 0 10px 0; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 0; }
:focus-visible {
  outline: 3px solid var(--ember-deep); outline-offset: 2px; border-radius: 4px;
}
/* Gated on .js so content is visible when JS is blocked/slow */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }
.js .reveal[data-delay="1"] { transition-delay: .08s; }
.js .reveal[data-delay="2"] { transition-delay: .16s; }
.js .reveal[data-delay="3"] { transition-delay: .24s; }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .pattern-grid { grid-template-columns: 1fr 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .stats-band { grid-template-columns: 1fr; gap: 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .solver-fields { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .nav a:not(.cta) { display: none; }
  .pattern-grid { grid-template-columns: 1fr; }
  .hero { padding: 60px 0 20px; }
  .tile-input { width: 52px; height: 62px; font-size: 28px; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
  .word-chip { opacity: 1; transform: none; }
}
