/* ===== Ross Family - Design Tokens ===== */
:root {
  --color-forest: #2E4034;
  --color-linen: #F7F0E3;
  --color-brick: #B5482A;
  --color-gold: #D4A24C;
  --color-sage: #4A5D52;
  --color-ink: #1C1C1A;
  --color-muted-on-dark: #9A958C;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", "SF Mono", monospace;

  --max-width: 1120px;
  --radius: 10px;
  --shadow-soft: 0 4px 20px rgba(28, 28, 26, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-linen);
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-forest);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 600;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.3rem; }

p { margin: 0 0 1em; }

a { color: var(--color-brick); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  font-size: 0.85rem;
  color: var(--color-sage);
  text-transform: uppercase;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header / Nav ===== */
.site-header {
  background: var(--color-forest);
  color: var(--color-linen);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-soft);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
}

.brand:hover { opacity: 0.9; }

.brand-logo {
  display: block;
  height: 56px;
  width: auto;
}

@media (max-width: 760px) {
  .brand-logo { height: 42px; }
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

nav.main-nav {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

nav.main-nav a {
  color: var(--color-linen);
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.85;
}

nav.main-nav a:hover,
nav.main-nav a.active {
  opacity: 1;
  text-decoration: none;
  color: var(--color-gold);
}

nav.main-nav a.nav-icon-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Icon-only nav links (Admin, My Profile) still need a real tap target
   even without a label, so they get a slightly larger icon and padding
   instead of relying on text width. */
nav.main-nav a.nav-icon-link--bare {
  padding: 4px;
}

nav.main-nav a.nav-icon-link--bare .nav-icon {
  width: 20px;
  height: 20px;
}

/* Admin / Profile / Log Out read as one cluster, so they sit closer
   together than the main nav's link-to-link gap. */
.nav-auth-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ===== "More" nav dropdown ===== */
.nav-more { position: relative; }

.nav-more-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font-family: inherit;
  color: var(--color-linen);
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.85;
  cursor: pointer;
  padding: 0;
}

.nav-more-trigger:hover,
.nav-more-trigger[aria-expanded="true"],
.nav-more-trigger.active {
  opacity: 1;
  color: var(--color-gold);
}

.nav-more-caret {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.nav-more-trigger[aria-expanded="true"] .nav-more-caret { transform: rotate(180deg); }

.nav-more-panel {
  position: absolute;
  top: calc(100% + 18px);
  left: 50%;
  min-width: 210px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 48px rgba(28, 28, 26, 0.24);
  padding: 8px;
  transform-origin: top center;
  transform: translate(-50%, -4px) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1),
              transform 180ms cubic-bezier(0.23, 1, 0.32, 1),
              visibility 180ms;
  z-index: 200;
}

.nav-more-panel::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%) rotate(45deg);
}

.nav-more.open .nav-more-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

nav.main-nav .nav-more-panel a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--color-ink);
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 1;
}

nav.main-nav .nav-more-panel a:hover,
nav.main-nav .nav-more-panel a.active {
  background: rgba(46, 64, 52, 0.07);
  text-decoration: none;
  color: var(--color-forest);
}

.nav-more-panel a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: var(--color-brick);
}

@media (prefers-reduced-motion: reduce) {
  .nav-more-caret,
  .nav-more-panel { transition: none; }
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-linen);
  color: var(--color-linen);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 1rem;
}

