/* ---------- Base ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --flame-1: #fff6d8;
  --flame-2: #ffd56b;
  --flame-3: #ff9d2e;

  --ink: #dfe1e4;        /* main text */
  --ink-dim: #9aa0a8;    /* secondary text */
  --ink-faint: #6f747b;  /* tertiary text */
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.3);

  --paper: #eceae4;
  --paper-ink: #33343a;
}

html, body { height: 100%; }

/* Phones resize the viewport while hiding their toolbar mid-scroll; any
   sliver that peeks through must be night, never the engine's white. */
html { background: #0e0f12; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(130% 100% at 50% 0%, rgba(60, 64, 72, 0.25) 0%, rgba(60, 64, 72, 0) 55%),
    linear-gradient(to bottom, #0e0f12 0%, #15161a 55%, #1a1b20 100%);
}

/* ---------- Language switch ---------- */
/* Auto-detected on load; this is the quiet fallback. Top-left so it never
   meets the modals' top-right close buttons. Sits above the gate (z 100), and
   fades out whenever a full-screen layer is open — language is chosen before
   diving into a modal, not inside one. */
.lang-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 0.7rem);
  left: calc(env(safe-area-inset-left, 0px) + 0.8rem);
  z-index: 101;
  display: inline-flex;
  align-items: stretch;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 21, 26, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  transition: opacity 0.35s ease;
}
/* The sliding knob sits behind the labels and glides to the active side. */
.lang-knob {
  position: absolute;
  top: 2px; bottom: 2px; left: 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--flame-2);
  transition: transform 0.25s ease;
}
.lang-toggle[data-active="es"] .lang-knob { transform: translateX(100%); }
.lang-lbl {
  position: relative;   /* ride above the knob */
  z-index: 1;
  flex: 1 1 0;
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 5px 12px;
  color: var(--ink-faint);
  transition: color 0.2s ease;
}
.lang-toggle[data-active="en"] .lang-lbl[data-lang="en"],
.lang-toggle[data-active="es"] .lang-lbl[data-lang="es"] { color: #1a1b20; }
.lang-toggle:focus-visible { outline: 2px solid var(--flame-2); outline-offset: 2px; }

/* Hide it while any full-screen layer is up (modals, stairwell, placement). */
.lang-toggle.chrome-hidden, .simple-toggle.chrome-hidden { opacity: 0; pointer-events: none; }

/* ---------- Simple mode ---------- */
/* The pill, under the language switch — labelled, because the person who
   needs it will never find a gear icon. */
.simple-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 3.4rem);
  left: calc(env(safe-area-inset-left, 0px) + 0.8rem);
  z-index: 101;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 21, 26, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink-dim);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.35s ease, background 0.2s ease, color 0.2s ease;
}
.simple-toggle.active { background: #d6bd7e; border-color: #d6bd7e; color: #1a1b20; }

/* the vigil keeps its candles — the flames just hold still (also the old-phone
   performance win) */
body.simple #candle-field .flame,
body.simple #candle-field .glow { animation-play-state: paused; }

/* lighting a candle: the match steps aside; tap-to-light is the way */
body.simple .strike-area, body.simple .strike-hint { display: none; }
body.simple .simple-light {
  display: inline-block;
  background: #d6bd7e;
  color: #1a1b20;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.6rem;
  font-size: 1.05rem;
  font-style: normal;
  font-family: inherit;
  cursor: pointer;
  opacity: 1;                 /* no waiting for the .shown timer — it IS the way */
  pointer-events: auto;
}
body.simple .simple-light:hover { background: #e2cd93; color: #1a1b20; }

/* the album is a wall, so the book's nav has nothing to do */
body.simple .book-nav { display: none; }

/* the reading page: every letter open, on paper, floating on the night —
   the same .night/.bare shell as the album (modals.css); the list scrolls
   in its own box exactly like the album's simple wall */
.modal.reading { width: min(600px, 94vw); }
.reading-list {
  display: flex; flex-direction: column; gap: 1rem;
  max-height: 86vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.reading-entry {
  background: #efeae0;
  color: #262523;
  border-radius: 8px;
  padding: 1rem 1.1rem 0.9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.reading-media { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.7rem; }
.reading-media img, .reading-media video { width: 100%; border-radius: 4px; display: block; }
.reading-entry .vmsg.on-paper { margin: 0.4rem 0 0.6rem; }
.reading-text { white-space: pre-wrap; line-height: 1.55; font-size: 1.02rem; }
.reading-trans { display: block; font-size: 0.7rem; color: #8a6d2a; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.reading-from { margin-top: 0.55rem; color: #6d675c; font-style: italic; font-size: 0.9rem; }

/* the simple photo wall */
.simple-wall {
  display: flex;
  gap: 10px;
  width: min(640px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.wall-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.wall-photo {
  display: block; width: 100%;
  border: 0; padding: 0; background: none; cursor: pointer; position: relative;
}
.wall-photo img, .wall-photo .vstill img, .wall-photo .vstill video {
  width: 100%; height: auto; border-radius: 6px; display: block;
}
.wall-photo .play-badge {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: rgba(240, 242, 245, 0.92);
  background: rgba(0, 0, 0, 0.22); border-radius: 6px;
  pointer-events: none;
}

/* ---------- Private-page gate ---------- */
#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(130% 100% at 50% 0%, rgba(60, 64, 72, 0.25) 0%, rgba(60, 64, 72, 0) 55%),
    linear-gradient(to bottom, #0e0f12 0%, #15161a 55%, #1a1b20 100%);
  transition: opacity 0.7s ease;
}

#gate.unlocking { opacity: 0; pointer-events: none; }

.gate-card {
  width: min(340px, 92vw);
  text-align: center;
}

.gate-candle {
  position: relative;
  width: 30px;
  margin: 0 auto 2.2rem;
}

.gate-title {
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.gate-sub {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-dim);
  margin-bottom: 1.3rem;
}

#gate-input {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.7rem;
}

#gate-input:focus {
  outline: none;
  border-color: #b9bcc0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

#gate-input.gate-shake { animation: shake 0.32s ease; }

.gate-err {
  margin-top: 0.9rem;
  font-size: 0.82rem;
  font-style: italic;
  color: #c98a7a;
}

