@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --bg-color: #0e1a12;
  --text-primary: #e0d8c0;
  --text-accent: #c5a059;
  --gold-accent: #8b7355;
  --card-bg: transparent;
}

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

body {
  background-color: var(--bg-color);
  background-image:
    radial-gradient(circle at center, transparent 0%, #000000 100%),
    linear-gradient(#1a221a 1px, transparent 1px),
    linear-gradient(90deg, #1a221a 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px, 20px 20px;
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: 'Cormorant Garamond', serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Remove old stars */
.stars,
.twinkling {
  display: none;
}

/* Living Tree Canvas - Fixed to Viewport */
#tree-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* Prevent Flash of Unfiltered Content */
body:not(.loaded) .member-card {
  opacity: 0;
  visibility: hidden;
  /* Ensure they don't take up layout space if desired, or just opacity to keep layout stable? Opacity is safer for layout. */
  transition: none;
}

/* --- Typography --- */
h1,
h2,
h3 {
  font-family: 'Cinzel', serif;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* --- Hero Section --- */
.hero-section {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

.title {
  font-size: 4rem;
  text-shadow: 0 0 10px #000;
  margin-bottom: 1rem;
}

.subtitle {
  font-size: 1.5rem;
  font-style: italic;
  color: var(--gold-accent);
}

.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.8;
  animation: bounce 2s infinite;
}

.arrow {
  width: 15px;
  height: 15px;
  border-right: 2px solid var(--text-primary);
  border-bottom: 2px solid var(--text-primary);
  transform: rotate(45deg);
}

/* --- Tree Container --- */
.tree-container {
  padding: 0 2rem;
  position: relative;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  z-index: 2;
  /* Content above canvas */
}

/* --- Generation Section --- */
.generation {
  margin-bottom: 250px;
  text-align: center;
  position: relative;
  /* z-index removed to let .member-card z-index take precedence */
}

.generation-title {
  font-size: 2rem;
  margin-bottom: 3rem;
  color: var(--gold-accent);
  text-shadow: 0 2px 4px #000;
}

.group-container {
  display: flex;
  justify-content: center;
  gap: 4rem;
  flex-wrap: nowrap;
  overflow-x: visible;
  /* Changed from auto to visible to allow cards to scale outside bounds */
  padding-bottom: 2rem;
  width: 100%;
}

/* --- Family Groups --- */
.family-group,
.family-branch {
  display: flex;
  gap: 2rem;
  justify-content: center;
  position: relative;
}

.siblings-group {
  display: flex;
  gap: 2rem;
  margin-left: 2rem;
}

/* --- Member Card --- */
.member-card {
  background: var(--card-bg);
  padding: 1rem;
  width: 200px;
  text-align: center;
  position: relative;
  z-index: 10;
  opacity: 1;
  transition: all 0.5s ease-out;
  /* Smooth transition for scale/opacity */
  cursor: pointer;
}

.member-card:hover {
  transform: scale(1.05);
  z-index: 20;
}

/* --- Focus Hierarchy Classes --- */
.member-card.dimmed {
  opacity: 0.4;
  filter: blur(0.5px) grayscale(0.8);
  transform: scale(0.9);
}

.member-card.focused {
  transform: scale(1.3);
  z-index: 50;
  opacity: 1;
  filter: none;
}

.member-card.focused .portrait {
  box-shadow: 0 0 20px #c5a059, 0 0 40px rgba(197, 160, 89, 0.4);
  border-color: #fff;
}

.member-card.partner {
  transform: scale(1.1);
  z-index: 40;
  opacity: 1;
  filter: none;
}

.member-card.lineage {
  transform: scale(1.05);
  /* Slightly larger */
  z-index: 30;
  opacity: 1;
  filter: none;
}

.member-card.lineage .portrait {
  border-color: #c5a059;
}

.member-card.sibling {
  transform: scale(0.9);
  opacity: 0.8;
  filter: grayscale(0.4);
}

/* --- Portrait --- */
.portrait {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #000;
  margin: 0 auto 1rem;
  border: 3px solid var(--gold-accent);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.member-card.main-line .portrait {
  width: 130px;
  height: 130px;
  border-color: var(--text-accent);
}

.member-card.deceased {
  /* filter: sepia(0.5) grayscale(0.5);  removing this as it conflicts with dimmed */
}

.member-card.deceased .portrait {
  /* Maintain visual cue */
  /* border-color: #554a3a; */
}

.info h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  text-shadow: 0 2px 4px #000;
  transition: font-size 0.3s;
}

.dates {
  font-size: 0.9rem;
  color: #999;
  font-style: italic;
}

/* --- Footer --- */
footer {
  padding: 2rem;
  text-align: center;
  color: #666;
  margin-top: 4rem;
  position: relative;
  z-index: 1;
}

@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-10px);
  }

  60% {
    transform: translateY(-5px);
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .group-container {
    gap: 3rem;
  }

  .member-card {
    width: 150px;
  }
}

/* Focus Hierarchy */
.member-card {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
}

.member-card.focused {
  transform: scale(1.2);
  z-index: 50;
  opacity: 1 !important;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6));
  border-color: rgba(255, 215, 0, 0.8);
}

.member-card.partner {
  transform: scale(1.1);
  z-index: 40;
  opacity: 1 !important;
}

.member-card.lineage {
  transform: scale(1.0);
  z-index: 30;
  opacity: 1 !important;
}

.member-card.sibling {
  transform: scale(0.85);
  opacity: 0.7;
  z-index: 20;
}

.member-card.dimmed {
  transform: scale(0.8);
  opacity: 0.3;
  z-index: 10;
  filter: grayscale(0.8);
}

/* Connection Lines */
.connection-line {
  transition: opacity 0.5s ease, stroke 0.5s ease, stroke-width 0.5s ease;
}

.connection-line.active {
  stroke: #FFD700;
  /* Gold */
  stroke-width: 3px;
  opacity: 0.8;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
  z-index: 100;
}

.connection-line.inactive {
  opacity: 0.1;
  stroke: #aaa;
}