@font-face {
  font-family: "Homemade Apple";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/HomemadeApple-Regular.ttf") format("truetype");
}

:root {
  --bg: #000000;
  --text: #e0e0e0;
  --text-muted: #999999;
  --accent: #1a8f85;
  --accent-bright: #2ad4c4;
  --accent-dim: rgba(26, 143, 133, 0.3);
  --grain-opacity: 0.04;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── starfield canvas ─────────────────────────── */

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── subtle grain overlay ─────────────────────── */

.memorial-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.memorial-bg__layer--grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── main layout ──────────────────────────────── */

.memorial {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  gap: clamp(0.75rem, 2vw, 1.25rem);
  text-align: center;
}

/* ── inverted cross ───────────────────────────── */

.memorial__cross {
  font-size: clamp(2.75rem, 6.5vw, 3.75rem);
  color: var(--text-muted);
  transform: rotate(180deg);
  line-height: 1;
  user-select: none;
  opacity: 0.45;
  margin-bottom: 0.25rem;
  text-shadow: 0 0 0 transparent;
  transition: text-shadow 0.4s ease, opacity 0.4s ease;
}

.memorial__cross.is-lit {
  opacity: 1;
  color: var(--accent-bright);
  text-shadow:
    0 0 8px rgba(42, 212, 196, 0.6),
    0 0 24px rgba(42, 212, 196, 0.3),
    0 0 48px rgba(42, 212, 196, 0.15);
  animation: cross-fade 4s ease-out forwards;
}

@keyframes cross-fade {
  0% {
    opacity: 1;
    color: var(--accent-bright);
    text-shadow:
      0 0 8px rgba(42, 212, 196, 0.6),
      0 0 24px rgba(42, 212, 196, 0.3),
      0 0 48px rgba(42, 212, 196, 0.15);
  }
  100% {
    opacity: 0.45;
    color: var(--text-muted);
    text-shadow: 0 0 0 transparent;
  }
}

/* ── portrait ─────────────────────────────────── */

.memorial__portrait {
  margin: 0;
  padding: 0;
}

.memorial__img {
  display: block;
  width: min(260px, 68vw);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  filter: grayscale(100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 1px rgba(42, 212, 196, 0.08),
    0 24px 48px rgba(0, 0, 0, 0.6);
}

/* ── typography ────────────────────────────────── */

.memorial__text {
  max-width: 32rem;
}

.memorial__name {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.memorial__line {
  margin: 0 0 0.5rem;
  font-size: clamp(1rem, 2.4vw, 1.125rem);
  color: var(--text-muted);
  font-style: italic;
}

.memorial__sub {
  margin: 0 0 1.25rem;
  font-size: clamp(0.8125rem, 2vw, 0.9375rem);
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── divider ──────────────────────────────────── */

.memorial__divider {
  width: 100%;
  max-width: 28rem;
  height: 1px;
  background: var(--accent-dim);
  margin: 0 auto 0.75rem;
}

/* ── chevron trigger ──────────────────────────── */

.memorial__toggle {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 0;
  background: none;
  border: none;
  cursor: pointer;
}

.memorial__toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.memorial__toggle:focus:not(:focus-visible) {
  outline: none;
}

.memorial__chevron {
  color: var(--accent-bright);
  opacity: 0.8;
  transition: opacity 0.25s ease;
}

.memorial__toggle:hover .memorial__chevron {
  opacity: 1;
}

/* ── overlay / modal ──────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.overlay.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.overlay__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 90%;
  max-width: 36rem;
  min-height: 40vh;
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.overlay__close {
  position: fixed;
  bottom: clamp(1.5rem, 3vh, 2.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent-bright);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.overlay__close.is-visible {
  opacity: 0.5;
  pointer-events: auto;
}

.overlay__close:hover {
  opacity: 1;
}

.overlay__close:focus {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.overlay__close:focus:not(:focus-visible) {
  outline: none;
}

/* ── stanzas ──────────────────────────────────── */

.stanza {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Georgia", "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(1.05rem, 2.8vw, 1.25rem);
  line-height: 2;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 1.2s ease;
  padding: clamp(1rem, 3vw, 2rem);
}

.stanza.is-active {
  opacity: 1;
}

.stanza--signature {
  font-style: normal;
}

.memorial__signature {
  font-family: "Homemade Apple", cursive;
  font-size: clamp(1.4rem, 3.5vw, 1.7rem);
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ── utility ──────────────────────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  #starfield {
    display: none;
  }

  .overlay {
    transition: none;
  }
}