@media (max-width: 760px) {
  nav.main-nav {
    display: none;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    padding: 16px 0 8px;
  }
  nav.main-nav.open { display: flex; }

  /* wrap is what lets the open menu take its own full-width row */
  .site-header .container { flex-wrap: wrap; gap: 12px; }

  /* The logo must give way rather than shove the button onto a second row.
     min-width:0 is the load-bearing part: a flex item will not shrink below
     its content width without it. */
  .brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* width+max-width+object-fit rather than height+width:auto, so the artwork
     scales down inside a shrinking box instead of holding its natural width.
     Avoids relying on intrinsic sizing of a viewBox-only SVG, which engines
     disagree about. 266px is its natural width at 42px tall. */
  .brand-logo {
    height: 42px;
    width: 100%;
    /* Hard cap to the space left after padding (48) + gap (12) + button (44),
       so the logo and button can always share row one. A flex-shrink approach
       does not work here: with flex-wrap:wrap the container wraps items rather
       than shrinking them, so min-width:0 alone never kicks in. */
    max-width: min(266px, calc(100vw - 104px));
    object-fit: contain;
    object-position: left center;
  }

  /* Fixed box so the header never depends on how the platform draws the
     hamburger glyph. Buttons do not inherit font-family, so iOS and Android
     were measuring different widths for the same markup. 44px also clears
     the touch target floor, which the old ~41x33 button did not. */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    line-height: 1;
  }

  /* The floating popover reads as a stray card once the nav itself is
     already a vertical stack - it becomes an inline accordion instead.
     grid-template-rows 0fr->1fr collapses/reveals it without animating
     height/padding/margin directly (layout-thrashing properties); only
     the grid track size changes, and the inner wrapper's overflow:hidden
     clips its content to that track. */
  .nav-more-panel {
    position: static;
    transform: none;
    box-shadow: none;
    background: none;
    opacity: 1;
    visibility: visible;
    pointer-events: none;
    min-width: 0;
    padding: 0;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 220ms cubic-bezier(0.23, 1, 0.32, 1);
  }

  .nav-more-panel::before { display: none; }

  .nav-more-panel-inner {
    overflow: hidden;
    min-height: 0;
    padding: 4px 0 0 14px;
  }

  .nav-more.open .nav-more-panel {
    /* Re-declared: the desktop rule of the same specificity
       (.nav-more.open .nav-more-panel { transform: translate(-50%, 0) ... })
       would otherwise still win and shift this static-flow element
       sideways by half its own width. */
    transform: none;
    grid-template-rows: 1fr;
    pointer-events: auto;
  }

  nav.main-nav .nav-more-panel a { color: var(--color-linen); }

  nav.main-nav .nav-more-panel a:hover,
  nav.main-nav .nav-more-panel a.active {
    background: rgba(247, 240, 227, 0.1);
    color: var(--color-gold);
  }

  .nav-more-panel a svg { fill: var(--color-gold); }
}

/* ===== Sign-in flash banner ===== */
.flash {
  background: #E4EDE4;
  border-bottom: 1px solid rgba(46, 64, 52, 0.18);
  color: var(--color-forest);
  font-size: 0.95rem;
  padding: 14px 24px;
  text-align: center;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--color-forest) 0%, #24332a 100%);
  color: var(--color-linen);
  padding: 72px 0 88px;
  isolation: isolate;
}

.hero:not(.hero--photo)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  /* Plain low-alpha hairlines drawn directly over the gradient, not a
     rasterized/blended image - at this low an opacity a blend mode like
     overlay would fight the base color and lighten it; flat compositing
     keeps the green reading as green, just faintly hatched. */
  background-image:
    repeating-linear-gradient(45deg, rgba(247, 240, 227, 0.05) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(247, 240, 227, 0.05) 0 1px, transparent 1px 9px);
}

.hero:not(.hero--photo) > .container { position: relative; z-index: 1; }

.hero h1 { color: var(--color-linen); }

.hero .tagline {
  font-family: var(--font-mono);
  color: var(--color-gold);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.hero p.lead {
  max-width: 640px;
  font-size: 1.15rem;
  color: #E9E2D3;
}

/* ===== Hero - full-bleed photo band (Home) =====
   Pure image, no text overlay. aspect-ratio is locked to the photo's
   native ratio so object-fit: contain always fills edge-to-edge with
   zero letterboxing (no one is ever cropped, and there are no hard
   bars). A soft inset vignette feathers the outer edge into the page. */
.hero--photo {
  position: relative;
  /* Must clear the padding .hero sets. This band holds no text, and on a
     narrow screen the ratio makes it shorter than that padding - the padding
     then wins and drives the width far past the viewport (160px of padding
     x 1772/582 = 487px inside a 375px phone), which breaks the whole page. */
  padding: 0;
  aspect-ratio: 1772 / 582;
  overflow: hidden;
  background: var(--color-forest);
}

.hero-photo-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.hero-photo-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 min(10vw, 140px) min(3vw, 40px) rgba(28, 28, 26, 0.55);
}

