/* Illustrated campaign story scene (views/story/storyPartial.jsx).
 *
 * The studio's own stylesheet is page-level — it restyles :root and body for
 * its standalone viewer — so the game owns the look here instead of vendoring
 * it. Every rule is scoped under #story-scene, and the player's element ids
 * are namespaced (cwl-story-*), so nothing leaks either way. */

#story-scene {
  --story-gold: #d6b875;
  --story-ink: #eee9dc;
  --story-muted: #92988a;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  color: var(--story-ink);
}

#story-scene .story-player {
  position: relative;
  border: 1px solid #c7b88640;
  border-radius: 10px;
  overflow: hidden;
  background: #10140f;
  box-shadow: 0 20px 70px #0006;
}

#story-scene .stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1f281d;
  /* Tapping the picture advances a panel (see public/story/vendor/story-player.js). */
  cursor: pointer;
}

#story-scene #cwl-story-pictures,
#story-scene #cwl-story-effects,
#story-scene .vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#story-scene #cwl-story-pictures img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.85s;
  will-change: transform;
  transform-origin: center;
}
#story-scene #cwl-story-pictures img.active { opacity: 1; }
#story-scene #cwl-story-effects { z-index: 2; }
#story-scene .vignette {
  z-index: 3;
  background: linear-gradient(0deg, #090e0bed 0%, #090e0b85 19%, transparent 49%, #0c120d45 100%);
}

#story-scene .panel-tag {
  position: absolute;
  z-index: 4;
  top: 20px;
  left: 22px;
  right: 22px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 9px;
  letter-spacing: 2px;
  text-shadow: 0 1px 5px #000;
}
#story-scene .panel-tag span {
  padding: 7px 10px;
  background: #101b13a6;
  border: 1px solid #ffffff21;
}
/* Two states the player puts on the stage that the game owns the look of (the
   studio's own rules live in its page-level scene-navigation.css, which is
   deliberately not vendored — see scripts/import-story.js).

   `silent` is a panel with no dialogue at all: chapter 6's closing beat, where
   the warlock resumes his work. The caption is already hidden inline by the
   player; the location tag has to go with it or the panel is not silent, it
   just has nothing to say.

   `blackout` is the hold on black that ends the campaign (panel.blackoutAt).
   The player fades the artwork and canvas out inline, so without a black stage
   behind them the hold lands on the stage's olive placeholder with the tag and
   vignette still painted over it. */
#story-scene .stage.story-silent .panel-tag {
  visibility: hidden;
}

#story-scene .stage.story-blackout {
  background: #000;
}

#story-scene .stage.story-blackout .panel-tag,
#story-scene .stage.story-blackout .vignette {
  visibility: hidden;
}

/* The skip control sits under the tag row so it never covers a caption. */
#story-scene .story-skip {
  position: absolute;
  z-index: 6;
  top: 52px;
  right: 22px;
  padding: 8px 13px;
  font-size: 11px;
  letter-spacing: 0.4px;
  color: #dfe4d8;
  background: #101b13c4;
  border: 1px solid #ffffff2e;
  border-radius: 6px;
  cursor: pointer;
}
#story-scene .story-skip:hover { background: #1b2a1ee0; border-color: var(--story-gold); color: var(--story-gold); }

#story-scene .caption {
  position: absolute;
  z-index: 4;
  bottom: 26px;
  left: 30px;
  right: 30px;
  max-width: 900px;
  --speaker-accent: var(--story-gold);
}
#story-scene .dialogue {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 19px 15px 14px;
  background: #0b1415eb;
  border: 1px solid #ffffff2e;
  border-left: 4px solid var(--speaker-accent);
  border-radius: 9px;
  box-shadow: 0 5px 24px #0005;
}
#story-scene .speaker-portrait {
  width: 70px;
  height: 70px;
  flex: 0 0 70px;
  border: 2px solid var(--speaker-accent);
  border-radius: 50%;
  background-repeat: no-repeat;
  background-color: #263326;
}
#story-scene .speaker-portrait[hidden] { display: none; }
/* A cue with no speaker and no line is narration on its own; the player
   hides the heading and the line for it, and the display rules below
   would otherwise beat the UA [hidden] rule. */
