/* Momo's warm storybook gallery: local, quiet, and made for reading. */
:root {
  --cream: #fff8ec;
  --paper: #fffdf7;
  --peach: #f6c9bd;
  --pink: #d97b86;
  --soft-brown: #775047;
  --ink: #382b28;
  --muted-ink: #684f49;
  --line: #dfb8ab;
  --focus: #724119;
  color-scheme: light;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 100%;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }
body { margin: 0; min-width: 0; overflow-x: hidden; background: var(--cream); }
button, summary { font: inherit; }

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.hero {
  position: relative;
  display: grid;
  gap: 2rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 4.5rem 1rem 3rem;
}
.hero::before,
.hero::after {
  position: absolute;
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  background: var(--pink);
  transform: rotate(45deg);
}
.hero::before { top: 2rem; left: 9%; }
.hero::after { top: 4rem; right: 8%; background: var(--soft-brown); }
.hero-copy { align-self: center; max-width: 38rem; }
.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--soft-brown);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
h1, h2 { margin: 0; color: var(--ink); line-height: 1.05; font-weight: 700; }
h1 { max-width: 8ch; font-size: clamp(3.1rem, 16vw, 6.7rem); letter-spacing: -0.055em; }
h2 { font-size: clamp(2rem, 8vw, 3.8rem); letter-spacing: -0.035em; }
.invitation { max-width: 34rem; margin: 1.3rem 0; color: var(--muted-ink); font-size: 1.12rem; line-height: 1.65; }

.music-button,
.lightbox-trigger,
.lightbox-close,
.lightbox-controls button {
  min-height: 44px;
  min-width: 44px;
  border: 2px solid var(--soft-brown);
  padding: 0.65rem 1rem;
  background: var(--paper);
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, sans-serif;
  font-weight: 700;
  cursor: pointer;
}
.music-button:disabled { cursor: not-allowed; opacity: 0.72; }
.music-status { min-height: 1.5em; margin: 0.55rem 0 0; color: var(--muted-ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

.hero-story { margin: 0; padding: 0.75rem; background: var(--paper); box-shadow: 0.6rem 0.6rem 0 var(--peach); transform: rotate(0.8deg); }
.story-image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: var(--paper);
}
.story-meta { padding: 0.85rem 0.2rem 0.15rem; }
figcaption { color: var(--ink); font-size: 1.16rem; font-weight: 700; }
.lightbox-trigger { margin-top: 0.65rem; width: 100%; }
.story-transcript { margin-top: 0.6rem; color: var(--muted-ink); line-height: 1.55; }
.story-transcript summary { min-height: 44px; display: flex; align-items: center; color: var(--soft-brown); cursor: pointer; font-family: "Trebuchet MS", Arial, sans-serif; font-weight: 700; }
.story-transcript p { margin: 0.4rem 0 0; padding-left: 0.8rem; border-left: 2px solid var(--line); }

.gallery-section { position: relative; max-width: 76rem; margin: 0 auto; padding: 3rem 1rem 5rem; }
.section-heading { max-width: 42rem; margin-bottom: 2.5rem; }
.story-gallery { display: grid; gap: 3rem; }
.gallery-story { margin: 0; min-width: 0; }
.gallery-story:nth-child(3n + 1) { transform: rotate(-0.45deg); }
.gallery-story:nth-child(3n + 2) { transform: translateY(0.7rem) rotate(0.35deg); }
.gallery-story:nth-child(3n) { transform: rotate(0.2deg); }
.gallery-story .story-frame { padding: 0.6rem; background: var(--paper); border: 1px solid var(--line); box-shadow: 0.45rem 0.45rem 0 var(--peach); }

.closing { position: relative; padding: 4.5rem 1rem 5rem; text-align: left; background: var(--peach); }
.closing h2, .closing p { max-width: 48rem; margin-left: auto; margin-right: auto; }
.closing p { margin-top: 1rem; margin-bottom: 0; color: var(--ink); font-size: clamp(1.25rem, 5vw, 2rem); line-height: 1.5; }
.closing-star { display: block; width: 0.9rem; height: 0.9rem; margin: 0 auto 1.5rem; background: var(--soft-brown); transform: rotate(45deg); }
dialog[hidden] { display: none; }

.lightbox {
  width: min(62rem, calc(100% - 1rem));
  height: fit-content;
  max-width: none;
  max-height: calc(100dvh - 1rem);
  margin: auto;
  border: 2px solid var(--soft-brown);
  padding: 0.65rem;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(56, 43, 40, 0.82); }
.lightbox-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.65rem;
  max-height: calc(100dvh - 2.3rem);
  min-height: 0;
}
.lightbox-close { justify-self: end; }
.lightbox-picture {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  height: min(52dvh, 28rem);
  background: var(--cream);
}
.lightbox-picture img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
}
.lightbox-copy { min-width: 0; }
.lightbox-copy h2 { font-size: clamp(1.45rem, 6vw, 2.35rem); }
.lightbox-copy p { margin: 0.45rem 0 0; line-height: 1.4; }
#lightbox-transcript { max-height: 4.3rem; overflow-y: auto; color: var(--muted-ink); }
.lightbox-status { font-family: "Trebuchet MS", Arial, sans-serif; font-weight: 700; }
.lightbox-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.lightbox-controls button:disabled { cursor: not-allowed; opacity: 0.5; }

