/* Story Reactor / A: one reusable assignment sheet, not a scene illustration.
   Real stock + shared fibre contours + alpha ink; every scenario stays text. */
#zineStoryApp {
  --field: #187e86; --paper: #f2e5b6; --ink: #242523;
  --action: #e96941; --accent: #b9d8cb;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: clamp(72px, 12vh, 122px) minmax(0, 1fr) clamp(74px, 12vh, 122px);
  gap: clamp(15px, 2.2vh, 28px);
  padding: clamp(20px, 3vh, 40px) clamp(26px, 4.2vw, 78px);
  min-height: 640px;
  height: 100svh; max-height: 1040px;
  background-size: 920px;
  font-family: var(--print-face);
  font-synthesis: none;
}
.zine-page:has(#zineStoryApp:not([hidden])) { min-height: 100svh; display: grid; align-content: center; }
.zine-page:has(#zineStoryApp:not([hidden])) .review-deck { display: none; }
.story-heading { display: flex; justify-content: space-between; align-items: start; min-width: 0; }
.story-heading h1, .story-wordmark { margin: 0; }
.story-title {
  display: flex; align-items: center; gap: 18px;
  border: 0; padding: 0 8px 3px 0; background: none;
  font: 900 clamp(34px, 4vw, 66px)/.85 var(--print-face);
  color: var(--paper); text-transform: uppercase; text-align: left;
  transform: rotate(-3deg);
}
.story-ink {
  mask: var(--ink-grain-mask, none) 0 0 / 192px 160px repeat;
  text-shadow: none; letter-spacing: .005em;
}
.story-title .story-ink { padding: .14em .06em; margin: -.14em -.06em; }
.story-chevron { width: 11px; height: 11px; flex: 0 0 11px; border: solid currentColor; border-width: 0 3px 3px 0; transform: rotate(45deg); margin-top: -5px; }
.story-title .story-chevron { color: var(--action); width: 15px; height: 15px; flex-basis: 15px; border-width: 0 5px 5px 0; }
.story-wordmark {
  color: var(--paper); font-size: clamp(23px, 2.3vw, 36px); line-height: 1;
  font-weight: 900; text-transform: uppercase; transform: rotate(-3deg);
  border-bottom: 3px solid currentColor; padding: 5px 0 7px;
}
.story-desk { position: relative; min-width: 0; min-height: 0; width: 87%; max-width: 1390px; justify-self: center; }
.story-sheet { position: relative; isolation: isolate; height: 100%; min-width: 0; transform: rotate(-.55deg); }
.story-paper-lift {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  filter: drop-shadow(1px 2px 1px #102e2b88) drop-shadow(7px 12px 7px #102e2b55);
}
.story-paper-surface {
  position: absolute; inset: 0;
  background: linear-gradient(112deg, #fff5ce30, transparent 35%, #5947200c), var(--stock) 24px 74px / 850px;
}
.story-copy {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  height: 100%; min-width: 0; gap: clamp(20px, 3vh, 36px);
  padding: clamp(44px, 5.6vh, 66px) clamp(40px, 5.8vw, 98px);
  color: var(--ink); text-align: center;
}
#storyTitle {
  margin: 0; padding-block: .12em; margin-block: -.12em;
  font: 900 clamp(54px, 6.1vw, 110px)/.98 var(--print-face);
  width: 100%; max-width: 21ch; text-transform: uppercase; text-wrap: balance; overflow-wrap: anywhere;
}
.story-stroke {
  display: block; width: clamp(98px, 18vw, 280px); height: clamp(7px, .8vw, 13px);
  flex: 0 0 auto; margin-top: -8px;
  background: var(--action) var(--stock) 30px 70px / 450px; background-blend-mode: multiply;
  clip-path: polygon(0 40%, 4% 0, 37% 15%, 98% 3%, 100% 67%, 95% 100%, 54% 82%, 1% 100%);
  transform: rotate(-1deg);
}
#storyPrompt {
  margin: 0; padding-block: .12em; margin-block: -.12em;
  font: 400 clamp(32px, 3.65vw, 64px)/1.13 var(--print-face);
  width: 100%; max-width: 38ch; text-wrap: balance; overflow-wrap: anywhere;
}
.story-sheet[data-density="short"] #storyTitle { max-width: 16ch; }
.story-sheet[data-density="short"] #storyPrompt { max-width: 30ch; text-wrap: balance; }
/* A title-only card remains centred on the same sheet. Its tear-off copy
   retains this state too, without a floating divider or empty text track. */
.story-sheet[data-has-prompt="false"] .story-stroke { display: none; }
@media (min-width: 901px) and (min-height: 801px) {
  .story-sheet[data-density="short"] #storyTitle { font-size: clamp(64px, 7.4vw, 128px); }
}
/* Long instructions receive a deliberate second type scale. Neither the
   sheet nor controls move, and nothing is clipped or silently abbreviated. */
.story-sheet[data-density="long"] #storyTitle { font-size: clamp(42px, 4.55vw, 80px); }
.story-sheet[data-density="long"] #storyPrompt { font-size: clamp(29px, 3.05vw, 52px); max-width: 46ch; }
.story-sheet[data-density="long"] .story-copy { gap: clamp(16px, 2.4vh, 28px); }
.story-type {
  position: absolute; z-index: 2; top: 0; left: 50%; translate: -50% -45%;
  display: flex; align-items: center; justify-content: center; margin: 0;
  border: 0; color: var(--ink); background: none;
  min-height: 52px; padding: 10px 25px 13px;
  font: 900 clamp(25px, 2.6vw, 42px)/1 var(--print-face); text-transform: uppercase;
  filter: drop-shadow(2px 3px 1px #233d3555); transform: rotate(1.5deg);
}
.story-control-paper {
  position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background: var(--accent) var(--stock) 170px 40px / 640px; background-blend-mode: multiply;
}
.story-controls { display: flex; align-items: center; justify-content: center; gap: clamp(18px, 2vw, 32px); min-width: 0; padding-left: 7%; }
.story-button {
  position: relative; isolation: isolate; border: 0; background: none;
  padding: 16px 32px 20px; min-height: 54px; color: var(--ink);
  text-transform: uppercase; font: 900 clamp(29px, 3.1vw, 52px)/1 var(--print-face);
  filter: drop-shadow(1px 2px 1px #172f2c70) drop-shadow(5px 7px 4px #172f2c45);
}
.story-button .story-control-paper { background-color: var(--action); }
.story-back { font-size: clamp(24px, 2.4vw, 38px); transform: rotate(1.5deg); }
.story-back .story-control-paper { background-color: var(--paper); }
.story-title:not(:disabled):hover { rotate: 1deg; }
.story-button:not(:disabled):hover { translate: 0 -2px; }
.story-button:not(:disabled):active { translate: 1px 2px; filter: drop-shadow(1px 1px 1px #172f2c60); }
.story-stage button:focus-visible { outline: 3px solid var(--ink); outline-offset: 5px; }
.story-stage :is(.story-title, .story-wordmark):focus-visible { outline-color: var(--paper); }
.story-stage button:disabled { opacity: .5; }
.story-host {
  position: absolute; z-index: 3; width: clamp(112px, 14vw, 232px); aspect-ratio: 1291 / 1218;
  left: 1.6%; bottom: 7%; transform: rotate(-9deg);
  filter: drop-shadow(2px 4px 1px #14333080) drop-shadow(5px 9px 5px #14333040);
  pointer-events: none;
}
.story-failure { position: absolute; inset: auto 15% 20%; padding: 18px; background: var(--paper); color: var(--ink); font-size: 25px; z-index: 8; }
.story-stage[data-phase="unavailable"] .story-desk { visibility: hidden; }
/* One short, interruptible whole-object entrance. Paper, label and ink are
   children of the same animated sheet; no looping motion while reading. */
.story-sheet[data-arrival="a"] { animation: story-arrive-a 320ms steps(1, end) both; }
.story-sheet[data-arrival="b"] { animation: story-arrive-b 320ms steps(1, end) both; }
@keyframes story-arrive-a {
  0% { transform: translate(9px, -5px) rotate(.7deg); }
  34% { transform: translate(-3px, 2px) rotate(-.85deg); }
  68%, 100% { transform: rotate(-.55deg); }
}
@keyframes story-arrive-b {
  0% { transform: translate(-7px, 4px) rotate(-1.4deg); }
  34% { transform: translate(2px, -1px) rotate(-.2deg); }
  68%, 100% { transform: rotate(-.55deg); }
}
.story-stage[data-mood="cheer"] .story-host { animation: story-nod 400ms steps(1, end) both; }
@keyframes story-nod {
  0%, 100% { transform: rotate(-9deg); }
  28% { transform: translateY(-5px) rotate(-5deg); }
  60% { transform: translateY(1px) rotate(-10deg); }
}
@media (min-width: 901px) and (max-height: 800px) {
  #zineStoryApp { grid-template-rows: 78px minmax(0, 1fr) 74px; gap: 22px; padding-block: 22px; }
  .story-title { font-size: 42px; }
  #storyTitle { font-size: clamp(54px, 5.1vw, 82px); }
  #storyPrompt { font-size: clamp(31px, 3vw, 46px); }
  .story-copy { padding-block: 38px; gap: 21px; }
  .story-sheet[data-density="long"] #storyTitle { font-size: clamp(40px, 3.6vw, 61px); }
  .story-sheet[data-density="long"] #storyPrompt { font-size: clamp(28px, 2.7vw, 42px); }
  .story-sheet[data-density="long"] .story-copy { gap: 17px; }
}
@media (max-width: 900px) {
  #zineStoryApp { height: auto; min-height: 100svh; max-height: none; padding: 24px 20px 28px; grid-template-rows: 92px minmax(430px, 1fr) auto; gap: 28px; overflow: hidden; }
  .story-desk { width: 100%; }
  .story-sheet { height: auto; min-height: 100%; }
  .story-copy { height: auto; min-height: 430px; padding: 46px 30px 54px; gap: 24px; }
  #storyTitle { font-size: clamp(43px, 7vw, 68px); }
  #storyPrompt { font-size: clamp(28px, 4.2vw, 40px); }
  .story-sheet[data-density="long"] #storyTitle { font-size: clamp(34px, 5.8vw, 54px); }
  .story-sheet[data-density="long"] #storyPrompt { font-size: clamp(25px, 3.8vw, 36px); }
  .story-controls { padding-left: 0; gap: 16px; }
  .story-button { font-size: clamp(25px, 4.2vw, 34px); padding: 15px 20px 18px; }
  .story-back { font-size: clamp(22px, 3.8vw, 28px); }
  .story-host { width: 96px; left: auto; right: 22px; top: 19px; bottom: auto; transform: rotate(7deg); }
  .story-wordmark { display: none; }
  .story-type { font-size: 28px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  #zineStoryApp { min-height: 100svh; height: auto; max-height: none; grid-template-rows: 57px minmax(230px, 1fr) 56px; padding: 16px 25px; gap: 15px; }
  .story-title { font-size: 28px; }
  .story-type { font-size: 23px; min-height: 44px; padding: 9px 18px; }
  .story-copy { min-height: 230px; padding: 32px 40px; gap: 16px; }
  #storyTitle { font-size: 38px; }
  #storyPrompt { font-size: 27px; }
  .story-sheet[data-density="long"] #storyTitle { font-size: 32px; }
  .story-sheet[data-density="long"] #storyPrompt { font-size: 25px; }
  .story-controls { padding: 0; }
  .story-button { font-size: 25px; padding: 12px 22px 15px; }
  .story-back { font-size: 23px; }
  .story-host { width: 65px; top: 12px; right: 24px; bottom: auto; left: auto; }
  .story-wordmark { display: none; }
  .story-stroke { height: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #zineStoryApp *, #zineStoryApp *::before, #zineStoryApp *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  #zineStoryApp { background: Canvas; color: CanvasText; }
  .story-ink { mask: none; }
  .story-copy, .story-title, .story-wordmark, .story-type, .story-button { color: CanvasText; }
  .story-paper-surface { background: Canvas; clip-path: none !important; border: 2px solid CanvasText; }
  .story-paper-lift, .story-button, .story-type { filter: none; }
  .story-button { background: ButtonFace; color: ButtonText; border: 2px solid ButtonText; }
  .story-type { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
  .story-control-paper { display: none; }
  .story-chevron, .story-title .story-chevron { color: ButtonText; }
  .story-host { forced-color-adjust: none; }
  .story-stage button:focus-visible { outline-color: Highlight; }
}
