/* ============================================================
   FAMILY TREE — Stylesheet
   Aesthetic: refined editorial, cream & deep ink, serif elegance
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────── */
:root {
  --cream:        #f5f0e8;
  --cream-dark:   #ede7d9;
  --cream-darker: #ddd5c2;
  --ink:          #1a1510;
  --ink-mid:      #3d3529;
  --ink-light:    #6b5f4e;
  --ink-faint:    #9e9183;
  --gold:         #a0845c;
  --gold-light:   #c9a97a;
  --gold-pale:    #e8d9c0;
  --red-accent:   #8b3a2f;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Jost', 'Helvetica Neue', sans-serif;

  --shadow-sm:    0 2px 8px rgba(26,21,16,0.08);
  --shadow-md:    0 6px 24px rgba(26,21,16,0.12);
  --shadow-lg:    0 16px 48px rgba(26,21,16,0.18);

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    20px;
  --radius-full:  9999px;

  --transition:   all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background-color: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(160,132,92,0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(160,132,92,0.05) 0%, transparent 50%);
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── Logout button ──────────────────────────────────────── */
.logout-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: none;
  border: 1px solid var(--cream-darker);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 400;
}
.logout-btn:hover {
  color: var(--ink-light);
  border-color: var(--ink-faint);
}

/* ── Site Header ────────────────────────────────────────── */
.site-header {
  text-align: center;
  padding: 4rem 1rem 2.5rem;
  position: relative;
}

.site-header::after {
  content: '';
  display: block;
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 1.5rem auto 0;
}

.header-ornament {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.75rem;
  display: block;
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--ink);
  line-height: 1.15;
}

.site-tagline {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 400;
}

/* ── Tree Layout ────────────────────────────────────────── */
.tree-main {
  padding: 1rem 1rem 4rem;
  overflow-x: auto;
}

.tree-container {
  min-width: 540px;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Generation label */
.gen-label {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
  margin-bottom: 1.25rem;
  position: relative;
  padding: 0 1.5rem;
}
.gen-label::before,
.gen-label::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40px;
  height: 1px;
  background: var(--cream-darker);
}
.gen-label::before { right: 100%; }
.gen-label::after  { left:  100%; }

/* Generation row */
.gen-row {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
  width: 100%;
}

.gen-spacer {
  height: 0.5rem;
}

/* Couple unit */
.couple-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Partners side by side */
.partners-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Union mark between partners */
.union-mark {
  font-size: 0.65rem;
  color: var(--gold);
  margin-top: 34px;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Member Card ────────────────────────────────────────── */
.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  width: 96px;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  outline: none;
  position: relative;
}
.member-card:hover,
.member-card:focus-visible {
  background: rgba(160,132,92,0.07);
  transform: translateY(-4px);
}
.member-card:focus-visible {
  box-shadow: 0 0 0 2px var(--gold);
}

.portrait-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-pale));
  flex-shrink: 0;
  position: relative;
}

.portrait-wrap {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: var(--cream-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-initials {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink-mid);
  line-height: 1;
}

.card-name {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.card-years {
  display: block;
  font-size: 0.65rem;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 2px;
  font-weight: 300;
}

/* ── Branch connectors ──────────────────────────────────── */
.child-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0;
}

.branch-stem {
  width: 1px;
  height: 28px;
  background: var(--cream-darker);
}

.child-row {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  position: relative;
}

/* Horizontal line above children */
.child-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: calc(50px);
  right: calc(50px);
  height: 1px;
  background: var(--cream-darker);
}
/* If only 1 child, hide the horizontal line */
.child-row:only-child::before { display: none; }

.child-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.child-tick {
  width: 1px;
  height: 24px;
  background: var(--cream-darker);
}

/* ── Site Footer ────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  border-top: 1px solid var(--cream-dark);
}

/* ══════════════════════════════════════════════════════════
   PROFILE PAGE
   ══════════════════════════════════════════════════════════ */

.profile-page {
  background-color: var(--cream);
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
  padding: 1.25rem 1.5rem;
  transition: var(--transition);
  font-weight: 500;
}
.back-link:hover { color: var(--gold); }
.back-arrow { font-size: 1rem; }

/* Profile hero section */
.profile-hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  flex-wrap: wrap;
}

.profile-portrait-wrap {
  flex-shrink: 0;
}

.profile-portrait {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--cream-dark);
  border: 4px solid transparent;
  background-clip: padding-box;
  box-shadow: 0 0 0 3px var(--gold-light), var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.initials-lg {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 600;
  color: var(--ink-mid);
}

