/* Portia Plays: the small wonders. Shared by every page. Everything here is a bonus: with no JavaScript, or with
   reduced motion asked for, the page is complete and still. */

/* pages that move into each other, where the browser can (Chrome, Edge, Safari 18.2+) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: pp-out 0.28s ease both; }
  ::view-transition-new(root) { animation: pp-in 0.42s ease both; }
}
@keyframes pp-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes pp-in { from { opacity: 0; transform: translateY(8px); } }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* reveals: content is visible unless this script is running and motion is welcome */
.wonder-motion [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 0.8s cubic-bezier(.2,.7,.2,1) var(--d, 0ms), transform 0.9s cubic-bezier(.2,.7,.2,1) var(--d, 0ms); }
.wonder-motion [data-reveal].is-in { opacity: 1; transform: none; }

/* the sound switch, in the masthead */
.sound-toggle { appearance: none; background: none; border: 1px solid rgba(167, 177, 198, 0.55); border-radius: 999px; width: 40px; height: 40px; display: inline-grid; place-items: center; cursor: pointer; color: #a7b1c6; padding: 0; }
.sound-toggle:hover { color: #fff; border-color: #fff; }
.sound-icon { display: block; }
.sound-toggle .wave { display: none; }
.sound-toggle[aria-pressed="true"] .wave { display: inline; }
.sound-toggle[aria-pressed="true"] .mute { display: none; }
.sound-toggle[aria-pressed="true"] { color: #f0c67e; border-color: #f0c67e; }

/* the toast: one line at a time, gold-edged, at the foot of the screen */
.pp-toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 60; max-width: min(560px, calc(100vw - 32px));
  background: rgba(24, 14, 40, 0.94); color: #f3ecfb; border: 1px solid rgba(240, 198, 126, 0.55); border-radius: 14px; padding: 12px 18px;
  font: 16px/1.45 'Lora', Georgia, serif; box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.45s cubic-bezier(.2,.8,.2,1);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pp-toast.show { opacity: 1; transform: translate(-50%, 0); }
.pp-toast-tag { display: block; font: 600 11px/1 'Lora', Georgia, serif; letter-spacing: 0.18em; text-transform: uppercase; color: #f0c67e; margin-bottom: 6px; }
.pp-toast[data-kind="portia"] { border-color: rgba(125, 211, 252, 0.6); }
.pp-toast[data-kind="portia"] .pp-toast-tag { color: #7dd3fc; }
.pp-toast[data-kind="portia"] .pp-toast-text { font-style: italic; }

/* the secrets counter, once there's something to count */
.pp-pill { position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 55; appearance: none; cursor: pointer;
  background: #1d1230; color: #f3ecfb; border: 1px solid rgba(240, 198, 126, 0.7); border-radius: 999px; padding: 8px 14px; font: 600 14px/1 'Lora', Georgia, serif;
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.6); opacity: 0; transform: scale(0.8); transition: opacity 0.4s, transform 0.5s cubic-bezier(.2,1.4,.4,1); }
.pp-pill.show { opacity: 1; transform: none; }
.pp-pill:hover { border-color: #f0c67e; }
.pp-pill-star { color: #f0c67e; }
.pp-panel { position: fixed; inset: 0; z-index: 70; background: rgba(12, 6, 22, 0.55); display: grid; place-items: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.pp-panel.open { opacity: 1; pointer-events: auto; }
.pp-sheet { position: relative; width: min(520px, 100%); max-height: 86vh; overflow: auto; background: #1d1230; color: #f3ecfb; border: 1px solid rgba(240, 198, 126, 0.5); border-radius: 18px; padding: 26px 24px 22px; font: 16px/1.5 'Lora', Georgia, serif; }
.pp-sheet h2 { font: 600 30px/1.1 'Vollkorn', Georgia, serif; margin: 4px 0 8px; color: #f8de94; }
.pp-sheet-k { font: 600 11px/1 'Lora', Georgia, serif; letter-spacing: 0.18em; text-transform: uppercase; color: #cbbfe0; margin: 0; }
.pp-sheet-note { color: #cbbfe0; margin: 0 0 14px; font-size: 15px; }
.pp-sheet ol { list-style: none; margin: 0; padding: 0; }
.pp-sheet li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 9px 0; border-top: 1px solid rgba(203, 191, 224, 0.16); color: #a99cc2; }
.pp-sheet li.got { color: #f3ecfb; }
.pp-sheet li .mark { color: #6d5f8a; text-align: center; }
.pp-sheet li.got .mark { color: #f0c67e; }
.pp-close { position: absolute; right: 12px; top: 10px; appearance: none; background: none; border: 0; color: #cbbfe0; font-size: 28px; line-height: 1; cursor: pointer; width: 40px; height: 40px; }
.pp-close:hover { color: #fff; }

.pp-shower { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 65; }

/* ---------------- the toys ---------------- */
.toy { position: relative; margin: 0; }
.toy-frame { position: relative; border-radius: 14px; overflow: hidden; border: 1.5px solid rgba(240, 198, 126, 0.75);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 28px 60px -30px rgba(0, 0, 0, 0.8), 0 0 60px -30px rgba(240, 198, 126, 0.45); background: #1a1030; aspect-ratio: 4 / 5; }
.toy-canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; image-rendering: pixelated; image-rendering: crisp-edges; }
.toy-canvas.toy-smooth { image-rendering: auto; }
.toy-canvas:focus-visible { outline: none; }
.toy-frame:focus-within { box-shadow: 0 0 0 3px #f0c67e, 0 28px 60px -30px rgba(0, 0, 0, 0.8); }
.toy figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 12px 4px 0; color: #e9def8; font: 500 17px/1.3 'Vollkorn', Georgia, serif; }
.toy figcaption .game { color: #f8de94; }
.toy figcaption .do { font: italic 15px/1.3 'Lora', Georgia, serif; color: #cbbfe0; text-align: right; }

/* the prompt, on the glass */
.toy-prompt { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2; pointer-events: none; white-space: nowrap;
  font: 600 13px/1 'Lora', Georgia, serif; letter-spacing: 0.08em; color: #fff6e0; background: rgba(20, 10, 34, 0.62); border: 1px solid rgba(240, 198, 126, 0.5); padding: 8px 12px; border-radius: 999px; transition: opacity 0.4s; }
.toy-prompt.gone { opacity: 0; }
.wonder-motion .toy-prompt:not(.gone) { animation: pp-breathe 2.6s ease-in-out infinite; }
@keyframes pp-breathe { 50% { box-shadow: 0 0 22px -2px rgba(240, 198, 126, 0.55); } }
.toy-gen { position: absolute; left: 12px; top: 12px; z-index: 2; font: 600 11px/1 'Lora', Georgia, serif; letter-spacing: 0.16em; text-transform: uppercase; color: #f0c67e; background: rgba(20, 10, 34, 0.55); padding: 6px 9px; border-radius: 999px; pointer-events: none; }
.toy-words { position: absolute; left: 14px; right: 14px; top: 14px; z-index: 3; pointer-events: none; color: #e0f2fe; font: italic 16px/1.45 'Vollkorn', Georgia, serif; text-shadow: 0 1px 8px rgba(10, 4, 20, 0.9); opacity: 0; transition: opacity 0.6s; }
.toy-words.show { opacity: 1; }
.toy-words b { display: block; font: 600 10.5px/1 'Lora', Georgia, serif; letter-spacing: 0.2em; font-style: normal; color: #7dd3fc; margin-bottom: 6px; }

/* the star's color, chosen once before first light */
.toy-colors { position: absolute; right: 12px; top: 10px; z-index: 3; display: flex; gap: 6px; }
.toy-dot { appearance: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); background: radial-gradient(circle at 35% 35%, #fff 0, var(--dot) 45%, var(--dot) 100%); cursor: pointer; padding: 0; }
.toy-dot[aria-checked="true"] { border-color: #fff6e0; box-shadow: 0 0 12px var(--dot); }

/* Sandkeeper's toy: the tilt switch and the card when it corks */
.toy-tilt { position: absolute; right: 10px; top: 10px; z-index: 3; appearance: none; border: 1px solid #5c4226; background: #f3ead8; color: #5c4226; font: 600 12px/1 'Lora', Georgia, serif; padding: 8px 10px; border-radius: 999px; cursor: pointer; box-shadow: 0 2px 0 #5c4226; }
.toy-card { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 4; background: rgba(243, 234, 216, 0.96); color: #33271d; border: 1px solid #cdbc9c; border-radius: 10px; padding: 9px 10px 7px; font: 14px/1.35 'Vollkorn', Georgia, serif; box-shadow: 0 14px 28px -14px rgba(0, 0, 0, 0.6); }
.wonder-motion .toy-card:not([hidden]) { animation: pp-in 0.5s cubic-bezier(.2,.8,.2,1) both; }
.toy-card p { margin: 0 0 6px; }
.toy-row { display: flex; gap: 6px; align-items: stretch; }
.toy-name { flex: 1; min-width: 0; }
.toy-name input { width: 100%; height: 100%; min-height: 36px; font: 600 20px/1 'Caveat', 'Vollkorn', cursive; color: #33271d; background: #fffaf0; border: 1px solid #cdbc9c; border-radius: 6px; padding: 2px 8px; margin: 0; }
.toy-name input:focus { outline: 2px solid #2f6a74; outline-offset: 1px; }
.toy-btn { appearance: none; border: 1px solid #5c4226; background: #7a5a34; color: #f3ead8; font: 600 14px/1 'Vollkorn', Georgia, serif; padding: 0 12px; min-height: 36px; border-radius: 7px; cursor: pointer; box-shadow: 0 2px 0 #5c4226; white-space: nowrap; }
.toy-btn:hover { background: #5c4226; }
.toy-again { appearance: none; background: none; border: 0; padding: 6px 0 0; color: #2f6a74; font: italic 13.5px/1 'Lora', Georgia, serif; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .pp-toast, .pp-pill, .pp-panel { transition: none; }
}
