/* ==========================================================================
   STARDUST COUNTDOWN SYSTEM — STYLE.CSS
   Neo-Romantic Theme: Amethyst & Amber (No Pink)
   ========================================================================== */

/* 1. Global Reset & Variables */
:root {
  /* OKLCH Color Palette (Amethyst & Amber Sunset) */
  --bg-hue: 270;
  --bg: oklch(0.06 0.015 var(--bg-hue));
  --bg-panel: oklch(0.10 0.02 var(--bg-hue));
  --bg-panel-lift: oklch(0.14 0.025 var(--bg-hue));
  
  --primary: oklch(0.65 0.16 var(--bg-hue));
  --primary-glow: oklch(0.65 0.16 var(--bg-hue) / 0.3);
  
  --accent: oklch(0.82 0.08 75); /* Warm Candlelight Amber */
  --accent-glow: oklch(0.82 0.08 75 / 0.35);
  
  --ink: oklch(0.96 0.008 var(--bg-hue));
  --muted: oklch(0.68 0.015 var(--bg-hue));
  --border: oklch(0.96 0.008 var(--bg-hue) / 0.12);
  --border-focus: oklch(0.82 0.08 75 / 0.5);

  /* Fonts */
  --font-display: 'Italiana', Georgia, serif;
  --font-body: 'Albert Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spacing System */
  --space-xs: clamp(0.5rem, 1vw, 0.75rem);
  --space-sm: clamp(0.75rem, 1.5vw, 1.25rem);
  --space-md: clamp(1.25rem, 2.5vw, 2rem);
  --space-lg: clamp(2rem, 4vw, 3.5rem);
  --space-xl: clamp(3.5rem, 6vw, 6rem);

  /* Elevation (No large card shadows per Neo-Kinpaku rules, borders + subtle tint shifts represent panels) */
  --panel-radius: 8px;
  --shadow-overlay: 0 24px 70px oklch(0% 0 0 / 0.6);
  --shadow-lift: 0 10px 30px oklch(0% 0 0 / 0.4);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Background Canvas */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at center, oklch(0.09 0.02 var(--bg-hue)) 0%, var(--bg) 100%);
}

/* ==========================================================================
   2. Landing Gate: Wax Sealed Love Letter Envelope
   ========================================================================== */
.envelope-gate {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 1.2s;
  perspective: 1000px;
}

.envelope-gate.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.envelope-wrapper {
  position: relative;
  width: min(420px, 90vw);
  height: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-overlay);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
}

.envelope {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-md);
  border-radius: 8px;
  overflow: hidden;
}

/* Diagonal envelope fold lines using CSS pseudo elements */
.envelope::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 210px solid transparent;
  border-right: 210px solid transparent;
  border-bottom: 140px solid oklch(0.11 0.02 var(--bg-hue) / 0.6);
  z-index: 3;
  pointer-events: none;
}

/* Adjust diagonal borders for small screens dynamically */
@media (max-width: 450px) {
  .envelope::before {
    border-left-width: 45vw;
    border-right-width: 45vw;
  }
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: oklch(0.13 0.025 var(--bg-hue));
  border-bottom: 1px solid var(--border);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  z-index: 4;
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope-wrapper.open .envelope-flap {
  transform: rotateX(180deg);
}

.envelope-paper {
  text-align: center;
  z-index: 2;
  transform: translateY(75px);
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope-heading {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  color: var(--accent);
  margin-bottom: var(--space-xs);
  font-weight: 300;
}

.envelope-subtext {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 300;
}

/* Gold Wax Seal Button */
.wax-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%) scale(1);
  width: 64px;
  height: 64px;
  background: radial-gradient(circle, oklch(0.85 0.10 75) 0%, oklch(0.70 0.11 75) 100%);
  border: 1px solid oklch(0.90 0.08 75 / 0.5);
  border-radius: 50%;
  box-shadow: 0 4px 12px oklch(0% 0 0 / 0.4), inset 0 2px 4px oklch(100% 0 0 / 0.3);
  cursor: pointer;
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  outline: none;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s, opacity 0.4s;
}

.wax-seal:hover {
  transform: translate(-50%, -30%) scale(1.08);
  box-shadow: 0 6px 18px oklch(0.82 0.08 75 / 0.4), inset 0 2px 4px oklch(100% 0 0 / 0.3);
}

