/* James Russell Baker — memorial.
   Palette drawn from the lighthouse illustration: parchment, sepia ink,
   soft slate blue, muted brick red. */

:root {
  --parchment: #f4ecda;
  --paper: #faf4e6;
  --ink: #3b352b;
  --ink-soft: #6f6655;
  --ink-faint: #9a8f79;
  --slate: #5d7c93;
  --slate-deep: #46647a;
  --brick: #a4543f;
  --rule: rgba(59, 53, 43, 0.18);
  --shadow: rgba(59, 53, 43, 0.12);
  --measure: 64rem;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.72;
  color: var(--ink);
  background-color: var(--parchment);
  /* Soft layered warmth — no external textures needed. */
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(255, 251, 240, 0.7), transparent 55%),
    radial-gradient(ellipse at 80% 110%, rgba(93, 124, 147, 0.08), transparent 50%);
  background-attachment: fixed;
}

/* --- Thank-you modal (shown after a memory is submitted) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(59, 53, 43, 0.45);
  backdrop-filter: blur(1px);
}
.modal {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  max-width: 24rem;
  width: 100%;
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 24px 60px -20px rgba(59, 53, 43, 0.5);
  animation: modal-in 0.25s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 2rem;
  margin: 0 0 0.5rem;
  color: var(--slate-deep);
}
.modal p { margin: 0 0 1.5rem; color: var(--ink-soft); font-size: 1.06rem; }
.modal-close {
  display: inline-block;
  font-family: "EB Garamond", serif;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #fdfaf2;
  background: var(--slate);
  text-decoration: none;
  border-radius: 2px;
  padding: 0.55rem 1.7rem;
  transition: background-color 0.15s ease;
}
.modal-close:hover { background: var(--slate-deep); }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

/* --- Layout shell --- */
.page {
  max-width: var(--measure);
  margin: 2.5rem auto;
  padding: clamp(1.5rem, 4vw, 3.75rem);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 50px -28px var(--shadow);
}

/* --- Masthead --- */
.masthead { text-align: center; margin-bottom: 1.75rem; }

.masthead h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.9rem, 7vw, 4.75rem);
  line-height: 1.04;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--ink);
}

.dates {
  font-style: italic;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
  letter-spacing: 0.02em;
}

.rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.4rem auto 0;
  max-width: 22rem;
  color: var(--ink-faint);
}
.rule::before, .rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--dir, right), transparent, var(--rule), transparent);
}
.rule span { font-size: 1rem; color: var(--slate); }

/* --- Obituary + floated illustration --- */
.obituary { overflow-wrap: break-word; }

.portrait {
  float: right;
  width: 46%;
  min-width: 19rem;
  margin: 0.4rem 0 1.25rem 2rem;
}
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  /* The illustration already carries a decorative border; a faint frame
     lifts it from the page without competing. */
  box-shadow: 0 10px 30px -18px var(--shadow);
}

/* Body paragraphs default to left-aligned. Note: this intentionally does NOT
   set text-align, so the centered masthead (dates) and .epitaph keep their
   own alignment — they live inside .obituary too. */
.obituary p {
  margin: 0 0 1.15rem;
}

/* "Fair winds and following seas." */
.epitaph {
  clear: both;
  text-align: center;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  color: var(--slate-deep);
  margin: 2.5rem auto 2rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  max-width: 32rem;
}

.arrangements {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* --- Memories --- */
.memories {
  clear: both;
  margin-top: 3rem;
  padding-top: 2.25rem;
  border-top: 2px solid var(--rule);
}

.memories h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 4.5vw, 2.7rem);
  text-align: center;
  margin: 0 0 1.75rem;
  color: var(--ink);
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}

.memory-list { list-style: none; margin: 0 0 2.5rem; padding: 0; }

.memory {
  background: var(--parchment);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--slate);
  border-radius: 2px;
  padding: 1.25rem 1.5rem 1rem;
  margin: 0 0 1.1rem;
}
.memory blockquote {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.6;
}
.attribution {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-style: italic;
}
.memory-date {
  display: inline-block;
  margin-left: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-faint);
  font-style: normal;
}

/* --- Share form --- */
.share {
  background: var(--parchment);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
}
.share h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 1.9rem;
  margin: 0 0 0.4rem;
}
.share-intro { color: var(--ink-soft); margin: 0 0 1.4rem; font-size: 1.02rem; }

.memory-form label {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}
.memory-form input[type="text"],
.memory-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink-faint);
  border-radius: 2px;
  padding: 0.65rem 0.8rem;
  margin: 0 0 1.2rem;
}
.memory-form textarea { resize: vertical; line-height: 1.55; }
.memory-form input:focus,
.memory-form textarea:focus {
  outline: none;
  border-color: var(--slate);
  box-shadow: 0 0 0 3px rgba(93, 124, 147, 0.18);
}

.memory-form button {
  font-family: "EB Garamond", serif;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
  color: #fdfaf2;
  background: var(--slate);
  border: none;
  border-radius: 2px;
  padding: 0.7rem 1.6rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.memory-form button:hover { background: var(--slate-deep); }

/* Honeypot — present in the DOM, hidden from humans. */
.hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --- Footer --- */
.page-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.98rem;
}

