:root {
  --ink: #25211f;
  --muted: #6d625c;
  --paper: #fffaf0;
  --paper-warm: #fbf1df;
  --paper-edge: #e1d4bc;
  --rose: #ae4b58;
  --moss: #5d704f;
  --blue: #486f86;
  --surface: #e9eee9;
  --shadow: 0 24px 70px rgba(37, 33, 31, 0.2);
  --ui-font: "Nunito", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --note-font: "Patrick Hand", "Bradley Hand", "Segoe Print", cursive;
  color-scheme: light;
  font-family: var(--ui-font);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(72, 111, 134, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(93, 112, 79, 0.07) 1px, transparent 1px),
    linear-gradient(128deg, rgba(174, 75, 88, 0.12), transparent 38%),
    linear-gradient(235deg, rgba(72, 111, 134, 0.18), transparent 48%),
    linear-gradient(160deg, #eef3ef 0%, #f8efe0 52%, #e7eef4 100%);
  background-size:
    56px 56px,
    56px 56px,
    auto,
    auto,
    auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.38;
  background:
    repeating-linear-gradient(102deg, rgba(37, 33, 31, 0.035) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(12deg, rgba(255, 250, 240, 0.32) 0 2px, transparent 2px 10px);
  mix-blend-mode: multiply;
}

body.lightbox-open {
  overflow: hidden;
}

button {
  font: inherit;
}

.memory-page {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 36px);
}

@keyframes soft-reveal {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body[data-unlocked="false"] .gallery-shell,
body[data-unlocked="true"] .lock-screen {
  display: none;
}

.lock-screen {
  width: min(520px, 100%);
  position: relative;
  isolation: isolate;
}

.lock-screen::before,
.lock-screen::after {
  content: "";
  position: absolute;
  left: 50%;
  z-index: -1;
  width: min(260px, 58vw);
  height: min(330px, 72vw);
  background:
    linear-gradient(var(--paper) 0 72%, var(--paper-warm) 72% 100%),
    repeating-linear-gradient(105deg, rgba(37, 33, 31, 0.025) 0 1px, transparent 1px 8px);
  border: 1px solid rgba(37, 33, 31, 0.1);
  border-radius: 5px;
  box-shadow: 0 20px 54px rgba(37, 33, 31, 0.16);
}

.lock-screen::before {
  top: -34px;
  transform: translateX(-78%) rotate(-8deg);
}

.lock-screen::after {
  right: 0;
  bottom: -32px;
  transform: translateX(-18%) rotate(7deg);
  opacity: 0.78;
}

.lock-card {
  position: relative;
  display: grid;
  gap: clamp(18px, 4vw, 28px);
  padding: clamp(22px, 6vw, 42px);
  background:
    repeating-linear-gradient(105deg, rgba(37, 33, 31, 0.03) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 250, 240, 0.88)),
    var(--paper);
  border: 1px solid rgba(37, 33, 31, 0.13);
  border-radius: 7px;
  box-shadow:
    0 26px 72px rgba(37, 33, 31, 0.2),
    0 2px 0 rgba(255, 255, 255, 0.76) inset;
  backdrop-filter: blur(12px);
  animation: soft-reveal 520ms ease both;
}

.secret-form {
  width: 100%;
  display: grid;
  gap: 10px;
}

.secret-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.secret-row input,
.secret-row button {
  min-height: 48px;
  border-radius: 6px;
}

.secret-row input {
  width: 100%;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.84);
  border: 1px solid rgba(32, 33, 36, 0.18);
  font-size: 1rem;
  box-shadow: inset 0 1px 4px rgba(37, 33, 31, 0.06);
}

.secret-row input:focus {
  outline: 3px solid rgba(71, 113, 143, 0.28);
  border-color: var(--blue);
}

.secret-row button {
  padding: 0 20px;
  color: var(--paper);
  background: linear-gradient(180deg, #2f2a27, #1f1c1a);
  border: 0;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 33, 31, 0.16);
  white-space: nowrap;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.secret-row button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(37, 33, 31, 0.2);
}

.secret-row button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.secret-error {
  min-height: 1.25em;
  margin: 0;
  color: var(--rose);
  font-size: 0.92rem;
  font-weight: 700;
}

