/* ========================================================
   double-standard.xyz — Styles
   Seapunk aesthetic, ocean-deep palette, serif-revival typography
   ======================================================== */

/* --- CSS Custom Properties & @property definitions --- */
@property --tide-position {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 100%;
}

:root {
  /* Palette — from DESIGN.md */
  --abyss: #0A1628;           /* Deep Trench */
  --surface: #C5D8E8;         /* Sea Glass */
  --primary: #0F2942;         /* Bathyal Blue */
  --secondary: #2A5F7A;       /* Washed Teal */
  --accent: #4FC3F7;          /* Bioluminescent */
  --text-light: #E8F0F6;      /* Sea Foam */
  --text-muted: #8EBDD6;      /* Pale Tide */
  --highlight: #00897B;       /* Abyssal Glow */
  --danger: #E57373;          /* Coral Warning */
  --gradient-start: #1A3A5C;  /* Photic Zone */
  --pale-tide: #C2D9E8;       /* Body text below tide */
  --dark-teal: #1E3A50;       /* Body text above tide */

  /* Typography */
  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-subheading: 'Lora', 'Georgia', serif;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-accent: 'DM Sans', 'Helvetica Neue', sans-serif;

  /* Sizing */
  --tide-line: 55%;
  --gap: clamp(12px, 2vw, 28px);
}

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

html {
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(0.95rem, 1.2vw + 0.2rem, 1.15rem);
  line-height: 1.72;
  color: var(--pale-tide);
  background: var(--abyss);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  transition: --tide-position 2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Full viewport gradient background — tide line splits surface/abyss */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    var(--surface) 0%,
    var(--surface) calc(var(--tide-position, 55%) - 60px),
    var(--gradient-start) var(--tide-position, 55%),
    var(--abyss) calc(var(--tide-position, 55%) + 60px),
    var(--abyss) 100%
  );
  z-index: -2;
  pointer-events: none;
  transition: --tide-position 0.3s ease;
}

/* --- Marine Snow --- */
#marine-snow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.snow-particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--text-light);
  border-radius: 50%;
  opacity: 0.2;
  will-change: transform, opacity;
  animation: snowfall linear infinite;
}

@keyframes snowfall {
  0% {
    transform: translateY(110vh) translateX(0);
    opacity: 0;
  }
  5% {
    opacity: 0.2;
  }
  95% {
    opacity: 0.15;
  }
  100% {
    transform: translateY(-10vh) translateX(20px);
    opacity: 0;
  }
}

/* --- Tide Line --- */
#tide-line {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

#tide-wave {
  position: absolute;
  top: var(--tide-position, 55%);
  left: 0;
  width: 100%;
  height: 10px;
  transform: translateY(-50%);
  will-change: top;
}

/* --- Background Shapes --- */
#bg-shapes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bg-shape {
  position: absolute;
  opacity: 0.6;
  will-change: transform;
}

.plankton-net {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 1;
}

.bg-radiolarian-1 {
  width: clamp(200px, 25vw, 400px);
  height: clamp(200px, 25vw, 400px);
  top: 8%;
  right: 5%;
  opacity: 0.15;
  animation: slowRotate 90s linear infinite, bgBreathe 12s ease-in-out infinite;
}

.bg-drift-1 {
  width: clamp(180px, 20vw, 350px);
  height: clamp(180px, 20vw, 350px);
  bottom: 12%;
  left: 3%;
  opacity: 0.12;
  animation: slowRotate 120s linear infinite reverse, bgBreathe 10s ease-in-out infinite;
}

.bg-nautilus-1 {
  width: clamp(160px, 18vw, 320px);
  height: clamp(160px, 18vw, 320px);
  top: 55%;
  right: 12%;
  opacity: 0.1;
  animation: slowRotate 100s linear infinite, bgBreathe 14s ease-in-out infinite;
}

@keyframes bgBreathe {
  0%, 100% { opacity: var(--bg-shape-opacity, 0.12); }
  50% { opacity: calc(var(--bg-shape-opacity, 0.12) * 1.3); }
}

/* --- Buoy Navigation --- */
#buoy-nav {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.buoy {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.6;
}

.buoy:hover {
  width: 12px;
  height: 12px;
  opacity: 1;
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.4);
}

.buoy.active {
  opacity: 1;
  animation: buoyPulse 2.5s ease-in-out infinite;
}

@keyframes buoyPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 195, 247, 0.4); }
  50% { box-shadow: 0 0 8px 4px rgba(79, 195, 247, 0.2); }
}

.buoy-tooltip {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(10, 22, 40, 0.85);
  padding: 4px 10px;
  border-radius: 3px;
}