/* Entrance: one orchestrated reveal, staggered by --delay */
.hero-reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: hero-reveal-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes hero-reveal-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-reveal {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ===== Sections ===== */
section { padding: 64px 0; }
section.alt { background: #EFE6D3; }

.section-head { margin-bottom: 36px; max-width: 640px; }

.section-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.section-head-row .section-head { margin-bottom: 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-sage);
  margin-bottom: 24px;
}

.back-link:hover { color: var(--color-forest); text-decoration: none; }

/* ===== Two-column layout (Home: intro + key dates) ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: start;
}

.two-col--bottom { align-items: end; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; gap: 48px; }
}

.lead {
  max-width: 60ch;
  font-size: 1.15rem;
  color: var(--color-sage);
}

/* ===== Cards / Grid ===== */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(28,28,26,0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(28, 28, 26, 0.12);
}

.card .mono { display: block; margin-bottom: 8px; }

.icon-link {
  display: block;
  width: 34px;
  margin: 0 auto 16px;
}

.card-icon {
  display: block;
  width: 34px;
  height: 34px;
  fill: var(--color-brick);
  transition: transform 0.2s ease, fill 0.2s ease;
}

.icon-link:hover .card-icon {
  fill: var(--color-forest);
  transform: scale(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .icon-link:hover .card-icon { transform: none; }
}

.icon-card .mono,
.icon-card h3 {
  text-align: center;
}

.card-list { list-style: none; margin: 0; padding: 0; }
.card-list li {
  padding: 14px 0;
  border-bottom: 1px solid rgba(28,28,26,0.08);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}
.card-list li:last-child { border-bottom: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: var(--color-brick);
  color: #fff;
}
.btn-primary:hover { background: #9c3c22; text-decoration: none; }

.btn-outline {
  background: transparent;
  border-color: var(--color-linen);
  color: var(--color-linen);
}
.btn-outline:hover { background: rgba(247,240,227,0.12); text-decoration: none; }

.btn-outline-dark {
  background: transparent;
  border-color: var(--color-forest);
  color: var(--color-forest);
}
.btn-outline-dark:hover { background: rgba(46,64,52,0.06); text-decoration: none; }

.btn-small {
  padding: 6px 16px;
  font-size: 0.8rem;
}

.btn-danger {
  background: transparent;
  border-color: var(--color-brick);
  color: var(--color-brick);
}
.btn-danger:hover { background: rgba(181,72,42,0.08); text-decoration: none; }

/* ===== Admin content management ===== */
.admin-manage-group { margin-bottom: 48px; }
.admin-manage-group h3 { margin-bottom: 12px; }

.admin-list { display: flex; flex-direction: column; gap: 1px; }

.admin-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 6px;
}

.admin-list-row-info { min-width: 0; }
.admin-list-row-info strong { display: block; }
.admin-list-row-info span { font-size: 0.85rem; color: var(--color-sage); }

.admin-list-row[data-deleting="true"] { opacity: 0.4; pointer-events: none; }

.admin-list-item { margin-bottom: 6px; }
.admin-list-item .admin-list-row { margin-bottom: 0; }

.admin-edit-panel {
  background: #fff;
  border-radius: 8px;
  padding: 20px 16px;
  margin-top: 6px;
  border: 1px solid rgba(28,28,26,0.08);
}

.admin-edit-panel .form-field { margin-bottom: 14px; }
.admin-edit-panel .form-field:last-of-type { margin-bottom: 0; }

.admin-edit-panel .form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ===== Badge / Tags ===== */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-gold);
  color: var(--color-ink);
  padding: 4px 10px;
  border-radius: 999px;
}

.badge.past {
  background: var(--color-sage);
  color: var(--color-linen);
}

/* ===== Timeline (Reunions archive / key dates) =====
   The line and each dot are both derived from the same --rail/--pad/--dot
   variables via calc(), so they're centered on each other by construction
   instead of by hand-tuned pixel offsets. */
.timeline {
  --rail: 5px;
  --line-w: 2px;
  --dot: 12px;
  --pad: 28px;
  position: relative;
  padding-left: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: var(--rail);
  top: 4px;
  bottom: 4px;
  width: var(--line-w);
  background-image: repeating-linear-gradient(
    to bottom,
    var(--color-gold) 0 6px,
    transparent 6px 12px
  );
}

