/**
 * Memorial site theme (aligned with Book of Condolences):
 * navy gradient, grain, gold accent, cream cards, Cormorant + Source Sans 3.
 */
:root {
  --navy: #1A2F4B;
  --navy-deep: #122338;
  --navy-hover: #243a52;
  --cream: #faf8f5;
  --cream-dark: #f0ebe4;
  --card: #fffcfa;
  --text-on-light: #2a3038;
  --muted: #5c6570;
  --muted-light: rgba(255, 255, 255, 0.72);
  --border: #e4ddd4;
  --border-soft: rgba(255, 255, 255, 0.12);
  --accent: #b8956a;
  --accent-soft: rgba(184, 149, 106, 0.35);
  --shadow-card: 0 2px 8px rgba(18, 35, 56, 0.06), 0 12px 32px rgba(18, 35, 56, 0.08);
  --radius: 14px;
  /* Home hero name: distinctive display serif (load font on index.html) */
  --font-memorial-name: 'Playfair Display', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

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

body {
  font-family: 'Source Sans 3', sans-serif;
  color: var(--text-on-light);
  min-height: 100vh;
  line-height: 1.55;
  position: relative;
  background-color: var(--navy-deep);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -15%, rgba(212, 201, 188, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 110% 85%, rgba(26, 47, 75, 0.9) 0%, transparent 50%),
    linear-gradient(168deg, #152a42 0%, var(--navy) 42%, var(--navy-deep) 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.45;
  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");
  mix-blend-mode: overlay;
}

.wrap {
  position: relative;
  z-index: 3;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.75rem;
}

.wrap--wide {
  max-width: 60rem;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted-light);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0.65rem 0.4rem 0;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.back:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.hero-ornament {
  display: block;
  width: 3rem;
  height: 1px;
  margin: 0 auto 1rem;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.85;
}

.hero h1,
h1.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.85rem, 5vw, 2.35rem);
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.65rem;
}

.page-home header h1 {
  font-family: var(--font-memorial-name);
  font-size: clamp(2.1rem, 6.5vw, 2.85rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.18;
  font-feature-settings: 'kern' 1, 'liga' 1, 'dlig' 1;
  color: #fffefb;
  text-shadow:
    0 0 42px rgba(255, 255, 255, 0.45),
    0 0 18px rgba(255, 255, 255, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.55),
    0 4px 24px rgba(0, 0, 0, 0.45);
}

.subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.35rem;
}

.lead {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9375rem;
  max-width: 28rem;
  margin: 0 auto;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.25);
}

.lead strong {
  color: #fff;
  font-weight: 600;
}

/* --- Home (index) --- */
.parallax-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  background-color: #152a42;
  background-image: url('images/wellington.png');
  background-size: auto, contain;
  background-position: center top;
  background-repeat: no-repeat;
  opacity: 0.48;
  will-change: transform;
  filter: grayscale(1);
  -webkit-filter: grayscale(1);
}

.page-content {
  position: relative;
  z-index: 3;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0 2rem;
}

