/* Ahenk Cep: paper, ink and one kiln-red accent. Newsreader for the voice of the page, Hanken Grotesk for the UI. */

:root {
  --bg: #f3efe7;
  --surface: #fbf9f4;
  --field: #f7f4ed;
  --ink: #1b1a17;
  --muted: #5f5b53;
  --line: #ddd6c8;
  --line-strong: #c9c0ae;
  --accent: #a8432a;
  --accent-ink: #fffaf5;
  --accent-soft: rgba(168, 67, 42, 0.14);
  --wave: #c9c0ae;
  --notice-bg: #ebe4d6;
  --error: #9e2a1c;
  --error-bg: #f6e3dc;
  --focus: #1f5fbf;
  --shadow: 0 1px 0 rgba(27, 26, 23, 0.04), 0 28px 56px -36px rgba(60, 40, 20, 0.35);
  --serif: "Newsreader Variable", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hanken Grotesk Variable", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r-lg: 22px;
  --r-md: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211;
    --surface: #1b1a18;
    --field: #161614;
    --ink: #ede8de;
    --muted: #a49e93;
    --line: #2f2d29;
    --line-strong: #46423b;
    --accent: #e98a6a;
    --accent-ink: #1b0f0a;
    --accent-soft: rgba(233, 138, 106, 0.16);
    --wave: #4a463f;
    --notice-bg: #201f1c;
    --error: #ff9b85;
    --error-bg: #2c1a15;
    --focus: #8ab8ff;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 28px 56px -36px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121211;
  --surface: #1b1a18;
  --field: #161614;
  --ink: #ede8de;
  --muted: #a49e93;
  --line: #2f2d29;
  --line-strong: #46423b;
  --accent: #e98a6a;
  --accent-ink: #1b0f0a;
  --accent-soft: rgba(233, 138, 106, 0.16);
  --wave: #4a463f;
  --notice-bg: #201f1c;
  --error: #ff9b85;
  --error-bg: #2c1a15;
  --focus: #8ab8ff;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 28px 56px -36px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16.5px/1.6 var(--sans);
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

.wrap { max-width: 1140px; margin: 0 auto; padding-inline: 32px; }

.sprite { position: absolute; }
.ic { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--ink); padding: 8px 14px; z-index: 10; border-radius: 8px; }
.skip:focus { left: 12px; }

.num { font-variant-numeric: tabular-nums lining-nums; }
.hint { color: var(--muted); font-size: 14px; }

kbd {
  font: 600 12px/1 var(--sans); padding: 3px 6px 2px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; color: var(--ink); background: var(--surface);
}