.wax-seal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Wax Seal Shake & Crack Animation */
.wax-seal.cracked {
  animation: crack-shake 0.6s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes crack-shake {
  10%, 90% { transform: translate(-50%, -30%) rotate(-4deg); }
  20%, 80% { transform: translate(-50%, -30%) rotate(5deg); }
  30%, 50%, 70% { transform: translate(-50%, -30%) rotate(-8deg); }
  40%, 60% { transform: translate(-50%, -30%) rotate(8deg); }
}

.seal-inner {
  font-size: 1.8rem;
  color: oklch(0.20 0.02 var(--bg-hue));
  user-select: none;
  transition: transform 0.6s ease;
}

.envelope-wrapper.open .wax-seal {
  transform: translate(-50%, -30%) scale(0) rotate(180deg);
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   3. Main Layout Structure
   ========================================================================== */
.site-root {
  position: relative;
  width: 100%;
  min-height: 100vh;
  z-index: 2;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.site-root.visible {
  opacity: 1;
}

.site-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-coord {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-line {
  width: 32px;
  height: 1px;
  background-color: var(--border);
}

.header-controls {
  display: flex;
  gap: var(--space-xs);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-icon:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: oklch(0.96 0.008 var(--bg-hue) / 0.04);
}

.btn-icon:focus-visible {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

/* Site Main */
.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-md) var(--space-xl) var(--space-md);
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   4. Telemetry Connection Bridge
   ========================================================================== */
.telemetry-bridge {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border);
  padding: var(--space-md);
  border-radius: var(--panel-radius);
  background-color: oklch(0.10 0.02 var(--bg-hue) / 0.3);
  backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
  .telemetry-bridge {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
    text-align: center;
  }
}

.telemetry-node {
  display: flex;
  flex-direction: column;
}

.node-label {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 300;
  margin-bottom: 2px;
}

.node-coords {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: var(--space-xs);
}

.node-time-box {
  display: flex;
  flex-direction: column;
}

.node-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--ink);
}

.node-horizon {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}

/* Telemetry center connection line */
.telemetry-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .telemetry-center {
    padding: var(--space-xs) 0;
  }
}

.distance-line {
  position: relative;
  width: 160px;
  height: 1px;
  background-color: var(--border);
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .distance-line {
    width: 80px;
  }
}

.distance-value {
  position: absolute;
  top: -12px;
  background-color: var(--bg);
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  cursor: default;
  user-select: none;
}

.distance-pulse {
  position: absolute;
  top: -2px;
  left: 0;
  width: 4px;
  height: 4px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: pulse-travel 4s linear infinite;
  box-shadow: 0 0 8px var(--accent);
}

@keyframes pulse-travel {
  0% { left: 0%; opacity: 0; }
  5% { opacity: 1; }
  95% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

.telemetry-msg {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* ==========================================================================
   5. Countdown Display
   ========================================================================== */
.countdown-display {
  text-align: center;
  margin: var(--space-md) 0 var(--space-lg) 0;
  width: 100%;
}

.countdown-heading {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 4.2rem);
  font-weight: 100;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: var(--space-md);
  text-wrap: balance;
}

.countdown-grid {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 3.5vw, 2.5rem);
  margin-bottom: var(--space-md);
}

.countdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 75px;
}

.countdown-num {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 8vw, 6.5rem);
  font-weight: 300;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 25px oklch(0.82 0.08 75 / 0.1);
}

/* Heartbeat widget */
.heartbeat-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: var(--space-sm);
  padding: 6px 16px;
  border-radius: 20px;
  background-color: oklch(0.96 0.008 var(--bg-hue) / 0.03);
  display: inline-flex;
  border: 1px solid oklch(0.96 0.008 var(--bg-hue) / 0.06);
}

.heart-pulse-box {
  position: relative;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: heart-lub-dub 1.2s infinite cubic-bezier(0.25, 0.8, 0.25, 1);
}

.heart-pulse-box::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: heart-ripple-ring 1.2s infinite cubic-bezier(0.215, 0.610, 0.355, 1);
  pointer-events: none;
}

@keyframes heart-ripple-ring {
  0% { transform: scale(0.6); opacity: 0; }
  10% { opacity: 0.5; }
  50% { opacity: 0; transform: scale(2.8); }
  100% { opacity: 0; transform: scale(2.8); }
}

/* Lub-dub double heartbeat pulse */
@keyframes heart-lub-dub {
  0% { transform: scale(1); }
  14% { transform: scale(1.24); }
  28% { transform: scale(1.08); }
  42% { transform: scale(1.32); }
  70% { transform: scale(1); }
}

.heartbeat-stats {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.heartbeat-stats span {
  color: var(--ink);
  font-weight: 500;
}

/* ==========================================================================
   6. Interactives Grid (Locket & Breathing)
   ========================================================================== */
.interactives-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  width: 100%;
  margin-bottom: var(--space-lg);
}

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

