/*
 * WonderQuest.
 *
 * Built on tokens.css - no raw colour, size or radius appears below. Mobile
 * first throughout: the page is a phone-width column even on a desktop
 * monitor, because that is the shape the whole family will actually hold.
 *
 * Nothing here is smaller than 15px and every tap target clears 44px. Half the
 * players are children, and they will be reading this on deck in Caribbean
 * sunlight, which is the worst viewing condition there is.
 */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--surface-sky);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s-4));
}

h1, h2, h3 { line-height: var(--lh-tight); margin: 0; }
p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Shell ---------------------------------------------------------------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-4) var(--gutter) var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.page--bare { padding-top: var(--s-6); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: calc(var(--safe-top) + var(--s-3)) var(--gutter) var(--s-3);
  background: var(--sky-gradient);
  color: var(--ink-on-colour);
}

.topbar__brand {
  display: flex; align-items: center; gap: var(--s-2);
  color: inherit; text-decoration: none; font-weight: var(--w-black);
  font-size: var(--t-lg);
}

.topbar__mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .22);
  font-size: var(--t-sm); font-weight: var(--w-black); letter-spacing: .5px;
}

.topbar__avatar {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-pill);
  background: var(--palm); color: var(--ink-on-colour);
  font-weight: var(--w-bold); text-decoration: none;
}

/* --- Bottom tabs ---------------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}

.tabbar__tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--ink-muted); text-decoration: none;
  font-size: var(--t-xs); font-weight: var(--w-medium);
}

.tabbar__tab.is-active { color: var(--brand-blue); font-weight: var(--w-bold); }
.tabbar__tab.is-disabled { opacity: .38; }
.tabbar__icon { width: 24px; height: 24px; }
.tabbar__icon svg { width: 100%; height: 100%; }

/* --- Welcome -------------------------------------------------------------- */

.welcome {
  max-width: var(--page-max); margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-6) var(--gutter);
}

.welcome__logo { font-size: var(--t-3xl); font-weight: var(--w-black); letter-spacing: -.5px; }
.welcome__logo--small { font-size: var(--t-2xl); }
.welcome__wonder { color: var(--brand-blue); }
.welcome__quest { color: var(--brand-orange); }

.welcome__tagline {
  color: var(--brand-orange-deep); font-weight: var(--w-bold); font-size: var(--t-sm);
  letter-spacing: .3px; text-align: center;
}

.welcome__sub { color: var(--ink-muted); font-size: var(--t-sm); text-align: center; }

/* --- Cards and forms ------------------------------------------------------ */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--lift);
  padding: var(--s-5);
}

.card--form { width: 100%; display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-3); }
.card__title { font-size: var(--t-xl); font-weight: var(--w-black); }

.field { display: flex; flex-direction: column; gap: var(--s-2); border: 0; padding: 0; margin: 0; }
.field__label { font-weight: var(--w-bold); font-size: var(--t-sm); color: var(--ink-soft); }
.field__hint { font-size: var(--t-sm); color: var(--ink-muted); }
.field__error { font-size: var(--t-sm); color: var(--coral-deep); font-weight: var(--w-medium); }

.input, .textarea {
  width: 100%;
  font: inherit; color: inherit;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunk);
  border: 2px solid var(--line);
  border-radius: var(--r);
  min-height: 48px;
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--ocean);
  background: var(--surface);
}

.input--code {
  text-transform: uppercase; letter-spacing: 6px; text-align: center;
  font-size: var(--t-2xl); font-weight: var(--w-black);
}

.textarea { resize: vertical; min-height: 110px; line-height: var(--lh-loose); }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 52px; padding: 0 var(--s-5);
  font: inherit; font-weight: var(--w-bold);
  border: 0; border-radius: var(--r-pill);
  text-decoration: none; cursor: pointer;
  transition: transform var(--fast) var(--ease-out), filter var(--fast) var(--ease-out);
}

.btn:active { transform: scale(.97); }
.btn--block { width: 100%; }
.btn--primary { background: var(--tile-board); color: var(--ink-on-colour); }
.btn--ghost { background: var(--surface-sunk); color: var(--ink); border: 2px solid var(--line); }

/* --- Avatars and segmented ------------------------------------------------ */

.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s-2); }

.avatar { position: relative; display: grid; place-items: center; cursor: pointer; }
.avatar input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.avatar__face {
  display: grid; place-items: center;
  width: 52px; height: 52px; font-size: 26px;
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
  border: 3px solid transparent;
  transition: border-color var(--fast) var(--ease-out), transform var(--fast) var(--ease-bounce);
}

.avatar input:checked + .avatar__face {
  border-color: var(--ocean);
  background: var(--ocean-mist);
  transform: scale(1.08);
}

.avatar input:focus-visible + .avatar__face { outline: 3px solid var(--brand-blue); outline-offset: 2px; }

