:root {
  color-scheme: dark;

  --background: #211410;
  --cream: #f0e3ce;
  --muted: #c5ad94;
  --gold: #d3ae72;
  --wine: #581c28;
  --line: #d3ae7233;

  /* Background texture settings. */
  --fine-leather-image: url("./assets/leather-grain.jpg");
  --fine-leather-size: 340px auto;
  --fine-leather-veil: rgba(33, 20, 16, 0.94);
}

/* ============================================================
   BASE
   ============================================================ */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--cream);
  background: var(--background) !important;
  font-family: Georgia, "Times New Roman", serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
}

::selection {
  background: var(--wine);
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 12px 18px;
  color: var(--background);
  background: var(--cream);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.wordmark,
.eyebrow,
nav,
.journey-controls,
.interaction-hint,
.footer-bottom,
.render-status {
  font-family: Arial, Helvetica, sans-serif;
}

.wordmark {
  text-decoration: none;
  color: var(--gold);
  font-size: 24px;
  letter-spacing: .32em;
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .25em;
  line-height: 1.7;
  color: var(--gold);
}

/* ============================================================
   HEADER AND SQUARE LOGO
   ============================================================ */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;

  padding: 23px 5vw;

  background: linear-gradient(
    #211410 30%,
    #211410ee 75%,
    transparent
  ) !important;

  border-bottom: 0 !important;
}

.site-header .header-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
}

.site-header .header-brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  object-fit: contain;
}

.site-header .header-brand-name {
  line-height: 1.15;
}

nav {
  display: flex;
  gap: clamp(14px, 3vw, 40px);
}

nav a {
  padding: 12px 0;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .13em;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}

nav a[aria-current="step"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ============================================================
   BOOK SCENE

   The interactive layout has FOUR rows:
   1. Compact introduction
   2. Book — receives the remaining height
   3. Chapter text
   4. Countdown and navigation

   The hint, status, announcement and progress indicator do not
   consume grid rows.
   ============================================================ */

.scene {
  position: relative;
  padding: 100px 36px 18px;

  background-color: #211410 !important;

  background-image:
    radial-gradient(
      ellipse at 50% 43%,
      #8a59352c,
      transparent 55%
    ),
    radial-gradient(
      ellipse at 90% 70%,
      #74253625,
      transparent 50%
    ),
    linear-gradient(
      var(--fine-leather-veil),
      var(--fine-leather-veil)
    ),
    var(--fine-leather-image) !important;

  background-size:
    auto,
    auto,
    auto,
    var(--fine-leather-size) !important;

  background-position:
    center,
    center,
    center,
    center top !important;

  background-repeat:
    no-repeat,
    no-repeat,
    no-repeat,
    repeat !important;
}

.enhanced .journey {
  height: 460svh;
}

.enhanced .scene {
  position: sticky;
  top: 0;
  height: 100svh;

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 6px;
}

.enhanced .introduction {
  grid-column: 1;
  grid-row: 1;
}

.enhanced .book-area {
  grid-column: 1;
  grid-row: 2;
}

.enhanced .stories {
  grid-column: 1;
  grid-row: 3;
}

.enhanced .journey-controls {
  grid-column: 1;
  grid-row: 4;
}

/* ============================================================
   SMALLER INTRODUCTION
   ============================================================ */

.introduction {
  min-width: 0;
  text-align: center;
}

.introduction .eyebrow {
  margin: 0 0 3px;
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  font-size: clamp(23px, 2.1vw, 32px);
  line-height: 1.15;
  font-weight: normal;
  letter-spacing: -.035em;
}

h1 em,
footer h2 em {
  color: var(--gold);
  font-weight: normal;
}

/* ============================================================
   CANVAS AND BOOK
   ============================================================ */

.book-area {
  position: relative;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: 400px;
  margin: 0 auto;
}

.enhanced .book-area {
  height: 100%;
  min-height: 0;
}

#canvas-host,
#canvas-host canvas,
.fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#canvas-host {
  opacity: 0;
  transition: opacity .7s;
}

#canvas-host canvas {
  display: block;
}

