/* ==========================================================================
   SAM — THE MAGICIAN
   Subpage layer: photos.html & 404.shtml
   --------------------------------------------------------------------------
   These pages share the tokens, header, atmosphere, buttons and footer that
   style.css already defines; this file only adds what is specific to them.
   Load order: css/style.css -> css/pages.css

   1.  Shared page shell
   2.  Photo memories grid
   3.  Photo lightbox
   4.  404 page
   5.  Responsive
   6.  Reduced motion
   ========================================================================== */

/* 1. SHARED PAGE SHELL =================================================== */

/* Subpages scroll as one document instead of swapping sections, so the
   full-viewport section padding is not wanted here. */
.section--page {
  min-height: 0;
  padding-bottom: clamp(48px, 8vw, 96px);
}

.section--page .section-body {
  animation: page-in 700ms var(--ease-out) both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(22px);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

.page-head {
  max-width: 820px;
}

.page-lede {
  margin-top: 18px;
  max-width: 56ch;
  color: var(--ink-muted);
  font-size: clamp(15px, 1.55vw, 18px);
  line-height: 1.7;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(24px, 4vw, 38px);
}

/* Small marker used on the "live" tile and in the footer. */
.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* 2. PHOTO MEMORIES GRID ================================================= */

/* A true masonry column layout: every photo keeps its own proportions, so
   nothing is ever cropped to fit a uniform grid. */
.photo-grid {
  margin-top: clamp(30px, 5vw, 56px);
  columns: 3;
  column-gap: 18px;
}

.photo-tile {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  overflow: hidden;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  cursor: zoom-in;
  text-align: left;
  transition:
    border-color var(--dur) var(--ease-out),
    box-shadow 620ms var(--ease-out),
    transform 620ms var(--ease-out);
}

.photo-tile img {
  display: block;
  width: 100%;
  height: auto;
  transition:
    transform 900ms var(--ease-out),
    filter 620ms var(--ease-out);
}

.photo-tile:hover,
.photo-tile:focus-visible {
  border-color: rgba(245, 212, 138, 0.34);
  box-shadow: 0 34px 70px -34px rgba(0, 0, 0, 0.92);
}

.photo-tile:hover img,
.photo-tile:focus-visible img {
  transform: scale(1.035);
  filter: brightness(1.04) saturate(1.05);
}

/* Bottom scrim + "view" chip appear on intent only. */
.photo-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 52%, rgba(8, 7, 12, 0.62) 100%);
  opacity: 0;
  transition: opacity 420ms var(--ease-out);
}

.photo-tile:hover::after,
.photo-tile:focus-visible::after {
  opacity: 1;
}

.photo-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(245, 212, 138, 0.38);
  background: rgba(8, 7, 12, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 380ms var(--ease-out),
    transform 380ms var(--ease-out);
  pointer-events: none;
}

.photo-tile:hover .photo-zoom,
.photo-tile:focus-visible .photo-zoom {
  opacity: 1;
  transform: none;
}

/* 3. PHOTO LIGHTBOX ====================================================== */

/* Reuses .profile-popup / .pp-content / .pp-media from style.css, which
   already shows the whole image instead of cropping it. */
.photo-lightbox .pp-content.is-empty {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.photo-lightbox .pp-media {
  box-shadow: 0 50px 110px -40px rgba(0, 0, 0, 0.95);
}

.photo-lightbox .pp-close {
  top: -8px;
  right: -8px;
}

@media (max-width: 560px) {
  .photo-lightbox .pp-close {
    top: 8px;
    right: 8px;
  }
}

/* 4. 404 PAGE ============================================================ */

.page-404 {
  overflow-x: hidden;
}

.page-404 .shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

.nf {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  padding: calc(var(--header-h) + clamp(20px, 4vw, 44px)) var(--gutter) clamp(24px, 4vw, 48px);
}

.nf-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.8fr);
  align-items: center;
  gap: clamp(32px, 5.5vw, 80px);
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
}

.nf-copy {
  min-width: 0;
}

.nf-glow {
  position: absolute;
  top: 4%;
  left: 32%;
  width: min(820px, 92vw);
  height: min(820px, 92vw);
  transform: translateX(-50%);
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 42%,
    rgba(139, 92, 246, 0.24),
    rgba(139, 92, 246, 0.07) 42%,
    transparent 68%
  );
  filter: blur(12px);
}