/* ---- header ---------------------------------------------------------------------------------------------------- */
.top { padding: 22px 0 0; }
.top-row { display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.mark { width: 34px; height: 34px; margin: -2px 0; }
.mark path { fill: none; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.mark .w1 { stroke: var(--ink); }
.mark .w2 { stroke: var(--accent); }
.brand-name { font: 500 24px/1 var(--serif); letter-spacing: -0.01em; }
.brand-sub {
  font: 600 11px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  margin-left: 8px; vertical-align: 4px;
}
.nav { display: flex; gap: 24px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 500; }
.nav a:hover { color: var(--ink); }
.tools { display: flex; align-items: center; gap: 8px; }
.icon-btn, .lang {
  font: 600 13px/1 var(--sans); letter-spacing: 0.06em; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; height: 36px; min-width: 36px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.icon-btn { padding: 0; width: 36px; }
.icon-btn:hover, .lang:hover { border-color: var(--line-strong); background: var(--surface); }
.icon-btn .ic { width: 18px; height: 18px; }
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: inline-block; }
:root[data-theme="dark"] .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ic-sun { display: inline-block; }
  :root:not([data-theme="light"]) .ic-moon { display: none; }
}

/* ---- hero ------------------------------------------------------------------------------------------------------ */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); grid-template-rows: auto 1fr;
  grid-template-areas: "copy composer" "facts composer"; column-gap: 72px; row-gap: 0; align-items: start;
  padding-top: 72px; padding-bottom: 56px;
}
.hero-copy { grid-area: copy; padding-top: 12px; }
.composer { grid-area: composer; }
.facts { grid-area: facts; }
.eyebrow {
  margin: 0 0 22px; font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.hero h1 {
  font-family: var(--serif); font-optical-sizing: auto; font-weight: 400; font-size: clamp(40px, 4.7vw, 64px);
  line-height: 1.02; letter-spacing: -0.025em; margin: 0 0 24px; text-wrap: balance;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: 18.5px; line-height: 1.6; color: var(--muted); margin: 0 0 36px; max-width: 34em; text-wrap: pretty; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.facts li { display: grid; grid-template-columns: 9.5em 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.facts strong { font-weight: 600; }
.facts span { color: var(--muted); }

/* ---- composer -------------------------------------------------------------------------------------------------- */
.composer {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px 28px 22px;
  box-shadow: var(--shadow); position: relative;
}

.load { margin: -4px 0 18px; font-size: 13.5px; color: var(--muted); transition: opacity 0.4s var(--ease); }
.load-row { display: flex; align-items: center; flex-wrap: wrap; column-gap: 10px; row-gap: 2px; min-height: 22px; }
.load-num { white-space: nowrap; }
.load-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.4s ease-in-out infinite; }
.load-num { margin-left: auto; }
.load .bar { height: 3px; margin-top: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.load .bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.25s var(--ease); }
.load.indeterminate .bar span { width: 30% !important; animation: slide 1.3s ease-in-out infinite; }
.load.done .load-dot { animation: none; background: #3f8f5a; }
.load.done .bar { opacity: 0; transition: opacity 0.6s; }
.load.error { color: var(--error); }
.load.error .load-dot { animation: none; background: var(--error); }
.load.error .bar { display: none; }
.link-btn { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 2px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; margin-left: auto; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

.label { display: block; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 8px; }

textarea {
  display: block; width: 100%; min-height: 150px; resize: vertical; color: var(--ink); background: var(--field);
  font: 400 22px/1.45 var(--serif); font-optical-sizing: auto; font-variant-numeric: lining-nums;
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea::placeholder { color: var(--muted); opacity: 0.8; font-style: italic; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.text-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 2px 18px; }
.text-meta #count { margin-left: auto; }
@media (pointer: coarse) { #text-hint { display: none; } }
.text-meta .num.over { color: var(--error); font-weight: 600; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.primary {
  font: 600 16.5px/1 var(--sans); color: var(--accent-ink); background: var(--accent); border: 0; border-radius: 999px;
  padding: 0 30px; height: 50px; min-width: 168px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.15s var(--ease), filter 0.2s;
}
.primary:hover:not(:disabled) { filter: brightness(1.06); }
.primary:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.primary:disabled { cursor: progress; }
.primary.busy::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: var(--p, 0%); background: currentColor; opacity: 0.45;
  transition: width 0.2s linear;
}
.ghost {
  font: 600 14.5px/1 var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 0 18px; height: 40px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; transition: border-color 0.2s, background-color 0.2s;
}
.ghost:hover { border-color: var(--line-strong); background: var(--field); }
.ghost[aria-expanded="true"] { background: var(--field); border-color: var(--line-strong); }
.ghost .ic { width: 18px; height: 18px; }

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; margin: 18px 0 0; padding: 18px; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-md); }
.settings[hidden] { display: none; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.field output { color: var(--ink); }
.field select, .field input[type="number"] {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0;
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); margin: 8px 0 0; }
.settings .hint { grid-column: 1 / -1; margin: 0; }

.status { min-height: 1.6em; margin: 12px 2px 4px; font-size: 14px; color: var(--muted); }
.status.error { color: var(--error); }

/* ---- players --------------------------------------------------------------------------------------------------- */
.result { margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--line); }
.player { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.play {
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; cursor: pointer; flex: none; transition: transform 0.15s var(--ease), background-color 0.2s, opacity 0.2s;
}
.play:hover:not(:disabled) { transform: scale(1.04); }
.play:disabled { opacity: 0.25; cursor: default; }
.play .ic { width: 22px; height: 22px; }
.play .ic-play { margin-left: 2px; }
.play .ic-pause, .play.playing .ic-play { display: none; }
.play.playing .ic-pause { display: inline-block; }
.play.loading { animation: pulse 1.1s ease-in-out infinite; }
.wave { position: relative; height: 56px; cursor: pointer; border-radius: 8px; touch-action: none; }
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.wave-empty {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; font: italic 400 16px/1.3 var(--serif);
  color: var(--muted);
}
.wave-empty::after { content: ""; flex: 1; height: 1px; background: repeating-linear-gradient(90deg, var(--line-strong) 0 2px, transparent 2px 6px); }
.is-empty .wave { cursor: default; }
.is-empty .time { visibility: hidden; }
.result:not(.is-empty) .wave-empty { display: none; }
.time { font-size: 13.5px; color: var(--muted); min-width: 4.6em; text-align: right; }

.result-row { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.result-row[hidden], .spoken[hidden] { display: none; }
.spoken { margin-top: 12px; font-size: 14.5px; }
.spoken summary { cursor: pointer; color: var(--muted); width: fit-content; }
.spoken p { margin: 8px 0 0; padding: 12px 14px; background: var(--field); border-radius: 12px; font: 17px/1.5 var(--serif); }

.neutral-note { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line-strong); font-size: 14px; color: var(--muted); }
.neutral-note p { margin: 0; }
.neutral-note a { font-weight: 600; white-space: nowrap; }

/* ---- notice ---------------------------------------------------------------------------------------------------- */
.notice {
  display: flex; gap: 14px; align-items: flex-start; background: var(--notice-bg); border-radius: var(--r-md);
  padding: 16px 20px; font-size: 14.5px; color: var(--ink);
}
.notice p { margin: 0; max-width: 90ch; }
.notice .ic { margin-top: 2px; color: var(--accent); }

/* ---- sections -------------------------------------------------------------------------------------------------- */
.section { padding-top: 96px; }
.section-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 72px; align-items: end; margin-bottom: 32px; }
.section-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); }
.section h2 {
  font-family: var(--serif); font-optical-sizing: auto; font-weight: 400; font-size: clamp(30px, 3.6vw, 44px);
  line-height: 1.08; letter-spacing: -0.02em; margin: 0; text-wrap: balance;
}
.section-lede { margin: 0; color: var(--muted); font-size: 16.5px; max-width: 40em; text-wrap: pretty; }

.examples, .big { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.examples { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.big { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px 18px;
  display: flex; flex-direction: column; gap: 12px; transition: border-color 0.25s, transform 0.25s var(--ease);
}
.card:hover { border-color: var(--line-strong); }
.card.is-playing { border-color: var(--accent); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 34px; }
.tag { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.card-text { margin: 0; font: 400 19px/1.45 var(--serif); font-optical-sizing: auto; font-variant-numeric: lining-nums; text-wrap: pretty; }
.card-spoken { margin: -4px 0 0; font-size: 13.5px; color: var(--muted); }
.card-spoken b { font-weight: 600; }
.card .player { gap: 12px; margin-top: auto; }
.card .play { width: 42px; height: 42px; }
.card .play .ic { width: 18px; height: 18px; }
.card .wave { height: 40px; }
.card .time { min-width: 3.4em; }
.use { height: 34px; padding: 0 14px 0 12px; font-size: 13.5px; margin-right: -6px; }

.big .card-text { font-size: 17.5px; }
.big-label { font: italic 400 30px/1 var(--serif); margin: 0; letter-spacing: -0.01em; }
.card .state { margin: 0; font-size: 13.5px; color: var(--muted); }
.card.unavailable .player { opacity: 0.5; }
.state { color: var(--muted); }
.more { margin: 22px 0 0; }
.more a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
.more a:hover span { text-decoration: underline; text-underline-offset: 3px; }
.more .ic { width: 18px; height: 18px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; counter-reset: step; border-top: 1px solid var(--line); }
.steps li { counter-increment: step; padding: 24px 28px 8px 0; }
.steps li + li { padding-left: 28px; border-left: 1px solid var(--line); }
.steps li::before { content: "0" counter(step); display: block; font: italic 400 15px/1 var(--serif); color: var(--accent); margin-bottom: 18px; }
.steps h3 { font: 400 24px/1.2 var(--serif); margin: 0 0 8px; }
.steps p { margin: 0; color: var(--muted); font-size: 15.5px; }
.limits { margin: 40px 0 0; max-width: 64em; font-size: 15.5px; color: var(--muted); }
.links { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.links a {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14.5px; transition: border-color 0.2s;
}
.links a:hover { border-color: var(--accent); }
.links small { font-weight: 500; color: var(--muted); font-size: 12.5px; }

/* ---- footer ---------------------------------------------------------------------------------------------------- */
.foot { margin-top: 112px; padding: 32px 0 44px; border-top: 1px solid var(--line); font-size: 14.5px; }
.foot-row { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.foot p { margin: 4px 0; }
.foot-brand { font: 500 20px/1 var(--serif); margin-bottom: 12px !important; }
.foot-meta { text-align: right; }

/* ---- entrance motion ------------------------------------------------------------------------------------------- */
.hero-copy > *, .composer, .facts { animation: rise 0.6s var(--ease) both; }
.facts { animation-delay: 0.18s; }
.hero-copy > :nth-child(2) { animation-delay: 0.05s; }
.hero-copy > :nth-child(3) { animation-delay: 0.1s; }
.composer { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- responsive ------------------------------------------------------------------------------------------------ */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "copy" "composer" "facts"; row-gap: 40px; padding-top: 48px; }
  .lede { margin-bottom: 0; }
  .section-head { grid-template-columns: 1fr; gap: 12px; }
  .big { grid-template-columns: 1fr; }
  .nav { display: none; }
  .tools { margin-left: auto; }
}
@media (max-width: 760px) {
  .examples { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .steps li, .steps li + li { padding: 20px 0 12px; border-left: 0; }
  .steps li + li { border-top: 1px solid var(--line); }
  .section { padding-top: 72px; }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 16px; }
  body { font-size: 16px; }
  .top { padding-top: 14px; }
  .hero { padding-top: 36px; padding-bottom: 40px; row-gap: 28px; }
  .eyebrow { margin-bottom: 16px; }
  .lede { font-size: 17px; }
  .facts li { grid-template-columns: 1fr; gap: 2px; }
  .composer { padding: 20px 16px 18px; border-radius: 18px; }
  textarea { font-size: 20px; min-height: 140px; padding: 14px; }
  .actions .primary { flex: 1 1 auto; }
  .settings { grid-template-columns: 1fr; }
  .player { gap: 12px; }
  .play { width: 46px; height: 46px; }
  .card { padding: 18px 16px 16px; }
  .foot-meta { text-align: left; }
  .foot { margin-top: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