.has-3d #canvas-host {
  opacity: 1;
}

/*
 * experience-mode.css controls the initial loading visibility
 * and the manually selected fallback.
 */
.fallback {
  display: grid;
  place-items: center;
  transition: opacity .5s;
}

.has-3d .fallback {
  opacity: 0;
  pointer-events: none;
}

.fallback-cover {
  position: relative;
  height: 82%;
  max-height: 330px;
  aspect-ratio: .68;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 18px;

  color: var(--gold);
  border: 8px solid #461620;
  outline: 1px solid #9d6c3f;
  outline-offset: -17px;

  background:
    repeating-radial-gradient(
      circle at 20% 30%,
      #ffffff06 0 1px,
      transparent 2px 4px
    ),
    linear-gradient(
      110deg,
      #250d14,
      #6a2935 20%,
      #411620
    );

  box-shadow:
    12px 18px 35px #0007,
    5px 3px #b7a185;

  transform: rotate(-5deg);
}

.fallback-cover > span:first-child {
  font-size: 7px;
  letter-spacing: .15em;
}

.fallback-cover strong {
  font-size: 30px;
  font-weight: normal;
  letter-spacing: .12em;
}

.fallback-cover em {
  font-size: 15px;
  line-height: 1.6;
}

.fallback-ornament {
  font-size: 28px;
}

.book-hit-area {
  display: none;
  position: absolute;
  inset: 5% 15%;
  z-index: 2;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.enhanced .book-hit-area {
  display: block;
}

/*
 * Remove the decorative caption visually.
 * Its existing HTML can remain; no JavaScript depends on it.
 */
.book-caption {
  display: none;
}

/* ============================================================
   CHAPTER TEXT
   ============================================================ */

.stories {
  width: min(100%, 720px);
  min-width: 0;
  margin: 0 auto;
  text-align: center;
}

.story {
  padding: 20px 0;
  scroll-margin-top: 120px;
}

.enhanced .stories {
  display: grid;
}

.enhanced .story {
  grid-area: 1 / 1;
  padding: 0;
}

.story .eyebrow {
  margin: 0 0 7px;
}

.story h2 {
  margin: 0 0 7px;
  font-size: clamp(25px, 3vw, 34px);
  font-weight: normal;
  letter-spacing: -.025em;
}

.story > p:last-child {
  max-width: 680px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

/* ============================================================
   COUNTDOWN AND NAVIGATION
   ============================================================ */

.journey-controls {
  display: none;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;

  column-gap: 20px;
  row-gap: 2px;

  width: min(100%, 460px);
  margin-inline: auto;

  font-size: 10px;
  letter-spacing: .1em;
}

.enhanced .journey-controls {
  display: flex;
}

.journey-controls button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  padding: 10px;
  background: transparent;
  color: var(--gold);
}

.journey-controls button:disabled {
  opacity: .3;
  cursor: default;
}

.chapter-timer {
  flex: 0 0 100%;
  min-width: 0;
}

.timer-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .08em;
}

.journey-controls #toggle-autoplay {
  padding: 6px 0 6px 12px;
  min-height: 36px;
  font-size: 9px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.gold-gauge {
  position: relative;
  height: 15px;
  overflow: hidden;
  padding: 2px;
  border: 1px solid #99713d;
  border-radius: 999px;
  background: linear-gradient(180deg, #0f0806, #39251b);

  box-shadow:
    inset 0 2px 5px #000c,
    0 1px 0 #edcf9133,
    0 3px 12px #0004;
}

.gold-gauge-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left center;
  transition: none;

  background: linear-gradient(
    180deg,
    #fff1c0 0%,
    #eacb80 18%,
    #c79b4b 43%,
    #926023 55%,
    #c99743 78%,
    #f0d692 100%
  );

  box-shadow:
    inset 0 1px 0 #fff7dccc,
    inset 0 -1px 2px #684016,
    0 0 10px #dfb56566;
}

.gold-gauge-ticks {
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  pointer-events: none;

  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1px),
    #28170855 calc(10% - 1px),
    #28170855 10%
  );
}