.nf-code {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(88px, 13.5vw, 176px);
  font-weight: 400;
  line-height: 0.84;
  letter-spacing: -0.045em;
  background: linear-gradient(
    180deg,
    var(--gold) 0%,
    rgba(245, 212, 138, 0.62) 56%,
    rgba(245, 212, 138, 0.16) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 24px 60px rgba(245, 212, 138, 0.18));
}

.nf-title {
  margin-top: clamp(8px, 1.4vw, 14px);
  font-family: var(--font-display);
  font-size: clamp(26px, 3.6vw, 46px);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.nf-title em {
  font-style: italic;
  color: var(--gold);
}

.nf-lede {
  margin-top: 16px;
  max-width: 44ch;
  color: var(--ink-muted);
  font-size: clamp(14px, 1.5vw, 17px);
}

.nf-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 12px;
  margin-top: clamp(22px, 3.2vw, 30px);
}

/* --- The print on the wall ---------------------------------------------- */

/* The artwork keeps its original image map, so it must never be scaled or
   rotated by a transform: that would drag the hit areas off the drawing.
   The bright GIF is treated as a physical print taped to the dark wall,
   which is what makes a white rectangle belong on this page at all. */
.nf-art {
  position: relative;
  justify-self: end;
  width: min(420px, 100%);
  margin: 0;
}

.nf-print {
  position: relative;
  padding: 11px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f6f0e2 0%, #e8dcc2 100%);
  box-shadow:
    0 0 0 1px rgba(245, 212, 138, 0.2),
    0 46px 94px -42px rgba(0, 0, 0, 0.96);
  transition: box-shadow 620ms var(--ease-out);
}

/* The strip of tape holding the print up. */
.nf-print::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 78px;
  height: 27px;
  transform: translateX(-50%) rotate(-1.5deg);
  border-radius: 2px;
  border: 1px solid rgba(245, 212, 138, 0.32);
  background: linear-gradient(180deg, rgba(245, 212, 138, 0.4), rgba(245, 212, 138, 0.16));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.nf-art:hover .nf-print {
  box-shadow:
    0 0 0 1px rgba(245, 212, 138, 0.34),
    0 52px 104px -42px rgba(0, 0, 0, 1);
}

/* Multiply turns the GIF's white background into warm paper instead of a
   glaring white block, while keeping the illustration's own colours. */
.nf-print img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
  mix-blend-mode: multiply;
  background: #f6f0e2;
}

.nf-print area {
  cursor: pointer;
}

.nf-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.nf-caption::before {
  content: "";
  width: 26px;
  height: 1px;
  background: rgba(245, 212, 138, 0.45);
}

/* 5. RESPONSIVE ========================================================== */

@media (max-width: 1023px) {
  .photo-grid {
    columns: 2;
  }
}

@media (max-width: 719px) {
  .photo-grid {
    columns: 1;
    column-gap: 0;
  }

  .photo-tile {
    margin-bottom: 16px;
  }

  /* Touch devices have no hover: keep the chip visible so the tile still
     reads as interactive. */
  .photo-zoom {
    opacity: 1;
    transform: none;
    padding: 6px 12px;
  }

  .photo-tile::after {
    opacity: 0.55;
  }
}

@media (max-width: 899px) {
  .nf {
    padding-top: calc(var(--header-h) + clamp(28px, 7vw, 56px));
  }

  .nf-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: clamp(28px, 6vw, 44px);
    text-align: center;
  }

  .nf-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 620px;
  }

  .nf-lede {
    max-width: 46ch;
  }

  .nf-actions {
    justify-content: center;
  }

  .nf-art {
    justify-self: center;
    width: min(330px, 74vw);
  }
}

@media (max-width: 560px) {
  .nf-actions {
    width: 100%;
  }

  .nf-actions .btn {
    width: 100%;
  }

  .nf-art {
    width: min(300px, 78vw);
  }

  .nf-code {
    font-size: clamp(84px, 30vw, 132px);
  }
}

/* 6. REDUCED MOTION ====================================================== */

@media (prefers-reduced-motion: reduce) {
  .photo-tile,
  .photo-tile img,
  .photo-tile::after,
  .photo-zoom,
  .nf-print {
    transition: none !important;
  }

  .photo-tile:hover img,
  .photo-tile:focus-visible img {
    transform: none;
  }

  .section--page .section-body {
    animation: none;
  }
}
