/* ==========================================================================
   08-lesson.css — the "learn on your own" layer

   Everything a zero-beginner child touches lives in this file: the plain
   six-tile start screen, the alphabet and number walls, the guided lesson
   cards and the phrase rows. It is written so those pages need nothing but a
   handful of class names — no inline styles, no per-view CSS.

   Rules kept deliberately strict:
     · one idea per tile, one action per tile, never more than two words of
       instruction;
     · every tappable thing is at least as tall as --tap (48px);
     · colour is never the only signal (each tone also carries an emoji/letter);
     · nothing here needs JavaScript to be readable.
   ========================================================================== */

/* ------------------------------------------------------------------ 1. tiles */
/* The six ways in. Four across on a laptop, two on a phone. */
.tile-grid {
  display: grid;
  gap: clamp(12px, 2vw, 18px);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

.tile {
  --tile-c: var(--brand);
  --tile-c-soft: var(--brand-soft);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 168px;
  padding: 22px 22px 18px;
  border: 3px solid var(--border);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 120% at 12% 0%, var(--tile-c-soft), transparent 62%),
    var(--surface);
  box-shadow: var(--sh-2);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform .16s var(--ease-bounce), box-shadow .18s var(--ease),
              border-color .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tile:hover {
  transform: translateY(-5px) rotate(-.5deg);
  border-color: var(--tile-c);
  box-shadow: var(--sh-4);
  text-decoration: none;
  color: inherit;
}
.tile:active { transform: translateY(-1px) scale(.99); }
.tile:focus-visible { outline: 3px solid var(--tile-c); outline-offset: 3px; }

.tile-emoji {
  font-size: 2.7rem;
  line-height: 1;
  filter: drop-shadow(0 3px 5px rgba(44, 36, 24, .14));
}
.tile-name {
  font-family: var(--display);
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--ink);
  line-height: 1.18;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.tile-sub {
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink-3);
  line-height: 1.35;
}
.tile .say-btn { font-size: .82rem; }
.tile-badge {
  position: absolute;
  right: 16px;
  top: 16px;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--tile-c);
  color: #fff;
  font-size: .84rem;
  font-weight: 900;
  box-shadow: var(--sh-1);
}
.tile-step {
  /* In the flow, not absolutely positioned: as a child's text size grows the
     label used to sit on top of the description and the Listen button. Pushed
     to the bottom with margin-top:auto so the tile still looks deliberate. */
  order: 9;
  margin-top: auto;
  padding-top: 6px;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--tile-c);
  opacity: .85;
}

.tile.tone-brand  { --tile-c: var(--brand);  --tile-c-soft: var(--brand-soft); }
.tile.tone-accent { --tile-c: var(--accent); --tile-c-soft: var(--accent-soft); }
.tile.tone-gold   { --tile-c: var(--gold);   --tile-c-soft: var(--gold-soft); }
.tile.tone-sky    { --tile-c: var(--sky);    --tile-c-soft: var(--sky-soft); }
.tile.tone-grape  { --tile-c: var(--grape);  --tile-c-soft: var(--grape-soft); }
.tile.tone-pink   { --tile-c: var(--pink);   --tile-c-soft: var(--pink-soft); }

/* a small tile used inside a view (letters, categories, phrases) */
.mini-tile {
  --tile-c: var(--brand);
  --tile-c-soft: var(--brand-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 132px;
  padding: 14px 12px;
  border: 3px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-1);
  cursor: pointer;
  text-align: center;
  color: inherit;
  text-decoration: none;
  transition: transform .16s var(--ease-bounce), border-color .16s var(--ease),
              box-shadow .18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.mini-tile:hover {
  transform: translateY(-4px);
  border-color: var(--tile-c);
  box-shadow: var(--sh-3);
  text-decoration: none;
  color: inherit;
}
.mini-tile .mt-emoji { font-size: 2.1rem; line-height: 1; }
.mini-tile .mt-name {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}
.mini-tile .mt-sub { font-size: .78rem; font-weight: 700; color: var(--ink-3); }

.mini-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 152px), 1fr));
}

/* a compact way back, used at the top of the learn pages */
.back-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.back-row a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: .92rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--sh-1);
  transition: transform .14s var(--ease-bounce), border-color .14s var(--ease);
}
.back-row a:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  text-decoration: none;
  color: var(--ink);
}
.back-row .br-emoji { font-size: 1.15rem; line-height: 1; }

/* --------------------------------------------------------------- 2. the wall */
/* A "wall" is the alphabet and the number line: big glyphs, tappable, honest
   about which sound is being taught. */
.wall {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 88px), 1fr));
}
.wall-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 96px;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: transform .14s var(--ease-bounce), border-color .14s var(--ease),
              background .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.wall-cell:hover { transform: translateY(-4px); border-color: var(--brand); }
