/* Lilly - a private language school.
 *
 * The design has one idea: the three-line block. A phrase in its own script, the way to say it, and what
 * it means, set the way an interlinear grammar sets a gloss - large text with quieter lines beneath it,
 * separated by air and hairlines rather than boxes and shadows. Everything else on the screen gets out of
 * its way. The palette is a calla lily: dark leaf green, warm stone paper, and pollen for the one moment
 * that matters, which is when Lilly is listening to you.
 */

:root {
  --ink:      #17251f;
  --ink-soft: #4a5b52;
  --ink-faint:#7d8b83;
  --ground:   #edeae3;
  --paper:    #faf8f4;
  --rule:     #d8d2c6;
  --leaf:     #2f6b4f;
  --leaf-soft:#e3ede7;
  --pollen:   #c98a12;
  --pollen-bg:#fbf0d8;
  --rose:     #a83a60;
  --rose-bg:  #f8e9ee;
  --shadow:   0 1px 0 var(--rule);
  --serif:    Literata, "Noto Serif Thai", "Noto Serif", Georgia, "Times New Roman", serif;
  --sans:     Archivo, "Noto Sans Thai", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
              Roboto, sans-serif;
  --wrap: 34rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:      #e9e6de;
    --ink-soft: #a9b4ac;
    --ink-faint:#77837b;
    --ground:   #101815;
    --paper:    #18211d;
    --rule:     #2b3730;
    --leaf:     #74c39a;
    --leaf-soft:#1d2d25;
    --pollen:   #e9bd5c;
    --pollen-bg:#2a2317;
    --rose:     #e58aa9;
    --rose-bg:  #2e1c23;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* The header and the tab bar are display:flex and display:grid, and a display rule in a stylesheet beats
 * the browser's own [hidden] rule. Without this line they are visible on the door screen, which is
 * exactly what the first browser test found. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------------------------------------------------------------- chrome */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1rem;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.top h1 {
  margin: 0; font: 600 1.05rem/1 var(--serif); letter-spacing: .01em;
  display: flex; align-items: baseline; gap: .45rem;
}
.top h1 .sub { font: 400 .8rem/1 var(--sans); color: var(--ink-faint); }
.top .spacer { flex: 1; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 1.25rem 1rem 6rem; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: .6rem .25rem .7rem; color: var(--ink-faint);
  font: 500 .74rem/1.4 var(--sans); letter-spacing: .01em;
  display: grid; gap: .18rem; justify-items: center;
  border-top: 2px solid transparent; margin-top: -1px;
}
.tabs button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabs button[aria-current="true"] { color: var(--leaf); border-top-color: var(--leaf); }

/* ---------------------------------------------------------- the three-line block */

.phrase { padding: .1rem 0 .1rem 0; }
.phrase .target {
  font: 500 clamp(1.6rem, 6.5vw, 2.05rem)/1.3 var(--serif);
  letter-spacing: -.01em; margin: 0 0 .3rem;
  overflow-wrap: break-word;
}
.phrase .target[lang="th"] { line-height: 1.75; font-size: clamp(1.5rem, 6vw, 1.9rem); }
.phrase .say {
  font: 400 .98rem/1.5 var(--sans); letter-spacing: .015em; color: var(--leaf);
  margin: 0 0 .2rem;
}
.phrase .say[lang="th"] { font-size: 1.05rem; line-height: 1.8; }
.phrase .mean {
  font: italic 400 1.02rem/1.5 var(--serif); color: var(--ink-soft); margin: 0;
}
.phrase .mean[lang="th"] { font-style: normal; line-height: 1.8; }

.speakable { cursor: pointer; }
.speakable:hover { text-decoration: underline dotted var(--ink-faint) 1px; text-underline-offset: 5px; }

.stem { border-left: 2px solid var(--rule); padding-left: 1rem; }
.stem.lilly { border-left-color: var(--leaf); }
.stem.you   { border-left-color: var(--pollen); }

/* --------------------------------------------------------------- surfaces */

.sheet {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 14px;
  padding: 1.15rem 1.15rem 1.25rem;
}
.sheet + .sheet { margin-top: .9rem; }

.rowlist { border-top: 1px solid var(--rule); }
.rowlist > * { border-bottom: 1px solid var(--rule); padding: .85rem .2rem; }

.eyebrow { font: 500 .8rem/1.4 var(--sans); color: var(--ink-faint); margin: 0 0 .15rem; }
h2 { font: 500 1.3rem/1.25 var(--serif); margin: 0 0 .5rem; letter-spacing: -.01em; }
h3 { font: 500 1.02rem/1.3 var(--serif); margin: 0 0 .3rem; }
p  { margin: 0 0 .7rem; }
.muted { color: var(--ink-soft); }
.tiny  { font-size: .84rem; color: var(--ink-faint); }

/* --------------------------------------------------------------- controls */

button.act {
  appearance: none; cursor: pointer; font: 500 .95rem/1 var(--sans);
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: .62rem 1.05rem; display: inline-flex; gap: .45rem;
  align-items: center; transition: background .12s ease, border-color .12s ease;
}
button.act:hover  { border-color: var(--ink-faint); }
button.act:active { background: var(--ground); }
button.act[disabled] { opacity: .45; cursor: default; }
button.act.solid { background: var(--leaf); border-color: var(--leaf); color: #fff; }
@media (prefers-color-scheme: dark) { button.act.solid { color: #0d1512; } }
button.act.big { padding: .85rem 1.4rem; font-size: 1.02rem; }
button.act svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; }

.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

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

/* the one place the design raises its voice: the microphone */

.mic {
  --size: 92px;
  position: relative; width: var(--size); height: var(--size); border-radius: 50%;
  border: 1px solid var(--leaf); background: var(--leaf); color: #fff;
  display: grid; place-items: center; cursor: pointer; appearance: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
@media (prefers-color-scheme: dark) { .mic { color: #0d1512; } }
.mic:active { transform: scale(.97); }
.mic svg { width: 34px; height: 34px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.mic[data-state="listening"] { background: var(--pollen); border-color: var(--pollen); color: #241a05; }
.mic[data-state="thinking"]  { background: var(--paper); color: var(--ink-faint); border-color: var(--rule); }
.mic .ring {
  position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--pollen);
  opacity: 0; transform: scale(.9);
}
.mic[data-state="listening"] .ring { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse {
  0%   { opacity: .55; transform: scale(.92); }
  100% { opacity: 0;   transform: scale(1.35); }
}
.miczone { display: grid; justify-items: center; gap: .55rem; padding: 1.1rem 0 .2rem; }
.miczone .hint { font: 500 .88rem/1.4 var(--sans); color: var(--ink-faint); text-align: center; }

/* ------------------------------------------------------------ the verdict */

.verdict { display: flex; align-items: baseline; gap: .6rem; margin: 0 0 .55rem; }
.verdict .word { font: 500 1.15rem/1 var(--serif); }
.verdict .pct  { font: 500 .9rem/1 var(--sans); color: var(--ink-faint); }
.band { height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; margin: .1rem 0 .9rem; }
.band i { display: block; height: 100%; width: 0; background: var(--leaf); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.v-perfect .word, .v-good .word { color: var(--leaf); }
.v-perfect .band i, .v-good .band i { background: var(--leaf); }
.v-close .word { color: var(--pollen); }
.v-close .band i { background: var(--pollen); }
.v-again .word, .v-missed .word { color: var(--rose); }
.v-again .band i, .v-missed .band i { background: var(--rose); }

.marks { display: flex; flex-wrap: wrap; gap: .3rem .4rem; margin: 0 0 .7rem; }
.marks span {
  font: 400 1.05rem/1.5 var(--serif); padding: .1rem .42rem; border-radius: 6px;
  opacity: 0; transform: translateY(3px); animation: settle .22s ease forwards;
}
.marks span[lang="th"] { line-height: 1.9; }
.marks .ok  { background: var(--leaf-soft); color: var(--ink); }
.marks .bad { background: var(--rose-bg);  color: var(--rose); text-decoration: underline
              wavy var(--rose) 1px; text-underline-offset: 4px; }
@keyframes settle { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .marks span { animation: none; opacity: 1; transform: none; }
  .mic[data-state="listening"] .ring { animation: none; opacity: .4; }
  .band i { transition: none; }
}

.heard { font: 400 .95rem/1.5 var(--sans); color: var(--ink-soft); }
.heard b { font-weight: 500; color: var(--ink); }

/* ------------------------------------------------------------- disclosure */

details.more { margin-top: .9rem; border-top: 1px solid var(--rule); padding-top: .7rem; }
details.more > summary {
  cursor: pointer; list-style: none; font: 500 .88rem/1.4 var(--sans); color: var(--leaf);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: " +"; }
details.more[open] > summary::after { content: " −"; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem .8rem; margin: .7rem 0 0; }
dl.facts dt { font: 500 .8rem/1.5 var(--sans); color: var(--ink-faint); }
dl.facts dd { margin: 0; font: 400 .95rem/1.5 var(--serif); }
dl.facts dd[lang="th"] { line-height: 1.8; }

.words { display: grid; gap: .45rem; margin: .75rem 0 0; }
.words div { display: grid; grid-template-columns: minmax(0,auto) 1fr; gap: .1rem .7rem; align-items: baseline; }
.words .w { font: 500 1.05rem/1.5 var(--serif); }
.words .w[lang="th"] { line-height: 1.9; }
.words .t { font: 400 .85rem/1.4 var(--sans); color: var(--leaf); }
.words .g { grid-column: 1 / -1; font: italic 400 .88rem/1.4 var(--serif); color: var(--ink-faint); }

/* ------------------------------------------------------------------ chat */

.turns { display: grid; gap: 1.3rem; margin-bottom: 1.2rem; }
/* A study card holds one short phrase and can afford to be large. A conversation turn is a sentence or
 * two, and at the study size it shouts. Same block, one step down the scale. */
.turns .phrase .target { font-size: clamp(1.25rem, 5vw, 1.5rem); }
.turns .phrase .target[lang="th"] { font-size: clamp(1.2rem, 4.8vw, 1.42rem); }
.chips { display: flex; gap: .45rem; flex-wrap: wrap; margin: .3rem 0 .9rem; }
.chips button {
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid var(--rule); background: var(--paper); border-radius: 12px;
  padding: .5rem .7rem; max-width: 100%;
}
.chips button:hover { border-color: var(--leaf); }
.chips .t { display: block; font: 500 1rem/1.45 var(--serif); }
.chips .t[lang="th"] { line-height: 1.8; }
.chips .n { display: block; font: 400 .8rem/1.35 var(--sans); color: var(--ink-faint); }

.fix {
  border-left: 2px solid var(--rose); background: var(--rose-bg);
  padding: .55rem .8rem; border-radius: 0 8px 8px 0; margin: .5rem 0 0;
}
.fix .was { text-decoration: line-through; color: var(--ink-faint); }
.fix .is  { font-weight: 500; }
.fix .why { display: block; font-size: .86rem; color: var(--ink-soft); margin-top: .15rem; }
.praise { color: var(--leaf); font-size: .9rem; margin-top: .4rem; }

.composer {
  position: sticky; bottom: 4.4rem; background: var(--ground);
  padding-top: .6rem; display: grid; gap: .5rem;
}
.composer textarea {
  width: 100%; resize: none; border: 1px solid var(--rule); border-radius: 12px;
  background: var(--paper); color: var(--ink); padding: .7rem .8rem;
  font: 400 1rem/1.45 var(--sans); min-height: 2.9rem;
}

/* -------------------------------------------------------------- progress */

.rings { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .8rem; }
.ring-card { display: grid; gap: .35rem; justify-items: start; }
.ring-card .n { font: 500 1.6rem/1 var(--serif); }
.meter { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; width: 100%; }
.meter i { display: block; height: 100%; background: var(--leaf); }
.meter.warm i { background: var(--pollen); }

.lesson-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; align-items: center; }
.lesson-row .t { font: 500 1rem/1.35 var(--serif); }
.lesson-row .s { font: 400 .82rem/1.4 var(--sans); color: var(--ink-faint); grid-column: 1; }
.lesson-row .m { font: 500 .82rem/1 var(--sans); color: var(--ink-faint); }
.lesson-row.locked { opacity: .5; }

/* --------------------------------------------------------------- the door */

.door { display: grid; gap: .8rem; padding-top: 2rem; }
.door .who {
  appearance: none; cursor: pointer; text-align: left; width: 100%;
  border: 1px solid var(--rule); background: var(--paper); border-radius: 16px;
  padding: 1.1rem 1.2rem; display: grid; gap: .2rem;
}
.door .who:hover { border-color: var(--leaf); }
.door .who .nm { font: 500 1.35rem/1.2 var(--serif); }
.door .who .ln { font: 400 .9rem/1.4 var(--sans); color: var(--ink-faint); }
.mark {
  font: 500 2.6rem/1 var(--serif); letter-spacing: -.02em; margin: 0 0 .1rem;
}
.mark em { font-style: italic; color: var(--leaf); }

.toast {
  position: fixed; left: 50%; bottom: 5.4rem; transform: translateX(-50%);
  background: var(--ink); color: var(--ground); padding: .6rem 1rem; border-radius: 999px;
  font: 500 .88rem/1.3 var(--sans); z-index: 60; max-width: 90vw; text-align: center;
}
.hidden { display: none !important; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--rule);
        border-top-color: var(--leaf); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