.gold-gauge::after {
  content: "";
  position: absolute;
  inset: 1px 3px auto;
  height: 40%;
  border-radius: 999px;
  background: linear-gradient(#ffffff26, transparent);
  pointer-events: none;
}

/* ============================================================
   LEFT-SIDE AUTOPLAY HINT

   Absolutely positioned within the scene, not fixed to the
   browser. It leaves with the book stage when scrolling away.
   It occupies no grid row.
   ============================================================ */

.interaction-hint {
  margin: 0;
  text-align: center;
  font-size: 9px;
  line-height: 1.6;
  color: var(--muted);
  letter-spacing: .08em;
}

.enhanced #hint {
  position: absolute;
  z-index: 4;
  left: 10px;
  top: 50%;
  bottom: auto;
  right: auto;

  width: auto;
  max-height: 60%;
  margin: 0;

  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
  text-align: center;
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: .05em;

  /* The hint is informational, not an interaction target. */
  pointer-events: none;
}

/* On wide screens, use a small horizontal note in the left gutter. */
@media (min-width: 1200px) {
  html.enhanced:not([data-book-experience="static"]) .scene {
    padding-inline: 150px;
  }

  .enhanced #hint {
    left: 24px;
    width: 108px;
    max-height: none;

    writing-mode: horizontal-tb;
    transform: translateY(-50%);

    text-align: left;
    font-size: 10px;
    line-height: 1.8;
  }
}

/* ============================================================
   STATUS AND PROGRESS
   ============================================================ */

.render-status {
  position: absolute;
  bottom: 5px;
  right: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 8px;
}

.progress {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
}

/* ============================================================
   PRODUCT BACKGROUND
   Product layout remains supplied by enhancements.js.
   ============================================================ */

.actual-products {
  background-color: #211410 !important;

  background-image:
    radial-gradient(
      ellipse at 50% 0,
      #8a59351c,
      transparent 70%
    ),
    linear-gradient(
      var(--fine-leather-veil),
      var(--fine-leather-veil)
    ),
    var(--fine-leather-image) !important;

  background-size:
    auto,
    auto,
    var(--fine-leather-size) !important;

  background-position:
    center,
    center,
    center top !important;

  background-repeat:
    no-repeat,
    no-repeat,
    repeat !important;
}

/* ============================================================
   FOOTER
   ============================================================ */

footer {
  padding: 85px max(6vw, 24px) 30px;
  border-top: 1px solid var(--line);
  background: #170e0c !important;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 45px;
  padding-bottom: 60px;
}

footer h2 {
  font-size: clamp(30px, 4vw, 45px);
  font-weight: normal;
  line-height: 1.2;
}

footer p,
address {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  line-height: 1.9;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  color: var(--muted);
  font-size: 11px;
}

.policy-links {
  display: flex;
  gap: 22px;
}

.policy-links button {
  border: 0;
  padding: 10px 0;
  background: none;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 5px;
}

/* ============================================================
   POLICY DIALOG
   ============================================================ */

dialog {
  width: min(600px, calc(100% - 32px));
  max-height: 85svh;
  padding: clamp(24px, 5vw, 45px);
  color: var(--cream);
  background: #291a16;
  border: 1px solid var(--gold);
  box-shadow: 0 25px 100px #0009;
}

dialog::backdrop {
  background: #100a08dc;
  backdrop-filter: blur(6px);
}

dialog h2 {
  font-size: 30px;
  font-weight: normal;
}

dialog h3 {
  color: var(--gold);
  font-weight: normal;
}

dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.close-dialog {
  float: right;
  min-height: 44px;
  padding: 8px 12px;
  background: none;
  border: 1px solid var(--line);
}

.draft {
  padding-left: 14px;
  border-left: 2px solid var(--gold);
}

#policy-content a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 4px;
  overflow-wrap: anywhere;
}

#policy-content li {
  margin-block: 10px;
  color: var(--muted);
  line-height: 1.75;
}

#policy-content address {
  color: var(--muted);
  font-style: normal;
  line-height: 1.8;
}

#policy-content hr {
  margin: 30px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.website-disclaimer summary {
  padding-block: 12px;
  color: var(--gold);
  font-size: 18px;
  line-height: 1.5;
  cursor: pointer;
}