.wall-cell.is-on { background: var(--brand-soft); border-color: var(--brand); }
.wall-cell:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.wall-cell .wc-glyph {
  font-family: var(--display);
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -.02em;
}
.wall-cell .wc-hint {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: var(--ink-4);
  text-transform: lowercase;
}
.wall-cell .wc-hint b { color: var(--brand); font-weight: 900; }

/* a single big letter: the detail card behind the wall */
.letter-stage {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  padding: clamp(18px, 3vw, 30px);
  border: 3px solid var(--border);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 100% at 50% 0%, var(--grape-soft), transparent 66%),
    var(--surface);
  box-shadow: var(--sh-3);
  text-align: center;
}
@media (min-width: 720px) {
  .letter-stage { grid-template-columns: 240px minmax(0, 1fr); text-align: left; }
}
.letter-glyph {
  font-family: var(--display);
  font-size: clamp(5rem, 12vw, 9rem);
  font-weight: 900;
  line-height: .9;
  letter-spacing: -.05em;
  background: linear-gradient(135deg, var(--grape), var(--sky));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}
.letter-name {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
}
.letter-example {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.letter-example .le-tr {
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 800;
}
.letter-example .le-en { font-size: .92rem; font-weight: 600; color: var(--ink-3); }

/* ----------------------------------------------------------- 3. number line */
.num-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 118px), 1fr));
}
.num-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 118px;
  padding: 12px 8px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: transform .14s var(--ease-bounce), border-color .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.num-cell:hover { transform: translateY(-4px); border-color: var(--sky); }
.num-cell .nc-digit {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}
.num-cell .nc-word { font-size: .95rem; font-weight: 800; color: var(--sky); }
.num-cell .nc-en { font-size: .72rem; font-weight: 700; color: var(--ink-4); }

/* --------------------------------------------------------------- 4. lessons */
.lesson-head {
  padding: clamp(18px, 3vw, 28px);
  border: 3px solid var(--border);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 100% at 8% 0%, var(--tile-c-soft, var(--brand-soft)), transparent 60%),
    var(--surface);
  box-shadow: var(--sh-2);
  margin-bottom: 20px;
}
.lesson-head h1 { margin: 0 0 4px; font-family: var(--display); letter-spacing: -.025em; }
.lesson-head .lh-tr {
  font-family: var(--display);
  font-size: clamp(1.2rem, 1rem + 1.4vw, 1.7rem);
  font-weight: 800;
  color: var(--brand);
  margin: 0 0 6px;
}
.lesson-head .lh-goal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: .84rem;
  font-weight: 900;
}

/* one teaching block inside a lesson: a heading, a line of explanation, words */
.lesson-block {
  padding: 18px;
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-1);
  margin-bottom: 18px;
}
.lesson-block > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.16rem;
  letter-spacing: -.01em;
}
.lesson-block > p {
  margin: 0 0 14px;
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-3);
  max-width: 70ch;
}

/* ----------------------------------------------------------- 5. phrase rows */
.phrase-list { display: grid; gap: 10px; }

.phrase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: border-color .16s var(--ease), transform .16s var(--ease);
}
.phrase:hover { border-color: var(--brand-tint); transform: translateY(-2px); }
.phrase .ph-main { min-width: 0; text-align: left; }
.phrase .ph-tr {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  overflow-wrap: break-word;
}
.phrase .ph-en { font-size: .88rem; font-weight: 600; color: var(--ink-3); }
.phrase .ph-note { font-size: .78rem; font-weight: 700; color: var(--ink-4); }
.phrase .ph-side {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

/* word chips: a word, its meaning, and one speaker — the site's atom */
.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 10px 8px 16px;
  border: 2px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: border-color .16s var(--ease), transform .16s var(--ease-bounce);
}
.word-chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.word-chip .wcw-tr {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 800;
  color: var(--ink);
}
.word-chip .wcw-en { font-size: .84rem; font-weight: 700; color: var(--ink-3); display: block; }
.word-chip.say-btn-inline .say-btn { min-height: 38px; padding: 0; width: 38px; }

.word-chips { display: flex; flex-wrap: wrap; gap: 10px; }

/* a big speak-me row: the largest sound target on any page */
.say-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.say-hero .sh-word {
  font-family: var(--display);
  font-size: clamp(1.3rem, 1rem + 2vw, 2.1rem);
  font-weight: 900;
  letter-spacing: -.02em;
}

/* ------------------------------------------------- 5b. tappable word text */
/* Any Turkish word rendered as plain text (an OCR page, a search snippet)
   carries .say-word + data-say; the delegated listener makes it speak. It must
   look tappable without looking like a link, so a soft underline on hover only. */