.js-ready .reveal-pending .story-frame {
  opacity: 0.35;
  transform: translateY(0.65rem);
}
.js-ready .reveal-visible .story-frame {
  opacity: 1;
  transform: none;
  transition: opacity 420ms ease-out, transform 420ms ease-out;
}

@media (min-width: 48rem) {
  .hero { grid-template-columns: minmax(0, 0.9fr) minmax(22rem, 1.1fr); align-items: center; padding: 6rem 2rem 5rem; }
  .gallery-section { padding: 5rem 2rem 7rem; }
  .story-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 3.5rem; row-gap: 5rem; }
  .gallery-story:nth-child(even) { margin-top: 4rem; }
  .lightbox { height: min(46rem, calc(100dvh - 2rem)); padding: 1rem; }
  .lightbox-panel {
    grid-template-columns: minmax(0, 1.6fr) minmax(16rem, 0.8fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 1rem;
    height: 100%;
    max-height: none;
  }
  .lightbox-close { grid-column: 2; grid-row: 1; }
  .lightbox-picture { grid-column: 1; grid-row: 1 / 4; height: auto; }
  .lightbox-copy { grid-column: 2; grid-row: 2; align-self: center; }
  .lightbox-controls { grid-column: 2; grid-row: 3; }
  #lightbox-transcript { max-height: 12rem; }
}

@media (min-width: 72rem) {
  .hero { gap: 5rem; padding-left: 3rem; padding-right: 3rem; }
  .gallery-section { padding-left: 3rem; padding-right: 3rem; }
  .story-gallery { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .gallery-story { grid-column: span 6; }
  .gallery-story:nth-child(4n + 2), .gallery-story:nth-child(4n + 3) { grid-column: 2 / span 5; }
  .gallery-story:nth-child(4n + 3) { grid-column: 7 / span 5; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .hero-story .story-frame,
  .gallery-story .story-frame,
  .reveal-pending .story-frame,
  .reveal-visible .story-frame {
    opacity: 1;
    transform: none;
    transition: none !important;
  }
}

@media print {
  :root, body { background: #fff; color: #000; }
  .music-button, .lightbox-trigger, .skip-link { display: none; }
  .hero, .story-gallery { display: block; }
  .hero-story, .gallery-story { break-inside: avoid; margin: 0 0 1.5rem; transform: none; box-shadow: none; }
  .story-transcript p { display: block; }
}
