/* =============================================================
   Kids' Corner — playground page styles.
   Reuses palette + fonts from styles.css.
   ============================================================= */

/* Element-level `hidden` must always win over component display rules. */
[hidden] { display: none !important; }

body.playground {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--aegean-deep);
}
/* Playground uses the same continuous sky + clouds as the book —
   no sea/horizon split (the previous overrides created a visible seam). */
.playground .stage__bg { z-index: 0; }
.playground .stage__sky { inset: 0; }
.playground .stage__clouds {
  inset: 0 0 50% 0;
  opacity: .75;            /* slightly softer so content stays legible */
}

/* ---------- Header ---------- */
.pg-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem clamp(1rem, 3vw, 2.5rem) 1rem;
  color: var(--paper);
}
/* Soft dark gradient behind the header so the title + tabs read clearly
   over any clouds drifting past behind them. */
.pg-header::before {
  content: "";
  position: absolute;
  inset: 0 0 -40px 0;
  background: linear-gradient(180deg, rgba(13,58,90,.55) 0%, rgba(13,58,90,0) 100%);
  pointer-events: none;
  z-index: -1;
}
.pg-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem .9rem;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(230,179,55,.55);
  border-radius: 999px;
  text-decoration: none;
  color: var(--paper);
  font-family: var(--inscription);
  font-size: .8em;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: background .2s ease, border-color .2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.pg-back:hover { background: rgba(0,0,0,.6); border-color: var(--saffron); }
.pg-title { text-align: center; }
.pg-title .cinzel {
  margin: 0 0 .15em;
  font-family: var(--inscription);
  font-weight: 500;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--saffron);
  font-size: .78em;
}
.pg-title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-style: italic;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.pg-spacer { justify-self: end; }

/* ---------- Tabs ---------- */
.pg-tabs {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  margin-bottom: 1.2rem;
}
.pg-tab {
  font: inherit;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05em;
  padding: .55rem 1.1rem;
  background: rgba(255,250,239,.92);
  color: var(--aegean-deep);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 3px 3px 0 0 rgba(0,0,0,.4);
  transition: transform .2s ease, background .2s ease, color .2s ease;
  display: inline-flex; align-items: center; gap: .4rem;
}
.pg-tab__emoji { font-family: var(--inscription); color: var(--terracotta); }
.pg-tab:hover { transform: translateY(-1px); }
.pg-tab.is-active {
  background: var(--terracotta);
  color: var(--paper);
  box-shadow: 3px 3px 0 0 var(--saffron);
}
.pg-tab.is-active .pg-tab__emoji { color: var(--saffron); }

/* ---------- Main area + cards ---------- */
.pg-main {
  position: relative;
  z-index: 5;
  padding: 0 clamp(1rem, 3vw, 2rem) 3rem;
  display: grid;
  place-items: start center;
}
.pg-panel {
  width: 100%;
  max-width: 980px;
}
.pg-panel:not(.is-active) { display: none; }

.card {
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 6px 6px 0 0 var(--aegean-deep), 0 30px 50px -30px rgba(0,0,0,.55);
  padding: clamp(1.4rem, 2.2vw, 2rem) clamp(1.4rem, 2.4vw, 2.4rem);
}
.card__header { margin-bottom: 1.2rem; }
.card__eyebrow {
  margin: 0 0 .25em;
  font-family: var(--inscription);
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--terracotta);
  font-size: .78em;
}
.card__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  color: var(--aegean-deep);
  line-height: 1.1;
  letter-spacing: -.01em;
}
.card__sub {
  margin: .6em 0 0;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1em;
}