.gallery-shell {
  width: min(1120px, 100%);
  display: grid;
  gap: clamp(10px, 1.6vw, 18px);
  animation: soft-reveal 520ms ease both;
}

.gallery-intro,
.lock-card {
  justify-items: center;
  text-align: center;
}

.gallery-intro {
  display: grid;
  padding-inline: 12px;
}

.gallery-title {
  max-width: 760px;
  margin: 0;
  color: var(--ink);
  font-family: var(--note-font);
  font-size: clamp(2.2rem, 6.6vw, 4.45rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 10px 26px rgba(37, 33, 31, 0.14);
}

.lock-card .gallery-title {
  font-size: clamp(2.1rem, 5vw, 3.08rem);
}

.title-names,
.title-place {
  display: block;
}

.title-names {
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--moss);
  font-size: clamp(0.78rem, 1.4vw, 0.92rem);
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.stage {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: clamp(8px, 2vw, 24px);
  filter: drop-shadow(0 22px 44px rgba(37, 33, 31, 0.08));
}

.carousel {
  min-width: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 10px 0 18px;
  outline: none;
}

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

.carousel:focus-visible {
  border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(71, 113, 143, 0.24);
}

.slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  padding: 0 clamp(6px, 2vw, 22px);
}

.instax-card {
  position: relative;
  isolation: isolate;
  width: min(100%, 440px);
  min-height: min(650px, calc(100svh - 178px));
  margin: 0;
  display: grid;
  align-content: start;
  gap: clamp(13px, 2.2vw, 18px);
  padding:
    clamp(12px, 2.5vw, 18px)
    clamp(12px, 2.5vw, 18px)
    clamp(24px, 4.5vw, 38px);
  background:
    repeating-linear-gradient(105deg, rgba(37, 33, 31, 0.028) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #fffdf7 0%, var(--paper) 62%, var(--paper-warm) 100%);
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  box-shadow:
    0 28px 76px rgba(37, 33, 31, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.86) inset,
    0 -1px 0 rgba(37, 33, 31, 0.05) inset;
  transform: rotate(var(--tilt)) scale(0.96);
  transition:
    transform 260ms ease,
    box-shadow 260ms ease,
    opacity 260ms ease;
  opacity: 0.78;
}

.instax-card::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 2;
  width: 92px;
  height: 24px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 5px, transparent 5px 10px),
    rgba(230, 208, 155, 0.64);
  border: 1px solid rgba(132, 104, 58, 0.12);
  border-radius: 2px;
  box-shadow: 0 5px 12px rgba(37, 33, 31, 0.1);
  transform: translateX(-50%) rotate(calc(var(--tilt) * -0.8));
}

.slide.is-active .instax-card {
  opacity: 1;
  transform: rotate(var(--tilt)) scale(1);
  box-shadow:
    0 32px 92px rgba(37, 33, 31, 0.27),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -1px 0 rgba(37, 33, 31, 0.05) inset;
}

