/* The random adventure's setup page (games/setup: the steps, the world and
   hero as they are written, the stats) and the game details screen, in the
   parchment manuscript style. The setup form itself is a table of cards
   now (pages/random_cards.css). */

/* The parchment itself, the nav, flash messages and buttons: pages/parchment.css */

/* ── Header ── */
.setup-header {
  padding: 2.5rem 1rem 1.5rem;
  border-bottom: none;
  margin-bottom: 2rem;
  text-align: center;
  position: relative;
}
.setup-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    #a0895e 20%,
    #8a7354 50%,
    #a0895e 80%,
    transparent 100%
  );
  opacity: 0.5;
}
.setup-header h1 {
  font-family: 'Cinzel', 'Palatino Linotype', serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #3a2a14;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.5);
}
/* ZUFALLSABENTEUER is one word, wider than a 360px phone at full spacing. */
@media (max-width: 400px) {
  .setup-header h1 { font-size: 1.35rem; letter-spacing: 0.12em; overflow-wrap: anywhere; }
}
.setup-header p {
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  color: #7a6548;
  font-size: 0.88rem;
  margin-top: 0.5rem;
  letter-spacing: 0.04em;
}

/* ── Card ── */
.setup-card {
  border: 1px solid rgba(138, 115, 84, 0.3);
  padding: 1.5rem;
  background: rgba(239, 227, 205, 0.35);
  max-width: 640px;
  margin: 0 auto 1rem;
  animation: riseIn 0.8s ease-out both;
  /* riseIn leaves a transform in place (fill mode "both"), which makes
     this a stacking context — so a tooltip inside it cannot escape on its own
     z-index, and .site-footer's z-index: 1 would paint over it. */
  position: relative;
  z-index: 2;
}


/* ── Labels ──
   As on the other parchment pages: the quiet ink is --ink-muted (about 5:1; it was
   #9a8568, about 2.4:1), and tracked
   Cinzel capitals are 0.7rem at least. */
.setup-card label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.4rem;
}

/* ── Textarea ── */
.setup-card textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(255, 250, 240, 0.4);
  color: #3a2a14;
  border: 1px solid rgba(138, 115, 84, 0.35);
  padding: 0.75rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}
.setup-card textarea::placeholder {
  color: #b5a382;
  font-style: italic;
}
.setup-card textarea:focus {
  border-color: #8a7354;
}

/* ── Select ── */
.setup-card select {
  background: rgba(239, 227, 205, 0.5);
  color: #5a4a30;
  border: 1px solid rgba(138, 115, 84, 0.35);
  padding: 0.3rem 0.5rem;
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
}

/* ── Form row ── */
.setup-form-row {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.setup-form-row--end { justify-content: flex-end; }

/* ── Narrator style badge ── */
.narrator-style-badge {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(138, 115, 84, 0.2);
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  font-style: italic;
  color: #7a6548;
  line-height: 1.5;
}
.narrator-style-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-style: normal;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin-right: 0.3rem;
}

/* ── Generated preview ── */
/* Typography only: the .setup-card around it is the frame. It drew a second
   border, fill and padding inside the first, which on a phone cost ~380px
   and read as cards inside cards. */
.generated-preview h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: #3a2a14;
  margin-bottom: 0.5rem;
}
.generated-preview p {
  font-family: 'Lora', Georgia, serif;
  color: #7a6548;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-line;
}
.generated-preview .hero-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: #3a2a14;
}

/* Maintained by HeroConditionService — set apart from the frozen description
   above it so the two are not read as one paragraph. */
.generated-preview .hero-condition {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(138, 115, 84, 0.2);
}
.generated-preview .hero-condition strong {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 0.2rem;
}

/* ── Equipment list ── */
.equipment-list {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(138, 115, 84, 0.2);
}
.equipment-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.equipment-item {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  color: #7a6548;
  padding: 0.1rem 0;
}
.equipment-item .item-name { color: #3a2a14; }
.equipment-item .item-status { color: var(--ink-muted); font-style: italic; }

/* ── Stat allocator ── */
.hero-stats {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(138, 115, 84, 0.2);
}
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}
.stats-label {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.stats-points {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  color: #3a2a14;
}
/* Scoped: .stat-row/.stat-label/.stat-value are also used by the game sidebar's
   hero stat bar, where this parchment brown is unreadable on a dark theme.
   The story cards (.story-page) have no .setup-header, and a Hero card's
   allocator is the same one. */
body:is(:has(.setup-header), :has(.story-page)) .stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0;
}
body:is(:has(.setup-header), :has(.story-page)) .stat-row .stat-label {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.85rem;
  color: #3a2a14;
}
.stat-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.stat-btn {
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid rgba(138, 115, 84, 0.5);
  background: transparent;
  color: #3a2a14;
  font-size: 1rem;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
@media (hover: hover) {
  .stat-btn:hover:not(:disabled) { background: rgba(138, 115, 84, 0.15); }
}
.stat-btn:disabled { opacity: 0.3; cursor: not-allowed; }
body:is(:has(.setup-header), :has(.story-page)) .stat-value {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  color: #3a2a14;
  min-width: 1.5rem;
  text-align: center;
}

/* ── Tag badges (read-only, setup page) ── */
.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}
.tag-badge {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.72rem;
  color: #7a6548;
  background: rgba(138, 115, 84, 0.08);
  border: 1px solid rgba(138, 115, 84, 0.25);
  padding: 0.15rem 0.5rem;
  line-height: 1.3;
}

