/* ========================================================================
   Hi, Canada! — Storybook stylesheet
   Aesthetic: warm cream paper, deep evergreen, maple, glacier turquoise.
   Display:  Fraunces (warm serif)
   Body:     Newsreader (literary serif)
   Hand:     Caveat (kid handwriting accents)
   ======================================================================== */

:root {
  --paper: #f7efe1;
  --paper-deep: #ebe0cb;
  --ink: #1d2a23;
  --ink-soft: #3b4a3f;
  --forest: #2b5037;
  --forest-deep: #1b3624;
  --moss: #6e8a55;
  --maple: #b94028;
  --maple-soft: #d8654a;
  --sun: #e8b652;
  --glacier: #4ea0a6;
  --glacier-pale: #b7d9d9;
  --tape: rgba(232, 182, 82, 0.55);

  --shadow-photo:
    0 1px 0 rgba(0, 0, 0, 0.05),
    0 8px 18px -8px rgba(46, 38, 24, 0.35),
    0 22px 40px -28px rgba(46, 38, 24, 0.45);

  --serif: "Fraunces", "Newsreader", Georgia, serif;
  --body: "Newsreader", Georgia, serif;
  --hand: "Caveat", "Brush Script MT", cursive;

  --maxw: 1240px;
  --gutter: clamp(1rem, 3vw, 2.5rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* paper grain texture: layered noisy radial gradients + SVG noise */
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 800px at 80% -10%, rgba(184, 124, 60, 0.10), transparent 70%),
    radial-gradient(800px 600px at -10% 30%, rgba(78, 160, 166, 0.08), transparent 60%),
    radial-gradient(900px 700px at 110% 80%, rgba(185, 64, 40, 0.06), transparent 65%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.16 0 0 0 0 0.13 0 0 0 0 0.08 0 0 0 0.12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: auto, auto, auto, 220px 220px;
  background-attachment: fixed, fixed, fixed, fixed;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

/* ---------------- Chapter dot nav ---------------- */

.chapter-nav {
  position: fixed;
  right: clamp(0.5rem, 2vw, 1.5rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.6rem 0.4rem;
  border-radius: 999px;
  background: rgba(247, 239, 225, 0.55);
  backdrop-filter: blur(8px);
}
.chapter-nav .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--forest);
  opacity: 0.35;
  position: relative;
  transition: opacity 0.25s, transform 0.25s;
}
.chapter-nav .dot:hover,
.chapter-nav .dot.active {
  opacity: 1;
  transform: scale(1.4);
}
.chapter-nav .dot:hover { background: var(--maple); }
.dot-label {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  background: var(--ink);
  color: var(--paper);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-family: var(--hand);
  font-size: 1.1rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.chapter-nav .dot:hover .dot-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
@media (max-width: 720px) { .chapter-nav { display: none; } }

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  min-height: 100svh;
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(2rem, 6vw, 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hero-leaf {
  position: absolute;
  inset: auto -8% -22% auto;
  width: min(60vw, 700px);
  color: var(--maple);
  opacity: 0.10;
  transform: rotate(18deg);
  pointer-events: none;
}
.hero-leaf::before {
  content: "";
  position: absolute;
  inset: 8% 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 182, 82, 0.15), transparent 70%);
}

.hero-inner {
  max-width: var(--maxw);
  width: 100%;
  position: relative;
}

.hero-eyebrow {
  font-family: var(--hand);
  color: var(--maple);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  margin: 0 0 1rem;
  letter-spacing: 0.02em;
  transform: rotate(-1.5deg);
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: linear-gradient(90deg, transparent, rgba(232, 182, 82, 0.35), transparent);
}

.hero-title {
  font-family: var(--serif);
  font-weight: 900;
  font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
  font-size: clamp(4.5rem, 16vw, 13rem);
  line-height: 0.85;
  letter-spacing: -0.04em;
  margin: 0;
  color: var(--forest-deep);
  display: flex;
  flex-direction: column;
}
.hero-line-1 {
  align-self: flex-start;
  transform: translateX(-0.05em);
}
.hero-line-2 {
  align-self: flex-start;
  color: var(--maple);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
}
.hero-bang {
  display: inline-block;
  color: var(--forest);
  transform: translateY(-0.05em) rotate(8deg);
}

.hero-script {
  font-family: var(--hand);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  color: var(--ink-soft);
  margin: 1rem 0 1.8rem;
  transform: rotate(-1deg);
  display: inline-block;
}

.hero-lede {
  font-family: var(--body);
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
  max-width: 56ch;
  margin: 0 0 2.5rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

.hero-stops {
  list-style: none;
  margin: 0 0 3.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0;
  border-top: 1px dashed var(--ink-soft);
  border-bottom: 1px dashed var(--ink-soft);
  max-width: 920px;
}
.stop {
  padding: 0.85rem 0.75rem;
  border-right: 1px dashed var(--ink-soft);
  display: flex;
  flex-direction: column;
  position: relative;
}
.stop:last-child { border-right: none; }
.stop-num {
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 0.78rem;
  color: var(--maple);
  letter-spacing: 0.08em;
}
.stop-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  margin-top: 0.15rem;
}
.stop-tag {
  font-family: var(--hand);
  font-size: 1rem;
  color: var(--moss);
  margin-top: 0.05rem;
}

.hero-scroll {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink-soft);
  font-family: var(--hand);
  font-size: 1.2rem;
}
.hero-arrow {
  display: inline-block;
  font-size: 1.6rem;
  animation: bob 2.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

/* ---------------- Prologue (between hero and Chapter 01) ---------------- */

.prologue {
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(3rem, 7vw, 5rem);
  max-width: var(--maxw);
  margin: 0 auto;
  text-align: center;
  position: relative;
}
.prologue-eyebrow {
  font-family: var(--hand);
  color: var(--moss);
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  margin: 0 0 0.6rem;
  letter-spacing: 0.05em;
  opacity: 0.85;
}
.prologue-headline {
  font-family: var(--serif);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(2.2rem, 5.5vw, 4.2rem);
  line-height: 0.95;
  margin: 0 0 clamp(1.5rem, 3vw, 2.5rem);
  color: var(--forest-deep);
  letter-spacing: -0.02em;
}
.prologue-inner {
  display: flex;
  justify-content: center;
}
.prologue .photo-card {
  /* Single column treatment — slightly bigger than a chapter grid item */
  max-width: 540px;
  width: 100%;
  grid-column: auto;
  margin: 0 auto;
}
.prologue .photo-card .photo-frame {
  transform: rotate(-1.4deg);
}
.prologue .photo-fact {
  text-align: left;
}

/* ---------------- Chapter ---------------- */

.chapter {
  padding: clamp(3rem, 8vw, 7rem) var(--gutter);
  max-width: var(--maxw);
  margin: 0 auto;
  position: relative;
}
.chapter + .chapter {
  border-top: 1px dashed rgba(29, 42, 35, 0.25);
}
.chapter::before {
  /* tiny decorative marker between chapters */
  content: "✦";
  position: absolute;
  top: -0.65em;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  color: var(--maple);
  padding: 0 0.6rem;
  font-size: 1.1rem;
}
.chapter:first-of-type::before { display: none; }
.chapter:first-of-type { border-top: none; }

.chapter-head {
  max-width: 760px;
  margin: 0 0 clamp(2rem, 5vw, 4rem);
}
.chapter-num {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--maple);
}
.chapter-num .num {
  font-style: normal;
  font-weight: 900;
  font-variation-settings: "opsz" 144, "WONK" 1;
  font-size: 1.5rem;
  margin-left: 0.5rem;
  vertical-align: -0.05em;
}
.chapter-title {
  font-family: var(--serif);
  font-weight: 900;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-size: clamp(2.8rem, 7vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  color: var(--forest-deep);
  margin: 0.2rem 0 0.6rem;
}
.chapter-sub {
  font-family: var(--hand);
  font-size: clamp(1.2rem, 1.8vw, 1.5rem);
  color: var(--moss);
  margin: 0 0 1.2rem;
}
.chapter-intro {
  font-family: var(--body);
  font-size: clamp(1.05rem, 1.3vw, 1.18rem);
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0;
}

/* ---------------- Photo grid ---------------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(1.2rem, 2.5vw, 2.4rem) clamp(1rem, 2.5vw, 2rem);
  grid-auto-flow: dense;
  align-items: start;
}
@media (max-width: 1000px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
}

.photo-card {
  margin: 0;
  grid-column: span 2;
  position: relative;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.16, 0.84, 0.36, 1);
}
.photo-card.visible {
  opacity: 1;
  transform: translateY(0);
}
.photo-card.span-wide { grid-column: span 3; }
.photo-card.span-tall { grid-column: span 2; grid-row: span 2; }
@media (max-width: 640px) {
  .photo-card,
  .photo-card.span-wide,
  .photo-card.span-tall { grid-column: span 2; grid-row: auto; }
}

.photo-frame {
  position: relative;
  background: #fbf8ee;
  padding: 12px 12px 14px;
  border-radius: 2px;
  box-shadow: var(--shadow-photo);
  transition: transform 0.45s cubic-bezier(0.16, 0.84, 0.36, 1), box-shadow 0.45s;
  will-change: transform;
}
.photo-card.tilt-l1 .photo-frame { transform: rotate(-1.6deg); }
.photo-card.tilt-l2 .photo-frame { transform: rotate(-2.8deg); }
.photo-card.tilt-r1 .photo-frame { transform: rotate(1.4deg); }
.photo-card.tilt-r2 .photo-frame { transform: rotate(2.6deg); }
.photo-card.tilt-0  .photo-frame { transform: rotate(0); }

.photo-frame:hover {
  transform: rotate(0) translateY(-4px) scale(1.015);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.05),
    0 14px 28px -10px rgba(46, 38, 24, 0.4),
    0 36px 60px -34px rgba(46, 38, 24, 0.55);
  z-index: 4;
  cursor: zoom-in;
}

.photo-img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper-deep);
  border-radius: 1px;
}
video.photo-img {
  object-fit: cover;
}
/* Until the source loads, the poster handles the visual; reserve aspect-ratio so layout doesn't jump */
video.photo-img[poster] {
  background:
    url(var(--poster, "")) center/cover no-repeat,
    var(--paper-deep);
}

/* Live Photo "LIVE" pill — Apple-style chip in the corner */
.live-pill {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.2rem 0.55rem 0.22rem 0.42rem;
  background: rgba(15, 20, 18, 0.55);
  color: #fff;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  text-transform: uppercase;
  opacity: 0.85;
  transition: opacity 0.3s;
}
.live-pill::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  animation: livepulse 2.4s ease-in-out infinite;
}
@keyframes livepulse {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.18); }
}
.photo-card.has-motion .photo-frame:hover .live-pill {
  opacity: 1;
}