.profile-info {
  flex: 1;
  min-width: 200px;
  padding-top: 0.5rem;
}

.profile-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 300;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.profile-dates {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 1rem;
}

.profile-bio {
  font-size: 0.95rem;
  color: var(--ink-light);
  line-height: 1.8;
  font-weight: 300;
  max-width: 480px;
}

/* ── Albums grid ────────────────────────────────────────── */
.albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  justify-items: center;
}

.album-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--cream-dark);
  border: 1px solid var(--cream-darker);
  transition: var(--transition);
  outline: none;
}
.album-card:hover,
.album-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold-light);
}

.album-cover {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--cream-dark);
}
.album-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.album-card:hover .album-cover-img { transform: scale(1.05); }

.album-cover-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(26,21,16,0.35) 0%, transparent 60%);
  pointer-events: none;
}

.album-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.album-placeholder-icon { font-size: 2rem; opacity: 0.3; }

.album-meta {
  padding: 12px 14px;
}
.album-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.album-photo-count {
  font-size: 0.7rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
  font-weight: 400;
}

/* ── Album overlay panel ────────────────────────────────── */
.album-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.album-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.album-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,21,16,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.album-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  background: var(--cream);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(40px);
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: var(--shadow-lg);
}
.album-overlay.active .album-panel {
  transform: translateY(0);
}

.album-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--cream-dark);
  flex-shrink: 0;
}
.album-panel-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.album-panel-count {
  font-size: 0.7rem;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}
.album-panel-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--cream-darker);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ink-light);
  cursor: pointer;
  background: none;
  transition: var(--transition);
  flex-shrink: 0;
}
.album-panel-close:hover {
  background: var(--cream-dark);
  color: var(--ink);
}

.album-photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 1rem 1.5rem 2rem;
  overflow-y: auto;
}

.album-photo-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--cream-dark);
  border: 1px solid var(--cream-darker);
  transition: var(--transition);
  outline: none;
}
.album-photo-item:hover,
.album-photo-item:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--gold-light);
}

.album-photo-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--cream-dark);
}
.album-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.album-photo-item:hover .album-photo-wrap img { transform: scale(1.04); }

.album-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.album-photo-caption {
  padding: 6px 8px;
  font-size: 0.68rem;
  color: var(--ink-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Gallery section (shared header styles) ─────────────── */
.gallery-section {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.gallery-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--cream-dark);
}

.gallery-heading {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.gallery-count {
  font-size: 0.75rem;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 400;
}

/* Gallery grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.gallery-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--cream-dark);
  border: 1px solid var(--cream-darker);
  transition: var(--transition);
  outline: none;
}
.gallery-item:hover,
.gallery-item:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold-light);
}

.gallery-img-wrap {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--cream-dark);
}
.gallery-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.gallery-item:hover .gallery-img-wrap img {
  transform: scale(1.04);
}

.gallery-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-dark);
}
.placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.placeholder-icon {
  font-size: 1.6rem;
  opacity: 0.4;
}
.placeholder-text {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}

.gallery-caption {
  padding: 8px 10px;
  font-size: 0.72rem;
  color: var(--ink-light);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Lightbox ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(26,21,16,0.94);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-img-wrap {
  max-width: 80vw;
  max-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img-wrap img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.lightbox-placeholder {
  width: 260px;
  height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.5);
}

.lightbox-caption {
  margin-top: 1rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 300;
  color: rgba(245,240,232,0.85);
  letter-spacing: 0.03em;
  text-align: center;
  font-style: italic;
}

.lightbox-counter {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245,240,232,0.35);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  color: rgba(245,240,232,0.6);
  font-size: 1.5rem;
  padding: 0.75rem;
  transition: color 0.2s;
  background: none;
  border: none;
  cursor: pointer;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { color: var(--cream); }

.lightbox-close { top: 1.25rem; right: 1.25rem; font-size: 1.1rem; }
.lightbox-prev  { left: 1rem; top: 50%; transform: translateY(-50%); font-size: 2.5rem; }
.lightbox-next  { right: 1rem; top: 50%; transform: translateY(-50%); font-size: 2.5rem; }

/* ── Responsive tweaks ──────────────────────────────────── */
@media (max-width: 600px) {
  .tree-main { padding: 0.5rem 0.5rem 3rem; }
  .gen-row { gap: 1.5rem; }
  .profile-hero { gap: 1.5rem; padding: 1.5rem 1rem 2rem; }
  .profile-portrait { width: 100px; height: 100px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .lightbox-prev { left: 0.25rem; }
  .lightbox-next { right: 0.25rem; }
}