#story-scene .speaker-heading[hidden],
#story-scene .dialogue h2[hidden],
#story-scene .dialogue[hidden] { display: none !important; }
#story-scene .dialogue-copy { min-width: 0; }
#story-scene .speaker-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  margin-bottom: 6px;
}
#story-scene #cwl-story-speaker {
  color: var(--speaker-accent);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin: 0;
}
#story-scene #cwl-story-speaker-role { color: #c0c8c5; font-size: 11px; }
#story-scene .dialogue h2 {
  font: normal clamp(19px, 2.1vw, 29px)/1.28 Georgia, serif;
  margin: 0;
  text-shadow: 0 2px 8px #000;
}
#story-scene .narration-caption {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 11px 4px 0;
  text-shadow: 0 1px 4px #000;
}
#story-scene .narration-label {
  font-size: 10px;
  color: #b0bdb3;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#story-scene #cwl-story-narration { color: #e3e8df; font-size: 13px; line-height: 1.6; }

#story-scene .transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  min-height: 60px;
}
#story-scene .transport button {
  font: inherit;
  font-size: 13px;
  color: var(--story-ink);
  cursor: pointer;
  border: 1px solid #ffffff24;
  background: transparent;
  border-radius: 5px;
  padding: 7px 11px;
}
#story-scene .transport button:hover { background: #ffffff0c; border-color: #d6b87580; }
#story-scene .transport button:disabled { opacity: 0.25; cursor: default; }
#story-scene .transport button[aria-pressed="true"] { color: var(--story-gold); border-color: var(--story-gold); }
#story-scene .transport .play {
  background: var(--story-gold);
  color: #1b2116;
  border-color: var(--story-gold);
  min-width: 74px;
  font-weight: 600;
}
#story-scene .progress { height: 3px; flex: 1; background: #ffffff1a; margin: 0 8px; }
#story-scene .progress > div { background: var(--story-gold); height: 100%; width: 0; }
#story-scene #cwl-story-time {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--story-muted);
  min-width: 46px;
}
#story-scene .story-motion { font-size: 11px; color: var(--story-muted); }

#story-scene .briefing {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 26px;
  padding: 26px 32px 30px;
  border-top: 1px solid #d6b87555;
  background: #d6b8750b;
}
#story-scene .briefing[hidden] { display: none; }
#story-scene .briefing .eyebrow {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--story-gold);
  margin: 0 0 10px;
}
#story-scene .briefing h3 { font: normal 28px Georgia, serif; margin: 0 0 12px; }
#story-scene .briefing p,
#story-scene .briefing li { font-size: 13px; line-height: 1.7; color: #cbd1c0; }
#story-scene .briefing ol { margin: 0; padding-left: 20px; }
#story-scene .briefing li { padding: 3px 0 3px 5px; }
#story-scene .briefing li::marker { color: var(--story-gold); }
#story-scene .briefing .brief-tip { font-size: 11px; color: var(--story-gold); margin-bottom: 0; }
#story-scene .story-cta { margin-top: 18px; }
#story-scene .story-cta .campaign-btn-play { width: 100%; }

#story-scene .story-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #1f281d;
  display: grid;
  place-items: center;
  color: var(--story-gold);
  font-size: 13px;
}
#story-scene .story-loading[hidden] { display: none; }

/* Reduced motion is a player state, not only an OS preference: it drops the
   camera push, crossfades, shake and particles but keeps the narrative. */
.reduced-motion #story-scene #cwl-story-pictures img { transition: none !important; }

#story-scene .story-player:fullscreen { display: flex; flex-direction: column; justify-content: center; background: #0b0f0a; }
#story-scene .story-player:fullscreen .stage { width: min(100vw, calc((100vh - 60px) * 16 / 9)); align-self: center; }

