:root {
  color-scheme: light;
  --ink: #162019;
  --muted: #5e6b61;
  --paper: #f7f1e7;
  --warm: #d78645;
  --leaf: #315941;
  --line: rgba(22, 32, 25, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(215, 134, 69, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(49, 89, 65, 0.18), transparent 38%),
    var(--paper);
  transition:
    background 10s ease,
    color 10s ease;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 214, 146, 0.16), transparent 28%),
    radial-gradient(circle at 20% 10%, rgba(124, 49, 42, 0.2), transparent 34%),
    #06070b;
  opacity: 0;
  transition: opacity 10s ease;
}

body.cinematic-active {
  color: #f8edd7;
}

body.cinematic-active::before {
  opacity: 1;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) 0;
}

.portrait {
  position: relative;
  min-height: 0;
}

.portrait::before {
  position: absolute;
  inset: 18px -18px -18px 18px;
  content: "";
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.34);
}

.photo-toggle {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
}

.photo-toggle:focus-visible {
  outline: 3px solid rgba(215, 134, 69, 0.78);
  outline-offset: 8px;
}

.photo-stack {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  max-height: calc(100vh - 80px);
  border: 1px solid rgba(22, 32, 25, 0.12);
  box-shadow: 0 28px 80px rgba(22, 32, 25, 0.22);
}

.photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition:
    opacity 780ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 920ms cubic-bezier(0.16, 1, 0.3, 1),
    filter 920ms cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-original {
  opacity: 1;
  transform: scale(1);
}

.photo-meme {
  opacity: 0;
  transform: scale(1.018);
  filter: saturate(1.1) contrast(1.04);
}

.photo-meme-final {
  opacity: 0;
  transform: scale(1.018);
  filter: saturate(1.12) contrast(1.08);
  transition:
    opacity 10s linear,
    transform 10s ease,
    filter 10s ease;
}

.photo-toggle.is-transformed .photo-original {
  opacity: 0;
  transform: scale(0.982);
  filter: brightness(1.05) saturate(1.08);
}

.photo-toggle.is-transformed .photo-meme {
  opacity: 1;
  transform: scale(1);
}

body.cinematic-active .photo-toggle.is-transformed .photo-meme-final {
  opacity: 1;
  transform: scale(1.012);
  filter: saturate(1.2) contrast(1.1) brightness(0.92);
}

.photo-toggle.is-transformed .photo-stack {
  box-shadow:
    0 28px 80px rgba(22, 32, 25, 0.22),
    0 0 34px rgba(255, 197, 102, 0.34);
}

.light-sweep {
  position: absolute;
  inset: -22%;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 52% 31%, rgba(255, 255, 255, 0.95), transparent 10%),
    linear-gradient(115deg, transparent 28%, rgba(255, 255, 255, 0.92) 44%, rgba(255, 207, 112, 0.78) 50%, transparent 68%);
  mix-blend-mode: screen;
  transform: translateX(-60%) rotate(6deg);
}

.photo-toggle.burst .light-sweep {
  animation: lightSweep 920ms cubic-bezier(0.16, 1, 0.3, 1);
}

.particle-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 999px;
  background: rgba(255, 226, 159, 0.95);
  box-shadow:
    0 0 14px rgba(255, 215, 128, 0.95),
    0 0 3px rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: particlePop 1100ms ease-out forwards;
}

.particle:nth-child(3n) {
  background: rgba(255, 255, 255, 0.92);
}

.particle:nth-child(4n) {
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.message {
  max-width: 520px;
  padding: clamp(22px, 4vw, 44px) 0;
}

.place {
  margin: 0 0 18px;
  color: var(--warm);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 24px;
  color: var(--leaf);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 500;
  line-height: 0.86;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.06rem, 1.8vw, 1.24rem);
  line-height: 1.72;
}

p + p {
  margin-top: 20px;
}

.lead {
  color: var(--ink);
  font-size: clamp(1.18rem, 2.05vw, 1.44rem);
  line-height: 1.58;
}

.message.is-flight-source {
  opacity: 0;
}

.floating-text-layer,
.spotlight-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.floating-text-layer {
  z-index: 8;
}

.floating-letter {
  position: fixed;
  left: 0;
  top: 0;
  display: inline-block;
  white-space: pre;
  will-change: transform, color, text-shadow;
  transform-origin: center;
  transition:
    color 10s ease,
    text-shadow 10s ease;
}

body.cinematic-active .floating-letter {
  color: #fff4d9 !important;
  text-shadow:
    0 0 10px rgba(255, 210, 133, 0.58),
    0 0 24px rgba(255, 171, 74, 0.22);
}

.spotlight-layer {
  z-index: 7;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 3.5s ease;
}

body.cinematic-active .spotlight-layer {
  opacity: 1;
}

.spotlight {
  position: absolute;
  left: 50%;
  top: -12vh;
  width: 34vw;
  min-width: 260px;
  height: 138vh;
  background: linear-gradient(
    92deg,
    transparent 0%,
    rgba(255, 235, 184, 0.02) 28%,
    rgba(255, 235, 184, 0.22) 49%,
    rgba(255, 235, 184, 0.04) 64%,
    transparent 100%
  );
  filter: blur(12px);
  opacity: 0.72;
  transform-origin: 50% 0%;
}

.spotlight-a {
  animation: spotlightPanA 12s ease-in-out infinite alternate;
}

.spotlight-b {
  width: 28vw;
  opacity: 0.54;
  animation: spotlightPanB 15s ease-in-out infinite alternate;
}

.spotlight-c {
  width: 22vw;
  opacity: 0.42;
  animation: spotlightPanC 18s ease-in-out infinite alternate;
}

@keyframes lightSweep {
  0% {
    opacity: 0;
    transform: translateX(-62%) rotate(6deg);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(58%) rotate(6deg);
  }
}

@keyframes particlePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }

  15% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.05);
  }
}

@keyframes spotlightPanA {
  0% {
    transform: translateX(-64vw) rotate(28deg);
  }

  100% {
    transform: translateX(18vw) rotate(-24deg);
  }
}

@keyframes spotlightPanB {
  0% {
    transform: translateX(38vw) rotate(-32deg);
  }

  100% {
    transform: translateX(-28vw) rotate(22deg);
  }
}

@keyframes spotlightPanC {
  0% {
    transform: translateX(-18vw) rotate(8deg);
  }

  100% {
    transform: translateX(36vw) rotate(-18deg);
  }
}

@media (max-width: 760px) {
  .page {
    width: 100%;
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }

  .portrait::before {
    display: none;
  }

  .photo-stack {
    width: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .message {
    max-width: none;
    padding: 30px 22px 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spotlight,
  .particle,
  .photo-toggle.burst .light-sweep {
    animation: none;
  }

  .photo,
  .photo-meme-final,
  body,
  .spotlight-layer {
    transition-duration: 1ms;
  }
}