/* washi tape pieces */
.tape {
  position: absolute;
  background: var(--tape);
  width: 56px;
  height: 18px;
  pointer-events: none;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.06);
}
.tape-tl {
  top: -8px;
  left: -10px;
  transform: rotate(-22deg);
}
.tape-br {
  bottom: -8px;
  right: -12px;
  transform: rotate(25deg);
  background: rgba(78, 160, 166, 0.5);
}

/* fact caption */
.photo-fact {
  position: relative;
  margin: 1.1rem 0.3rem 0 0.3rem;
  padding: 0.85rem 0.95rem 0.85rem 2.5rem;
  background: rgba(255, 252, 244, 0.7);
  border: 1px solid rgba(29, 42, 35, 0.12);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset,
              0 6px 14px -10px rgba(29, 42, 35, 0.5);
  font-family: var(--body);
  font-size: 0.96rem;
  line-height: 1.45;
  color: var(--ink);
}
.photo-fact p { margin: 0; }
.fact-pin {
  position: absolute;
  left: 0.7rem;
  top: 0.6rem;
  width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--maple);
  color: var(--paper);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--serif);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.fact-place {
  display: inline-block;
  margin-top: 0.5rem;
  font-family: var(--hand);
  color: var(--moss);
  font-size: 1.05rem;
}

