/* ==========================================================================
   25 Reasons I Love You — styles.css
   Landing (chalkboard) → board of polaroids → flip-card viewer.
   No image files: the chalk dust is an inline SVG feTurbulence data URI.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  --board: #1f2a24;
  --chalk: #f4f1e8;
  --paper: #fbf6ea;
  --ink: #2b2a6b;
  --frame: #6b4a2e;
  --card-w: clamp(170px, 60vw, 270px);

  --font-script: "Great Vibes", "Segoe Script", "Brush Script MT", cursive;
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;

  /* Dusty chalk speckle, baked in at low alpha so it can be a single
     background layer instead of an extra element. */
  --chalk-dust: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='d'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.11 0 0 0 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23d)'/%3E%3C/svg%3E");

  /* Layered smudges: chalk haze, a wiped patch, and a soft vignette. */
  --chalk-smudges:
    radial-gradient(ellipse 58% 42% at 17% 12%, rgba(244, 241, 232, 0.07), rgba(244, 241, 232, 0) 68%),
    radial-gradient(ellipse 46% 34% at 84% 74%, rgba(244, 241, 232, 0.055), rgba(244, 241, 232, 0) 70%),
    radial-gradient(ellipse 34% 22% at 63% 22%, rgba(244, 241, 232, 0.045), rgba(244, 241, 232, 0) 72%),
    radial-gradient(ellipse 72% 46% at 48% 104%, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0) 72%),
    radial-gradient(ellipse 90% 60% at 50% -12%, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0) 66%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0) 16%, rgba(0, 0, 0, 0) 84%, rgba(0, 0, 0, 0.3));

  --photo-shadow: 0 10px 18px -8px rgba(0, 0, 0, 0.7), 0 2px 5px rgba(0, 0, 0, 0.42);
  --photo-shadow-hover: 0 22px 38px -12px rgba(0, 0, 0, 0.75), 0 4px 10px rgba(0, 0, 0, 0.4);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --------------------------------------------------------------------------
   2. Global
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: 100vh; /* fallback */
  height: 100svh;
  margin: 0;
  overflow: hidden;
  background: var(--board);
}

body {
  color: var(--chalk);
  font-family: var(--font-hand);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.8);
  outline-offset: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3. Chalkboard (landing + board share the surface and the wooden frame)
   -------------------------------------------------------------------------- */
.landing,
.board {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: var(--board);
  background-image: var(--chalk-dust), var(--chalk-smudges);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: 220px 220px, cover, cover, cover, cover, cover;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Wooden frame: a grain strip at the top … */
.landing::before,
.board::before,
.landing::after,
.board::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 2px, rgba(255, 255, 255, 0.05) 2px 5px, rgba(0, 0, 0, 0) 5px 12px, rgba(0, 0, 0, 0.14) 12px 14px),
    linear-gradient(180deg, #7d5838, var(--frame) 42%, #432c1b);
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.landing::before,
.board::before {
  top: 0;
  height: clamp(10px, 1.5vh, 18px);
}

/* … and a deeper ledge at the bottom, dusted with chalk. */
.landing::after,
.board::after {
  bottom: 0;
  height: clamp(14px, 2.4vh, 26px);
  background-image:
    radial-gradient(ellipse 26% 120% at 18% 0%, rgba(244, 241, 232, 0.28), rgba(244, 241, 232, 0) 72%),
    radial-gradient(ellipse 30% 130% at 74% 0%, rgba(244, 241, 232, 0.2), rgba(244, 241, 232, 0) 70%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 2px, rgba(255, 255, 255, 0.05) 2px 5px, rgba(0, 0, 0, 0) 5px 12px, rgba(0, 0, 0, 0.14) 12px 14px),
    linear-gradient(180deg, #7d5838, var(--frame) 34%, #3b2717);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

/* --------------------------------------------------------------------------
   4. Landing
   -------------------------------------------------------------------------- */
.landing {
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.6vh, 26px);
  padding-inline: max(6vw, env(safe-area-inset-left), env(safe-area-inset-right));
  text-align: center;
  opacity: 1;
  transform: scale(1);
  visibility: visible;
  transition: opacity 450ms ease, transform 450ms var(--ease-out), visibility 0s linear 0s;
}

body.is-board .landing,
body:not(.is-landing) .landing {
  opacity: 0;
  transform: scale(1.05);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 450ms ease, transform 450ms var(--ease-out), visibility 0s linear 450ms;
}

.landing__heading {
  margin: 0;
  max-width: 100%;
  font-weight: 400;
  line-height: 1;
}

/* Chalk lettering: stacked shadows give the slightly rough, glowing edge. */
.landing__title {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-script);
  font-size: clamp(2.75rem, 13.5vw, 8.5rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: var(--chalk);
  text-shadow:
    0 0 1px rgba(244, 241, 232, 0.9),
    1px 1px 0 rgba(244, 241, 232, 0.28),
    -1px -1px 0 rgba(244, 241, 232, 0.22),
    0 0 10px rgba(244, 241, 232, 0.4),
    0 0 34px rgba(244, 241, 232, 0.2),
    0 0 72px rgba(244, 241, 232, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.45);
  transition: text-shadow 300ms ease, transform 300ms var(--ease-out);
}

.landing__title:active {
  transform: scale(0.985);
}

.landing__title:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.85);
  outline-offset: 14px;
}

