/* Dilo — Inglés para la vida diaria
   Type: Atkinson Hyperlegible (Braille Institute), chosen for beginning readers.
   Palette: river navy + marigold, cool mist background. */

@font-face {
  font-family: "Atkinson";
  src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --ink: #14324F;        /* river navy: text, borders, primary buttons */
  --ink-soft: #4E6478;   /* secondary text */
  --bg: #EAF0F4;         /* cool mist */
  --surface: #FFFFFF;
  --line: #C9D5DE;
  --sun: #FFC530;        /* marigold: listen buttons, "you" bubbles */
  --sun-ink: #14324F;
  --sun-wash: #FFF1C7;
  --go: #1D7F52;
  --go-wash: #DDF2E7;
  --stop: #B53A27;
  --stop-wash: #FBE3DE;
  --focus: #0B6BCB;

  --r-bubble: 22px;
  --r-btn: 14px;
  --gutter: 16px;
  --maxw: 640px;

  --t-xs: 0.875rem;
  --t-sm: 1rem;
  --t-md: 1.125rem;
  --t-lg: 1.375rem;
  --t-xl: 1.75rem;
  --t-xxl: 2.25rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6EEF4;
    --ink-soft: #A6B7C6;
    --bg: #0D1B28;
    --surface: #15283A;
    --line: #2A4258;
    --sun: #FFC530;
    --sun-ink: #14324F;
    --sun-wash: #3A3217;
    --go: #5FD39C;
    --go-wash: #173A2B;
    --stop: #FF8A73;
    --stop-wash: #46221C;
    --focus: #7CC0FF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #E6EEF4; --ink-soft: #A6B7C6; --bg: #0D1B28; --surface: #15283A; --line: #2A4258;
  --sun-wash: #3A3217; --go: #5FD39C; --go-wash: #173A2B; --stop: #FF8A73; --stop-wash: #46221C;
  --focus: #7CC0FF; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Atkinson", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--t-md);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; }

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

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.noscript, .loading { padding: 32px var(--gutter); max-width: var(--maxw); margin: 0 auto; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--gutter);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; }
.brand-mark path:first-child { fill: var(--sun); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.brand-wave { fill: none; stroke: var(--sun-ink); stroke-width: 2.5; stroke-linecap: round; }
.brand-name { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.02em; }

.lang { display: flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.lang button {
  border: 0; background: transparent; padding: 6px 14px; min-height: 40px; min-width: 48px;
  font-weight: 700; font-size: var(--t-sm); cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 20px var(--gutter) 32px; outline: none; }
.stack > * + * { margin-top: 16px; }
.section-title { font-size: var(--t-lg); font-weight: 700; margin: 32px 0 8px; }
.muted { color: var(--ink-soft); }

/* ---------- Speech bubble (the signature element) ---------- */
.bubble {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--r-bubble);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
}
.bubble::after {
  content: ""; position: absolute; left: 26px; bottom: -13px;
  width: 22px; height: 22px; background: inherit;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  transform: skewX(35deg) rotate(45deg) scale(.75);
  border-bottom-right-radius: 4px;
}
.bubble .en { font-size: var(--t-xl); font-weight: 700; line-height: 1.22; letter-spacing: -0.01em; }
.bubble .es { margin-top: 6px; color: var(--ink-soft); font-size: var(--t-md); }
.bubble-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.hero { margin-top: 4px; }
.hero-kicker { font-size: var(--t-sm); color: var(--ink-soft); margin-bottom: 10px; }
.hero .bubble { padding: 22px 20px 18px; }
.hero .bubble .en { font-size: var(--t-xxl); }
.hero-lead { font-size: var(--t-md); margin-top: 18px; max-width: 34ch; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border-radius: var(--r-btn); border: 2px solid var(--ink);
  background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: var(--t-sm); text-decoration: none; cursor: pointer;
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-listen { background: var(--sun); color: var(--sun-ink); border-color: var(--sun-ink); }
.btn-quiet { border-color: var(--line); }
.btn-block { width: 100%; min-height: 56px; font-size: var(--t-md); }
.btn[aria-pressed="true"] { background: var(--sun-wash); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.is-playing { box-shadow: 0 0 0 4px var(--sun-wash); }
.icon-btn { min-width: 48px; padding: 10px 12px; }

/* ---------- Situation list ---------- */
.situations { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.situations li { border-bottom: 1px solid var(--line); }
.situation {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px;
  padding: 14px 4px; text-decoration: none;
}
.situation:hover .situation-title { text-decoration: underline; text-underline-offset: 3px; }
.situation-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--ink);
}
.situation-icon svg { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.situation.is-done .situation-icon { background: var(--sun); border-color: var(--sun-ink); }
.situation.is-done .situation-icon svg { stroke: var(--sun-ink); }
.situation-title { font-size: var(--t-lg); font-weight: 700; display: block; }
.situation-sub { font-size: var(--t-sm); color: var(--ink-soft); display: block; }
.situation-status { font-size: var(--t-xs); color: var(--ink-soft); text-align: right; white-space: nowrap; }
.situation.is-done .situation-status { color: var(--go); font-weight: 700; }

.meter { margin: 6px 0 14px; font-size: var(--t-sm); color: var(--ink-soft); }
.meter-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter-bar span { display: block; height: 100%; background: var(--go); border-radius: 99px; }

/* ---------- Lesson header and steps ---------- */
.lesson-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.lesson-head h1 { font-size: var(--t-xl); }
.lesson-head .sub { font-size: var(--t-sm); color: var(--ink-soft); }
.back { flex: none; }

.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 22px; counter-reset: step; }
.steps li { flex: 1; }
.steps a {
  display: block; text-decoration: none; text-align: center;
  padding: 8px 4px 10px; font-size: var(--t-xs); font-weight: 700; color: var(--ink-soft);
  border-bottom: 4px solid var(--line);
}
.steps a::before { counter-increment: step; content: counter(step) ". "; }
.steps a[aria-current="step"] { color: var(--ink); border-bottom-color: var(--sun); }
.steps a.is-passed { color: var(--ink); border-bottom-color: var(--ink); }

.phrase-list { list-style: none; margin: 0; padding: 0; }
.phrase-list > li + li { margin-top: 18px; }
.phrase-num { font-size: var(--t-xs); color: var(--ink-soft); margin-bottom: 6px; }

.tip {
  border-left: 6px solid var(--sun);
  background: var(--surface);
  padding: 14px 16px; border-radius: 0 12px 12px 0;
  margin-top: 28px;
}
.tip strong { display: block; margin-bottom: 2px; }

.next-row { margin-top: 28px; }

/* ---------- Conversation ---------- */
.chat { list-style: none; margin: 0; padding: 0; }
.chat li { display: flex; flex-direction: column; margin-bottom: 16px; }
.chat .who { font-size: var(--t-xs); color: var(--ink-soft); margin: 0 6px 4px; }
.chat .line {
  max-width: 86%;
  border: 2px solid var(--ink); border-radius: 18px;
  padding: 10px 14px; background: var(--surface);
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start;
}
.chat .line .en { font-weight: 700; font-size: var(--t-md); line-height: 1.3; }
.chat .line .es { font-size: var(--t-sm); color: var(--ink-soft); }
.chat .them { align-items: flex-start; }
.chat .them .line { border-bottom-left-radius: 4px; }
.chat .you { align-items: flex-end; }
.chat .you .line { background: var(--sun-wash); border-bottom-right-radius: 4px; }
.chat .you .who { text-align: right; }
.chat li.is-speaking .line { box-shadow: 0 0 0 4px var(--sun); }
.mini-play {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink);
  background: var(--sun); color: var(--sun-ink); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.mini-play svg { width: 18px; height: 18px; }
.chat-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.toggle-es { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); min-height: 48px; cursor: pointer; }
.toggle-es input { width: 22px; height: 22px; accent-color: var(--ink); }
.hide-es .chat .es { visibility: hidden; }

/* ---------- Practice ---------- */
.q-count { font-size: var(--t-sm); color: var(--ink-soft); }
.q-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 20px; }
.q-bar span { display: block; height: 100%; background: var(--ink); transition: width .3s ease; }
.q-prompt { font-size: var(--t-sm); color: var(--ink-soft); margin-bottom: 8px; }
.q-big { font-size: var(--t-xl); font-weight: 700; line-height: 1.25; margin-bottom: 18px; }