.photo-window {
  position: relative;
  z-index: 1;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #d9ded8;
  border-radius: 4px;
  border: 1px solid rgba(37, 33, 31, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(32, 33, 36, 0.06),
    0 10px 18px rgba(37, 33, 31, 0.08);
  cursor: zoom-in;
}

.photo-window img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-window::after {
  content: "+";
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: rgba(32, 33, 36, 0.62);
  border: 1px solid rgba(255, 250, 240, 0.34);
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  pointer-events: none;
}

.photo-window:hover::after,
.photo-window:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.photo-window:focus-visible {
  outline: 4px solid rgba(71, 113, 143, 0.32);
  outline-offset: 4px;
}

.photo-window--contain {
  display: grid;
  place-items: center;
  background:
    linear-gradient(45deg, rgba(32, 33, 36, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(32, 33, 36, 0.06) 25%, transparent 25%),
    #ece9df;
  background-size: 18px 18px;
}

.photo-window--portrait {
  aspect-ratio: 4 / 5;
}

.photo-window--contain img {
  object-fit: contain;
}

figcaption {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 7px;
  align-items: start;
  min-height: 118px;
  padding-inline: 3px;
}

figcaption p {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-family: var(--note-font);
  font-size: clamp(1.36rem, 2.45vw, 1.56rem);
  line-height: 1.26;
  overflow-wrap: anywhere;
}

.short-caption p {
  font-size: clamp(1.54rem, 2.72vw, 1.76rem);
  line-height: 1.2;
}

.nav-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0 0 4px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.84);
  border: 1px solid rgba(37, 33, 31, 0.12);
  border-radius: 50%;
  box-shadow:
    0 14px 36px rgba(37, 33, 31, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.78) inset;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.nav-button span {
  font-size: 2.5rem;
  line-height: 1;
}

.nav-button:hover {
  background: #fffaf0;
  transform: translateY(-1px);
}

.nav-button:focus-visible,
.dot:focus-visible {
  outline: 3px solid rgba(71, 113, 143, 0.44);
  outline-offset: 4px;
}

.nav-button:disabled {
  opacity: 0.32;
  cursor: default;
  transform: none;
}

.dots {
  min-height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  padding-inline: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  padding: 0;
  background: rgba(37, 33, 31, 0.2);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition:
    width 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.dot:hover {
  transform: scale(1.18);
}

.dot[aria-current="true"] {
  width: 28px;
  background: var(--blue);
  border-radius: 999px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(17, 18, 20, 0.9);
  backdrop-filter: blur(16px);
}

.lightbox[aria-hidden="true"] {
  display: none;
}

.lightbox-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.lightbox-button {
  min-width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0 13px;
  color: #fffaf0;
  background: rgba(255, 250, 240, 0.14);
  border: 1px solid rgba(255, 250, 240, 0.2);
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 850;
  cursor: pointer;
}

.lightbox-button:hover {
  background: rgba(255, 250, 240, 0.22);
}

.lightbox-button:focus-visible {
  outline: 3px solid rgba(255, 250, 240, 0.42);
  outline-offset: 3px;
}

.lightbox-close {
  margin-left: 8px;
  font-size: 1.5rem;
}

.lightbox-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
}

.lightbox-stage.is-dragging {
  cursor: grabbing;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  transform: translate3d(var(--lightbox-x, 0px), var(--lightbox-y, 0px), 0)
    scale(var(--lightbox-scale, 1));
  transform-origin: center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

@media (max-width: 680px) {
  .memory-page {
    padding: 14px 10px 18px;
  }

  .lock-card {
    padding: 24px 18px;
  }

  .lock-screen::before,
  .lock-screen::after {
    width: 190px;
    height: 248px;
    opacity: 0.56;
  }

  .secret-row {
    grid-template-columns: 1fr;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .gallery-title {
    max-width: 100%;
    font-size: clamp(1.9rem, 8.4vw, 2.65rem);
    line-height: 1;
  }

  .lock-card .gallery-title {
    font-size: clamp(2rem, 8.8vw, 2.8rem);
  }

  .title-names {
    font-size: 0.8em;
  }

  .stage {
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
  }

  .nav-button {
    width: 40px;
    height: 40px;
    padding-bottom: 3px;
  }

  .previous {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
  }

  .next {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .carousel {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-block: 6px 8px;
  }

  .nav-button span {
    font-size: 2.15rem;
  }

  .slide {
    padding-inline: 0;
  }

  .instax-card {
    width: min(100%, 420px);
    min-height: auto;
  }

  .instax-card::before {
    top: -10px;
    width: 78px;
    height: 20px;
  }

  figcaption {
    min-height: 112px;
  }

  .photo-window::after {
    opacity: 1;
    transform: none;
  }

  .lightbox {
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .lightbox-toolbar {
    justify-content: flex-end;
  }

  .lightbox-button {
    min-width: 42px;
    height: 42px;
  }

}

@media (max-width: 360px) {
  .memory-page {
    padding-inline: 6px;
  }

  .gallery-title {
    font-size: clamp(1.72rem, 8.1vw, 2rem);
  }

  .lock-card .gallery-title {
    font-size: clamp(1.82rem, 8.6vw, 2.12rem);
  }

  .stage {
    gap: 7px;
  }

  .nav-button {
    width: 34px;
    height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .carousel {
    scroll-behavior: auto;
  }

  .lock-card,
  .gallery-shell,
  .instax-card,
  .nav-button,
  .dot {
    animation: none;
    transition: none;
  }
}