.say-word {
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s var(--ease), color .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.say-word:hover,
.say-word:focus-visible {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
  outline: none;
}
.say-word.saying { background: var(--brand-tint); box-shadow: 0 0 0 2px var(--brand-tint); }

/* the OCR text layer becomes a wall of tappable words */
.tl-page pre .say-word { padding: 0 1px; }
.tl-page .tl-listen {
  display: inline-flex; align-items: center; gap: 6px;
  float: right; margin-top: -6px; margin-right: 6px;
}

/* --------------------------------------------------------- 6. small helpers */.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 26px 0 12px;
}
.section-title h2 { margin: 0; font-family: var(--display); letter-spacing: -.015em; }
.section-title p { margin: 2px 0 0; font-size: .88rem; font-weight: 600; color: var(--ink-3); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.kid-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px dashed var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink-2);
}
.kid-note .kn-ic { font-size: 1.5rem; line-height: 1; flex: none; }

.progress-track {
  position: relative;
  height: 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 2px solid var(--border);
  overflow: hidden;
}
.progress-track > i {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--gold), var(--brand));
  transition: width .4s var(--ease-out);
}

/* the "I learned it" button — one per lesson, always the same place */
.lesson-done {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 16px 18px;
  border: 3px solid var(--accent);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
}
.lesson-done.is-done { border-color: var(--ok); background: var(--ok-soft); }

/* ------------------------------------------------------- 7. grown-ups drawer */
.grown-list { display: grid; gap: 10px; }
.grown-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}
.grown-list a:hover { border-color: var(--brand); text-decoration: none; color: inherit; }
.grown-list .gl-ic { font-size: 1.3rem; }

/* the small print at the bottom of the menu */
.drawer-foot {
  margin-top: auto;
  padding: 14px 16px 18px;
  border-top: 1px solid var(--border);
  line-height: 1.45;
}

/* ------------------------------------------- 8c. the header at large text sizes */
/* "My page" and "Lessons" are two words; at the biggest text size the header
   links wrapped onto two lines and made the bar 110px tall. Keep each link on
   one line and let the bar scroll instead of growing. */
@media (min-width: 901px) {
  .app-header .nav a { white-space: nowrap; }
  .app-header .wrap { overflow-x: auto; overflow-y: hidden; }
  .app-header .hsearch input { min-width: 150px; }
}

/* ------------------------------------------------- 8b. the quiet footer */
.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 0;
}
.foot-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.foot-links a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .84rem;
  font-weight: 700;
  color: var(--ink-3);
  text-decoration: none;
}
.foot-links a:hover { color: var(--ink); text-decoration: underline; }

/* ---------------------------------------------------------------- 8. motion */
@media (prefers-reduced-motion: reduce) {
  .tile, .mini-tile, .wall-cell, .num-cell, .phrase, .word-chip { transition: none; }
  .tile:hover, .mini-tile:hover, .wall-cell:hover, .num-cell:hover,
  .phrase:hover, .word-chip:hover { transform: none; }
}

@media (max-width: 560px) {
  .tile { min-height: 140px; padding: 18px 18px 14px; }
  .tile-emoji { font-size: 2.2rem; }
  .tile-name { font-size: 1.15rem; }
  .say-hero { padding: 12px; }
}

/* ---------------------------------------- 9. small screens and tablets = fingers */
/* A phone or a small tablet is the most likely device for this site, and a 38px
   circle is not a child's target. Every speaker, chip and small button grows to
   44px at these widths, whatever view rendered it. */
@media (max-width: 820px) {
  .say-icon { width: 44px; height: 44px; }
  .say-md, .say-sm { min-height: 44px; padding: 8px 14px; }
  .word-chip .say-btn,
  .word-chip .say-btn.say-sm,
  .word-chip .say-btn.say-md { width: 44px; min-height: 44px; }
  .word-chips .word-chip { min-height: 52px; }
  .kid-chip,
  #view .chip,
  #view .say-btn.say-sm { min-height: 44px; }
  #view a.btn,
  #view button.btn,
  #view button:not([class]) { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  #view .kpi { min-height: 44px; }
  /* A row of buttons that fits a laptop does not fit a phone. Several views build
     a plain .row of controls; none of them should be able to push the page
     sideways, so rows wrap on a narrow screen. */
  #view .row { flex-wrap: wrap; }
  /* A wide table must not be given a min-width: that floor propagates out of an
     overflow-hidden card and makes the whole document scroll sideways (measured:
     431px of scroll on a 390px screen). Let it shrink; the cells wrap. */
  .tbl { table-layout: fixed; }
  .tbl th, .tbl td { padding: 8px 8px; overflow-wrap: anywhere; }
}