.website-disclaimer summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}

/* ============================================================
   SHORT-SCREEN BUTTON-CONTROLLED LAYOUT

   app.js applies .manual below its height threshold.
   Allow normal page scrolling instead of squeezing the book.
   ============================================================ */

.enhanced.manual .journey {
  height: auto;
}

.enhanced.manual .scene {
  position: relative;
  height: auto;
  min-height: 0;
  grid-template-rows: auto 320px auto auto;
}

/* ============================================================
   MOBILE HEADER AND TYPOGRAPHY
   ============================================================ */

@media (max-width: 600px) {
  .site-header {
    flex-direction: column;
    gap: 4px;
    padding: 15px 16px;
  }

  .wordmark {
    font-size: 20px;
  }

  .site-header .header-brand {
    gap: 9px;
  }

  .site-header .header-brand-logo {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  nav {
    width: 100%;
    justify-content: space-around;
    gap: 8px;
  }

  nav a {
    font-size: 9px;
    letter-spacing: .04em;
  }

  .scene {
    padding: 120px 30px 16px;
  }

  .introduction .eyebrow {
    font-size: 8px;
    letter-spacing: .12em;
    margin-bottom: 3px;
  }

  h1 {
    font-size: 23px;
    line-height: 1.15;
  }

  .story h2 {
    font-size: 25px;
  }

  .story > p:last-child {
    font-size: 13px;
    line-height: 1.6;
  }

  .story .eyebrow {
    font-size: 8px;
  }

  .enhanced #hint {
    left: 7px;
    font-size: 8px;
    letter-spacing: .02em;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* Compact typography when vertical room is limited. */
@media (max-height: 720px) and (min-height: 561px) {
  .introduction .eyebrow {
    margin-bottom: 2px;
  }

  h1 {
    font-size: 23px;
  }

  .story h2 {
    font-size: 24px;
    margin-bottom: 5px;
  }

  .story .eyebrow {
    margin-bottom: 5px;
  }

  .story > p:last-child {
    font-size: 12px;
    line-height: 1.5;
  }

  .enhanced .scene {
    gap: 4px;
  }
}

/* ============================================================
   SMALLER CHAPTER HEADINGS
   Scope these changes to the interactive presentation.
   ============================================================ */

html:not([data-book-experience="static"]) #stories .story h2 {
  margin-bottom: 5px;
  font-size: clamp(21px, 1.8vw, 26px);
  line-height: 1.15;
}

html:not([data-book-experience="static"]) #stories #heading-3 {
  font-size: clamp(20px, 1.6vw, 24px);
}

/* ============================================================
   COMPACT COUNTDOWN ROW

   Status | Gold progress bar | Pause/Resume

   Previous/next chapter controls remain on the row underneath.
   ============================================================ */

#scene .journey-controls {
  width: min(100%, 720px);
  min-width: 0;
  column-gap: 20px;
  row-gap: 0;
}

#scene .chapter-timer {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 2fr)
    minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;

  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  min-height: 44px;
}

#scene #timer-label {
  min-width: 0;
  margin: 0;

  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: .02em;
  text-align: left;

  /* Allow long loading or banner messages to wrap. */
  white-space: normal;
  overflow-wrap: anywhere;
}

#scene #chapter-gauge {
  width: 100%;
  min-width: 0;
  margin: 0;
}

#scene .journey-controls #toggle-autoplay {
  justify-self: stretch;
  min-width: 44px;
  min-height: 44px;
  padding: 6px 0 6px 4px;

  font-family: Arial, Helvetica, sans-serif;
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: .02em;
  text-align: right;

  white-space: normal;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Keep all three elements alongside each other on phones.
   Text can wrap instead of overflowing or being truncated. */
@media (max-width: 600px) {
  #scene .chapter-timer {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 1.2fr)
      minmax(0, 1fr);
    column-gap: 8px;
  }

  #scene #timer-label,
  #scene .journey-controls #toggle-autoplay {
    font-size: 10px;
    letter-spacing: 0;
  }
}