/* ---------------- Lightbox ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 8, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border: none;
  padding: 2rem 1rem;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
/* Media + caption stack together, vertically centered in the viewport. */
.lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 96vw;
}
.lightbox img {
  max-width: 96vw;
  max-height: min(82vh, calc(100vh - 9rem));
  object-fit: contain;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  background: #000;
  cursor: zoom-out;
}
.lightbox-hint {
  position: fixed;
  bottom: 0.7rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--paper);
  font-family: var(--hand);
  opacity: 0.45;
  font-size: 0.95rem;
  pointer-events: none;
}

/* Caption sits in the stage below the photo — no overlay on the media. */
.lightbox-caption {
  position: relative;
  max-width: min(72ch, 92vw);
  margin: 0;
  padding: 0.45rem 1rem 0.5rem 2.4rem;
  background: rgba(247, 239, 225, 0.94);
  color: var(--ink);
  border: 1px solid rgba(29, 42, 35, 0.18);
  border-radius: 3px;
  font-family: var(--body);
  font-size: clamp(0.92rem, 1.1vw, 1.02rem);
  line-height: 1.4;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 12px 24px -14px rgba(0, 0, 0, 0.5);
  z-index: 105;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.lightbox.open .lightbox-caption.has-content {
  opacity: 1;
  transform: translateY(0);
}
.lightbox-caption .lightbox-fact {
  margin: 0;
}
.lightbox-fact-pin {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--maple);
  color: var(--paper);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--serif);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
