/* Histia 2.0 homepage. Loaded on the homepage only, after styles.css.
 *
 * The page follows the app: the story is watched in the dark (the theatre),
 * the notebook is read in daylight (the vellum). The hero is a real lesson the
 * visitor can play, built from the app's own plates, questions and notes; the
 * rest walks through one lesson with native 2.0 captures.
 *
 * Performance: no framework, no video. Images are WebP at two widths with
 * fixed aspect ratios (no layout shift); only the first plate is fetched
 * eagerly. Motion stops with prefers-reduced-motion. */

@font-face {
  font-family: "Caveat";
  src: url("./assets/fonts/caveat-semibold-latin.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --night: #15100c;
  --night-2: #241a12;
  --cream: #f6f1e7;
  --vellum: #f4ecdc;
  --vellum-deep: #e9dec7;
  --gold-hi: #f3dca8;
  --gold-lo: #c9954a;
  --ink-hand: #2b2118;
  --green: #2f4b3a;
  --green-soft: #e3ecdf;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
}

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

.gold {
  font-style: italic;
  background: linear-gradient(180deg, var(--gold-hi) 0%, #e2b96b 55%, var(--gold-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}

/* ---------- Hero: the theatre ---------- */
.v2-hero {
  position: relative;
  overflow: hidden;
  color: var(--cream);
  background:
    radial-gradient(60% 70% at 72% 38%, rgba(196, 140, 72, 0.22) 0%, rgba(196, 140, 72, 0) 70%),
    radial-gradient(120% 90% at 50% 0%, #2c2016 0%, var(--night) 62%);
}
.v2-hero::after { /* film grain, a few hundred bytes of SVG */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.v2-hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 34px;
  padding: 34px 0 54px;
}
.v2-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid rgba(243, 220, 168, 0.35);
  border-radius: 999px;
  font-size: 0.86rem;
  color: rgba(246, 241, 231, 0.86);
  margin-bottom: 18px;
}
.v2-badge b {
  font-weight: 700;
  background: var(--gold-hi);
  color: var(--night);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.78rem;
}
.v2-hero h1 {
  font-size: clamp(2.5rem, 7.2vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin-bottom: 18px;
  color: var(--cream);
}
.v2-hero .lead {
  font-size: 1.12rem;
  line-height: 1.6;
  color: rgba(246, 241, 231, 0.8);
  max-width: 33rem;
  margin-bottom: 24px;
}
.v2-hero .hero-actions { margin-bottom: 14px; }
.v2-hero .cta { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); }
.v2-hero .secondary-link { color: var(--gold-hi); }
.v2-hero .store-note { color: rgba(246, 241, 231, 0.66); }
.v2-hero .store-note a { color: rgba(246, 241, 231, 0.8); }
.v2-hero .bf-promo { background: rgba(246, 241, 231, 0.08); color: var(--cream); border-color: rgba(243, 220, 168, 0.3); }
.v2-hero .store-qr { display: none; }
.v2-hero .store-qr figcaption { color: rgba(246, 241, 231, 0.6); }

/* The stage: a plate, its brass counter, and the lesson card. */
.lesson-stage {
  position: relative;
  width: min(100%, 520px);
  margin: 0 auto 56px;
}
.plate {
  position: relative;
  aspect-ratio: 4 / 3; /* a band on phones; square beside the card on wide screens */
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: #2a2017;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(243, 220, 168, 0.18);
}
.plate img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1.1s ease, transform 9s linear;
}
.plate img.is-on { opacity: 1; transform: scale(1); }
.plate::after { /* vignette, like the theatre */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 90% at 50% 45%, transparent 55%, rgba(10, 7, 4, 0.55) 100%);
  pointer-events: none;
}
.counter {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.counter-digits { display: flex; gap: 3px; padding: 4px; border-radius: 5px; background: #2a1f15; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #b98d4f; }
.counter-digits span {
  display: inline-block;
  width: 1.15em;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.35;
  color: #2a1f15;
  background: linear-gradient(180deg, #fbf3df, #e8d8b4);
  border-radius: 3px;
}
.counter-digits span.roll { animation: roll 0.55s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes roll { from { transform: translateY(-60%); opacity: 0; } to { transform: none; opacity: 1; } }
.counter-place {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.02rem;
  color: var(--gold-hi);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

/* On phones the card sits under the plate, in the flow, overlapping it a
 * little. Its height is reserved for the longest question and the note, so
 * neither answering nor the next story moves the page (no layout shift). */
.lesson-card {
  position: relative;
  z-index: 3;
  margin: -48px 3% 0;
  min-height: 452px;
  padding: 20px 20px 18px;
  border-radius: 8px;
  background: var(--vellum);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.lesson-card .kicker {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.92rem;
  color: #8c2a1e;
  margin-bottom: 6px;
}
.lesson-card h2 {
  font-size: 1.32rem;
  line-height: 1.22;
  margin-bottom: 4px;
}
.lesson-card .sub { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 12px; }
.options { display: grid; gap: 7px; }
.option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  text-align: left;
  font: inherit;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--vellum-deep);
  border: 1px solid rgba(35, 28, 18, 0.1);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.3s, transform 0.15s;
}
.option:hover { background: #e2d4b8; }
.option:active { transform: scale(0.99); }
.option:focus-visible { outline: 2px solid #8c2a1e; outline-offset: 2px; }
.lesson-card.is-answered .option { cursor: default; opacity: 0.45; }
.lesson-card.is-answered .option.is-right { opacity: 1; background: var(--green-soft); border-color: rgba(47, 75, 58, 0.55); color: var(--green); }
.lesson-card.is-answered .option.is-right::before { content: "✓"; font-weight: 700; }
.lesson-card.is-answered .option.is-picked:not(.is-right) { opacity: 0.7; text-decoration: line-through; text-decoration-color: rgba(140, 42, 30, 0.6); }

/* The note's place is ruled from the start, like a notebook page waiting for
 * ink: the answer writes into it instead of pushing the card open. */
.note {
  position: relative;
  margin-top: 12px;
  padding-top: 10px;
  min-height: 112px;
  border-top: 1px solid rgba(35, 28, 18, 0.12);
  background: repeating-linear-gradient(180deg, transparent 0 33px, rgba(35, 28, 18, 0.1) 33px 34px);
  background-position: 0 36px; /* rules sit under the handwritten lines (34px each) */
}
.note .reveal-line, .note .kept { opacity: 0; transition: opacity 0.4s; }
.lesson-card.is-answered .note .reveal-line, .lesson-card.is-answered .note .kept { opacity: 1; }
.note .reveal-line { font-size: 0.86rem; line-height: 22px; color: var(--green); font-weight: 600; margin-bottom: 4px; }
.note .hand {
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1.42rem;
  line-height: 34px;
  color: var(--ink-hand);
  padding-right: 64px;
  /* the ink is written left to right */
  clip-path: inset(0 100% 0 0);
}
.lesson-card.is-answered .note .hand { animation: write 1.6s 0.25s steps(28, end) forwards; }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
.note .kept { font-family: var(--font-display); font-style: italic; font-size: 0.85rem; color: var(--ink-soft); margin-top: 4px; }
.stamp {
  position: absolute;
  right: -4px;
  bottom: -2px;
  width: 74px;
  height: 74px;
  border: 2px solid rgba(160, 52, 40, 0.72);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(160, 52, 40, 0.8);
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: rotate(-14deg) scale(1.6);
  opacity: 0;
}
.stamp::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(160, 52, 40, 0.5); border-radius: 50%; }
.lesson-card.is-answered .stamp { animation: stamp 0.35s 1.75s cubic-bezier(.3, 1.6, .5, 1) forwards; }
@keyframes stamp { to { transform: rotate(-14deg) scale(1); opacity: 1; } }

.stage-nav {
  position: relative;
  z-index: 4;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stage-dots { display: flex; gap: 8px; }
.stage-dots button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.stage-dots button::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(246, 241, 231, 0.3); transition: background 0.3s, transform 0.3s; }
.stage-dots button[aria-current="true"]::before { background: var(--gold-hi); transform: scale(1.25); }
.stage-next {
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--gold-hi);
  background: none;
  border: 1px solid rgba(243, 220, 168, 0.35);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}
.stage-next:hover { background: rgba(243, 220, 168, 0.1); }
.stage-caption { font-size: 0.8rem; color: rgba(246, 241, 231, 0.55); }

@media (min-width: 960px) {
  .v2-hero-grid { grid-template-columns: 0.95fr 1.05fr; align-items: center; gap: 56px; padding: 70px 0 110px; }
  .v2-hero .store-qr { display: flex; }
  .lesson-stage { width: 100%; max-width: 580px; margin: 0 0 0 auto; min-height: 520px; }
  .plate { width: 72%; aspect-ratio: 1; }
  .lesson-card { position: absolute; margin: 0; top: 50%; right: 0; width: 60%; min-height: 430px; transform: translateY(-46%); }
  .stage-nav { position: absolute; left: 0; right: 0; bottom: -56px; margin: 0; }
}
@media (max-width: 420px) {
  .lesson-card { margin: -40px 2% 0; padding: 16px 15px 14px; min-height: 528px; }
  .lesson-card h2 { font-size: 1.16rem; }
}

/* ---------- One lesson, played ---------- */
.v2-play { background: var(--vellum); padding: 88px 0 70px; }
.v2-play .section-head h2, .v2-notebook h2, .v2-world h2, .v2-devices h2 { font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.08; letter-spacing: -0.01em; }
.v2-play .gold, .v2-notebook .gold, .v2-devices .gold { background: linear-gradient(180deg, #b6822f, #8a5a1c); -webkit-background-clip: text; background-clip: text; }
.play-grid { display: grid; gap: 40px; }
.play-phone { display: none; }
.play-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 64px; }
.play-step { display: grid; gap: 18px; }
.play-step .num { font-family: var(--font-display); font-style: italic; color: #8c2a1e; font-size: 1.02rem; margin-bottom: 4px; }
.play-step h3 { font-size: clamp(1.45rem, 3vw, 1.9rem); line-height: 1.15; margin-bottom: 8px; }
.play-step p { color: var(--ink-soft); font-size: 1.04rem; max-width: 30rem; }
.mini-phone {
  width: min(78%, 300px);
  margin: 0 auto;
  aspect-ratio: 1320 / 2868;
  border-radius: 36px;
  padding: 9px;
  background: #1d1712;
  box-shadow: 0 24px 50px rgba(35, 28, 18, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.mini-phone img { width: 100%; height: 100%; object-fit: cover; border-radius: 28px; display: block; }

@media (min-width: 960px) {
  .play-grid { grid-template-columns: 420px 1fr; gap: 72px; align-items: start; }
  .play-phone {
    display: block;
    position: sticky;
    top: 92px;
    height: min(80vh, 760px);
    aspect-ratio: 1320 / 2868;
    margin: 0 auto;
    border-radius: 48px;
    padding: 11px;
    background: #1d1712;
    box-shadow: 0 40px 80px rgba(35, 28, 18, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  .play-phone .screens { position: relative; width: 100%; height: 100%; border-radius: 38px; overflow: hidden; background: #efe6d3; }
  .play-phone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s ease; }
  .play-phone img.is-on { opacity: 1; }
  .play-steps { gap: 0; }
  .play-step { min-height: 72vh; align-content: center; }
  .play-step .mini-phone { display: none; }
  .play-step { opacity: 0.35; transition: opacity 0.4s; }
  .play-step.is-on { opacity: 1; }
}

/* ---------- Notebook: ink that fades ---------- */
.v2-notebook { padding: 90px 0; background: linear-gradient(180deg, var(--vellum) 0%, #efe4cd 100%); }
.notebook-grid { display: grid; gap: 40px; align-items: center; }
.notebook-copy p { color: var(--ink-soft); font-size: 1.06rem; max-width: 32rem; margin-top: 12px; }
.fade-card {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  padding: 26px 26px 22px;
  background: #fbf6ea;
  border-radius: 8px;
  box-shadow: 0 26px 60px rgba(35, 28, 18, 0.18);
  transform: rotate(-1.2deg);
}
.fade-card .tag { font-family: var(--font-display); font-style: italic; font-size: 0.9rem; color: #8c2a1e; margin-bottom: 10px; }
.fade-line {
  font-family: var(--hand);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.32;
  color: var(--ink-hand);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(35, 28, 18, 0.12);
  margin-bottom: 8px;
  transition: opacity 0.9s ease, filter 0.9s ease;
}
.fade-card[data-ink="2"] .fade-line { opacity: 0.55; filter: blur(0.4px); }
.fade-card[data-ink="1"] .fade-line { opacity: 0.25; filter: blur(0.9px); }
.fade-card[data-ink="0"] .fade-line { opacity: 0.1; filter: blur(1.4px); }
.fade-card .stamp { position: absolute; right: 18px; bottom: 54px; }
.fade-card.is-engraved .stamp { animation: stamp 0.35s cubic-bezier(.3, 1.6, .5, 1) forwards; }
.fade-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.fade-controls button {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--cream);
}
.fade-controls button:hover { background: #3a2e20; }
.fade-controls small { color: var(--ink-soft); }
.schedule { display: flex; align-items: center; gap: 10px; margin-top: 22px; font-size: 0.86rem; color: var(--ink-soft); }
.schedule i { flex: 1; height: 2px; background: repeating-linear-gradient(90deg, rgba(35, 28, 18, 0.35) 0 10px, transparent 10px 18px); }
.widgets-line { margin-top: 22px; padding: 14px 16px; border-left: 3px solid var(--brass); background: rgba(255, 255, 255, 0.45); border-radius: 0 6px 6px 0; font-size: 0.98rem; color: var(--ink-soft); }
@media (min-width: 960px) { .notebook-grid { grid-template-columns: 1fr 1fr; gap: 70px; } }

/* ---------- Map and threads ---------- */
.v2-world { padding: 90px 0 60px; background: #1f3f4a; color: var(--cream); }
.v2-world .section-head p { color: rgba(246, 241, 231, 0.75); }
.world-grid { display: grid; gap: 54px; }
.world-card { display: grid; gap: 26px; align-items: center; }
.world-card h3 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.15; margin-bottom: 10px; color: var(--cream); }
.world-card p { color: rgba(246, 241, 231, 0.78); font-size: 1.04rem; max-width: 30rem; }
.world-card .mini-phone { background: #0f2329; }
.vehicles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding: 0; list-style: none; }
.vehicles li { padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(243, 220, 168, 0.35); color: var(--gold-hi); font-family: var(--font-display); font-style: italic; font-size: 0.98rem; }
.v2-world .text-link { color: var(--gold-hi); display: inline-block; margin-top: 16px; }
.season {
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(176, 56, 42, 0.22);
  border: 1px solid rgba(243, 220, 168, 0.25);
  font-size: 0.96rem;
  color: var(--cream);
}
.season b { color: var(--gold-hi); font-family: var(--font-display); font-style: italic; font-weight: 600; font-size: 1.05rem; }
@media (min-width: 960px) {
  .world-grid { grid-template-columns: 1fr 1fr; gap: 60px; }
  .world-card { grid-template-columns: 240px 1fr; }
}
.v2-world .era-band { margin-top: 64px; background: transparent; border-top: 1px solid rgba(243, 220, 168, 0.2); border-bottom: 0; }

/* ---------- Every screen ---------- */
.v2-devices { padding: 90px 0 30px; background: var(--paper); }
.devices-row { display: grid; gap: 22px; align-items: end; margin-top: 10px; }
.devices-row figure { margin: 0; }
.devices-row img { width: 100%; height: auto; border-radius: 14px; box-shadow: 0 22px 50px rgba(35, 28, 18, 0.2); }
.devices-row figcaption { text-align: center; font-size: 0.9rem; color: var(--ink-soft); margin-top: 12px; }
.devices-row { max-width: 820px; margin-left: auto; margin-right: auto; }
@media (min-width: 760px) { .devices-row { grid-template-columns: 1.15fr 1fr; gap: 34px; } }

/* App Store screenshots, 2.0 */
#screenshots .shot img { border: 0; border-radius: 22px; }

@media (prefers-reduced-motion: reduce) {
  .plate img { transition: opacity 0.3s; transform: none; }
  .plate img.is-on { transform: none; }
  .counter-digits span.roll { animation: none; }
  .lesson-card.is-answered .note .hand { animation: none; clip-path: none; }
  .lesson-card.is-answered .stamp, .fade-card.is-engraved .stamp { animation: none; opacity: 1; transform: rotate(-14deg); }
  .play-step { opacity: 1; }
}
