/*
 * Anonymous demo — the hub of three adventures, and the sign-in wall.
 *
 * The hub is the first thing an ad click sees, so it borrows the sign-in page's
 * antiquarian-manuscript idiom rather than inventing a second visual language:
 * parchment surface (see pages/sessions.css), Cinzel for display type, Lora
 * italic for prose, and the same brown palette. The wall is different — it
 * appears inside the dark game console, so it is styled for that surface below.
 */

/* ── Hub ────────────────────────────────────────────────────────────────── */

/*
 * The header is kept deliberately short. These cards are 9:16, so they are tall
 * by construction, and on an ad landing page three portraits below the fold are
 * three portraits nobody sees. Everything above them earns its height or goes.
 */
.demo-hub {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  text-align: center;
}

.demo-ornament {
  display: block;
  font-size: 1.6rem;
  color: #8a7354;
  letter-spacing: 0.3em;
  line-height: 1;
  opacity: 0.6;
  user-select: none;
  margin-bottom: 0.75rem;
}

.demo-logo {
  max-width: 190px;
  width: 55%;
  height: auto;
  margin-bottom: 0.9rem;
}

.demo-heading {
  font-family: 'Cinzel', 'Palatino Linotype', serif;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #3a2a14;
  margin: 0 0 0.6rem;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.5);
}

.demo-subtitle {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: #7a6548;
  max-width: 40rem;
  margin: 0 auto 1.6rem;
  line-height: 1.6;
}

.demo-resume { margin-bottom: 1.6rem; }

/* ── The three plates ───────────────────────────────────────────────────── */

.demo-cards {
  display: grid;
  /* The track minimum must stay under the width three columns actually get
     (~10.8rem), or auto-fit silently drops to two and the plates double in
     height. Note html is font-size: 125%, so 1rem is 20px here, not 16. */
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1.25rem;
  /* Sized so three 9:16 plates clear the fold on a laptop viewport. */
  max-width: 35rem;
  margin: 0 auto 1.75rem;
}

/* button_to wraps each card in a form; the form must add no layout of its own. */
.demo-cards form { margin: 0; display: block; }

/*
 * 9:16 because these hold character portraits. The aspect ratio is on the
 * button itself, so the caption overlays the portrait rather than sitting
 * beneath it — otherwise the card is 9:16 plus a text block and no longer
 * matches the art it was cut for.
 */
.demo-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  color: inherit;
  text-align: left;
  border: 1px solid rgba(138, 115, 84, 0.55);
  /* Image comes from an inline custom property, so a fourth demo needs no CSS. */
  background: var(--card-image) center / cover no-repeat, #cbb894;
  box-shadow: 0 1px 3px rgba(90, 60, 20, 0.18);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

@media (hover: hover) {
  .demo-card:hover {
    transform: translateY(-4px);
    border-color: #8a7354;
    box-shadow: 0 6px 18px rgba(90, 60, 20, 0.28);
  }
}

/* Warm rather than neutral black, so the portrait sits on parchment tones. */
.demo-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(28, 18, 8, 0.92) 0%,
    rgba(28, 18, 8, 0.72) 28%,
    rgba(28, 18, 8, 0.15) 55%,
    transparent 75%
  );
  transition: opacity 0.35s ease;
}

@media (hover: hover) {
  .demo-card:hover .demo-card-overlay { opacity: 0.88; }
}

.demo-card-content {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.1rem 1.15rem 1.25rem;
}