/* --- Responsive --- */
@media (max-width: 720px) {
  body { font-size: 1.12rem; }
  .portrait {
    float: none;
    width: 100%;
    min-width: 0;
    margin: 0 auto 1.75rem;
    max-width: 30rem;
  }
}

/* --- Admin (utilitarian) --- */
body.admin { background: #ece5d4; }
.admin-wrap { max-width: 46rem; margin: 2rem auto; padding: 0 1rem; }
.admin-wrap h1 { font-family: "Cormorant Garamond", serif; font-weight: 600; }
.admin-wrap h2 { border-bottom: 1px solid var(--rule); padding-bottom: 0.3rem; margin-top: 2rem; }
.admin-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  margin: 0 0 0.9rem;
}
.admin-card.pending { border-left: 4px solid var(--brick); }
.admin-card.approved { border-left: 4px solid var(--slate); }
.admin-meta { margin: 0 0 0.5rem; font-size: 0.92rem; color: var(--ink-soft); }
.admin-meta .ip { color: var(--ink-faint); font-size: 0.82rem; }
.admin-msg { margin: 0 0 0.8rem; white-space: pre-wrap; }
.admin-actions { display: flex; gap: 0.6rem; }
.admin-actions form { margin: 0; }
.admin-actions button {
  font: inherit;
  border: none;
  border-radius: 2px;
  padding: 0.4rem 1.1rem;
  cursor: pointer;
  color: #fff;
}
.admin-actions .approve { background: #4f8060; }
.admin-actions .reject { background: #9e4a3c; }

/* ===== Family photo album ===== */

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 18px 50px -28px var(--shadow);
  padding: 2.5rem;
  max-width: 26rem;
  width: 100%;
  text-align: center;
}
.login-card h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 2.2rem;
  margin: 0 0 0.25rem;
}
.login-sub { color: var(--ink-soft); font-style: italic; margin: 0 0 1.75rem; }
.login-error { color: var(--brick); margin: 0 0 1rem; }
.login-card label {
  display: block; text-align: left;
  font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 0.35rem;
}
.login-card input {
  width: 100%; font-family: inherit; font-size: 1.1rem;
  background: var(--parchment); border: 1px solid var(--ink-faint);
  border-radius: 2px; padding: 0.65rem 0.8rem; margin: 0 0 1.4rem;
}
.login-card input:focus { outline: none; border-color: var(--slate); box-shadow: 0 0 0 3px rgba(93,124,147,0.18); }
.login-card button {
  width: 100%; font-family: "EB Garamond", serif; font-size: 1.1rem;
  color: #fdfaf2; background: var(--slate); border: none; border-radius: 2px;
  padding: 0.7rem; cursor: pointer; transition: background-color 0.15s ease;
}
.login-card button:hover { background: var(--slate-deep); }
.login-foot { margin: 1.5rem 0 0; font-size: 0.95rem; }
.login-foot a { color: var(--slate-deep); }

/* Gallery header */
.gallery-body { background-color: var(--parchment); }
.gallery-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: var(--paper); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 10;
}
.gallery-title { flex: 1; text-align: center; }
.gallery-title h1 {
  font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0; line-height: 1.1;
}
.gallery-title p { margin: 0.1rem 0 0; color: var(--ink-soft); font-size: 0.95rem; font-style: italic; }
.gallery-back { color: var(--slate-deep); text-decoration: none; white-space: nowrap; }
.gallery-logout {
  font-family: "EB Garamond", serif; font-size: 0.95rem; color: var(--ink-soft);
  background: transparent; border: 1px solid var(--rule); border-radius: 2px;
  padding: 0.4rem 0.9rem; cursor: pointer; white-space: nowrap;
}
.gallery-logout:hover { background: var(--parchment); }

/* Grid */
.gallery { padding: clamp(1rem, 4vw, 2.5rem); max-width: 90rem; margin: 0 auto; }
.year { margin-bottom: 2.5rem; }
.year h2 {
  font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600;
  font-size: 1.8rem; color: var(--slate-deep);
  margin: 0 0 1rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.ph {
  display: block; aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: 2px; background: var(--parchment); cursor: zoom-in;
}
.ph img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.25s ease, filter 0.25s ease;
}
.ph:hover img { transform: scale(1.05); filter: brightness(1.04); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(28, 25, 20, 0.92); padding: 2rem;
}
.lightbox[hidden] { display: none; }
.lb-stage { margin: 0; max-width: 92vw; max-height: 86vh; display: flex; }
.lb-img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 2px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.lb-btn {
  position: absolute; background: rgba(250,244,230,0.12); color: #fdfaf2;
  border: none; cursor: pointer; border-radius: 50%;
  width: 3rem; height: 3rem; font-size: 2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.15s ease;
}
.lb-btn:hover { background: rgba(250,244,230,0.28); }
.lb-close { top: 1rem; right: 1rem; font-size: 1.8rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-download {
  position: absolute; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  color: #fdfaf2; font-size: 0.95rem; text-decoration: none;
  background: rgba(250,244,230,0.14); padding: 0.45rem 1.2rem; border-radius: 2px;
}
.lb-download:hover { background: rgba(250,244,230,0.28); }

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .lb-prev { left: 0.25rem; } .lb-next { right: 0.25rem; }
}
