@charset "UTF-8";

/* Licensed display face, self-hosted. Subset to Latin + common punctuation. */
@font-face {
  font-family: 'Brightwall';
  src: url('../assets/fonts/brightwall.woff2') format('woff2'),
       url('../assets/fonts/brightwall.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ── tokens ────────────────────────────────────────────────── */
:root {
  --bg: #d7ecf9;
  --paper-top: #ffffff;
  --paper-mid: #ffffff;
  --paper-bot: #ffffff;
  --ink: #0e5a9c;
  --ink-soft: #1273bf;
  --brand: #23a7e1;
  --brand-deep: #1a6fc4;
  --btn: #8cc4ea;
  --btn-idle: #c8ddee;
  --line: #cfe6f6;
  --muted: #7fb4dc;
  --pad: clamp(18px, 5.5vw, 30px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  /* Open Sans has no Thai glyphs — the browser falls through to Noto Sans Thai
     per glyph, so Latin renders in Open Sans and Thai in Noto Sans Thai */
  font-family: 'Open Sans', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
}
img { max-width: 100%; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* ── shell ─────────────────────────────────────────────────── */
.stage {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.frame {
  position: relative;
  display: flex;
  flex-direction: column;
  /* cover art and its lettering are sized against the frame, not the viewport,
     so the desktop card and a phone screen get the same proportions */
  container-type: inline-size;
  width: 100%;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--paper-top) 0%, var(--paper-mid) 55%, var(--paper-bot) 100%);
  overflow-x: hidden;
}
@media (min-width: 768px) {
  .stage { padding: 12px; }
  .frame {
    height: 96dvh;
    min-height: 0;
    width: auto;
    max-width: 96vw;
    aspect-ratio: 0.73;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(30, 110, 180, .18);
    scrollbar-width: thin;
  }
}

.screen {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  animation: fadeUp .42s ease both;
}
.screen[hidden] { display: none; }
.screen--pad {
  padding: max(18px, env(safe-area-inset-top)) var(--pad) calc(34px + env(safe-area-inset-bottom));
}

/* ── shared controls ───────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}
.iconbtn {
  width: 52px; height: 52px;
  flex: none;
  border: none; border-radius: 50%;
  background: #9fcdee; color: #fff;
  font-size: 26px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(30, 110, 180, .18);
}
.iconbtn:active { transform: scale(.95); }

.actions { margin-top: auto; padding-top: 28px; display: flex; justify-content: center; }
.actions--row { gap: 12px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  color: #fff;
  transition: background .2s ease, opacity .2s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn--pill {
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--btn);
  border-radius: 40px;
  padding: 11px 14px 11px 28px;
  font-size: clamp(18px, 4.6vw, 22px);
  box-shadow: 0 6px 16px rgba(60, 140, 205, .32);
  min-height: 56px;
}
.btn--wide { padding-left: 34px; }
.btn__dot {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  background: #fff; color: #3f8ccd;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.btn[disabled], .btn[aria-disabled="true"] {
  background: var(--btn-idle);
  box-shadow: none;
  opacity: .75;
  cursor: not-allowed;
}
.btn--soft {
  background: var(--btn);
  border-radius: 40px;
  padding: 13px 26px;
  font-size: clamp(16px, 4.2vw, 19px);
  box-shadow: 0 6px 16px rgba(60, 140, 205, .32);
  min-height: 50px;
}

/* ── cover ─────────────────────────────────────────────────── */
.screen--cover { position: relative; justify-content: flex-start; }
.cover__art {
  position: absolute; inset: 0;
  background: url('../assets/bg-cover.webp') center bottom/cover no-repeat #0b1a24;
}
.cover__art::after {
  content: '';
  position: absolute; inset: 0;
  /* the artwork is already dark — just deepen the top and bottom a touch so the
     lettering and the button keep their contrast */
  background: linear-gradient(180deg, rgba(6, 20, 30, .34) 0%, rgba(6, 20, 30, 0) 34%, rgba(6, 20, 30, 0) 78%, rgba(6, 20, 30, .28) 100%);
}
.cover__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 6cqw calc(11cqw + env(safe-area-inset-bottom));
  flex: 1;
  color: #eaf7ff;
  text-shadow: 0 2px 14px rgba(0, 20, 40, .55);
}
.cover__title {
  margin: 10cqw 0 0;
  font-size: 6.6cqw;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
}
.cover__accent {
  color: #b7ecff;
  font-weight: 500;
  font-size: 13.5cqw;
  /* the big "น้ำ" rides above the baseline of the rest of the headline */
  line-height: 0;
  position: relative;
  top: 0.12em;
  margin: 0 .12em;
}
.cover__sub {
  margin: 3.4cqw 0 0;
  font-size: 3.15cqw;
  font-weight: 400;
  line-height: 1.65;
}
.cover__lead {
  /* Pinned to the vertical centre of .cover__body (which is position:relative)
     instead of flowing after the title/sub — so it stays centred on screen
     no matter how long the headline or subtitle text runs, on any device.
     width:100% + left/right:0 keeps horizontal centering symmetric regardless
     of Brightwall's right-leaning kerning (a shrink-wrapped box would center
     text only within its own narrow width, not the full column). */
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  width: 100%;
  margin: 0;
  font-family: 'Brightwall', cursive;
  font-size: 12cqw;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: -.01em;
  color: #f2fdff;
  text-shadow:
    0 0 4px rgba(255, 255, 255, .9),
    0 0 18px rgba(150, 232, 255, .85),
    0 0 44px rgba(96, 190, 255, .7),
    0 0 90px rgba(60, 150, 240, .45);
}
.cover__lead-sm { font-size: .52em; }
.cover__start { margin-top: auto; }

/* ── form ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  margin: 22px 0 4px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(30, 110, 180, .14);
}
.tab {
  flex: 1;
  padding: 14px 8px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: clamp(16px, 4.4vw, 20px);
  cursor: pointer;
  background: #a9d3ef;
  color: #fff;
  min-height: 52px;
}
.tab[aria-selected="true"] { background: var(--brand-deep); }

.fields { margin-top: 20px; display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label { font-weight: 600; font-size: clamp(15px, 4.2vw, 18px); }
.field__input {
  width: 100%;
  padding: 14px 16px;
  border: 1.6px solid var(--line);
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 1px 3px rgba(30, 110, 180, .05);
  min-height: 50px;
}
.field__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(35, 167, 225, .15);
}
.field__input[aria-invalid="true"] { border-color: #e2748a; }
.field__error { font-size: 13px; color: #d3556e; min-height: 0; }
.field__error:empty { display: none; }

/* ── story / reveal ────────────────────────────────────────── */
.scene {
  /* auto/auto + max-width/max-height (not width:100% + object-fit) so the box
     always matches the image's own aspect ratio — story1 and story2 have
     different crops, and a fixed-width box would letterbox the taller one
     instead of actually rendering shorter */
  width: auto;
  height: auto;
  max-width: 100%;
  /* dvh-capped so a tall source image can never push the "next" button below
     the fold on a short phone screen */
  max-height: 24dvh;
  display: block;
  border-radius: 18px;
  margin: 14px auto 0;
}
.scene--god { max-width: 380px; max-height: 20dvh; margin-inline: auto; }
.story {
  margin: 18px 2px 0;
  font-size: clamp(15px, 4.1vw, 18px);
  line-height: 1.85;
  color: var(--ink-soft);
  text-wrap: pretty;
  text-align: center
}
.story--quote {
  font-style: italic;
  color: var(--brand);
  border-left: 3px solid var(--line);
  padding-left: 14px;
  text-align: center
}
.reveal__title {
  margin: 20px 0 0;
  text-align: center;
  font-size: clamp(22px, 6vw, 28px);
  color: var(--brand);
  font-weight: 700;
}

/* ── question ──────────────────────────────────────────────── */
.progress__label { font-size: 15px; font-weight: 500; color: var(--muted); }
.progress {
  height: 6px;
  border-radius: 6px;
  background: #dcedf9;
  margin: 14px 2px 0;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #5bb8ec, var(--brand));
  width: 0;
  transition: width .4s ease;
}
.qhead { text-align: center; margin: 22px 2px 6px; }
.qhead__setup {
  margin: 0 0 10px;
  font-size: clamp(15px, 4.1vw, 18px);
  line-height: 1.65;
  color: var(--ink-soft);
  font-weight: 500;
  text-wrap: pretty;
}
.qhead__ask {
  margin: 0;
  font-size: clamp(19px, 5.6vw, 24px);
  line-height: 1.45;
  color: var(--brand);
  font-weight: 700;
  text-wrap: pretty;
}
.options { margin-top: 16px; display: flex; flex-direction: column; gap: 13px; }
.option {
  text-align: left;
  width: 100%;
  padding: 15px 18px;
  border-radius: 22px;
  font-family: inherit;
  font-size: clamp(15px, 4vw, 16px);
  line-height: 1.55;
  cursor: pointer;
  color: var(--ink-soft);
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: 0 3px 8px rgba(30, 110, 180, .08);
  transition: all .2s ease;
}
.option__key { font-weight: 700; margin-right: 6px; }
.option[aria-pressed="true"] {
  background: #e3f4ff;
  border: 2.5px solid var(--brand);
  box-shadow: 0 6px 16px rgba(35, 167, 225, .25);
}

/* ── result ────────────────────────────────────────────────── */
.screen--result { background: #fff; }
.result { text-align: center; animation: pop .5s ease both; }
.result__hero {
  width: 100%;
  max-width: 460px;
  margin: 8px auto 4px;
  display: block;
  border-radius: 20px;
}
.result__name {
  margin: 10px 0 0;
  font-family: 'Brightwall', cursive;
  font-size: clamp(26px, 7.4vw, 36px);
  font-weight: 400;
  color: var(--brand);
  line-height: 1.35;
}
.result__tag {
  margin-top: 24px;
  font-size: clamp(16px, 4.2vw, 19px);
  font-weight: 700;
  color: var(--brand);
}
.result__desc {
  margin: 14px auto 0;
  max-width: 520px;
  font-size: clamp(15px, 4.1vw, 17px);
  line-height: 1.8;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.teambox {
  margin-top: 22px;
  padding: 18px 16px;
  border: 1.5px solid var(--line);
  border-radius: 20px;
}
.teambox__head { margin: 0; font-size: clamp(16px, 4.4vw, 19px); font-weight: 600; color: var(--brand); }
.teambox__mates { display: flex; justify-content: center; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.mate { width: 130px; }
.mate img { width: 100%; border-radius: 14px; display: block; }
.mate span { display: block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); line-height: 1.35; }
.teambox__note { margin: 12px 0 0; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.teambox__why {
  margin: 14px 0 0;
  font-size: clamp(14px, 3.8vw, 15px);
  line-height: 1.8;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.sendstate {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.sendstate--err { color: #d3556e; }

.downloadhint {
  margin: 14px auto 0;
  max-width: 380px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  background: #eef8fe;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
}

/* ── QWATER summary (below the download/restart buttons) ──────── */
.summary { margin-top: 34px; display: flex; flex-direction: column; gap: 26px; }

.qwbox {
  position: relative;
  margin-top: 18px;
  padding: 30px 18px 22px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: #ffffff;
}
.qwbox__label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn);
  color: #fff;
  font-weight: 600;
  font-size: clamp(14px, 3.8vw, 17px);
  padding: 9px 26px;
  border-radius: 40px;
  box-shadow: 0 4px 10px rgba(60, 140, 205, .28);
  white-space: nowrap;
}
.qwgrid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px 14px;
}
.qwgrid__item {
  width: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.qwgrid__item img { width: 84px; height: 84px; object-fit: contain; }
.qwgrid__name {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.3;
}
.qwgrid__tag { font-size: 11px; color: var(--muted); margin-top: 1px; }

.qwquote {
  margin: 0;
  text-align: center;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(15px, 4.2vw, 18px);
  line-height: 1.65;
  color: var(--brand);
  padding: 0 6px;
  text-wrap: balance;
}

.qwvalues {
  position: relative;
  margin-top: 18px;
  padding: 30px 18px 22px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: #ffffff;
}
.qwvalues__pill {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn);
  color: #fff;
  font-weight: 600;
  font-size: clamp(14px, 3.8vw, 17px);
  padding: 9px 26px;
  border-radius: 40px;
  box-shadow: 0 4px 10px rgba(60, 140, 205, .28);
  white-space: nowrap;
}
.qwvalues__item + .qwvalues__item { margin-top: 20px; }
.qwvalues__title {
  margin: 0;
  text-align: center;
  font-weight: 700;
  font-size: clamp(14.5px, 3.9vw, 16.5px);
  color: var(--brand);
}
.qwvalues__desc {
  margin: 5px auto 0;
  max-width: 480px;
  text-align: center;
  font-size: clamp(13.5px, 3.6vw, 15px);
  line-height: 1.7;
  color: var(--ink-soft);
  text-wrap: pretty;
}