.page-home .container {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

.page-home header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.page-home .date-block {
  background: var(--card);
  background-image: linear-gradient(180deg, #fff 0%, var(--cream) 100%);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.page-home .date-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.page-home .date-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

.page-home .links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.page-home .link-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, var(--navy) 0%, #152d45 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.88rem 1.5rem;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  font-size: 0.98rem;
  text-align: center;
  letter-spacing: 0.03em;
  transition:
    transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1),
    box-shadow 0.22s ease,
    filter 0.22s ease,
    border-color 0.22s ease;
  box-shadow: 0 5px 18px rgba(26, 47, 75, 0.45);
}

.page-home .link-card:hover,
.page-home .link-card:focus {
  filter: brightness(1.12);
  color: #fff;
  transform: translateY(-5px) scale(1.035);
  outline: none;
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow:
    0 14px 36px rgba(18, 30, 48, 0.55),
    0 0 0 3px rgba(184, 149, 106, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.page-home .link-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.page-home .link-card:active {
  transform: translateY(-1px) scale(0.985);
  filter: brightness(1.05);
  box-shadow: 0 4px 14px rgba(18, 30, 48, 0.5);
  transition-duration: 0.08s;
}

.page-home .link-card .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
  opacity: 0.95;
}

.page-home .link-card .icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.page-home footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

.page-view-counter {
  font-size: 0.8rem;
  margin: 0.65rem 0 0;
  letter-spacing: 0.04em;
}

.page-home .page-view-counter {
  color: rgba(255, 255, 255, 0.68);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.page-gallery .page-view-counter--gallery {
  color: var(--muted);
  margin-top: 1.35rem;
  text-align: center;
}

.page-condolences .page-view-counter--condolences {
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  margin-top: 1.1rem;
  padding: 0 0.5rem 0.25rem;
}

.page-thankyou .page-view-counter--thankyou {
  text-align: center;
  margin-top: 1.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-obituary .page-view-counter--obituary {
  text-align: center;
  margin-top: 1.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-home .link-card--btn {
  appearance: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

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

.home-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  box-sizing: border-box;
}

.home-modal[hidden] {
  display: none !important;
}

.home-modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 32, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}

.home-modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 22rem;
  padding: 1.75rem 1.5rem 1.5rem;
  background: linear-gradient(180deg, #fff 0%, var(--cream) 100%);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-card);
  text-align: center;
  outline: none;
}

.home-modal__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid rgba(26, 47, 75, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--navy);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.home-modal__close:hover {
  background: #fff;
  border-color: var(--accent);
  transform: scale(1.06);
}

.home-modal__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.home-modal__title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 0.65rem;
  padding-right: 2.25rem;
  letter-spacing: 0.02em;
}

.home-modal__text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

/* --- Gallery --- */
.page-gallery .nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.page-gallery .nav-row a {
  color: var(--muted-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.page-gallery .nav-row a:hover {
  color: #fff;
  text-decoration: underline;
}

.page-gallery .nav-row .sep {
  opacity: 0.35;
  color: rgba(255, 255, 255, 0.5);
}

.page-gallery .gallery-header {
  margin-bottom: 1.25rem;
}

.page-gallery .gallery-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.75rem, 4vw, 2.1rem);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  margin-bottom: 0.5rem;
}

.page-gallery .gallery-header .lead {
  margin: 0;
  text-align: left;
}

.page-gallery .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.7rem;
}

.page-gallery .thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border-soft);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  animation: theme-fade-in 0.45s ease forwards;
}

@keyframes theme-fade-in {
  to { opacity: 1; }
}

.page-gallery .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.page-gallery .thumb:hover img {
  transform: scale(1.05);
}

.page-gallery .thumb:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-gallery .state {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  line-height: 1.55;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.12);
}

.page-gallery .state.err {
  color: #ffcdd2;
  border-color: rgba(255, 150, 150, 0.35);
}

.page-gallery .state code {
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.page-gallery .lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 12, 20, 0.94);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Let JS receive horizontal swipes (pan-y hands them to the browser). */
  touch-action: none;
  overscroll-behavior: none;
}

.page-gallery .lightbox.open {
  display: flex;
}

.page-gallery .lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.page-gallery .lightbox-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
}

.page-gallery .lightbox-close,
.page-gallery .lightbox-nav {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    transform 0.2s cubic-bezier(0.34, 1.25, 0.64, 1),
    box-shadow 0.2s ease;
}

.page-gallery .lightbox-close:hover,
.page-gallery .lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(184, 149, 106, 0.5);
}

.page-gallery .lightbox-close:active,
.page-gallery .lightbox-nav:active:not(:disabled) {
  transform: scale(0.96);
  transition-duration: 0.08s;
}

.page-gallery .lightbox-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

/* --- Thank you --- */
.page-thankyou .wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.page-thankyou .hero {
  margin-bottom: 1.5rem;
}