/* ---------- Quiz ---------- */
.quiz {
  display: grid;
  gap: 1rem;
}
.quiz__progress {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.2em;
  color: var(--olive);
}
.quiz__q {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.2rem, 1.8vw, 1.6rem);
  color: var(--aegean-deep);
  line-height: 1.2;
}
.quiz__answers {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .55rem;
}
.quiz__a {
  font: inherit;
  font-family: var(--body);
  font-size: 1.05em;
  width: 100%;
  text-align: left;
  padding: .8rem 1rem;
  background: #fffaef;
  color: var(--ink);
  border: 2px solid var(--paper-edge);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.quiz__a:hover { border-color: var(--aegean); background: #fff; transform: translateY(-1px); }
.quiz__a.is-correct { border-color: #2e7d32; background: #e3f1d6; color: #1a4720; }
.quiz__a.is-wrong   { border-color: #b34031; background: #f7d8d2; color: #6b1a13; }
.quiz__a:disabled { cursor: default; }
.quiz__a.is-correct::before, .quiz__a.is-wrong::before {
  display: inline-block;
  margin-right: .5em;
  font-family: var(--inscription);
  font-weight: 700;
  width: 1em;
  text-align: center;
}
.quiz__a.is-correct::before { content: "✓"; }
.quiz__a.is-wrong::before   { content: "✗"; }

.quiz__feedback {
  margin: 0;
  min-height: 1.5em;
  font-family: var(--hand);
  font-size: 1.2em;
}
.quiz__feedback[data-state="ok"] { color: var(--olive); }
.quiz__feedback[data-state="bad"] { color: var(--terracotta); }

.quiz__controls { display: flex; justify-content: flex-end; }

.quiz-summary {
  text-align: center;
  display: grid;
  gap: 1rem;
  justify-items: center;
}
.quiz-summary h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--aegean-deep);
}
.quiz-summary__score {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 5vw, 4rem);
  color: var(--terracotta);
  line-height: 1;
  margin: 0;
}
.quiz-summary__sep { color: var(--aegean-mute); margin: 0 .15em; }
.quiz-summary__line {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.5em;
  color: var(--olive);
}

/* ---------- Match ---------- */
.match__board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
  margin: .5rem 0 1rem;
}
@media (max-width: 600px) {
  .match__board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.match__card {
  font: inherit;
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--aegean-deep);
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  perspective: 800px;
  padding: 0;
  overflow: hidden;
  transition: box-shadow .2s ease;
  box-shadow: 3px 3px 0 0 rgba(0,0,0,.45);
}
.match__card:hover { box-shadow: 4px 4px 0 0 rgba(0,0,0,.55); }
.match__inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .5s var(--ease);
}
.match__card.is-flipped .match__inner,
.match__card.is-locked .match__inner { transform: rotateY(180deg); }