.demo-card-title {
  font-family: 'Cinzel', serif;
  /* Tuned so a two-word title sits on one line at the plate's width; longer
     ones wrap, which is fine. */
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f2e6cc;
  /* Insurance for a title that lands on a bright patch of portrait. */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.demo-card-tagline {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  line-height: 1.55;
  color: rgba(238, 224, 198, 0.88);
}

/* The cards already carry a bottom margin, so the shared divider's own 2rem
   would push the pitch a full screen away from what it is pitching against. */
.demo-hub .signin-divider { width: 40%; margin: 0.25rem auto 1.4rem; }

/* The pitch for an account: curated worlds are the demo, your own is the product. */
.demo-own-adventure {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.88rem;
  line-height: 1.7;
  color: #6a5540;
  max-width: 34rem;
  margin: 0 auto 1rem;
}

.demo-own-adventure-cta { margin: 0; }

/* ── The wall ───────────────────────────────────────────────────────────── */

/*
 * .console-panel is a bounded flex column with overflow:hidden, and #action-area
 * is an ordinary shrinkable item sized for the one-line action form. The wall is
 * several times taller, so it has to claim its height from the scrolling turn
 * log rather than be squeezed against the panel edge.
 */
.console-panel > #action-area:has(.demo-wall) { flex-shrink: 0; }

.demo-wall {
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--theme-accent, #8ab4a0);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.35);
  text-align: center;
}

.demo-wall-title {
  margin: 0 0 0.6rem;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.demo-wall-body {
  margin: 0 auto 1rem;
  max-width: 48ch;
  line-height: 1.6;
  opacity: 0.85;
}

.demo-wall-benefits {
  list-style: none;
  margin: 0 auto 1.25rem;
  padding: 0;
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* The same fleuron the landing page uses for its feature list. */
.demo-wall-benefits li::before {
  content: "❦";
  color: var(--theme-accent, #8ab4a0);
  margin-right: 0.6rem;
}

.demo-wall .google-btn {
  margin: 0 auto;
  background: rgba(138, 180, 160, 0.12);
  border-color: var(--theme-accent, #8ab4a0);
  box-shadow: none;
  color: var(--theme-text, #c8c8b4);
}

@media (hover: hover) {
  .demo-wall .google-btn:hover {
    background: rgba(138, 180, 160, 0.2);
    color: #fff;
  }
}

/*
 * The standalone wall page is the non-turbo fallback and renders on parchment,
 * not in the console — so the dark treatment above has to be undone.
 */
.demo-wall-screen {
  max-width: 34rem;
  margin: 0 auto;
  padding: 5rem 2rem;
}

.demo-wall-screen .demo-wall {
  border-color: rgba(138, 115, 84, 0.55);
  background: transparent;
  color: #5a4a30;
}

.demo-wall-screen .demo-wall-title { color: #3a2a14; }

/*
 * Inside the console the wall inherits the game's monospace, which is right
 * there. On parchment it has to read as the manuscript does.
 */
.demo-wall-screen .demo-wall-body,
.demo-wall-screen .demo-wall-benefits {
  font-family: 'Lora', Georgia, serif;
  line-height: 1.75;
  color: #5a4a30;
  opacity: 1;
}
.demo-wall-screen .demo-wall-benefits li::before { color: #a0895e; }

.demo-wall-screen .demo-wall .google-btn {
  background: rgba(210, 190, 155, 0.12);
  border-color: #a08058;
  color: #5a4a30;
}

@media (hover: hover) {
  .demo-wall-screen .demo-wall .google-btn:hover { color: #3a2a14; }
}

.demo-wall-back {
  margin-top: 1.5rem;
  text-align: center;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.demo-wall-back a { color: #6a5540; text-decoration: none; }
@media (hover: hover) {
  .demo-wall-back a:hover { color: #3a2a14; }
}

/* ── Demo chrome on the game screen ─────────────────────────────────────── */

/*
 * game/layout.css hides .app-nav on the game screen so the console fills the
 * viewport, and the demo nav goes with it. Its two parts live in the game's
 * top bar instead (games/show): the turns-left counter is what keeps the wall
 * from feeling like a bait-and-switch, and the sign-in link is the only route
 * to an account from inside the demo. Pushed right, so on a phone they sit
 * beside the menu button rather than over it.
 */
.game-topbar-demo {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  /* Longer languages on a narrow phone (German at 320px) wrap to two lines
     rather than pushing the menu button off the screen, which cannot scroll. */
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 0.2rem;
  margin-left: auto;
  margin-right: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--theme-text);
  background: color-mix(in srgb, var(--theme-bg) 70%, transparent);
  backdrop-filter: blur(2px);
  /* The bar lets clicks through to the story; this part takes them. */
  pointer-events: auto;
}

/* The logo and the menu button hold their size; the demo part gives way. */
.game-topbar:has(.game-topbar-demo) { gap: 0.5rem; }
.game-topbar:has(.game-topbar-demo) .game-topbar-home,
.game-topbar:has(.game-topbar-demo) .game-topbar-menu { flex-shrink: 0; }

/*
 * On a phone the counter and the way in fill the bar's first row, so the
 * hero's strip (games/_topbar_stats) takes a row of its own under the logo. A
 * grid, not flex-wrap: wrapping sent the whole counter, and at 320px the menu
 * button, onto rows of their own, where now the counter shrinks and breaks
 * inside its box. The story starts under both rows.
 */
@media (max-width: 768px) {
  .game-topbar:has(.game-topbar-demo) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "home demo menu" "stats stats stats";
    row-gap: 0.3rem;
  }
  .game-topbar:has(.game-topbar-demo) .game-topbar-home { grid-area: home; }
  .game-topbar:has(.game-topbar-demo) .game-topbar-demo { grid-area: demo; justify-self: end; }
  .game-topbar:has(.game-topbar-demo) .game-topbar-menu { grid-area: menu; }
  .game-topbar:has(.game-topbar-demo) .topbar-stats { grid-area: stats; justify-self: start; margin-left: 0; }
  body:has(.game-topbar-demo) .turn-log { padding-top: 4.75rem; }
  body:has(.game-topbar-demo) .console-panel::before { height: 5.5rem; }
}
/* Under 360px the counter breaks over two lines in Polish and German. */
@media (max-width: 359px) {
  body:has(.game-topbar-demo) .turn-log { padding-top: 6rem; }
  body:has(.game-topbar-demo) .console-panel::before { height: 6.5rem; }
}

/* Sized by the bar, which is smaller on a phone; elsewhere they keep their own. */
.game-topbar-demo .app-nav-demo-turns,
.game-topbar-demo .app-nav-demo-cta { font-size: inherit; }

/*
 * On a desktop the bar floats over the sidebar's top, so the sidebar starts
 * below it or the setting name reads with a chunk bitten out of it. On a phone
 * the sidebar is an overlay drawn over the bar, and needs no room for it.
 */
@media (min-width: 769px) {
  body:has(.game-topbar-demo) .right-panel { padding-top: 2.25rem; }
}

.app-nav-demo-turns { font-size: 0.85rem; opacity: 0.8; white-space: nowrap; }

.app-nav-demo-cta {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--theme-accent, #8ab4a0);
  border-radius: 3px;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .demo-hub { padding: 2rem 1.25rem 3rem; }
  .demo-heading { font-size: 1.15rem; }
  /* Two across rather than one: a single 9:16 card fills a phone screen. */
  .demo-cards { grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
  /* An odd last plate (three demos) sat alone under the left one. It takes
     the whole row at one column's width, centred. */
  .demo-cards > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 0.9rem) / 2);
  }
  .demo-card-title { font-size: 0.78rem; letter-spacing: 0.12em; }
  .demo-card-tagline { font-size: 0.72rem; }
  .game-topbar-demo { font-size: 0.72rem; gap: 0.45rem; padding: 0.25rem 0.45rem; }
}

/* ── Age and terms gate ── */
.demo-terms {
  max-width: 35rem;
  margin: 0 auto 1.1rem;
}
.demo-terms-label {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.55rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  line-height: 1.45;
  /* Parchment ink, like the heading and subtitle above it. --theme-text is the
     dark game theme's light grey and vanishes on this surface. */
  color: #5a4a30;
  cursor: pointer;
  text-align: left;
}
.demo-terms-label input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 0.2rem;
  width: 0.95rem;
  height: 0.95rem;
  accent-color: #5a4a30;
  cursor: pointer;
}
.demo-terms-label a {
  color: #3a2a14;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (hover: hover) {
  .demo-terms-label a:hover {
    color: #1f1608;
  }
}
/* The plates stay visible while closed — hiding them would leave a paid click
   looking at an empty page — but they read as unavailable and cannot be sent. */
.demo-card[aria-disabled="true"] {
  opacity: 0.55;
  filter: saturate(0.55);
}
/* A plate tapped before the tick: the box is what is missing, so point at it. */
.demo-terms.is-needed .demo-terms-label { outline: 1px solid #7a3a2a; outline-offset: 0.4rem; }
.demo-terms-needed {
  margin: 0.6rem 0 0;
  text-align: center;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: #7a3a2a;
}
.demo-terms-needed:empty { display: none; }
