/* Greene Family Heritage — Stylesheet */
html { scroll-behavior: smooth; }

:root {
  --color-bg: #1a1a2e;
  --color-surface: #16213e;
  --color-card: #0f3460;
  --color-accent: #e94560;
  --color-gold: #c9a959;
  --color-text: #e0e0e0;
  --color-text-muted: #a0a0b0;
  --color-link: #7ec8e3;
  --color-earth: #8B6914;
  --color-forest: #2d5a27;
  --color-parchment: rgba(245, 235, 220, 0.05);
  --font-heading: 'Playfair Display', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --max-width: 1100px;
}

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

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
}

a {
  color: var(--color-link);
  text-decoration: none;
  background-image: linear-gradient(var(--color-link), var(--color-link));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.3s ease;
}
a:hover {
  text-decoration: none;
  background-size: 100% 1px;
}

/* Navigation */
nav {
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-gold);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
nav .site-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--color-gold);
}
nav .nav-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
nav .nav-links a {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  transition: color 0.2s;
}
nav .nav-links a:hover, nav .nav-links a.active { color: var(--color-gold); text-decoration: none; background-size: 0% 1px; }

/* Hamburger menu toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-gold);
  color: var(--color-gold);
  font-size: 1.5rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s;
}
.nav-toggle:hover { background: rgba(201,169,89,0.15); }

.nav-divider {
  display: none;
}

/* Story navigation */
.story-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(201,169,89,0.2);
}
.story-nav a {
  display: block;
  padding: 1rem;
  background: var(--color-surface);
  border: 1px solid rgba(201,169,89,0.2);
  border-radius: 8px;
  max-width: 48%;
  transition: border-color 0.3s;
}
.story-nav a:hover {
  border-color: var(--color-gold);
  background-size: 0% 1px;
}
.story-nav .nav-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.story-nav .nav-title {
  font-family: var(--font-heading);
  color: var(--color-gold);
  font-size: 1rem;
  margin-top: 0.25rem;
}
.story-nav .next { margin-left: auto; text-align: right; }

/* Hero (legacy) */
.hero {
  background: linear-gradient(135deg, var(--color-surface), var(--color-bg));
  padding: 4rem 2rem;
  text-align: center;
  border-bottom: 1px solid rgba(201,169,89,0.3);
}
.hero h1 {
  font-family: var(--font-heading);
  font-size: 3rem;
  color: var(--color-gold);
  margin-bottom: 0.5rem;
}
.hero .subtitle {
  font-size: 1.2rem;
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Hero — Cinematic */
.hero-cinematic {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  overflow: hidden;
}
.hero-cinematic .hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(26, 26, 46, 0.7) 0%,
    rgba(22, 33, 62, 0.85) 50%,
    rgba(26, 26, 46, 0.95) 100%
  );
  z-index: 1;
}
.hero-cinematic .hero-content {
  position: relative;
  z-index: 2;
  padding: 2rem;
  max-width: 800px;
}
.hero-cinematic h1 {
  font-family: var(--font-heading);
  font-size: 3.8rem;
  color: var(--color-gold);
  margin-bottom: 0.75rem;
  animation: fadeInUp 1s ease forwards;
  opacity: 0;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8), 0 0 40px rgba(0,0,0,0.5);
}
.hero-cinematic .subtitle {
  font-size: 1.3rem;
  color: #e0e0e0;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 1s ease 0.3s forwards;
  opacity: 0;
  text-shadow: 0 1px 10px rgba(0,0,0,0.9), 0 0 30px rgba(0,0,0,0.6);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Scroll indicator */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: fadeInUp 1s ease 0.8s forwards;
  opacity: 0;
}
.scroll-indicator .chevron {
  width: 24px;
  height: 24px;
  border-right: 2px solid var(--color-gold);
  border-bottom: 2px solid var(--color-gold);
  transform: rotate(45deg);
  animation: bounceDown 2s infinite;
}
@keyframes bounceDown {
  0%, 100% { transform: rotate(45deg) translateY(0); opacity: 1; }
  50%      { transform: rotate(45deg) translateY(8px); opacity: 0.5; }
}

/* Container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem;
}

/* Section headings */
h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: var(--color-gold);
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(201,169,89,0.3);
}
h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--color-text);
  margin: 1.5rem 0 0.75rem;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.card {
  background: var(--color-surface);
  border: 1px solid rgba(201,169,89,0.2);
  border-radius: 8px;
  padding: 1.5rem;
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
}
.card:hover {
  border-color: var(--color-gold);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 30px rgba(201,169,89,0.15), 0 0 0 1px rgba(201,169,89,0.3);
}
.card .card-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--color-gold);
  margin-bottom: 0.5rem;
}
.card .card-dates {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}
.card .card-detail { font-size: 0.95rem; margin-bottom: 0.3rem; }
.card .card-detail strong { color: var(--color-text); }
.card .confidence-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-top: 0.5rem;
}
.confidence-high { background: #1b5e20; color: #a5d6a7; }
.confidence-medium { background: #e65100; color: #ffcc80; }
.confidence-low { background: #b71c1c; color: #ef9a9a; }

/* Timeline */
.timeline { position: relative; padding-left: 2rem; margin: 2rem 0; }
.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--color-gold), var(--color-accent));
  border-radius: 2px;
}
.timeline-event {
  position: relative;
  margin-bottom: 2rem;
  padding-left: 1.5rem;
}
.timeline-event::before {
  content: '';
  position: absolute;
  left: -2.35rem;
  top: 0.4rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-bg);
}
.timeline-event .event-year {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--color-accent);
  margin-bottom: 0.25rem;
}
.timeline-event .event-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.3rem;
}
.timeline-event .event-desc {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* Tree */
#tree-container {
  width: 100%;
  min-height: 500px;
  background: var(--color-surface);
  border: 1px solid rgba(201,169,89,0.2);
  border-radius: 8px;
  overflow: hidden;
}
.node circle { cursor: pointer; stroke: var(--color-gold); stroke-width: 2px; }
.node text { fill: var(--color-text); font-size: 12px; font-family: var(--font-body); }
.link { fill: none; stroke: rgba(201,169,89,0.4); stroke-width: 1.5px; }