.timeline .event {
  position: relative;
}

.timeline .event::before {
  content: "";
  position: absolute;
  /* box-sizing must be border-box here specifically: the centering calc
     assumes the 2px border is included in --dot's 12px, not added on top
     of it. Without it the true rendered circle is 16px (12 + 2px border
     each side), 2px wider than the math accounts for, and its center
     lands 2px right of the rail instead of on it. */
  box-sizing: border-box;
  left: calc(var(--rail) + (var(--line-w) / 2) - var(--pad) - (var(--dot) / 2));
  top: 4px;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--color-brick);
  border: 2px solid var(--color-linen);
}

.timeline .date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-sage);
  text-transform: uppercase;
}

/* ===== Quote / Story block ===== */
.quote-block {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.35;
  color: var(--color-forest);
  margin: 40px 0;
  max-width: 680px;
  padding-top: 8px;
  font-style: italic;
}

.quote-block::before {
  content: "\201C";
  display: block;
  font-family: var(--font-display);
  font-style: normal;
  font-size: 3rem;
  line-height: 1;
  color: var(--color-brick);
  margin-bottom: 4px;
}

/* ===== Footer ===== */
footer.site-footer {
  background: var(--color-ink);
  color: #C9C6BC;
  padding: 48px 0 32px;
  margin-top: 64px;
}

footer.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

footer.site-footer a { color: var(--color-gold); }

footer.site-footer .mono { color: var(--color-muted-on-dark); }

footer.site-footer .fine-print {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted-on-dark);
  margin-top: 24px;
  width: 100%;
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

/* ===== Recipe Box ===== */
.recipe-controls {
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#recipe-search {
  max-width: 420px;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid rgba(28,28,26,0.18);
  border-radius: 8px;
  background: #fff;
  color: var(--color-ink);
}

#recipe-search:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 1px;
  border-color: var(--color-forest);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fff;
  border: 1px solid rgba(28,28,26,0.18);
  color: var(--color-sage);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tag-pill:hover:not(.active) {
  border-color: var(--color-forest);
  color: var(--color-forest);
}

.tag-pill.active {
  background: var(--color-forest);
  border-color: var(--color-forest);
  color: var(--color-linen);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.recipe-card {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.recipe-card:hover,
.recipe-card:focus-visible {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(28, 28, 26, 0.12);
}

.recipe-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.recipe-card h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-sage);
  margin: 18px 0 6px;
}

.recipe-author {
  margin-top: 16px;
  margin-bottom: 0;
}

/* ===== Memory Wall / Story Booth ===== */
.story-wall {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.story-card h3 { margin-bottom: 12px; }

.story-card audio,
.story-card video {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.story-card video {
  border-radius: 8px;
  background: var(--color-ink);
}

.story-author {
  margin-top: 8px;
  margin-bottom: 0;
}

/* ===== Photo Gallery ===== */
.photo-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.photo-tile {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(28, 28, 26, 0.12);
}

.photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-tile figcaption {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

.photo-tile figcaption .mono {
  font-size: 0.7rem;
  color: var(--color-sage);
}

@media (prefers-reduced-motion: reduce) {
  .photo-tile { transition: none; }
  .photo-tile:hover { transform: none; }
}

/* ===== Family tree: connections editor ===== */
.connections-list { margin-bottom: 22px; }

.connections-group + .connections-group { margin-top: 14px; }

.connections-group > p {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-sage);
  margin-bottom: 6px;
}

.connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(28, 28, 26, 0.08);
}

.connection-row:last-child { border-bottom: none; }

.connections-empty {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-sage);
}

.connections-add {
  border-top: 1px solid rgba(28, 28, 26, 0.12);
  padding-top: 20px;
}

/* ===== Family Directory ===== */
.directory-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.profile-photo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 12px;
  background: var(--color-linen);
}

.profile-photo-placeholder {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--color-linen);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--color-brick);
}

/* Gated photo placeholder - a signed-out visitor sees this instead of a
   photo request that would just fail (photo files require a session). */