.segmented { display: grid; grid-auto-flow: column; gap: var(--s-2); }
.segmented__option { position: relative; }
.segmented__option input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.segmented__option span {
  display: grid; place-items: center; min-height: 48px; padding: 0 var(--s-3);
  border-radius: var(--r); background: var(--surface-sunk);
  border: 2px solid var(--line); font-weight: var(--w-bold); font-size: var(--t-sm);
}

.segmented__option input:checked + span {
  background: var(--ocean-mist); border-color: var(--ocean); color: var(--ocean-deep);
}

/* --- Home ----------------------------------------------------------------- */

.greeting__hello { font-size: var(--t-2xl); font-weight: var(--w-black); }
.greeting__sub { color: var(--ink-muted); margin-top: var(--s-1); }

.daycard {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--lift);
  padding: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
}

.daycard--quiet { align-items: flex-start; }

.daycard__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }

.daycard__badge {
  background: var(--sun-mist); color: var(--sun-deep);
  font-weight: var(--w-black); font-size: var(--t-sm);
  padding: var(--s-1) var(--s-3); border-radius: var(--r-pill);
}

.daycard__date { color: var(--ink-muted); font-size: var(--t-xs); font-weight: var(--w-bold); letter-spacing: .5px; }
.daycard__chapter { font-size: var(--t-xl); font-weight: var(--w-black); color: var(--ocean-deep); }
.daycard__title { font-weight: var(--w-bold); }
.daycard__theme { color: var(--ink-soft); }
.daycard__where { color: var(--ink-muted); font-size: var(--t-sm); }

.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-sunk); overflow: hidden; margin-top: var(--s-2); }
.progress__fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--tile-board); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

.stat {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--lift-sm);
  padding: var(--s-4); display: flex; flex-direction: column; gap: 2px;
}

.stat__icon { width: 24px; height: 24px; }
.stat__icon svg { width: 100%; height: 100%; }
.stat__icon--sun { color: var(--sun-deep); }
.stat__icon--cloud { color: var(--ocean); }
.stat__value { font-size: var(--t-xl); font-weight: var(--w-black); }
.stat__value--small { font-size: var(--t-base); }
.stat__label { font-size: var(--t-sm); color: var(--ink-muted); }

/* --- Tiles ---------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

.tile {
  position: relative;
  display: flex; flex-direction: column; gap: var(--s-1);
  min-height: 118px; padding: var(--s-4);
  border-radius: var(--r-lg);
  color: var(--ink-on-colour); text-decoration: none;
  box-shadow: var(--lift);
  transition: transform var(--fast) var(--ease-out);
}

.tile:active { transform: scale(.98); }
.tile--reflection { background: var(--tile-reflection); }
.tile--games      { background: var(--tile-games); }
.tile--battle     { background: var(--tile-battle); }
.tile--board      { background: var(--tile-board); }

.tile.is-disabled { opacity: .5; }
.tile.is-done { filter: saturate(.75); }

.tile__icon { width: 26px; height: 26px; }
.tile__icon svg { width: 100%; height: 100%; }
.tile__title { font-weight: var(--w-black); font-size: var(--t-base); margin-top: auto; }
.tile__sub { font-size: var(--t-sm); opacity: .92; }

.tile__go { position: absolute; top: var(--s-4); right: var(--s-3); width: 18px; height: 18px; opacity: .8; }
.tile__go svg { width: 100%; height: 100%; }

/* --- Screen headers ------------------------------------------------------- */

.screenhead { display: flex; align-items: center; gap: var(--s-3); }

.screenhead__back {
  display: grid; place-items: center; width: 44px; height: 44px; margin-left: calc(var(--s-3) * -1);
  color: var(--ink); text-decoration: none;
}

.screenhead__backicon { width: 22px; height: 22px; transform: rotate(180deg); }
.screenhead__backicon svg { width: 100%; height: 100%; }
.screenhead__title { font-size: var(--t-lg); font-weight: var(--w-black); }

.daystamp {
  font-size: var(--t-xs); font-weight: var(--w-black); letter-spacing: 1px;
  color: var(--ink-muted); text-transform: uppercase;
}

.reflection__heading { font-size: var(--t-2xl); font-weight: var(--w-black); }

.observation {
  background: var(--ocean-mist); border-radius: var(--r-lg);
  padding: var(--s-4); color: var(--ink-soft); line-height: var(--lh-loose);
}

/* --- Scripture ------------------------------------------------------------ */

.scripturecard {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-4); font: inherit; text-align: left; cursor: pointer;
  background: var(--surface); border: 0; border-left: 5px solid var(--sun);
  border-radius: var(--r-lg); box-shadow: var(--lift-sm); color: inherit;
}

.scripturecard--slim { padding: var(--s-3) var(--s-4); }
.scripturecard__icon { width: 26px; height: 26px; color: var(--sun-deep); flex: none; }
.scripturecard__icon svg { width: 100%; height: 100%; }
.scripturecard__text { display: flex; flex-direction: column; flex: 1; }
.scripturecard__ref { font-weight: var(--w-black); font-size: var(--t-lg); }
.scripturecard__cta { font-size: var(--t-sm); color: var(--ink-muted); }
.scripturecard__go { width: 18px; height: 18px; color: var(--ink-muted); flex: none; }
.scripturecard__go svg { width: 100%; height: 100%; }