/* Celtic divider */
.celtic-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2.5rem 0;
  color: var(--color-gold);
}
.celtic-divider::before,
.celtic-divider::after {
  content: '';
  flex: 1;
  max-width: 200px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
}
.celtic-divider::before { background: linear-gradient(90deg, transparent, var(--color-gold)); }
.celtic-divider::after  { background: linear-gradient(90deg, var(--color-gold), transparent); }

/* Blockquote (for letter) */
blockquote {
  position: relative;
  background: var(--color-surface);
  border-left: 4px solid var(--color-gold);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--color-text-muted);
  border-radius: 0 8px 8px 0;
  overflow: hidden;
}
blockquote::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, var(--color-parchment) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, var(--color-parchment) 0%, transparent 50%);
  pointer-events: none;
}
blockquote strong { color: var(--color-text); font-style: normal; }

/* Person detail modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-gold);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal .close-btn {
  float: right;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal h3 { color: var(--color-gold); margin-top: 0; }

/* Mobile tree alternative */
.tree-mobile-view {
  display: none;
}

.tree-gen {
  margin-bottom: 1.5rem;
}
.tree-gen-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--color-gold);
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(201,169,89,0.2);
  margin-bottom: 0.75rem;
  cursor: pointer;
}
.tree-gen-title::after {
  content: ' ▾';
  font-size: 0.8rem;
}
.tree-gen-title.collapsed::after {
  content: ' ▸';
}
.tree-person {
  padding: 0.6rem 0.75rem;
  margin: 0.3rem 0;
  background: var(--color-surface);
  border-left: 3px solid var(--color-gold);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: background 0.2s;
}
.tree-person:active {
  background: rgba(201,169,89,0.1);
}
.tree-person-name {
  font-weight: 600;
  color: var(--color-text);
}
.tree-person-dates {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.tree-person-relation {
  font-size: 0.8rem;
  color: var(--color-gold);
  font-style: italic;
}
.tree-person.indent-1 { margin-left: 1.5rem; border-left-color: #4caf50; }
.tree-person.indent-2 { margin-left: 3rem; border-left-color: #ff9800; }
.tree-person.indent-3 { margin-left: 4.5rem; border-left-color: #7ec8e3; }

/* Footer */
footer {
  background: var(--color-surface);
  border-top: 1px solid rgba(201,169,89,0.3);
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: 3rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .hero .subtitle { font-size: 1rem; }
  .hero-cinematic h1 { font-size: 2.4rem; }
  .hero-cinematic .subtitle { font-size: 1rem; }
  .hero-cinematic { min-height: 60vh; background-attachment: scroll; }
  .card-grid { grid-template-columns: 1fr; gap: 1rem; }
  .card { overflow-wrap: break-word; word-break: break-word; }
  .container { padding: 1rem; }

  .timeline { padding-left: 1.5rem; }
  .timeline-event { padding-left: 1rem; }
  .timeline-event::before { left: -1.85rem; width: 10px; height: 10px; }

  #map-container { height: 300px !important; }

  .nav-toggle { display: block; }
  nav .nav-inner { flex-wrap: nowrap; }
  nav .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    padding-top: 1rem;
    order: 3;
  }
  nav .nav-links.open {
    display: flex;
    border-top: 1px solid rgba(201,169,89,0.2);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
  }

  #tree-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 400px;
    position: relative;
  }
  #tree-container::after {
    content: '\2190 Scroll to explore \2192';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    background: rgba(26,26,46,0.9);
    padding: 4px 12px;
    border-radius: 12px;
    pointer-events: none;
    z-index: 5;
  }

  .tree-mobile-view { display: block; }
  #tree-container { display: none; }

  .leaflet-marker-icon, .leaflet-interactive { min-width: 44px; min-height: 44px; }

  .nav-divider {
    display: block;
    height: 1px;
    background: rgba(201,169,89,0.15);
    margin: 0.25rem 0;
  }
}

/* Touch-friendly: remove hover effects on touch devices */
@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(201,169,89,0.2);
  }
  .card:active {
    border-color: var(--color-gold);
    background: rgba(201,169,89,0.05);
  }
  a:hover {
    background-size: 0% 1px;
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
  nav { padding-left: max(2rem, env(safe-area-inset-left)); padding-right: max(2rem, env(safe-area-inset-right)); }
  .container { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  footer { padding-bottom: max(2rem, env(safe-area-inset-bottom)); }
}

/* Small phones */
@media (max-width: 380px) {
  .hero-cinematic h1 { font-size: 1.8rem; }
  .hero-cinematic .subtitle { font-size: 0.9rem; }
  h2 { font-size: 1.5rem; }
  .card { padding: 1rem; }
  .card .card-name { font-size: 1.05rem; }
  nav .site-title { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
  .card:hover { transform: none; }
  .hero-cinematic h1,
  .hero-cinematic .subtitle,
  .scroll-indicator { animation: none; opacity: 1; }
  .scroll-indicator .chevron { animation: none; }
}