/* ── Progress indicator ── */
.setup-progress {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.setup-progress-step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: #b5a382;
  text-transform: uppercase;
}
.setup-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #b5a382;
  background: transparent;
  transition: all 0.3s ease;
}
.setup-progress-step.in-progress .setup-progress-dot {
  background: #c8a84e;
  border-color: #c8a84e;
  animation: progressPulse 1.2s ease-in-out infinite;
}
.setup-progress-step.in-progress {
  color: #7a6548;
}
.setup-progress-step.complete .setup-progress-dot {
  background: #6a8a60;
  border-color: #6a8a60;
}
.setup-progress-step.complete {
  color: #5a7a50;
}
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* On a phone the whole row does not fit — six labelled steps run off both
   edges, and a centred flex row clips them symmetrically, so the first and
   last step are half-gone. Collapse to dots, naming only the step being
   worked on; the coloured dots still carry where setup has got to. */
@media (max-width: 640px) {
  .setup-progress {
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
  }

  /* Only the running (or stopped) step's name is shown on a phone; the rest
     are kept for a screen reader, which display:none took away. */
  .setup-progress-step:not(.in-progress, .failed) > .setup-progress-name {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* The step a setup stopped on (games/_setup_failed), in the flash-alert ink. */
.setup-progress-step.failed .setup-progress-dot { background: #9a5a4a; border-color: #9a5a4a; }
.setup-progress-step.failed { color: #7a3a2a; }

/* A stopped setup: why, and the ways on. First on the page after the steps,
   so a phone sees it without scrolling. */
.setup-failed { border-color: rgba(154, 90, 74, 0.45); }
.setup-failed-reason { color: #7a3a2a; font-family: 'Lora', Georgia, serif; font-weight: 600; margin: 0 0 0.4rem; }
.setup-failed-note { margin: 0; font-family: 'Lora', Georgia, serif; font-size: 0.85rem; line-height: 1.6; color: #5a4a33; }
.setup-failed-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: 1rem 0 0.75rem; }
.setup-failed-actions form { margin: 0; }
.setup-error-message { color: #7a3a2a; font-family: 'Lora', Georgia, serif; }

/* The tags chosen for a random adventure: a line under the steps, not a card. */
.setup-tags { justify-content: center; max-width: 640px; margin: 0 auto 1rem; }
/* The card a line of tags was placed on, leading it; a setup from before the
   cards has one unnamed line. */
.setup-tags-card { align-self: center; margin-right: 0.2rem; font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-muted); }

/* The hero's picture on parchment, and a line rather than a frame when no
   picture is coming (games/_hero_portrait). A full-size frame stays while one
   is being drawn, so the image does not shift the page when it lands. */
.generated-preview .hero-portrait { background: rgba(138, 115, 84, 0.1); border-color: rgba(138, 115, 84, 0.5); }
.generated-preview .portrait-gallery, .generated-preview .portrait-actions { justify-content: center; }
.generated-preview .hero-portrait.is-empty {
  aspect-ratio: auto; max-width: none; margin: 0 0 0.5rem; padding: 0;
  border: 0; background: none; justify-content: flex-start; text-align: left;
}
@media (max-width: 640px) {
  .generated-preview .hero-portrait:not(.is-empty) { max-width: 200px; }
}

/* ── Start bar (games/setup) ──
   Pinned to the foot of the screen over the cards (z 3 to their 2), with the
   phone's safe area under it. Two groups, so a phone keeps it to one row:
   the ways back and aside on the left, Start (with its reminder) on the right. */
.setup-start-bar {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem;
  max-width: 640px; margin: 0 auto; box-sizing: border-box;
  padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
  background: var(--panel-header, #e6d8bd);
  border: 1px solid rgba(138, 115, 84, 0.45); border-bottom: 0;
  box-shadow: 0 -6px 14px rgba(58, 42, 20, 0.12);
}
.setup-start-bar-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1rem; min-width: 0; }
.setup-start-bar-go { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; flex-shrink: 0; }
.setup-start-bar .details-edit-link { font-size: 0.68rem; display: inline-flex; align-items: center; min-height: 2rem; }
.setup-start-bar .setup-points-hint { min-height: 0; font-size: 0.62rem; }
.setup-start-bar .setup-points-hint[hidden] { display: none; }
.setup-start-bar .setup-waiting-dots { display: inline-flex; align-items: center; min-width: 2.5rem; min-height: 2rem; }
@media (pointer: coarse) { .setup-start-bar :is(.btn, .details-edit-link:not(.setup-points-hint)) { min-height: 44px; } }
/* Keyboard focus and a jump to the allocator stop above the bar, not under it. */
html:has(.setup-start-bar) { scroll-padding-bottom: 5rem; }