.interactive-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s;
}

.interactive-card:hover {
  transform: translateY(-2px);
  border-color: oklch(0.96 0.008 var(--bg-hue) / 0.2);
}

.card-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.5s;
}

.interactive-card:hover .card-glow {
  opacity: 0.9;
}

.locket-icon {
  color: var(--accent);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2;
}

.locket-icon:hover {
  transform: scale(1.1) rotate(15deg);
}

.locket-icon.unlocked {
  transform: scale(1.1) rotate(360deg);
  color: var(--accent);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 300;
  margin-bottom: 6px;
  color: var(--ink);
  z-index: 2;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 260px;
  z-index: 2;
  margin-bottom: var(--space-xs);
}

.locket-message {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent);
  margin-top: var(--space-xs);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  width: 100%;
  z-index: 2;
  opacity: 0;
  transform: translateY(10px);
  animation: reveal-text 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Shared Breath Widget */
.breathing-circle-wrapper {
  width: 80px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--space-sm);
  z-index: 2;
}

.breathing-circle {
  width: 32px;
  height: 32px;
  background-color: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent-glow);
  transition: all 4s ease-in-out;
}

/* Classes handled via JS interval */
.breathing-circle.inhale {
  width: 72px;
  height: 72px;
  background-color: var(--accent-glow);
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent);
}

.breathing-state {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 4px;
  z-index: 2;
}

/* ==========================================================================
   7. Lockbox Trigger & Polaroid Scattered Canvas
   ========================================================================== */
.lockbox-trigger-section {
  margin: var(--space-sm) 0 var(--space-md) 0;
}

.btn-lockbox {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 16px 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px oklch(0% 0 0 / 0.2);
}

.btn-lockbox:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px oklch(0.82 0.08 75 / 0.15);
}

.lockbox-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, oklch(0.82 0.08 75 / 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.btn-lockbox:hover .lockbox-glow {
  transform: translateX(100%);
}

.btn-lockbox:focus-visible {
  outline: 1px solid var(--accent);
}

/* Polaroid Overlay Container */
.polaroid-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: oklch(0.04 0.01 270 / 0.92);
  backdrop-filter: blur(15px);
  z-index: 90;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s;
}

.polaroid-canvas.visible {
  opacity: 1;
  visibility: visible;
}

.polaroid-instructions {
  position: absolute;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
  z-index: 10;
  text-align: center;
  width: 90vw;
}

.polaroid-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

/* The Polaroid Frame CSS with fly-out elastic transitions */
.polaroid-card {
  position: absolute;
  background: oklch(0.99 0.002 90); /* Authentic polaroid off-white paper */
  padding: 12px 12px 36px 12px;
  width: 220px;
  height: 270px;
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.35);
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  border-radius: 2px;
  
  /* Initial state: minimized at lockbox button coordinates */
  left: 50%;
  top: 85%;
  transform: translate(-50%, -50%) rotate(0deg) scale(0.05);
  opacity: 0;

  /* Elastic transitions for smooth stagger reveals */
  transition: left 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              top 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              transform 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              opacity 0.6s ease-out,
              box-shadow 0.3s;
  z-index: 5;
}

/* Active Drag State overrides transitions for responsive physical dragging */
.polaroid-card.dragging {
  cursor: grabbing;
  box-shadow: 0 20px 48px oklch(0% 0 0 / 0.5);
  transform: scale(1.04) rotate(var(--drag-rotation, 0deg));
  transition: transform 0.05s, box-shadow 0.2s; /* Snappier response during drag */
}

.polaroid-img-wrapper {
  width: 100%;
  height: 196px;
  background-color: oklch(0.08 0.005 270);
  overflow: hidden;
  position: relative;
  pointer-events: none;
}

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