.choices { display: grid; gap: 10px; }
.choice {
  text-align: left; padding: 14px 16px; min-height: 56px;
  border: 2px solid var(--line); border-radius: var(--r-btn); background: var(--surface);
  font-size: var(--t-md); font-weight: 700; cursor: pointer;
}
.choice:hover:not(:disabled) { border-color: var(--ink); }
.choice.is-right { border-color: var(--go); background: var(--go-wash); }
.choice.is-wrong { border-color: var(--stop); background: var(--stop-wash); }
.choice:disabled { cursor: default; }

.answer-zone {
  min-height: 72px; padding: 10px; border: 2px dashed var(--ink-soft); border-radius: var(--r-btn);
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; margin-bottom: 14px;
}
.answer-zone:empty::before { content: attr(data-empty); color: var(--ink-soft); font-size: var(--t-sm); padding: 8px; }
.word-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.word {
  padding: 10px 14px; min-height: 48px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--surface); font-weight: 700; font-size: var(--t-md); cursor: pointer;
}
.word.is-used { visibility: hidden; }
.answer-zone .word { background: var(--sun-wash); }

.feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-btn); font-size: var(--t-md); }
.feedback.ok { background: var(--go-wash); border: 2px solid var(--go); }
.feedback.no { background: var(--stop-wash); border: 2px solid var(--stop); }
.feedback strong { display: block; }
.q-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.q-actions .btn { flex: 1; }