/* --- Questions ------------------------------------------------------------ */

.questions__heading { font-size: var(--t-base); font-weight: var(--w-bold); color: var(--ink-soft); }
.questions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }

.question {
  display: flex; gap: var(--s-3); align-items: flex-start;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--lift-sm); padding: var(--s-4);
}

.question__number {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: var(--r-pill);
  background: var(--brand-blue); color: var(--ink-on-colour);
  font-weight: var(--w-black); font-size: var(--t-sm);
}

.question__text { line-height: var(--lh-loose); }

/* --- Answers -------------------------------------------------------------- */

.answer {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--lift-sm);
  padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3);
}

.answer__prompt { display: flex; gap: var(--s-3); align-items: flex-start; }
.answer__count { text-align: right; font-size: var(--t-xs); color: var(--ink-muted); }
.answer.is-submitted { background: var(--palm-mist); }

.answer__final {
  background: var(--surface); border-radius: var(--r);
  padding: var(--s-3) var(--s-4); line-height: var(--lh-loose); color: var(--ink-soft);
}

.savenote, .notice {
  display: flex; align-items: flex-start; gap: var(--s-2);
  font-size: var(--t-sm); color: var(--ink-muted);
  background: var(--surface-sunk); border-radius: var(--r);
  padding: var(--s-3) var(--s-4);
}

.notice--good { background: var(--palm-mist); color: var(--palm-deep); font-weight: var(--w-medium); }

.notice__icon, .savenote__icon { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.notice__icon svg, .savenote__icon svg { width: 100%; height: 100%; }

/* --- Modal ---------------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--gutter); }
.modal[hidden] { display: none; }

.modal__backdrop { position: absolute; inset: 0; background: rgba(10, 30, 50, .55); }

.modal__card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
  padding: var(--s-6) var(--s-5) var(--s-5);
  border-radius: var(--r-xl); box-shadow: var(--lift-lg);
  background: var(--surface);
  display: flex; flex-direction: column; gap: var(--s-3); align-items: center; text-align: center;
  animation: modal-in var(--normal) var(--ease-bounce);
}

.modal__card--parchment { background: var(--surface-parchment); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.modal__close {
  position: absolute; top: var(--s-3); right: var(--s-3);
  width: 40px; height: 40px; border: 0; border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .06); color: var(--ink);
  font-size: 24px; line-height: 1; cursor: pointer;
}

.modal__icon { width: 34px; height: 34px; color: var(--sun-deep); }
.modal__icon svg { width: 100%; height: 100%; }
.modal__title { font-size: var(--t-2xl); font-weight: var(--w-black); }
.modal__body { display: flex; flex-direction: column; gap: var(--s-3); }
.modal__verse { font-size: var(--t-lg); line-height: var(--lh-loose); font-style: italic; }
.modal__summary { color: var(--ink-soft); line-height: var(--lh-loose); }
.modal__actions { width: 100%; display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.modal__note { font-size: var(--t-xs); color: var(--ink-muted); }

/* --- Wider screens -------------------------------------------------------- */
/* The column stays phone-shaped; only the breathing room grows. A family
   adventure read on a laptop should still look like the thing on the phone. */

@media (min-width: 640px) {
  .page { padding-top: var(--s-5); }
  .tiles { gap: var(--s-4); }
}

/* --- Preview bar ----------------------------------------------------------
   Deliberately loud and deliberately not in the brand palette: it must read as
   scaffolding rather than as part of the adventure. Somebody who mistakes a
   preview for the real day answers tomorrow's questions today, and finds them
   already used when tomorrow comes. */

.previewbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--gutter);
  background: repeating-linear-gradient(
    45deg, #2b2b2b, #2b2b2b 12px, #3a3a3a 12px, #3a3a3a 24px);
  color: #ffd84a; text-decoration: none;
  font-size: var(--t-sm); font-weight: var(--w-bold);
}

.previewbar strong { letter-spacing: 1.5px; }
.previewbar__exit { margin-left: auto; opacity: .85; }

/* The preview day list needs a real select, not the code input's styling. */
select.input { appearance: none; background-image: none; }

/* Before the adventure starts this is the only thing an admin can do, so it
   is a real control rather than a footnote. */
.previewcta {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-4);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  text-decoration: none; color: var(--ink);
  background: var(--surface);
}

.previewcta__title { font-weight: var(--w-black); }
.previewcta__sub { font-size: var(--t-sm); color: var(--ink-muted); }

/* Not built yet. Flatter and greyer than merely locked, so it cannot be
   mistaken for something that would work if only you tapped harder. */
.tile.is-soon {
  background: var(--surface-sunk);
  color: var(--ink-muted);
  box-shadow: none;
  border: 1px solid var(--line);
}

.tile.is-soon .tile__icon { opacity: .5; }
