/* Silly Stories: a puppet theatre behind the green bottle (SILLY-STORIES-PLAN.md).
   The room's layout (the fixed overlay, the layers, the creature slot) is shared in
   potions.css; it has no benches, so the stage has the whole screen.

   Palette: the bottle's emerald for the curtains and her picks, lamp gold for the word
   being read, warm paper for cards and pages, and plum rock behind. One loud thing: her
   picked words in the story, as green pills with their pictures. */

#silly {
  --rock-far: #170f2a; --rock: #2b2047; --ink: #120b22;
  --velvet: #1f7a5a; --velvet-lit: #3fb488; --velvet-dark: #13543d;
  --gold: #f2c45a; --gold-dark: #b8862f;
  --paper: #fdf7e6; --paper-edge: #eadcb8; --ink-text: #2c2440;
  --pick: #c9f5e2; --pick-edge: #2fa877; --pick-ink: #0f5238;
  --marker: #ffd75e;
  grid-template-rows: minmax(0, 1fr);
}

/* ---------------------------------------------------------------- the room */

.ss-ceiling     { fill: #1b1330; }
.ss-backcloth   { fill: #2a1f45; }
.ss-fold.lit    { fill: var(--velvet-lit); }
.ss-fold.dark   { fill: var(--velvet); }
.ss-fold        { stroke: var(--velvet-dark); stroke-width: 2; }
.ss-tie         { fill: var(--gold); stroke: var(--gold-dark); stroke-width: 2; }
.ss-tassel      { fill: var(--gold); }
.ss-valance     { fill: var(--velvet); stroke: var(--velvet-dark); stroke-width: 2; }
.ss-bead        { fill: var(--gold); }
.ss-lintel      { fill: #3a2c5c; }
.ss-trim        { fill: var(--gold); }
.ss-stage-lip   { fill: #5a3a20; }
.ss-bulb        { fill: #fff1c2; filter: drop-shadow(0 0 6px #ffd75e); }
.ss-floor       { fill: #120b22; }
.ss-cushion-rim { fill: none; stroke: #e6fff3; stroke-opacity: 0.7; stroke-width: 3; stroke-dasharray: 6 8; }

#silly .creature-slot { width: 26%; pointer-events: none; }

/* The stage holds every view. Sizes are in container units, so the cards, tiles and
   words grow and shrink with the scene on every screen. */
.ss-stage {
  position: absolute; pointer-events: auto; container-type: size;
  font-family: var(--ui); color: var(--ink-text);
}

/* The stories button over the creature: three books. */
.ss-shelf-btn {
  position: absolute; transform: translate(-50%, -50%); z-index: 3; pointer-events: auto;
  width: max(60px, 7%); aspect-ratio: 1; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #f2fff8, #9fe6c6); border: 3px solid #e6fff3;
  box-shadow: 0 6px 12px rgba(7, 4, 15, 0.45);
}
.ss-shelf-btn[hidden] { display: none; }
.ss-shelf-btn svg { width: 70%; height: 70%; }

/* --------------------------------------------------------------- the shelf */

/* Playbills pinned up on the stage, three across, each a little crooked. Since v1.73.0 the
   shelf scrolls: two rows fill the stage and the next row's pins and tops peek up at the
   bottom edge, so more stories read as "keep going". A finger drags it (snapping to a row),
   and gold arrows on the right curtain move it a row at a time. */
.ss-shelf {
  position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 38cqh;
  gap: 5cqh 4cqw; padding: 5.5cqh 4cqw 6cqh; align-items: stretch;
  scroll-snap-type: y proximity; scroll-padding-top: 5.5cqh;
}
.ss-shelf::-webkit-scrollbar { display: none; }
.ss-shelf .ss-card { scroll-snap-align: start; }
.ss-shelf.more-below { -webkit-mask-image: linear-gradient(to bottom, #000 86%, rgba(0,0,0,0.3) 100%); mask-image: linear-gradient(to bottom, #000 86%, rgba(0,0,0,0.3) 100%); }
.ss-shelf.more-above { -webkit-mask-image: linear-gradient(to top, #000 86%, rgba(0,0,0,0.3) 100%); mask-image: linear-gradient(to top, #000 86%, rgba(0,0,0,0.3) 100%); }
.ss-shelf.more-above.more-below { -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, #000 14%, #000 86%, rgba(0,0,0,0.3) 100%); mask-image: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, #000 14%, #000 86%, rgba(0,0,0,0.3) 100%); }

/* The arrows sit on the right curtain, clear of the cards, and nudge the way there is more. */
.ss-scroll {
  position: absolute; right: -11.2cqw; width: max(56px, 9cqw); aspect-ratio: 1; padding: 0; border-radius: 50%;
  display: grid; place-items: center; z-index: 2;
  background: radial-gradient(circle at 40% 30%, #ffe39a, var(--gold) 60%, var(--gold-dark));
  border: 4px solid #fff3c8; box-shadow: 0 8px 16px rgba(7, 4, 15, 0.5);
}
.ss-scroll svg { width: 62%; height: 62%; fill: none; stroke: #5a2e12; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ss-scroll.up { top: 6cqh; }
.ss-scroll.up svg { rotate: 180deg; }
.ss-scroll.down { bottom: 6cqh; }
.ss-scroll[hidden] { display: none; }
.ss-scroll:active { scale: 0.92; }
@media (prefers-reduced-motion: no-preference) {
  .ss-scroll.down svg { animation: nudge-down 1.6s ease-in-out infinite; }
  .ss-scroll.up svg { animation: nudge-up 1.6s ease-in-out infinite; }
}
@keyframes nudge-down { 50% { translate: 0 12%; } }
@keyframes nudge-up { 50% { translate: 0 -12%; } }
.ss-card {
  position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.6cqh;
  padding: 2.6cqh 1.6cqw 2cqh; border-radius: 18px; rotate: var(--tilt);
  background: var(--paper); border: 4px solid var(--gold);
  box-shadow: 0 10px 22px rgba(7, 4, 15, 0.5), inset 0 0 0 3px var(--paper-edge);
  transition: transform 0.15s ease;
}
.ss-card:active { transform: scale(0.96); }
.ss-card-pin {
  position: absolute; top: -12px; left: 50%; width: 22px; height: 22px; translate: -50% 0; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff9e9e, #c2364a); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.ss-card-art {
  position: relative; flex: 1; min-height: 0; height: 0; aspect-ratio: 1; max-width: 100%; display: block;
  background: radial-gradient(circle at 50% 60%, #e6fff3, #c9f5e2 60%, #9fe6c6); border-radius: 50%;
}
.ss-card-art img { position: absolute; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25)); }
.ss-cover-0 { width: 52%; left: 24%; top: 26%; }
.ss-cover-1 { width: 32%; left: 2%; top: 8%; rotate: -12deg; }
.ss-cover-2 { width: 32%; right: 2%; top: 8%; rotate: 12deg; }
.ss-card-title {
  font: 800 clamp(0.85rem, 3.2cqw, 1.8rem)/1.05 var(--display); color: var(--velvet-dark); text-align: center;
}

/* ---------------------------------------------------------------- the picks */

.ss-picks { position: absolute; inset: 2% 2% 3%; display: flex; flex-direction: column; align-items: center; gap: 2.6cqh; }

/* The bottle's label: the story's name and a slot for each pick. The slot she is on
   glows and bobs; a filled one shows its picture and a little swap mark. */
.ss-label {
  display: flex; align-items: center; gap: 2.4cqw; padding: 1.4cqh 2.4cqw;
  background: var(--paper); border: 4px solid var(--pick-edge); border-radius: 22px;
  box-shadow: 0 8px 18px rgba(7, 4, 15, 0.45);
}
.ss-label-title { font: 800 clamp(0.95rem, 3cqw, 1.7rem)/1.1 var(--display); color: var(--velvet-dark); max-width: 22cqw; }
.ss-slots { display: flex; gap: 1.6cqw; }
.ss-slot {
  position: relative; width: max(56px, 11cqh); aspect-ratio: 1; padding: 0; border-radius: 16px;
  display: grid; place-items: center; background: #f2fbf6; border: 3px dashed #9fd6bd;
}
.ss-slot .ss-q { font: 800 clamp(1.2rem, 6cqh, 2.4rem)/1 var(--display); color: #9fd6bd; }
.ss-slot.now { border: 4px solid var(--gold); background: #fff6d8; animation: slot-bob 1.4s ease-in-out infinite; }
.ss-slot.now .ss-q { color: var(--gold-dark); }
.ss-slot.filled { border: 3px solid var(--pick-edge); background: var(--pick); }
.ss-slot.filled img { width: 76%; height: 76%; pointer-events: none; }
.ss-swap {
  position: absolute; right: -8px; top: -8px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; line-height: 1; color: #fff;
  background: var(--pick-edge); border: 2px solid #fff;
}
.ss-slot-num {
  position: absolute; left: 50%; bottom: -10px; translate: -50% 0; min-width: 20px; height: 20px; border-radius: 10px;
  font: 700 12px/20px var(--ui); color: #fff; background: var(--velvet-dark); text-align: center;
}
/* The bonus slot: gold, with a star where the number would be. */
.ss-slot.bonus { border-color: #e9c25a; background: #fff8dd; }
.ss-slot.bonus .ss-q { color: #d3a43a; }
.ss-slot.bonus .ss-slot-num { background: #d3a43a; font-size: 13px; }
.ss-slot.bonus.filled { border-style: solid; background: #ffefb8; }
.ss-prompt.bonus { background: linear-gradient(180deg, #e9b93e, #c48c1c); border-color: #ffe39a; }
@keyframes slot-bob { 50% { translate: 0 -5px; box-shadow: 0 0 0 6px rgba(242, 196, 90, 0.35); } }

/* The prompt is a button too: a tap says it again and the pictures bounce. */
.ss-prompt {
  display: inline-flex; align-items: center; gap: 12px; padding: 1cqh 3cqw 1cqh 1.6cqw; min-height: 52px;
  font: 800 clamp(1.1rem, 3.6cqw, 2.1rem)/1.1 var(--display); color: #fff;
  background: var(--velvet); border: 3px solid var(--velvet-lit); border-radius: 999px;
  box-shadow: 0 6px 14px rgba(7, 4, 15, 0.45);
}
.ss-prompt svg { width: clamp(30px, 6cqh, 44px); height: auto; flex: none; }
.ss-prompt path { fill: #fff; }
.ss-prompt .wave { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }

.ss-options {
  flex: 1; min-height: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr);
  gap: 2.2cqh 2.4cqw; padding: 0 6cqw;
}
.ss-option {
  min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6cqh;
  padding: 1.2cqh 1cqw; border-radius: 22px; background: var(--paper);
  border: 3px solid var(--paper-edge); box-shadow: 0 6px 14px rgba(7, 4, 15, 0.4);
  font: 700 clamp(0.85rem, 2.6cqw, 1.4rem)/1.1 var(--ui); color: var(--ink-text);
  transition: transform 0.12s ease;
}
.ss-option img { flex: 1; min-height: 0; max-width: 70%; aspect-ratio: 1; object-fit: contain; pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.2)); }
.ss-option span { pointer-events: none; }
.ss-option:active { transform: scale(0.94); }

/* Her own words (src/my-words.js, v1.83.0): a column of Word Lab plaques beside the drawn options,
   headed by the word flask so she knows where they came from. Upright, they are a row underneath. */
.ss-choices { flex: 1; min-height: 0; width: 100%; display: flex; gap: 2.4cqw; }
.ss-choices > .ss-options { flex: 1; width: auto; min-width: 0; }
.ss-choices.has-mine { padding: 0 3cqw; }
.ss-choices.has-mine > .ss-options { padding: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ss-choices.has-mine .ss-option span { text-align: center; }
.ss-mine {
  position: relative; flex: none; width: 15cqw; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 1.4cqh;
  padding: 5cqh 1cqw 1.4cqh; border-radius: 22px; background: rgba(43, 29, 76, 0.72);
  border: 3px dashed rgba(255, 196, 107, 0.7);
}
/* the word flask sits on the column's top edge, as a badge, so the words get the height */
.ss-mine-from {
  position: absolute; left: 50%; top: 0; translate: -50% -45%; width: clamp(24px, 7cqh, 46px); height: auto;
  pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}
.ss-option.mine { min-width: 0; padding: 0.5cqh; background: #3b2a66; border-color: #ffc46b; border-radius: 18px; }
.ss-option.mine img { max-width: 100%; height: 100%; filter: none; border-radius: 12px; }
/* a phone: the stage is short, so the column narrows to give the drawn options' labels room */
@container (max-height: 330px) {
  .ss-choices.has-mine { padding: 0 1.5cqw; gap: 1.6cqw; }
  .ss-choices.has-mine .ss-option { padding-inline: 0.2cqw; font-size: 0.64rem; letter-spacing: -0.02em; }
  .ss-mine { width: 16cqw; gap: 1cqh; padding: 1cqh 0.8cqw; }
  .ss-mine-from { display: none; }      /* no room for the badge above a finger-sized word */
}

.ss-ghost { position: absolute; pointer-events: none; z-index: 70; }

/* All three picked: the picks in a row and the big green button. */
.ss-ready { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5cqh; }
.ss-ready-row { display: flex; gap: 4cqw; }
.ss-ready-pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: 700 clamp(0.9rem, 2.8cqw, 1.5rem)/1 var(--ui); color: var(--pick-ink);
  padding: 1.6cqh 2cqw; border-radius: 20px; background: var(--pick); border: 3px solid var(--pick-edge);
}
.ss-ready-pick img { width: clamp(56px, 15cqh, 120px); }
.ss-read-btn {
  display: inline-flex; align-items: center; gap: 16px; padding: 2cqh 5cqw 2cqh 3cqw; min-height: 64px;
  font: 800 clamp(1.4rem, 5cqw, 2.8rem)/1 var(--display); color: #fff;
  background: radial-gradient(circle at 40% 30%, #6fe0b0, #1f9a6c); border: 4px solid #e6fff3; border-radius: 999px;
  box-shadow: 0 10px 22px rgba(7, 4, 15, 0.5); animation: read-pulse 1.8s ease-in-out infinite;
}
.ss-read-btn svg { width: clamp(48px, 10cqh, 80px); height: auto; }
.ss-read-btn .bk { fill: #fdf7e6; stroke: #0f5238; stroke-width: 3; }
.ss-read-btn .sp { stroke: #0f5238; stroke-width: 2; }
.ss-read-btn .pl { fill: #1f9a6c; }
@keyframes read-pulse { 50% { scale: 1.05; box-shadow: 0 0 0 10px rgba(111, 224, 176, 0.3), 0 10px 22px rgba(7, 4, 15, 0.5); } }

/* ----------------------------------------------------------------- the book */

.ss-book {
  position: absolute; left: 0; right: 0; top: 0; bottom: 15%; display: grid; grid-template-columns: 1.15fr 1fr;
  filter: drop-shadow(0 14px 18px rgba(7, 4, 15, 0.55)); touch-action: pan-y;
}
.ss-page { position: relative; overflow: hidden; background: var(--paper); box-shadow: inset 0 0 0 2px var(--paper-edge); }
.ss-left  { border-radius: 18px 4px 4px 18px; background: linear-gradient(90deg, var(--paper) 84%, #efe3c4); }
.ss-right { border-radius: 4px 18px 18px 4px; background: linear-gradient(270deg, var(--paper) 84%, #efe3c4); }
.ss-spine {
  position: absolute; left: 53.5%; top: 0; bottom: 0; width: 6px; translate: -50% 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.18));
}
.ss-num { position: absolute; bottom: 4%; left: 8%; font: 600 0.9rem/1 var(--ui); color: #a08a6a; }

/* The words. Lexend, which was made for early readers, wide-spaced. Words still to come
   are a little softer; words read are full ink; the word being said gets a marker swipe. */
.ss-text {
  position: absolute; left: 8%; right: 6%; top: 7%; bottom: 13%; overflow: hidden;
  font-family: var(--ui); font-weight: 600; line-height: 1.7; letter-spacing: 0.01em; color: #6b6280;
}
.ss-sent { cursor: pointer; }
.ss-text .w { position: relative; border-radius: 6px; white-space: nowrap; transition: color 0.15s ease; }
.ss-text .w.said { color: var(--ink-text); }
.ss-text .w.lit { color: #1a1426; }
.ss-text .w.lit::before {
  content: ''; position: absolute; inset: 8% -4px 4% -4px; z-index: -1; border-radius: 6px 10px 8px 12px;
  background: var(--marker); transform-origin: left center; animation: marker 0.14s ease-out;
}
@keyframes marker { from { transform: scaleX(0.2); } }
.ss-text { isolation: isolate; }

/* Her picks in the story: a green pill with the picture, on the line like a word. */
.ss-pill {
  display: inline-flex; align-items: center; gap: 0.18em; vertical-align: baseline;
  padding: 0 0.32em 0 0.14em; margin: 0 0.04em; border-radius: 999px;
  font: inherit; font-weight: 800; color: var(--pick-ink); line-height: 1.25;
  background: var(--pick); border: 2px solid var(--pick-edge);
  transition: transform 0.12s ease, background-color 0.15s ease;
}
.ss-pill img { width: 1.2em; height: 1.2em; pointer-events: none; }
.ss-pill.lit { background: var(--marker); border-color: var(--gold-dark); transform: scale(1.08); }

/* The right page: the picks this page is about, on a little round stage. */
.ss-scene {
  position: absolute; inset: 10% 8% 12%; display: flex; align-items: flex-end; justify-content: center; gap: 4%;
  background: radial-gradient(ellipse 60% 18% at 50% 92%, rgba(47, 168, 119, 0.35), transparent 70%);
}
.ss-actor { flex: 1; max-width: 46%; padding: 0; background: none; border: 0; }
.ss-actor img { width: 100%; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.22)); pointer-events: none; }
.ss-scene.n1 .ss-actor { max-width: 66%; }
.ss-scene.n3 .a1 { margin-bottom: 18%; }
.ss-actor { animation: actor-sway 3.2s ease-in-out infinite; }
.ss-actor.a1 { animation-delay: -1s; }
.ss-actor.a2 { animation-delay: -2s; }
@keyframes actor-sway { 50% { translate: 0 -4%; rotate: 2deg; } }

/* The controls under the book: back, read or pause, forward. */
.ss-controls { position: absolute; left: 0; right: 0; bottom: 0; height: 13%; display: flex; justify-content: center; align-items: center; gap: 6cqw; }
.ss-ctl {
  height: 100%; max-height: 72px; min-height: 52px; aspect-ratio: 1; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #ffd27a, #e09a3a); border: 3px solid #fff3c8;
  box-shadow: 0 6px 12px rgba(7, 4, 15, 0.4);
}
.ss-ctl[disabled] { opacity: 0.35; }
.ss-ctl svg { width: 58%; height: 58%; }
.ss-ctl path { fill: none; stroke: #5a2e12; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ss-play { background: radial-gradient(circle at 40% 30%, #6fe0b0, #1f9a6c); border-color: #e6fff3; max-height: 84px; }
.ss-play path, .ss-play rect { fill: #fff; stroke: none; }

/* ------------------------------------------------------------------ The End */

.ss-end { position: absolute; inset: 4% 4% 6%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4cqh;
  background: var(--paper); border-radius: 24px; border: 4px solid var(--gold); box-shadow: 0 12px 24px rgba(7, 4, 15, 0.5); }
.ss-end-title { font: 800 clamp(2rem, 9cqw, 4.6rem)/1 var(--display); color: var(--velvet-dark); background: none; border: 0; }
.ss-end-btns { display: flex; gap: 5cqw; }
.ss-again, .ss-to-shelf {
  display: inline-flex; align-items: center; gap: 12px; min-height: 60px; padding: 1.4cqh 3.6cqw 1.4cqh 2cqw; border-radius: 999px;
  font: 800 clamp(1.1rem, 3.6cqw, 2rem)/1 var(--display); color: #fff; box-shadow: 0 8px 16px rgba(7, 4, 15, 0.4);
}
.ss-again { background: radial-gradient(circle at 40% 30%, #6fe0b0, #1f9a6c); border: 4px solid #e6fff3; }
.ss-again svg rect { fill: #fff; } .ss-again svg circle { fill: #1f9a6c; }
.ss-to-shelf { background: radial-gradient(circle at 40% 30%, #ffd27a, #e09a3a); border: 4px solid #fff3c8; color: #5a2e12; }
.ss-again svg, .ss-to-shelf svg { width: clamp(36px, 8cqh, 54px); height: auto; }

/* An upright iPad or a phone: the stage keeps the scene's box; the picks go two across. */
@media (max-aspect-ratio: 5/6) {
  #silly .creature-slot { width: 30%; }
}
@container (max-aspect-ratio: 4/5) {
  .ss-options { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 1fr); }
  .ss-choices { flex-direction: column; }
  .ss-choices.has-mine > .ss-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ss-mine { width: 100%; height: 17cqh; grid-auto-flow: column; grid-auto-columns: 17cqh; justify-content: center; padding: 1cqh 2cqw; }
}

@media (prefers-reduced-motion: reduce) {
  .ss-slot.now, .ss-read-btn, .ss-actor { animation: none; }
  .ss-text .w.lit::before { animation: none; }
}