/* Phone: keep the whole 16:9 picture and move the caption below it, so a
   portrait screen never crops the artwork the panel is about. */
@media (max-width: 760px) {
  #story-scene { padding: 10px 8px 28px; }
  #story-scene .stage { aspect-ratio: auto; padding-top: 56.25%; }
  #story-scene #cwl-story-pictures,
  #story-scene #cwl-story-effects,
  #story-scene .vignette { height: auto; aspect-ratio: 16 / 9; bottom: auto; }
  #story-scene .vignette { background: linear-gradient(0deg, #090e0b73, transparent 55%); }
  #story-scene .caption {
    position: relative;
    inset: auto;
    max-width: none;
    padding: 14px 12px 18px;
    background: #10180f;
    cursor: auto;
  }
  #story-scene .dialogue { padding: 12px; gap: 11px; align-items: flex-start; }
  #story-scene .speaker-portrait { width: 50px; height: 50px; flex-basis: 50px; }
  #story-scene .dialogue h2 { font-size: 19px; }
  #story-scene .narration-caption { display: block; margin: 12px 6px 0; }
  #story-scene .narration-label { display: block; margin-bottom: 4px; }
  #story-scene .panel-tag { top: 10px; left: 10px; right: 10px; font-size: 7px; letter-spacing: 0.5px; }
  #story-scene .panel-tag span { padding: 6px; }
  #story-scene .story-skip { top: 38px; right: 10px; padding: 6px 10px; font-size: 10px; }
  #story-scene .transport { gap: 5px; padding: 9px 10px; flex-wrap: wrap; }
  #story-scene .story-motion { display: none; }
  #story-scene .briefing { grid-template-columns: 1fr; gap: 12px; padding: 20px 16px 24px; }
  #story-scene .briefing h3 { font-size: 23px; }
}

/* Victory-screen entry point to the chapter's epilogue (views/tinybits/
   midgame.jsx). Mirrors the replay bar that sits directly beneath it. */
.game-over-story-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px auto 4px;
}
.game-over-story-watch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 18px;
  background: linear-gradient(to bottom, #e6ce6a 0%, #c8960c 50%, #b7892b 100%);
  color: #1a0a00;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid #b7892b;
  cursor: pointer;
}
.game-over-story-watch:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(200, 150, 12, 0.35);
}

/* ===== Unwatched stories (misc/storyProgress.js) =====
   A story the player can watch but hasn't opened yet: story buttons pulse gold
   and carry a "New" pill, campaign hexes get a book badge, and the home
   menu's Chronicles button shows how many are waiting. */
@keyframes story-unseen-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 206, 106, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(230, 206, 106, 0); }
}

.campaign-btn-story.story-unseen {
  border-color: #e6ce6a;
  color: #e6ce6a;
  animation: story-unseen-pulse 1.8s ease-in-out infinite;
}

.story-new-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd54a, #c98b14);
  color: #3a2a00;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  vertical-align: middle;
}

.game-over-story-bar.story-unseen .game-over-story-watch {
  animation: story-unseen-pulse 1.8s ease-in-out infinite;
}

.chronicle-card.story-unseen {
  outline: 2px solid #e6ce6a;
  outline-offset: 2px;
}

.chronicle-new {
  position: absolute;
  top: 8px;
  left: 8px;
  margin: 0;
}

.hex-story-badge {
  position: absolute;
  top: 32%; /* below the star row */
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd54a, #c98b14);
  color: #3a2a00;
  font-size: 0.75rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: story-unseen-pulse 1.8s ease-in-out infinite;
}

.menu-button-badge-story {
  top: 14px;
  left: 14px;
  background: linear-gradient(135deg, #ffd54a, #c98b14);
  color: #3a2a00;
}

@media (prefers-reduced-motion: reduce) {
  .campaign-btn-story.story-unseen,
  .game-over-story-bar.story-unseen .game-over-story-watch,
  .hex-story-badge {
    animation: none;
  }
}