.landing__hint {
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4vw, 1.35rem);
  letter-spacing: 0.06em;
  color: rgba(244, 241, 232, 0.85);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  animation: chalk-pulse 2.6s ease-in-out infinite;
}

@keyframes chalk-pulse {
  0%,
  100% {
    opacity: 0.68;
  }
  50% {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   5. Board + track
   -------------------------------------------------------------------------- */
.board {
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 450ms ease 120ms, visibility 0s linear 570ms;
}

body.is-board .board {
  opacity: 1;
  visibility: visible;
  transition: opacity 450ms ease 180ms, visibility 0s linear 0s;
}

/* Initial state, stated explicitly: landing up, board put away. */
body.is-landing .landing {
  opacity: 1;
  transform: scale(1);
  visibility: visible;
  pointer-events: auto;
}

body.is-landing .board {
  opacity: 0;
  visibility: hidden;
}

/* The board stays laid out (but invisible) while marked hidden, so the
   script can measure the track before the landing is dismissed. Visibility,
   not display, is what hides it. */
.board[hidden] {
  display: block;
}

.board__track {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  /* pan-x keeps the swipe; pinch-zoom still lets a low-vision user enlarge
     the captions. */
  touch-action: pan-x pinch-zoom;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.board__track::-webkit-scrollbar {
  display: none;
}

.board__track.is-dragging {
  cursor: grabbing;
}

.board__track:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.55);
  outline-offset: -6px;
}

.board__set {
  display: flex;
  align-items: center;
  flex: none;
  padding-inline: 4vw;
}

.board__hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + clamp(14px, 2.4vh, 26px) + 8px);
  z-index: 6;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--font-hand);
  font-size: clamp(0.85rem, 3.4vw, 1.05rem);
  letter-spacing: 0.08em;
  color: rgba(244, 241, 232, 0.6);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   6. Pin (shared by polaroids and the note card)
   -------------------------------------------------------------------------- */
.pin {
  position: absolute;
  top: -9px;
  left: 50%;
  z-index: 2;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 52% 58%, var(--pin, #c0392b), rgba(0, 0, 0, 0.5) 96%);
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 -1px 2px rgba(0, 0, 0, 0.35);
}

/* Needle shadow, cast onto the paper under the pin head. */
.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 82%;
  width: 9px;
  height: 6px;
  transform: translate(-50%, 3px);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0) 72%);
}

/* --------------------------------------------------------------------------
   7. Polaroid
   -------------------------------------------------------------------------- */
.polaroid {
  position: relative;
  display: block;
  flex: none;
  width: var(--card-w);
  margin-left: calc(clamp(16px, 5vw, 48px) + var(--dx, 0px));
  padding: calc(var(--card-w) * 0.08) calc(var(--card-w) * 0.08) calc(var(--card-w) * 0.24);
  border: 0;
  border-radius: 2px;
  background: #fdfdfb;
  box-shadow: var(--photo-shadow);
  transform: translateY(var(--dy, 0px)) rotate(var(--rot, 0deg));
  transition: transform 280ms var(--ease-out), box-shadow 280ms ease;
  text-align: center;
  color: var(--ink);
}