.buoy:hover .buoy-tooltip {
  opacity: 1;
}

/* --- Sections --- */
.full-viewport {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.section-snap {
  scroll-snap-align: start;
}

.content-section {
  padding: clamp(60px, 8vw, 120px) clamp(20px, 5vw, 80px);
  position: relative;
  min-height: 80vh;
}

/* --- Intro / Descent Section --- */
#intro {
  z-index: 10;
}

.intro-content {
  text-align: center;
  position: relative;
  z-index: 5;
}

.intro-shape {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
  opacity: 0;
  animation: introShapeFade 2s ease-out 0.5s forwards;
}

.radiolarian {
  width: clamp(120px, 20vw, 220px);
  height: clamp(120px, 20vw, 220px);
  animation: slowRotate 60s linear infinite;
  will-change: transform;
}

@keyframes slowRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes introShapeFade {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.intro-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5.5vw + 0.5rem, 5rem);
  letter-spacing: 0.02em;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.title-above {
  color: var(--primary);
  opacity: 0;
  animation: letterReveal 1.5s ease-out 1s forwards;
}

.title-below {
  color: var(--text-light);
  opacity: 0;
  animation: letterReveal 1.5s ease-out 1.4s forwards;
}

.title-rule {
  display: block;
  width: clamp(100px, 30vw, 300px);
  height: 1px;
  background: var(--accent);
  opacity: 0;
  animation: ruleReveal 1.2s ease-out 1.2s forwards;
  margin: 8px 0;
}

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

@keyframes ruleReveal {
  from { opacity: 0; width: 0; }
  to { opacity: 0.6; width: clamp(100px, 30vw, 300px); }
}

