:root {
  --felt: #685641;
  --felt-dark: #4e4032;
  --paper: #fffaf0;
  --ink: #2c2621;
  --purple: #a66bff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #17100c;
  color: #fff9ef;
  font-family:
    Inter,
    "Noto Sans SC",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
}

body.memory-modal-open {
  overflow: hidden;
}

/* =========================================================
   PAGE / FELT TEXTURE
   ========================================================= */

.memory-board-page {
  min-height: 100vh;
  padding-top: 112px;
  background:
    radial-gradient(circle at 20% 10%, rgba(176, 119, 255, .08), transparent 26%),
    linear-gradient(180deg, #17110e 0 390px, #30261d 390px);
}

.memory-board-hero {
  width: min(1180px, calc(100% - 42px));
  margin: 0 auto 34px;
  text-align: center;
}

.memory-board-back {
  display: inline-flex;
  margin-bottom: 24px;
  color: rgba(231, 212, 250, .52);
  font-size: 10px;
  letter-spacing: .08em;
  text-decoration: none;
}

.memory-board-kicker {
  color: #b785ff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .34em;
}

.memory-board-hero h1 {
  margin: 12px 0 9px;
  font-family: "Noto Serif SC", "Songti SC", Georgia, serif;
  font-size: clamp(38px, 5vw, 66px);
  font-weight: 500;
}

.memory-board-hero p {
  max-width: 670px;
  margin: 0 auto;
  color: rgba(248, 238, 226, .56);
  font-size: 13px;
  line-height: 1.8;
}

.memory-board-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 18px;
}

.memory-board-stats strong {
  color: #c69cff;
  font-family: Georgia, serif;
  font-size: 19px;
}

.memory-board-stats span {
  color: rgba(232, 214, 249, .34);
  font-size: 7px;
  letter-spacing: .20em;
}

.memory-year-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.memory-year-button {
  height: 31px;
  padding: 0 14px;
  border: 1px solid rgba(197, 163, 237, .17);
  border-radius: 999px;
  background: rgba(32, 24, 31, .58);
  color: rgba(244, 233, 255, .52);
  font-size: 10px;
  cursor: pointer;
}

.memory-year-button.active {
  border-color: rgba(185, 132, 255, .62);
  background: rgba(124, 75, 194, .24);
  color: #fff;
}

/* =========================================================
   FELT CANVAS
   Compact enough for 50+ photos.
   ========================================================= */

.felt-canvas {
  position: relative;
  width: min(1510px, calc(100% - 32px));
  min-height: 720px;
  margin: 0 auto 70px;
  padding: 108px 42px 70px;
  overflow: hidden;
  border: 15px solid #3c2d21;
  border-radius: 9px;
  background:
    radial-gradient(circle at 13px 11px, rgba(255,255,255,.055) 0 1px, transparent 1.6px),
    radial-gradient(circle at 31px 25px, rgba(0,0,0,.055) 0 1px, transparent 1.6px),
    linear-gradient(135deg, rgba(255,255,255,.025), rgba(0,0,0,.03)),
    var(--felt);
  background-size:
    42px 38px,
    51px 47px,
    auto,
    auto;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, .42),
    inset 0 0 70px rgba(18, 10, 5, .20);
}

.felt-canvas::before {
  content: "";
  position: absolute;
  inset: 10px;
  pointer-events: none;
  border: 1px solid rgba(255, 242, 220, .08);
}

.memory-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns:
    repeat(auto-fill, minmax(108px, 1fr));
  align-items: start;
  gap: 29px 22px;
}

.memory-photo-card {
  --rotate: 0deg;
  --shift-x: 0px;
  --shift-y: 0px;

  position: relative;
  justify-self: center;
  width: min(100%, 142px);
  padding: 7px 7px 20px;
  border: 0;
  background: var(--paper);
  box-shadow:
    0 6px 12px rgba(28, 18, 12, .24),
    0 1px 1px rgba(41, 29, 20, .18);
  cursor: zoom-in;
  transform:
    translate(var(--shift-x), var(--shift-y))
    rotate(var(--rotate));
  transform-origin: 50% 36%;
  transition:
    transform .20s ease,
    box-shadow .20s ease,
    z-index 0s;
}

.memory-photo-card:nth-child(4n + 1)::before {
  content: "";
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -9px;
  width: 38px;
  height: 16px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(239, 220, 180, .72);
  box-shadow: 0 1px 3px rgba(0,0,0,.09);
}

.memory-photo-card:nth-child(4n + 2)::before,
.memory-photo-card:nth-child(4n + 3)::before,
.memory-photo-card:nth-child(4n + 4)::before {
  content: "";
  position: absolute;
  z-index: 4;
  left: 50%;
  top: -6px;
  width: 9px;
  height: 9px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #8f5d50;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.28),
    0 2px 3px rgba(0,0,0,.24);
}