.polaroid__photo {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: #cfcac2;
}

.polaroid__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.polaroid__photo.is-missing {
  /* Keep the grey card, drop the broken-image chrome, show the label. */
  background: #cfcac2;
}

.polaroid__photo.is-missing img {
  display: none;
}

.polaroid__photo.is-missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8%;
  font-family: var(--font-hand);
  font-size: clamp(0.85rem, 3.4vw, 1.05rem);
  line-height: 1.2;
  color: rgba(43, 42, 107, 0.8);
  text-align: center;
}

.polaroid__caption {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 4.5%;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4.4vw, 1.35rem);
  font-weight: 500;
  line-height: 1.1;
  color: var(--ink);
  text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .polaroid:hover {
    box-shadow: var(--photo-shadow-hover);
    transform: translateY(calc(var(--dy, 0px) - 8px)) rotate(calc(var(--rot, 0deg) * 0.28)) scale(1.015);
  }

  .note-card:hover {
    box-shadow: var(--photo-shadow-hover);
    transform: translateY(calc(var(--dy, 0px) - 8px)) rotate(calc(var(--rot, 0deg) * 0.28)) scale(1.015);
  }
}

.polaroid:focus-visible {
  box-shadow: var(--photo-shadow-hover), 0 0 0 6px rgba(31, 42, 36, 0.9), 0 0 0 8px rgba(244, 241, 232, 0.5);
  transform: translateY(calc(var(--dy, 0px) - 8px)) rotate(calc(var(--rot, 0deg) * 0.28)) scale(1.015);
}

/* --------------------------------------------------------------------------
   8. Final note card (same height as a polaroid, ~1.15× as wide)
   -------------------------------------------------------------------------- */
.note-card {
  position: relative;
  display: block;
  flex: none;
  width: calc(var(--card-w) * 1.15);
  height: calc(var(--card-w) * 1.37);
  margin-left: calc(clamp(16px, 5vw, 48px) + var(--dx, 0px));
  padding: calc(var(--card-w) * 0.09) calc(var(--card-w) * 0.08) calc(var(--card-w) * 0.08) calc(var(--card-w) * 0.08 + 26px);
  border: 0;
  border-radius: 2px;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(to bottom, rgba(43, 42, 107, 0) 0 26px, rgba(43, 42, 107, 0.13) 26px 27px),
    radial-gradient(ellipse 120% 70% at 50% 0%, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, #fdf8ee, #f6efdf);
  background-position: 0 7px, 0 0, 0 0;
  box-shadow: var(--photo-shadow);
  transform: translateY(var(--dy, 0px)) rotate(var(--rot, 0deg));
  transition: transform 280ms var(--ease-out), box-shadow 280ms ease;
  text-align: left;
  color: var(--ink);
}

/* Red margin rule, like a page torn from a notebook. */
.note-card::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 24px;
  width: 1.5px;
  background: rgba(192, 57, 43, 0.4);
}

.note-card__text {
  position: relative;
  z-index: 1;
  display: block;
  font-family: var(--font-hand);
  font-size: clamp(1.2rem, 4.8vw, 1.7rem);
  font-weight: 500;
  line-height: 1.32;
  color: var(--ink);
  text-wrap: pretty;
}

.note-card:focus-visible {
  box-shadow: var(--photo-shadow-hover), 0 0 0 6px rgba(31, 42, 36, 0.9), 0 0 0 8px rgba(244, 241, 232, 0.5);
  transform: translateY(calc(var(--dy, 0px) - 8px)) rotate(calc(var(--rot, 0deg) * 0.28)) scale(1.015);
}

/* --------------------------------------------------------------------------
   9. Viewer
   -------------------------------------------------------------------------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 0s linear 200ms;
}

body.viewer-open .viewer {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 200ms ease;
}

/* The body class is authoritative: it can open a viewer that still carries
   the initial `hidden` attribute from the shell. */
body.viewer-open .viewer[hidden] {
  display: block;
}

.viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 12, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.viewer__stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    calc(env(safe-area-inset-top) + 62px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 16px);
  /* The stage spans the whole viewer, so it must not swallow taps meant for
     the backdrop or the close button; only the card takes pointer events. */
  pointer-events: none;
}

.viewer__card {
  position: relative;
  display: block;
  width: min(88vw, calc(80vh * 0.8), 520px);
  width: min(88vw, calc(80svh * 0.8), 520px);
  aspect-ratio: 4 / 5;
  /* The card is sized by the viewport, so the note text is sized by the
     card (cq units) instead of by vw — width-based text overflows a card
     that shrank because of the viewport height. */
  container-type: size;
  /* The 3D context of the flip is the inner card, so the perspective belongs
     here (a grandchild is not affected by the stage's). */
  perspective: 1400px;
  pointer-events: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.viewer__card:focus {
  outline: none;
}

.viewer__card:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.8);
  outline-offset: 6px;
}

.viewer__inner {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 650ms var(--ease-out);
}

.viewer.is-flipped .viewer__inner {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 3px;
  box-shadow: 0 26px 60px -18px rgba(0, 0, 0, 0.85), 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Front = polaroid frame around the photo. */
.face--front {
  padding: 4.5%;
  background: #fdfdfb;
  box-shadow: 0 26px 60px -18px rgba(0, 0, 0, 0.85), 0 6px 16px rgba(0, 0, 0, 0.5);
}

.viewer__photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #cfcac2;
  pointer-events: none;
}

/* A photo that fails inside the viewer: keep the polaroid frame, grey the
   photo window, and show a label if the caller supplied one. */
.face--front.is-missing::before {
  content: "";
  position: absolute;
  inset: 4.5%;
  background: #cfcac2;
}

.face--front.is-missing .viewer__photo {
  visibility: hidden;
}

.face--front.is-missing::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10%;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4vw, 1.3rem);
  color: rgba(43, 42, 107, 0.8);
  text-align: center;
}

/* Back = ruled note paper with the reason. */
.face--back {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(18px, 5.5%, 36px) clamp(18px, 6%, 38px);
  transform: rotateY(180deg);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(to bottom, rgba(43, 42, 107, 0) 0 27px, rgba(43, 42, 107, 0.12) 27px 28px),
    radial-gradient(ellipse 120% 60% at 50% 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, #fdf8ee, #f6efdf);
  color: var(--ink);
  text-align: center;
}

.note__num {
  flex: none;
  margin-top: auto;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4vw, 1.4rem); /* fallback: no container queries */
  font-size: clamp(0.75rem, 5cqh, 1.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(43, 42, 107, 0.75);
}

.note__text {
  display: block;
  width: 100%;
  min-height: 0;
  margin-bottom: auto;
  padding-block: clamp(8px, 2.4%, 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-hand);
  font-size: clamp(1.25rem, 5.4vw, 2rem); /* fallback: no container queries */
  font-size: clamp(14px, 5cqh, 2rem);
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  text-wrap: pretty;
}

/* Final card: one side only, no flip. */
.viewer.is-note-only .viewer__inner {
  transform: none;
}

.viewer.is-note-only .face--front {
  display: none;
}

.viewer.is-note-only .face--back {
  transform: none;
  -webkit-backface-visibility: visible;
  backface-visibility: visible;
}

.viewer.is-note-only .viewer__card {
  cursor: default;
}

.viewer.is-note-only .note__num {
  display: none;
}

.viewer.is-note-only .note__text {
  margin-top: auto;
  margin-bottom: auto;
}

.viewer__close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 12px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1.5px solid rgba(244, 241, 232, 0.45);
  border-radius: 50%;
  background: rgba(31, 42, 36, 0.55);
  color: var(--chalk);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: background-color 200ms ease, border-color 200ms ease;
}

.viewer__close span {
  display: block;
  margin-top: -2px;
  font-family: var(--font-hand);
  font-size: 1.9rem;
  line-height: 1;
}

.viewer__close:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.9);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .viewer__close:hover {
    border-color: rgba(244, 241, 232, 0.8);
    background: rgba(52, 70, 60, 0.7);
  }
}