.page-thankyou .thank-card {
  background: var(--card);
  background-image: linear-gradient(180deg, #fff 0%, var(--cream) 100%);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.6rem;
  max-width: 26rem;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.page-thankyou .portrait-wrap {
  width: 100%;
  max-width: 180px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-soft);
  box-shadow: 0 8px 28px rgba(18, 35, 56, 0.12);
}

.page-thankyou .portrait-wrap img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.page-thankyou .message {
  font-size: 0.98rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.page-thankyou .btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--navy) 0%, #152d45 100%);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition:
    transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1),
    box-shadow 0.22s ease,
    filter 0.22s ease,
    border-color 0.22s ease;
  box-shadow: 0 5px 18px rgba(26, 47, 75, 0.42);
}

.page-thankyou .btn-back:hover,
.page-thankyou .btn-back:focus {
  filter: brightness(1.1);
  transform: translateY(-4px) scale(1.03);
  outline: none;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 12px 32px rgba(18, 30, 48, 0.5),
    0 0 0 3px rgba(184, 149, 106, 0.4);
}

.page-thankyou .btn-back:active {
  transform: translateY(-1px) scale(0.98);
  filter: brightness(1.04);
  box-shadow: 0 4px 14px rgba(18, 30, 48, 0.45);
  transition-duration: 0.08s;
}

.page-thankyou .btn-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- Obituary / pictures (images/index.html) --- */
.page-obituary .obituary-panel {
  background: var(--card);
  background-image: linear-gradient(180deg, #fff 0%, var(--cream) 100%);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.15rem 1.4rem;
  box-shadow: var(--shadow-card);
}

.page-obituary .gallery {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-obituary .gallery img,
.page-obituary .gallery a {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(18, 35, 56, 0.06);
}

.page-obituary .gallery a {
  display: block;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.page-obituary .gallery a:hover {
  box-shadow: 0 8px 24px rgba(18, 35, 56, 0.1);
  transform: translateY(-2px);
}

.page-obituary .gallery img {
  display: block;
  height: auto;
}

.page-obituary .pdf-link {
  display: block;
  padding: 1rem 1.15rem;
  background: linear-gradient(180deg, var(--navy) 0%, #152d45 100%);
  color: #fff !important;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 5px 18px rgba(26, 47, 75, 0.38);
  transition:
    transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1),
    box-shadow 0.22s ease,
    filter 0.22s ease,
    border-color 0.22s ease;
}

.page-obituary .pdf-link:hover {
  filter: brightness(1.1);
  transform: translateY(-4px) scale(1.02);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 12px 32px rgba(18, 30, 48, 0.48),
    0 0 0 3px rgba(184, 149, 106, 0.38);
}

.page-obituary .pdf-link:active {
  transform: translateY(-1px) scale(0.98);
  filter: brightness(1.04);
  box-shadow: 0 4px 14px rgba(18, 30, 48, 0.42);
  transition-duration: 0.08s;
}

.page-obituary .caption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .home-modal__close {
    transition-duration: 0.01ms;
  }

  .home-modal__close:hover {
    transform: none;
  }

  .page-home .link-card,
  .page-thankyou .btn-back,
  .page-obituary .pdf-link,
  .page-gallery .lightbox-close,
  .page-gallery .lightbox-nav {
    transition-duration: 0.01ms;
  }

  .page-home .link-card:hover,
  .page-home .link-card:focus,
  .page-thankyou .btn-back:hover,
  .page-thankyou .btn-back:focus,
  .page-obituary .pdf-link:hover,
  .page-gallery .lightbox-close:hover,
  .page-gallery .lightbox-nav:hover:not(:disabled) {
    transform: none;
  }

  .page-home .link-card:active,
  .page-thankyou .btn-back:active,
  .page-obituary .pdf-link:active,
  .page-gallery .lightbox-close:active,
  .page-gallery .lightbox-nav:active:not(:disabled) {
    transform: none;
  }
}