.profile-photo-gated {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--color-linen);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--color-sage);
  border: 1px dashed rgba(74, 93, 82, 0.35);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.profile-photo-gated:hover {
  background: rgba(74, 93, 82, 0.08);
  color: var(--color-forest);
  text-decoration: none;
}

.profile-photo-gated svg { width: 20px; height: 20px; flex-shrink: 0; }

.profile-photo-gated span {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.2;
  padding: 0 6px;
  text-align: center;
}

.profile-card h3 { margin: 0; }
.profile-card .profile-branch { color: var(--color-sage); }
.profile-card .profile-location { font-size: 0.85rem; color: var(--color-sage); }
.profile-card .profile-bio { font-size: 0.9rem; margin-top: 8px; }
.profile-card .profile-contact { font-size: 0.9rem; margin-top: 8px; }
.profile-card .profile-contact a { color: var(--color-forest); }

/* ===== Family Tree ===== */
#tree-canvas-wrap {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid rgba(28,28,26,0.08);
  box-shadow: var(--shadow-soft);
  margin-top: 16px;
  overflow: hidden;
  height: 560px;
}

#tree-canvas { width: 100%; height: 100%; cursor: grab; }
#tree-canvas:active { cursor: grabbing; }

/* Pinch and Ctrl/Cmd-scroll cover touch and trackpad, but neither is
   discoverable on a plain mouse - these buttons are the fallback. */
#tree-zoom-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

#tree-zoom-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: #fff;
  border: 1px solid rgba(28,28,26,0.14);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  color: var(--color-forest);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

#tree-zoom-controls button:hover { background: #F7F0E3; }
#tree-zoom-controls button:active { transform: scale(0.94); }

#tree-zoom-controls button svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

#tree-zoom-reset {
  width: auto !important;
  border-radius: 999px;
  padding: 0 14px !important;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
  #tree-zoom-controls button { transition: none; }
}

#tree-legend {
  display: flex;
  gap: 28px;
  margin-top: 14px;
}
#tree-legend span { display: inline-flex; align-items: center; gap: 8px; }

.legend-swatch {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 2px solid var(--color-sage);
}
.legend-swatch.dashed { border-top-style: dashed; }

.tree-node { cursor: pointer; }

.tree-node > circle:not(.node-ring) {
  fill: var(--color-forest);
  stroke: var(--color-linen);
  stroke-width: 2px;
  /* No transition here on purpose. Transitioning fill/stroke between two
     var() colours never resolves in the browser - it sticks on the start
     colour, so the selected state silently never appeared. Selection and
     hover are feedback anyway, and feedback should be immediate. */
}

/* The +/- badge already marks who has children, so fill is free to carry the
   one piece of state this page was missing: who you are currently editing.
   Gold is the same "active" signal the nav uses. */
.tree-node.is-selected > circle:not(.node-ring) {
  fill: var(--color-brick);
  stroke: var(--color-gold);
  stroke-width: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .tree-node:hover > circle:not(.node-ring) {
    stroke: var(--color-gold);
    stroke-width: 3px;
  }
}

.tree-node:focus { outline: none; }
.tree-node:focus-visible > circle:not(.node-ring) {
  stroke: var(--color-gold);
  stroke-width: 3px;
}

.tree-node image { pointer-events: none; }
.tree-node .node-ring {
  fill: none;
  stroke: var(--color-linen);
  stroke-width: 2px;
  pointer-events: none;
}

.node-toggle { cursor: pointer; }

/* An 18px badge is well under the touch floor, so an invisible disc widens
   the hit area without changing what the eye sees. */
.node-toggle .hit {
  fill: transparent;
  stroke: none;
}