.match__face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.match__face--front {
  background: linear-gradient(135deg, var(--aegean), var(--aegean-deep));
  color: var(--saffron);
  font-family: var(--inscription);
  font-size: 1.5em;
  font-weight: 700;
}
.match__face--back { transform: rotateY(180deg); background: var(--paper); }
.match__face--back img { width: 100%; height: 100%; object-fit: cover; display: block; }
.match__face--back .match__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.1em, 1.6vw, 1.4em);
  color: var(--aegean-deep);
  padding: .5rem;
  line-height: 1.1;
}
.match__card.is-locked { animation: lock-pulse .5s ease; }
.match__card.is-mismatch { animation: shake .5s ease; }
@keyframes lock-pulse {
  0%, 100% { box-shadow: 3px 3px 0 0 rgba(0,0,0,.45); }
  50%      { box-shadow: 0 0 0 4px var(--saffron), 3px 3px 0 0 rgba(0,0,0,.45); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50%      { transform: translateX(-4px); }
}
.match__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.match__progress {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.4em;
  color: var(--olive);
}
/* Celebration card — shown when all 6 pairs are matched. */
.match__win {
  position: relative;
  margin: 1.2rem 0 0;
  padding: 1.2rem 1.4rem 1.4rem;
  text-align: center;
  background:
    radial-gradient(ellipse at top, rgba(214,104,144,.18), transparent 70%),
    var(--paper);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 6px 6px 0 0 var(--aegean-deep);
  animation: win-pop .55s cubic-bezier(.34,1.56,.64,1) both;
}
.match__win__eyebrow {
  margin: 0 0 .15em;
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: .18em;
  font-style: italic;
  color: var(--bougainvillea);
  font-size: clamp(.85em, .4vw + .7em, 1em);
}
.match__win__title {
  margin: 0 0 .35em;
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "SOFT" 100, "opsz" 144;
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
  color: var(--aegean-deep);
  line-height: 1.05;
}
.match__win__line {
  margin: 0 0 .9em;
  font-family: var(--hand);
  font-size: 1.4em;
  color: var(--ink-soft);
}
.match__win__again { padding: .7rem 1.4rem; }

@keyframes win-pop {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .match__win { animation: none; }
}

/* canvas-confetti renders into its own <canvas>; this layer must sit
   above everything but ignore pointer events so the win card stays
   clickable. */
canvas.confetti-canvas,
canvas[style*="position: fixed"] {
  pointer-events: none !important;
}

/* ---------- Coloring ---------- */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: .5rem;
}
.color-tile {
  background: #fffaef;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: .6rem;
  display: grid;
  gap: .5rem;
  text-align: center;
  box-shadow: 3px 3px 0 0 var(--aegean-deep);
  transition: transform .2s ease, box-shadow .2s ease;
}
.color-tile:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--aegean-deep); }
.color-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  filter: grayscale(.85) contrast(1.05);
  transition: filter .25s ease;
}
.color-tile:hover img { filter: grayscale(0) contrast(1); }
.color-tile h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.1em;
  color: var(--aegean-deep);
}
.color-note {
  margin: 1.4rem 0 0;
  font-family: var(--hand);
  font-size: 1.3em;
  color: var(--olive);
  text-align: center;
  min-height: 1.5em;
}

/* ---------- Story ---------- */
.card--story { padding-bottom: 2.5rem; }
.story {
  font-family: var(--body);
  font-size: 1.08em;
  line-height: 1.7;
  color: var(--ink);
  max-width: 64ch;
  margin: 0 auto;
}
.story p { margin: 0 0 1em; }
.story strong { color: var(--aegean-deep); }
.story .dropcap {
  float: left;
  font-family: var(--display);
  font-weight: 800;
  font-size: 4em;
  line-height: .82;
  padding: .04em .14em 0 0;
  color: var(--terracotta);
}
.story__hero {
  margin: 0 -1.5rem 1.5rem;
}
.story__hero img {
  width: 100%;
  display: block;
  border-radius: 4px;
  border: 2px solid var(--ink);
}
.story__inline {
  width: 38%;
  margin: .4em 1rem 1em;
  padding: 0;
}
.story__inline--right { float: right; margin-right: 0; }
.story__inline--left  { float: left; margin-left: 0; }
.story__inline img {
  width: 100%;
  display: block;
  border-radius: 4px;
  border: 2px solid var(--ink);
}
.story__inline figcaption {
  font-family: var(--hand);
  font-size: 1.1em;
  color: var(--ink-mute);
  text-align: center;
  margin-top: .25em;
}
.story__end {
  clear: both;
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px dashed var(--paper-edge);
  font-style: italic;
  color: var(--ink-soft);
}
.story__end .hand { color: var(--terracotta); }
@media (max-width: 600px) {
  .story__inline { float: none; width: 100%; margin: 1em 0; }
}

/* ---------- Footer ---------- */
.pg-footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 1rem;
  color: rgba(251,246,232,.7);
  font-size: .85em;
}
.pg-footer a { color: var(--saffron); text-decoration: underline solid rgba(230,179,55,.5); text-underline-offset: 3px; }

/* Reusable button variant */
.btn--ghost {
  background: transparent;
  color: var(--aegean-deep);
  border: 2px solid var(--aegean-deep);
  box-shadow: none;
  padding: .55rem 1rem;
  cursor: pointer;
  font-family: var(--inscription);
  font-weight: 500;
  font-size: .8em;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: background .15s ease, color .15s ease;
}
.btn--ghost:hover { background: var(--aegean-deep); color: var(--paper); }
