/* Reading setup before the first comic: full screen on KOA's cream page, one question per screen,
   progress bar at the top (like Duolingo), Georgia titles and 3D cards. The comic is not visible behind. */
.setup.setup{
  --ink:#29202b;--card-ink:#3d3054;--muted:#6f6170;--paper:#faf5ea;--card:#fffdf9;--lilac:#efe6f7;--purple:#76518e;--lav:#bda1e2;
  --font:"Segoe UI",Inter,Arial,sans-serif;--thai:"Noto Sans Thai Looped","Noto Sans Thai",Tahoma,"Leelawadee UI",sans-serif;
  position:fixed;inset:0;width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;margin:0;padding:0;border:0;border-radius:0;
  background:#faf5ea;color:var(--ink);font-family:var(--font);overflow:hidden
}
.setup.setup[open]{display:flex;flex-direction:column;align-items:center}
.setup.setup:focus{outline:none}
.setup.setup::backdrop{background:#faf5ea}
.setup :focus:not(:focus-visible){outline:none}
.setup .setup-head,.setup .setup-body,.setup .setup-foot{width:100%;max-width:520px}

.setup .setup-head{display:grid;grid-template-columns:44px 1fr auto;align-items:center;gap:12px;padding:16px 18px 6px}
.setup .setup-back{display:grid;place-items:center;width:40px;height:40px;padding:0;border:1px solid #e2d6c6;border-radius:50%;background:#fff;color:var(--ink);cursor:pointer}
.setup .setup-back svg{width:20px;height:20px}
.setup .setup-back[hidden]{display:grid;visibility:hidden}
.setup .setup-back{grid-column:1}.setup .setup-skip{grid-column:3}
.setup .setup-progress{grid-column:2;height:14px;border-radius:999px;background:#e9e1ee;overflow:hidden;box-shadow:inset 0 2px 0 #0000000d}
.setup .setup-progress span{display:block;height:100%;border-radius:999px;background:linear-gradient(180deg,#cdb4ec,#9f7bd0);box-shadow:inset 0 -3px 0 #0000001a;transition:width .35s ease}
.setup .setup-skip{min-height:40px;padding:0 4px;border:0;background:none;color:var(--muted);font:800 .95rem var(--font);cursor:pointer}

.setup .setup-body{flex:1;overflow-y:auto;display:flex;flex-direction:column;padding:16px 20px 20px}
.setup .setup-art{display:grid;place-items:center;width:84px;height:84px;margin:6px 0 14px;border-radius:50%;background:#fff;border:2px solid var(--card-ink);box-shadow:0 4px 0 var(--card-ink)}
.setup .setup-art img{width:52px;height:auto}
.setup .setup-title{margin:0 0 8px;font:700 clamp(1.7rem,6.5vw,2.1rem)/1.15 Georgia,serif;letter-spacing:-.02em;color:var(--ink)}
.setup .setup-subtitle{margin:0 0 22px;font-size:1rem;line-height:1.5;color:var(--muted)}

.setup .setup-options{display:grid;gap:14px}
.setup .setup-option{display:flex;flex-direction:column;align-items:flex-start;gap:6px;width:100%;padding:16px 18px;border:2px solid var(--card-ink);border-radius:18px;background:var(--card);box-shadow:0 4px 0 var(--card-ink);color:var(--ink);font-family:var(--font);text-align:left;cursor:pointer;transition:transform .08s,background .15s}
.setup .setup-option:hover{background:#fff}
.setup .setup-option:active{transform:translateY(3px);box-shadow:0 1px 0 var(--card-ink);background:var(--lilac)}
.setup .setup-option-top{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.setup .setup-option-top strong{font-size:1.1rem;font-weight:900}
.setup .setup-badge{padding:3px 10px;border-radius:999px;background:var(--purple);color:#fff;font-size:.72rem;font-weight:900;letter-spacing:.02em}
.setup .setup-sample{font-size:1.7rem;line-height:1.3;color:var(--ink)}
.setup .setup-sample[lang="th"]{font-family:var(--thai)}
.setup .setup-sample[lang="th-Latn"]{font-weight:800}
.setup .setup-option-text{font-size:.93rem;line-height:1.45;color:var(--muted)}

/* Try it: a speech bubble whose words can be tapped */
/* The comics' own speech bubble (assets/home/bubble.svg, drawn like scripts/manhwa/bubbles.mjs: ink outline,
   one-piece tail down-left), as on the home page (.tap-bubble). Lettering font of the reader: Andika, Thai in
   Noto Sans Thai Looped. A tapped word becomes its meaning in the same font and size, rose-red, like .word-flip. */
.setup .setup-bubble{align-self:center;display:flex;flex-wrap:wrap;align-content:center;justify-content:center;gap:.1em .32em;width:min(100%,400px);aspect-ratio:440/320;margin:10px 0 18px;padding:4% 10% 15.8%;background:url(/assets/home/bubble.svg?v=2) center/100% 100% no-repeat;filter:drop-shadow(0 10px 16px #29202b26);font:800 clamp(1.5rem,6.6vw,2.1rem)/1.22 Andika,"Noto Sans Thai Looped","Noto Sans Thai",Tahoma,"Segoe UI",Arial,sans-serif;color:#141018}
.setup .setup-bubble[lang="th"]{gap:.1em 0;font-weight:700}
.setup .setup-word{padding:0 .04em;border:0;border-radius:0;background:none;font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.setup .setup-word.is-turned{color:#c23a5e;animation:setup-flip .28s ease-out}
.setup .setup-bubble[lang="th"] .setup-word.is-turned{padding:0 .2em}
@keyframes setup-flip{from{opacity:0}to{opacity:1}}
.setup .setup-demo-hint{margin:0;text-align:center;font-weight:800;color:var(--purple)}
.setup .setup-demo-hint.is-done{color:#2d6b3f}

/* Ready: the comic's cover */
.setup .setup-cover{display:grid;place-items:center;margin:8px 0 6px}
.setup .setup-cover img{width:min(210px,55vw);height:auto;aspect-ratio:2/3;object-fit:cover;border:2px solid var(--card-ink);border-radius:14px;box-shadow:0 6px 0 var(--card-ink),0 20px 36px #29202b33;animation:setup-pop .45s cubic-bezier(.2,1.3,.4,1) both}
@keyframes setup-pop{from{opacity:0;transform:translateY(16px) scale(.92)}to{opacity:1;transform:none}}

.setup .setup-foot{padding:12px 20px calc(18px + env(safe-area-inset-bottom))}
.setup .setup-foot:empty{display:none}
.setup .setup-primary{display:flex;align-items:center;justify-content:center;width:100%;min-height:58px;border:2px solid var(--card-ink);border-radius:18px;background:linear-gradient(180deg,#cdb4ec,#b48fe0);box-shadow:0 5px 0 var(--card-ink);color:#21162e;font:900 1.08rem var(--font);cursor:pointer}
.setup .setup-primary:active{transform:translateY(4px);box-shadow:0 1px 0 var(--card-ink)}
/* 15/11: the sentence shakes a little every 2.6 s until the first tap, to make the reader want to touch it. */
.setup .setup-bubble.is-nudging{animation:setup-nudge 2.6s ease-in-out .8s infinite;transform-origin:50% 70%}
@keyframes setup-nudge{0%,62%,100%{transform:none}66%{transform:rotate(-2.2deg) scale(1.03)}72%{transform:rotate(2.2deg) scale(1.03)}78%{transform:rotate(-1.4deg) scale(1.02)}84%{transform:rotate(1deg)}90%{transform:none}}
/* Phones: the bubble of the demo and its hint fit on the screen without scrolling. */
@media(max-height:760px){.setup .setup-body{padding-top:10px}.setup .setup-subtitle{margin-bottom:14px}.setup .setup-bubble{width:min(100%,340px);margin:4px 0 12px}}
@media(prefers-reduced-motion:reduce){.setup .setup-bubble.is-nudging,.setup .setup-word.is-turned,.setup .setup-option,.setup .setup-cover img,.setup .setup-progress span{animation:none;transition:none}}

/* Journey progress bar in the reading setup */
.setup .setup-progress{height:10px;border:2px solid #3d3054;border-radius:999px;background:#eee5f5;box-shadow:0 2px 0 #3d3054;overflow:hidden}
.setup .setup-progress span{display:block;height:100%;border-radius:0;background:#c39ae6;box-shadow:none;transition:width .35s ease}

/* Which language do you speak? One row per language, with its drawn flag */
.setup .setup-languages{gap:12px}
.setup .setup-language{flex-direction:row;align-items:center;gap:14px;padding:12px 16px}
.setup .setup-language strong{font-size:1.08rem;font-weight:800}
.setup .setup-language .setup-flag{width:40px;height:auto;flex:none}
.setup .setup-language[aria-current="true"]{background:var(--lilac)}

/* 15/11 (interface review): the questions sit in the middle of the screen instead of leaving its bottom half
   empty; after the first tap, one message (green), the long-press tip under it in small plain text. */
.setup .setup-body{justify-content:center}
.setup .setup-body>.setup-title{margin-top:auto}.setup .setup-body>:last-child{margin-bottom:auto}
.setup .setup-demo-tip{margin-top:6px;font-weight:600;font-size:.9rem;color:var(--muted)}

/* 15/11 (Alexis): first visit of the home page (koa-welcome.js), mock-up V2: the cover of the first comic as a
   card, the promise of the site, one big button. Then the language, the level and the demo. */
.setup.koa-welcome-dlg .welcome-head{display:flex;justify-content:space-between;align-items:center;padding:14px 20px 0}
.setup .welcome-brand{display:flex;align-items:center;gap:8px;color:var(--ink);text-decoration:none;font:900 1.4rem var(--font);letter-spacing:-.02em}
.setup .welcome-login{color:var(--ink);font:800 .92rem var(--font);text-decoration:none;padding:8px 2px}
.setup .welcome-body{align-items:center;padding-top:10px;padding-bottom:calc(14px + env(safe-area-inset-bottom))}
/* The cover takes the height left by the rest (header, promise, button, trust line): nothing scrolls. */
.setup .welcome-cover{width:max(96px,min(270px,64vw,calc((100dvh - 330px) * .62)));margin:auto 0 0;transform:rotate(-2.5deg)}
.setup .welcome-cover img{display:block;width:100%;height:auto;aspect-ratio:2/3;object-fit:cover;border:2px solid var(--card-ink);border-radius:16px;box-shadow:0 7px 0 var(--card-ink),0 18px 40px #3d305433;animation:setup-pop .45s cubic-bezier(.2,1.3,.4,1) both}
.setup .welcome-title{margin:26px 0 0;max-width:420px;text-align:center;font:700 clamp(1.6rem,7vw,2.1rem)/1.15 Georgia,serif;letter-spacing:-.02em;color:var(--ink)}
.setup .welcome-title .wind-zero{color:#c23a5b}
.setup .welcome-foot{display:flex;flex-direction:column;align-items:center;width:100%;max-width:480px;margin:26px 0 auto}
.setup .welcome-trust{display:flex;flex-wrap:wrap;justify-content:center;gap:4px 14px;margin:14px 0 0;padding:0;list-style:none;color:var(--muted);font-size:.88rem}
.setup .welcome-trust li::before{content:"✓ ";color:#2f7a4a;font-weight:800}
@media(max-height:700px){.setup .welcome-title{margin-top:16px;font-size:1.5rem}.setup .welcome-foot{margin-top:18px}}
html.koa-welcome,html.koa-welcome body{background:#faf5ea!important}
/* 15/11 (Alexis): on a phone the setup does not move, like an app: no scrolling of the page behind, no
   rubber band; the welcome and the language screens fit the screen and cannot be dragged. */
html.koa-welcome,html.koa-welcome body,html:has(dialog.setup[open]),html:has(dialog.setup[open]) body{overflow:hidden;overscroll-behavior:none}
.setup.setup,.setup .setup-body{overscroll-behavior:none}
.setup.koa-welcome-dlg>.setup-head,.setup.koa-welcome-dlg>.setup-body{overflow:hidden;touch-action:none}
@media(max-height:700px){.setup .setup-languages{gap:9px}.setup .setup-language{padding:9px 16px}.setup .setup-language .setup-flag{width:34px}}
/* Small phones (iPhone SE, browser bars shown: about 550 px): the level, the demo and the long press fit too. */
@media(max-height:620px){
  .setup .setup-head{padding:10px 18px 2px}.setup .setup-body{padding:6px 20px 6px}
  .setup .setup-title{font-size:1.45rem;margin-bottom:4px}.setup .setup-subtitle{font-size:.92rem;line-height:1.35;margin-bottom:10px}
  .setup .setup-options{gap:10px}.setup .setup-option{padding:10px 14px;gap:3px}.setup .setup-option-text{font-size:.86rem;line-height:1.35}
  .setup .setup-level .setup-sample{font-size:1.05rem}
  .setup .setup-bubble{width:min(100%,270px);margin:2px 0 8px}
  .setup .setup-foot{padding:6px 20px calc(10px + env(safe-area-inset-bottom))}.setup .setup-primary{min-height:50px}
}
/* The tapped language shows at once while the comic's page loads. */
.setup .setup-languages.is-going .setup-language:not([aria-current]){opacity:.45}
.setup .setup-languages.is-going .setup-language[aria-current]{transform:translateY(3px);box-shadow:0 1px 0 var(--card-ink)}
html.koa-welcome body>:not(dialog){visibility:hidden}

/* Your level of Thai (koa-reading-setup.js): three cards, each says what it sets. */
.setup .setup-level .setup-sample{font-size:1.25rem}
/* The demo: a finger shows where to tap until the first tap; "Continue" only appears after it. */
.setup .setup-bubble{position:relative}
.setup .setup-finger{position:absolute;width:44px;height:52px;pointer-events:none;animation:setup-tap 1.6s ease-in-out infinite;filter:drop-shadow(0 3px 4px #0003)}
.setup .setup-finger svg{width:100%;height:100%}
@keyframes setup-tap{0%,100%{transform:translate(6px,10px)}45%{transform:translate(0,0) scale(.92)}55%{transform:translate(0,0) scale(.92)}}
/* Its place is kept while it is hidden, so the bubble does not move when it appears (same for the hint, which
   grows to two lines, and the long-press tip). */
.setup .setup-bubble~.setup-demo-hint:not(.setup-demo-tip){min-height:2.6em;display:flex;align-items:flex-start;justify-content:center}
.setup .setup-demo-tip{visibility:hidden;min-height:2.9em}
.setup .setup-demo-tip.is-shown{visibility:visible}
.setup .setup-foot .setup-primary.is-waiting{visibility:hidden}
.setup .setup-foot .setup-primary:not(.is-waiting){animation:setup-pop .35s ease-out both}
@media(prefers-reduced-motion:reduce){.setup .setup-finger,.setup .welcome-cover img{animation:none}}

/* 15/11 (Alexis): the bubbles of the setup are never selected like text, and the phone's own long-press menu
   does not open on them (only our translation). */
.setup .setup-bubble,.setup .setup-bubble *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
/* Step 5, press and hold: the finger stays down, a ring fills around it; the bubble fills up while held. */
.setup .setup-bubble.is-hold{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.setup .setup-bubble .setup-line{display:contents}
.setup .setup-bubble .setup-sentence{color:#c23a5e;animation:setup-flip .28s ease-out}
.setup .setup-bubble.is-pressing{transform:scale(.97);transition:transform .45s ease-out}
.setup .setup-finger.is-hold{animation:setup-hold 2.2s ease-in-out infinite}
.setup .setup-finger.is-hold::before{content:"";position:absolute;left:-2px;top:-14px;width:30px;height:30px;border-radius:50%;border:3px solid #c39ae6;opacity:0;animation:setup-ring 2.2s ease-in-out infinite}
@keyframes setup-hold{0%,100%{transform:translate(6px,10px)}18%,75%{transform:translate(0,0) scale(.92)}}
@keyframes setup-ring{0%,18%{opacity:0;transform:scale(.4)}30%{opacity:1}75%{opacity:1;transform:scale(1.25)}85%,100%{opacity:0;transform:scale(1.25)}}
@media(prefers-reduced-motion:reduce){.setup .setup-finger.is-hold,.setup .setup-finger.is-hold::before{animation:none}}

/* 15/11 (Alexis): after the setup, the top of the reader is shown once: the script, the translation, the word
   counter. The page dims around a lit frame; a card under it says what it does. */
.setup-tour{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;overflow:hidden;font-family:"Segoe UI",Inter,Arial,sans-serif;color:#29202b}
.setup-tour::backdrop{background:transparent}
.setup-tour:focus{outline:none}
.setup-tour .tour-spot{position:fixed;border-radius:18px;box-shadow:0 0 0 3px #c39ae6,0 0 0 200vmax rgba(26,19,30,.62);transition:all .3s ease;pointer-events:none}
.setup-tour .tour-card{position:fixed;left:16px;right:16px;max-width:420px;margin:0 auto;padding:16px 18px 18px;border:2px solid #3d3054;border-radius:18px;background:#fffdf9;box-shadow:0 5px 0 #3d3054;transition:top .3s ease}
.setup-tour .tour-card p{margin:0 0 14px;font-size:1.02rem;line-height:1.45;font-weight:600}
.setup-tour .tour-card .tour-step{display:block;margin-bottom:6px;color:#76518e;font-size:.8rem;font-weight:800}
.setup-tour .tour-next{display:flex;align-items:center;justify-content:center;width:100%;min-height:52px;border:2px solid #3d3054;border-radius:16px;background:linear-gradient(180deg,#cdb4ec,#b48fe0);box-shadow:0 4px 0 #3d3054;color:#21162e;font:900 1.02rem "Segoe UI",Inter,Arial,sans-serif;cursor:pointer}
.setup-tour .tour-next:active{transform:translateY(3px);box-shadow:0 1px 0 #3d3054}
.setup-tour :focus:not(:focus-visible){outline:none}
@media(prefers-reduced-motion:reduce){.setup-tour .tour-spot,.setup-tour .tour-card{transition:none}}