.intro-subtitle {
  font-family: var(--font-accent);
  font-weight: 500;
  font-size: clamp(0.7rem, 0.9vw, 0.85rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 12px;
  opacity: 0;
  animation: letterReveal 1s ease-out 1.8s forwards;
}

/* --- Masonry Grid --- */
.masonry-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr 0.8fr;
  gap: var(--gap);
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

/* --- Tile Base --- */
.tile {
  position: relative;
  padding: clamp(20px, 3vw, 36px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

/* --- Tile States (Progressive Disclosure) --- */
.tile-hidden {
  opacity: 0;
  border: 1px solid rgba(125, 185, 222, 0.15);
  background: transparent;
}

.tile-hidden > * {
  opacity: 0;
  transform: translateY(12px);
}

.tile-revealed {
  opacity: 1;
}

.tile-revealed > * {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.2s,
              transform 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.2s;
}

/* Stagger by column — left first, center second, right third */
.tile-revealed[data-col="1"] {
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1),
              background 0.6s cubic-bezier(0.23, 1, 0.32, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              backdrop-filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-revealed[data-col="2"] {
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.12s,
              background 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.12s,
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              backdrop-filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile-revealed[data-col="3"] {
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.24s,
              background 0.6s cubic-bezier(0.23, 1, 0.32, 1) 0.24s,
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              backdrop-filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Drift Tiles (60%) --- */
.drift-tile {
  border-radius: 2px;
  border: 1px solid rgba(125, 185, 222, 0.15);
  background: rgba(10, 22, 40, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.drift-tile.tile-revealed {
  border: 1px solid rgba(125, 185, 222, 0.15);
  background: rgba(10, 22, 40, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.drift-tile:hover {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: rgba(125, 185, 222, 0.4);
  transform: translateY(-2px);
}

/* --- Depth Tiles (25%) --- */
.depth-tile {
  border-radius: 2px;
  border: none;
  background: rgba(10, 22, 40, 0.55);
  box-shadow: 0 8px 40px rgba(5, 15, 35, 0.5);
  min-height: 280px;
}

.depth-tile.tile-revealed {
  background: rgba(10, 22, 40, 0.55);
  box-shadow: 0 8px 40px rgba(5, 15, 35, 0.5);
  border: none;
}

/* --- Specimen Tiles (15%) — circular portholes --- */
.specimen-tile {
  border-radius: 50%;
  border: 1px solid rgba(125, 185, 222, 0.15);
  background: rgba(10, 22, 40, 0.2);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.specimen-tile.tile-revealed {
  background: rgba(10, 22, 40, 0.2);
  border: 1px solid rgba(125, 185, 222, 0.15);
}

.specimen-svg {
  width: 80%;
  height: 80%;
  opacity: 0.6;
  animation: specimenBreathe 8s ease-in-out infinite, slowRotate 60s linear infinite;
  will-change: transform;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Specimen hover: accelerate rotation, brighten */
.specimen-tile:hover .specimen-svg {
  opacity: 1;
  animation: specimenBreathe 8s ease-in-out infinite, slowRotate 8s linear infinite;
}

.specimen-tile:hover .specimen-svg line,
.specimen-tile:hover .specimen-svg circle,
.specimen-tile:hover .specimen-svg ellipse,
.specimen-tile:hover .specimen-svg path {
  stroke: var(--accent);
  transition: stroke 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes specimenBreathe {
  0%, 100% { transform: scale(1) rotate(var(--specimen-rotate, 0deg)); }
  50% { transform: scale(1.03) rotate(var(--specimen-rotate, 0deg)); }
}

/* --- Double Standard Sections — paired contrast tiles --- */
.double-standard-section {
  display: flex;
  align-items: center;
  justify-content: center;
}

.double-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 4vw, 60px);
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Light version (above tide — surface palette) */
.double-tile-light {
  background: rgba(197, 216, 232, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 20px rgba(15, 41, 66, 0.15);
  border: 1px solid rgba(197, 216, 232, 0.3);
}

.double-tile-light.tile-revealed {
  background: rgba(197, 216, 232, 0.25);
  box-shadow: 0 4px 20px rgba(15, 41, 66, 0.15);
  border: 1px solid rgba(197, 216, 232, 0.3);
}

.double-tile-light h2 {
  color: var(--primary);
}

.double-tile-light p {
  color: var(--dark-teal);
}

.double-tile-light .tile-label {
  color: var(--secondary);
}

.double-tile-light .pull-quote {
  color: var(--secondary);
  border-left-color: var(--secondary);
}

/* Dark version (below tide — abyssal palette) */
.double-tile-dark {
  background: rgba(10, 22, 40, 0.7);
  box-shadow: 0 8px 40px rgba(5, 15, 35, 0.6);
  border: none;
}

.double-tile-dark.tile-revealed {
  background: rgba(10, 22, 40, 0.7);
  box-shadow: 0 8px 40px rgba(5, 15, 35, 0.6);
  border: none;
}

.double-tile-dark h2 {
  color: var(--text-light);
}

.double-tile-dark p {
  color: var(--pale-tide);
}

.double-tile-dark .tile-label {
  color: var(--accent);
}

.double-tile-dark .pull-quote {
  color: var(--text-muted);
  border-left-color: var(--accent);
}

/* --- Typography --- */
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5.5vw + 0.5rem, 5rem);
  letter-spacing: 0.02em;
  color: var(--text-light);
  line-height: 1.15;
  margin-bottom: 0.5em;
}

h3 {
  font-family: var(--font-subheading);
  font-weight: 500;
  font-size: clamp(1.1rem, 2vw + 0.3rem, 1.6rem);
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 0.5em;
}

p {
  margin-bottom: 1em;
}

p:last-child {
  margin-bottom: 0;
}

.tile-label {
  display: block;
  font-family: var(--font-accent);
  font-weight: 500;
  font-size: clamp(0.7rem, 0.9vw, 0.85rem);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 12px;
}

.pull-quote {
  font-family: var(--font-subheading);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(1.1rem, 2vw + 0.3rem, 1.6rem);
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: 16px;
  margin-top: 1.2em;
  line-height: 1.45;
}

/* --- Links --- */
a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--highlight);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
  color: var(--accent);
  border-bottom-width: 2px;
}

/* --- Intro Descent Animation (body-level) --- */
body.loading {
  --tide-position: 100%;
}

body.descended {
  --tide-position: 55%;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .masonry-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tile[data-col="3"] {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 300px;
  }

  .double-pair {
    grid-template-columns: 1fr;
  }

  #buoy-nav {
    right: 12px;
    gap: 14px;
  }

  .buoy-tooltip {
    display: none;
  }
}

@media (max-width: 600px) {
  .masonry-grid {
    grid-template-columns: 1fr;
  }

  .tile[data-col="3"] {
    max-width: 250px;
  }

  .content-section {
    padding: 40px 16px;
  }

  #buoy-nav {
    right: 8px;
    gap: 12px;
  }

  h2 {
    font-size: clamp(1.8rem, 4vw + 0.5rem, 3rem);
  }

  .intro-title {
    font-size: clamp(1.8rem, 4vw + 0.5rem, 3.5rem);
  }
}

/* --- Utility: Descent intro loading state --- */
.intro-loading .intro-shape,
.intro-loading .intro-title,
.intro-loading .intro-subtitle {
  animation: none;
  opacity: 0;
}