/* --------------------------------------------------------------------------
   10. Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }

  .landing__hint {
    animation: none;
    opacity: 0.9;
  }

  /* No lift or straightening on hover — the cards stay exactly where pinned. */
  .polaroid:hover,
  .polaroid:focus-visible,
  .note-card:hover,
  .note-card:focus-visible {
    transform: translateY(var(--dy, 0px)) rotate(var(--rot, 0deg));
  }

  .polaroid:hover,
  .note-card:hover {
    box-shadow: var(--photo-shadow);
  }
}

/* --------------------------------------------------------------------------
   11. Short viewports / very small screens
   -------------------------------------------------------------------------- */
@media (max-height: 620px) {
  :root {
    --card-w: clamp(150px, 42vw, 215px);
  }

  .landing__title {
    font-size: clamp(2.6rem, 11vw, 6rem);
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  :root {
    /* Scale with height so the card, its --dy offset, rotation and pin all
       stay inside the track on short landscape screens. */
    --card-w: clamp(120px, 40vh, 168px);
  }

  .viewer__card {
    /* Fit the stage: 62px top padding + 24px bottom padding, plus slack. */
    width: min(78vw, calc((100vh - 100px) * 0.8), 520px);
    width: min(78vw, calc((100svh - 100px) * 0.8), 520px);
  }
}

@media (max-width: 380px) {
  .board__set {
    padding-inline: 3vw;
  }

  .note-card {
    padding-left: calc(var(--card-w) * 0.06 + 24px);
  }
}

/* --------------------------------------------------------------------------
   12. Unlock
   -------------------------------------------------------------------------- */
.unlock {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 26px);
  padding: max(20px, env(safe-area-inset-top)) max(18px, 6vw)
    max(20px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--board);
  background-image: var(--chalk-dust), var(--chalk-smudges);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  background-size: 220px 220px, cover, cover, cover, cover, cover;
  color: var(--chalk);
  text-align: center;
}

body:not(.is-locked) .unlock {
  display: none;
}

.unlock__title {
  margin: 0;
  max-width: 100%;
  font-family: var(--font-script);
  font-size: clamp(2.1rem, 10vw, 4.5rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-wrap: balance;
  color: var(--chalk);
  text-shadow:
    0 0 1px rgba(244, 241, 232, 0.9),
    1px 1px 0 rgba(244, 241, 232, 0.28),
    -1px -1px 0 rgba(244, 241, 232, 0.22),
    0 0 10px rgba(244, 241, 232, 0.4),
    0 0 34px rgba(244, 241, 232, 0.2),
    0 6px 18px rgba(0, 0, 0, 0.45);
}

.unlock__form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.unlock__form label {
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4vw, 1.2rem);
  letter-spacing: 0.05em;
  color: rgba(244, 241, 232, 0.9);
}

.unlock__form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(244, 241, 232, 0.45);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--chalk);
  font: inherit;
  font-size: 1.15rem;
  text-align: center;
}

.unlock__form input:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.85);
  outline-offset: 3px;
}

.unlock__form button {
  min-width: 120px;
  min-height: 44px;
  padding: 8px 26px;
  border: 1px solid rgba(244, 241, 232, 0.6);
  border-radius: 999px;
  background: rgba(244, 241, 232, 0.1);
  color: var(--chalk);
  font-family: var(--font-hand);
  font-size: clamp(1.05rem, 4vw, 1.3rem);
  letter-spacing: 0.06em;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.unlock__form button:disabled {
  opacity: 0.55;
  cursor: default;
}

.unlock__form button:focus-visible {
  outline: 2px dashed rgba(244, 241, 232, 0.9);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .unlock__form button:not(:disabled):hover {
    border-color: rgba(244, 241, 232, 0.9);
    background: rgba(244, 241, 232, 0.18);
  }
}

.unlock__error {
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(1rem, 4vw, 1.15rem);
  color: #f2b6aa;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.unlock__status {
  min-height: 1.4em;
  margin: 0;
  font-family: var(--font-hand);
  font-size: clamp(0.95rem, 3.6vw, 1.1rem);
  color: rgba(244, 241, 232, 0.78);
}