.polaroid-caption {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: oklch(0.12 0.01 70); /* Dark pen ink look */
  text-align: center;
  margin-top: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* Close overlay button */
.btn-close-overlay {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 12;
}

.btn-close-overlay:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ==========================================================================
   8. Footer: Love Letters (Three Envelopes)
   ========================================================================== */
.site-footer {
  width: 100%;
  padding: var(--space-lg) var(--space-md) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.footer-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: var(--space-md);
}

.letters-row {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.letter-envelope {
  position: relative;
  width: 130px;
  height: 90px;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s;
  box-shadow: var(--shadow-lift);
}

.letter-envelope:hover {
  transform: translateY(-4px) rotate(-2deg);
  border-color: var(--accent);
}

.letter-envelope.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.letter-envelope.locked:hover {
  transform: translateY(-2px) rotate(0deg);
  border-color: var(--border);
}

/* Flap shape behind */
.envelope-back {
  position: absolute;
  inset: 0;
  background-color: oklch(0.96 0.008 var(--bg-hue) / 0.02);
  clip-path: polygon(0 0, 100% 0, 50% 50%);
  pointer-events: none;
}

.envelope-paper-small {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--muted);
  transition: color 0.4s;
}

.letter-envelope:hover .envelope-paper-small {
  color: var(--accent);
}

/* ==========================================================================
   9. Modal Dialogs (Drawer & Letter Overlays)
   ========================================================================== */
dialog {
  border: none;
  background: transparent;
  color: var(--ink);
  max-width: 100vw;
  max-height: 100vh;
}

dialog::backdrop {
  background-color: oklch(0% 0 0 / 0.7);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.5s ease;
}

dialog[open]::backdrop {
  opacity: 1;
}

/* Modal Drawer (Settings) */
.modal-drawer {
  position: fixed;
  top: 0;
  right: 0;
  left: auto;
  bottom: 0;
  height: 100%;
  width: min(440px, 90vw);
  background-color: var(--bg-panel-lift);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-overlay);
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.modal-drawer[open] {
  transform: translateX(0);
}

.drawer-content {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--accent);
  font-weight: 300;
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-xs);
}

.form-group {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"],
input[type="datetime-local"] {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="datetime-local"]:focus {
  border-color: var(--border-focus);
}

/* Theme color switcher list */
.theme-picker {
  display: flex;
  gap: var(--space-xs);
  margin-top: 4px;
}

.theme-btn {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-btn::before {
  content: '';
  width: 8px;
  height: 8px;
  background-color: var(--theme-preview-color);
  border-radius: 50%;
}

.theme-btn.active {
  border-color: var(--accent);
  color: var(--ink);
  background-color: oklch(0.96 0.008 var(--bg-hue) / 0.04);
}

.drawer-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: auto;
  padding-top: var(--space-md);
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: oklch(0.12 0.02 var(--bg-hue));
  border: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 14px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.3s;
  text-align: center;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 14px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-secondary:hover {
  color: var(--ink);
  border-color: var(--accent);
}

/* Love Letter Overlay Modal */
.letter-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
  width: min(520px, 92vw);
  max-height: 85vh;
  background: oklch(0.99 0.002 90); /* Vintage parchment white */
  color: oklch(0.12 0.01 var(--bg-hue)); /* Dark letter ink */
  border-radius: 4px;
  box-shadow: var(--shadow-overlay);
  padding: var(--space-md);
  overflow-y: auto;
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s;
}

.letter-modal[open] {
  transform: translate(-50%, -50%);
  opacity: 1;
}

.letter-modal-content {
  display: flex;
  flex-direction: column;
}

.letter-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: oklch(0.40 0.01 var(--bg-hue));
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.letter-salutation {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 300;
  margin-bottom: var(--space-sm);
  color: oklch(0.15 0.02 var(--bg-hue));
}

.letter-body-text {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: var(--space-sm);
  color: oklch(0.20 0.015 var(--bg-hue));
  font-style: italic;
  font-weight: 300;
}

.letter-signature {
  font-family: var(--font-display);
  font-size: 1.4rem;
  text-align: right;
  margin-top: var(--space-xs);
  margin-bottom: var(--space-md);
  color: oklch(0.15 0.02 var(--bg-hue));
}

.btn-close-letter {
  align-self: center;
  padding: 10px 24px;
  background-color: oklch(0.20 0.02 var(--bg-hue));
  color: oklch(0.99 0.002 90);
}

/* Fullscreen Polaroid Lightbox */
.lightbox-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  padding: 0;
  overflow: visible;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-img-frame {
  background: oklch(0.99 0.002 90);
  padding: 16px 16px 48px 16px;
  box-shadow: var(--shadow-overlay);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 80vh;
}

.lightbox-img-frame img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.lightbox-caption {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: oklch(0.12 0.01 var(--bg-hue));
  margin-top: 18px;
}

.btn-close-lightbox {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 1.8rem;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.btn-close-lightbox:hover {
  opacity: 1;
}

/* ==========================================================================
   10. Custom Floating Sparkles & Animations
   ========================================================================== */
.sparkle {
  position: fixed;
  width: 4px;
  height: 4px;
  background-color: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 0 6px var(--accent);
  animation: sparkle-fade 0.8s ease-out forwards;
}

@keyframes sparkle-fade {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ==========================================================================
   11. Utility & Utility Classes
   ========================================================================== */
.hidden {
  display: none !important;
}

/* Prefers Reduced Motion overrides */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
  .breathing-circle {
    transition: none !important;
  }
}