@media (max-width: 700px) {
  .lightbox-caption {
    max-width: 94vw;
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem 0.45rem 2.1rem;
  }
}

/* Prev / next nav buttons (translucent chevrons on the sides) */
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(48px, 7vw, 84px);
  height: clamp(48px, 7vw, 84px);
  border-radius: 999px;
  background: rgba(20, 16, 8, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(2rem, 4vw, 3rem);
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 110;
  transition: background 0.2s, transform 0.2s, opacity 0.2s;
  padding: 0;
  padding-bottom: 0.15em; /* optical centering of chevron glyph */
  user-select: none;
}
.lightbox-nav:hover:not(:disabled) {
  background: rgba(20, 16, 8, 0.55);
  transform: translateY(-50%) scale(1.06);
}
.lightbox-nav:active:not(:disabled) {
  transform: translateY(-50%) scale(0.96);
}
.lightbox-nav:disabled {
  opacity: 0.18;
  cursor: not-allowed;
}
.lightbox-nav-prev { left: clamp(0.5rem, 2vw, 1.6rem); }
.lightbox-nav-next { right: clamp(0.5rem, 2vw, 1.6rem); }

/* Counter pill at top */
.lightbox-counter {
  position: fixed;
  top: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--paper);
  background: rgba(20, 16, 8, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  opacity: 0.85;
  pointer-events: none;
  z-index: 105;
}

/* ---------------- Finis ---------------- */

.finis {
  padding: clamp(3rem, 8vw, 6rem) var(--gutter) clamp(3rem, 6vw, 4rem);
  text-align: center;
  background:
    linear-gradient(180deg, transparent, rgba(43, 80, 55, 0.05));
}
.finis-inner { max-width: 720px; margin: 0 auto; }
.finis-mark {
  font-family: var(--hand);
  color: var(--maple);
  font-size: 1.6rem;
  margin: 0 0 1.5rem;
  letter-spacing: 0.4em;
}
.finis-stats {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  color: var(--forest-deep);
  margin: 0 0 1rem;
}
.finis-stats strong { color: var(--maple); font-weight: 700; }
.finis-thanks {
  font-family: var(--hand);
  font-size: 1.25rem;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------------- Motion reduce ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .photo-card { opacity: 1; transform: none; }
  .photo-card .photo-frame { transform: none; }
  /* Don't autoplay motion clips for users who opt out */
  video.photo-img { display: none; }
  .photo-card.has-motion .photo-frame::after {
    content: "";
    display: block;
    width: 100%;
    aspect-ratio: var(--ar, 4/3);
    background: var(--poster, var(--paper-deep)) center/cover no-repeat;
  }
}