.node-toggle .badge-dot {
  fill: var(--color-linen);
  stroke: var(--color-sage);
  stroke-width: 1.5px;
}
.node-toggle text {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  fill: var(--color-forest);
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .node-toggle:hover .badge-dot { fill: #fff; stroke: var(--color-forest); }
}
/* Press feedback: SVG groups already carry a translate, so scaling here would
   fight it. Colour shift reads just as immediately. */
.node-toggle:active .badge-dot { fill: var(--color-gold); stroke: var(--color-forest); }
.node-toggle:focus { outline: none; }
.node-toggle:focus-visible .badge-dot { fill: #fff; stroke: var(--color-forest); stroke-width: 2.5px; }
.tree-node text {
  font-family: var(--font-body);
  font-size: 12px;
  fill: var(--color-ink);
}
.tree-node .node-years {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--color-sage);
}
.tree-link {
  fill: none;
  stroke: var(--color-sage);
  stroke-width: 1.5px;
}
.tree-link.spouse {
  stroke-dasharray: 4 3;
}
.tree-link.stem {
  stroke-dasharray: none;
}

/* One authored entrance for the whole diagram rather than a separate effect
   per node. The auto-fit zoom settles underneath it, so they read as one move. */
@media (prefers-reduced-motion: no-preference) {
  #tree-canvas > g {
    animation: tree-settle-in 340ms cubic-bezier(0.23, 1, 0.32, 1) both;
  }
}

@keyframes tree-settle-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Forms ===== */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.form-field label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-sage);
}

.form-field .hint {
  font-size: 0.85rem;
  color: var(--color-sage);
}

.form-field input,
.form-field textarea,
.form-field select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid rgba(28,28,26,0.18);
  border-radius: 8px;
  background: #fff;
  color: var(--color-ink);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-ink);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-forest);
  flex-shrink: 0;
}

.form-field input:focus-visible,
.form-field textarea:focus-visible,
.form-field select:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 1px;
  border-color: var(--color-forest);
}

.form-field textarea { resize: vertical; min-height: 90px; }

.form-error {
  font-size: 0.85rem;
  color: var(--color-brick);
}

.form-status {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.form-status.success { background: rgba(46,64,52,0.08); color: var(--color-forest); }
.form-status.error { background: rgba(181,72,42,0.08); color: var(--color-brick); }
.form-status[hidden] { display: none; }

/* ===== Auth gate modal ===== */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 28, 26, 0);
  transition: background-color 200ms ease-out;
}

.auth-gate-overlay.open { background: rgba(28, 28, 26, 0.55); }

.auth-gate-dialog {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(28, 28, 26, 0.28);
  transform-origin: center;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.23, 1, 0.32, 1), opacity 220ms ease-out;
}

.auth-gate-overlay.open .auth-gate-dialog {
  transform: scale(1);
  opacity: 1;
}

.auth-gate-body { padding: 40px 32px 32px; }

.auth-gate-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-sage);
  background: transparent;
  transition: background-color 150ms ease, transform 150ms ease-out;
}

.auth-gate-close svg { width: 20px; height: 20px; }
.auth-gate-close:hover { background: rgba(74, 93, 82, 0.1); color: var(--color-forest); }
.auth-gate-close:active { transform: scale(0.92); }

.auth-gate-body h3 {
  margin: 0 0 12px;
  font-size: 1.5rem;
  padding-right: 32px;
}

.auth-gate-reason {
  margin: -6px 0 16px;
  font-size: 1rem;
  color: var(--color-forest);
}

.auth-gate-help {
  margin: 0 0 24px;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--color-sage);
}

.auth-gate-form .form-field input {
  font-size: 1.1rem;
  padding: 14px 16px;
}

.auth-gate-submit {
  width: 100%;
  font-size: 1.05rem;
  padding: 16px 20px;
}

.auth-gate-success { text-align: center; padding: 8px 0 4px; }

.auth-gate-success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(46, 64, 52, 0.1);
  color: var(--color-forest);
}

.auth-gate-success-icon svg { width: 28px; height: 28px; }

.auth-gate-success h4 { margin: 0 0 8px; font-size: 1.25rem; }

.auth-gate-success-text {
  margin: 0 0 24px;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--color-sage);
}

.auth-gate-again { width: 100%; }

.auth-gate-status { text-align: left; }

@media (max-width: 560px) {
  .auth-gate-body { padding: 32px 22px 24px; }
}

/* ===== Focus states (a11y) ===== */
a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card,
  .btn {
    transition: none;
  }
  .grid .card:hover,
  .btn:active {
    transform: none;
  }
  .auth-gate-overlay,
  .auth-gate-dialog {
    transition: none;
  }
}