.listen-big {
  width: 96px; height: 96px; border-radius: 50%; margin: 6px auto 22px;
  display: grid; place-items: center; border: 3px solid var(--sun-ink);
  background: var(--sun); color: var(--sun-ink); cursor: pointer;
}
.listen-big svg { width: 40px; height: 40px; }
.listen-row { display: flex; justify-content: center; gap: 12px; align-items: center; }
.listen-row .btn { margin-bottom: 22px; }

.mic {
  width: 104px; height: 104px; border-radius: 50%; margin: 8px auto 16px;
  display: grid; place-items: center; border: 3px solid var(--ink); background: var(--surface); cursor: pointer;
}
.mic svg { width: 44px; height: 44px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.mic.is-listening { background: var(--stop-wash); border-color: var(--stop); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px transparent; } 0%,100% { box-shadow: 0 0 0 0 var(--stop-wash); } }
.heard { text-align: center; font-size: var(--t-md); min-height: 1.5em; }

/* ---------- Result ---------- */
.result { text-align: center; padding-top: 12px; }
.result .score { font-size: 4rem; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.result .score small { font-size: var(--t-lg); color: var(--ink-soft); font-weight: 400; }
.result h2 { font-size: var(--t-xl); margin: 18px 0 6px; }
.result .stack { text-align: left; margin-top: 28px; }

/* ---------- Saved / about ---------- */
.page-title { font-size: var(--t-xxl); letter-spacing: -0.02em; margin-bottom: 8px; }
.empty { padding: 24px 0; max-width: 40ch; }
.saved-from { font-size: var(--t-xs); color: var(--ink-soft); margin: 22px 0 8px; font-weight: 700; }
.prose p + p, .prose h2 + p { margin-top: 10px; }
.prose h2 { font-size: var(--t-lg); margin-top: 28px; }
.prose ul { padding-left: 22px; margin: 10px 0 0; }
.prose li + li { margin-top: 6px; }
.notice { background: var(--stop-wash); border: 2px solid var(--stop); border-radius: 12px; padding: 12px 14px; font-size: var(--t-sm); margin-bottom: 16px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 10px; text-decoration: none; font-size: var(--t-xs); color: var(--ink-soft); min-height: 60px;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar a[aria-current="page"] svg { fill: var(--sun); stroke: var(--ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: var(--t-sm); font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
  max-width: calc(100% - 32px);
}
.toast.is-on { opacity: 1; }

@media (min-width: 700px) {
  .hero .bubble .en { font-size: 2.75rem; }
  main { padding-top: 32px; }
}

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