.memory-photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: #ddd;
}

.memory-photo-card:hover,
.memory-photo-card:focus-visible {
  z-index: 12;
  transform:
    translate(var(--shift-x), calc(var(--shift-y) - 8px))
    rotate(0deg)
    scale(1.13);
  box-shadow:
    0 18px 32px rgba(31, 18, 11, .34),
    0 0 0 2px rgba(195, 148, 255, .22);
  outline: none;
}

.memory-photo-caption {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: rgba(46, 36, 29, .72);
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 9px;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* hover sticky-note */
.memory-hover-note {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: calc(100% + 12px);
  width: 150px;
  padding: 10px 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px) rotate(-2deg);
  background: #f5eaa8;
  box-shadow: 0 8px 18px rgba(35, 23, 12, .23);
  color: #55472e;
  text-align: left;
  transition:
    opacity .18s ease,
    transform .18s ease;
}

.memory-photo-card:hover .memory-hover-note,
.memory-photo-card:focus-visible .memory-hover-note {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-2deg);
}

.memory-hover-note strong {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
}

.memory-hover-note span,
.memory-hover-note small {
  display: block;
  font-size: 8px;
  line-height: 1.5;
}

.memory-hover-note small {
  margin-top: 4px;
  color: rgba(67, 53, 34, .65);
}

.memory-loading,
.memory-empty {
  grid-column: 1 / -1;
  padding: 80px 20px;
  color: rgba(255, 243, 227, .58);
  text-align: center;
}

/* =========================================================
   LIGHTBOX
   ========================================================= */

.memory-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 24px;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity .22s ease,
    visibility .22s ease;
}

.memory-modal.open {
  visibility: visible;
  opacity: 1;
}

.memory-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(4, 4, 8, .80);
  backdrop-filter: blur(9px);
  cursor: zoom-out;
}

.memory-modal-card {
  position: relative;
  z-index: 2;
  width: min(1050px, 94vw);
  max-height: 88dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(270px, .7fr);
  overflow: hidden;
  border: 1px solid rgba(207, 174, 246, .22);
  border-radius: 22px;
  background: #0d0d16;
  box-shadow: 0 35px 100px rgba(0, 0, 0, .55);
}

.memory-modal-photo {
  min-height: min(72vh, 720px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050509;
}

.memory-modal-photo img {
  width: 100%;
  height: 100%;
  max-height: 78dvh;
  display: block;
  object-fit: contain;
}

.memory-modal-copy {
  padding: 46px 34px 32px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 70% 0, rgba(155, 91, 244, .10), transparent 35%),
    #10101b;
}

.memory-modal-meta {
  color: #b98aff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  line-height: 1.6;
}

.memory-modal-copy h2 {
  margin: 13px 0 12px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 27px;
  font-weight: 500;
}

.memory-modal-copy p {
  margin: 0;
  color: rgba(243, 236, 249, .62);
  font-size: 13px;
  line-height: 1.85;
}

.memory-modal-close,
.memory-modal-nav {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 1px solid rgba(218, 193, 249, .22);
  background: rgba(7, 7, 13, .72);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.memory-modal-close {
  right: 16px;
  top: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 22px;
}

.memory-modal-nav {
  top: 50%;
  width: 42px;
  height: 58px;
  transform: translateY(-50%);
  border-radius: 13px;
  font-size: 31px;
}

.memory-modal-prev {
  left: 15px;
}

.memory-modal-next {
  left: calc(65% - 57px);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
  .felt-canvas {
    padding: 92px 25px 55px;
    border-width: 11px;
  }

  .memory-grid {
    grid-template-columns:
      repeat(auto-fill, minmax(96px, 1fr));
    gap: 25px 17px;
  }

  .memory-photo-card {
    max-width: 124px;
  }

  .memory-modal-card {
    grid-template-columns: 1fr;
    max-height: 91dvh;
    overflow-y: auto;
  }

  .memory-modal-photo {
    min-height: 52vh;
  }

  .memory-modal-copy {
    padding: 25px 24px 30px;
  }

  .memory-modal-next {
    left: auto;
    right: 15px;
  }
}

@media (max-width: 560px) {
  .memory-board-page {
    padding-top: 92px;
  }

  .memory-board-hero {
    width: calc(100% - 28px);
  }

  .memory-board-hero p {
    font-size: 12px;
  }

  .felt-canvas {
    width: calc(100% - 14px);
    padding: 36px 13px 45px;
    border-width: 8px;
  }

  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 10px;
  }

  .memory-photo-card {
    width: 100%;
    padding: 5px 5px 15px;
  }

  .memory-photo-caption {
    font-size: 8px;
  }

  .memory-hover-note {
    display: none;
  }

  .memory-modal {
    padding: 10px;
  }

  .memory-modal-card {
    width: 100%;
    border-radius: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition-duration: .01ms !important;
  }
}
