/*
  Unglare site styles
  - Minimal static CSS
  - SVG-driven hero with 3 states: off -> glare -> unglare
  - No images, only vectors/gradients
*/

:root {
  --bg-0: #070a0f;
  --bg-1: #0b0f15;
  --text: #f5f1e8;
  --muted: var(--text);
  --brand: #ffd58a; /* warm accent for Unglare */

  --t-fast: 150ms;
  --t-med: 250ms;
  --t-slow: 400ms;

  --radius: 999px;

  /* Eye lid variables (used inside SVG via CSS vars) */
  --lid-y: 0px;      /* open by default */
  --lid-blink: 0px;  /* transient add-on for micro-blink */
}

/* Animation keyframes */
@keyframes noise-surge {
  0%, 100% { opacity: 1; }
  5% { opacity: 0.8; }
  10% { opacity: 1; }
  25% { opacity: 0.7; }
  30% { opacity: 1; }
  40% { opacity: 0.9; }
  55% { opacity: 1; }
  70% { opacity: 0.6; }
  80% { opacity: 1; }
}

@keyframes horizontal-jiggle-1 {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-5px) rotate(2deg); }
  50% { transform: translateX(5px) rotate(-2deg); }
  75% { transform: translateX(-2px) rotate(1deg); }
}

@keyframes horizontal-jiggle-2 {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(5px) rotate(-2deg); }
  50% { transform: translateX(-5px) rotate(2deg); }
  75% { transform: translateX(2px) rotate(-1deg); }
}

@keyframes lunge {
  100% { transform: translate(-425px, -30px) scale(10); }
}

@keyframes scream-buildup {
  0% { filter: url(#horror-noise); }
  100% { filter: url(#scream-filter); }
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Remove tap highlight on mobile for interactive elements */
a,
button,
[role="button"],
[role="radio"],
#plant,
#girl {
  -webkit-tap-highlight-color: transparent;
}

/* Basic reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main { display: flex; flex-direction: column; min-height: 100vh; }

.site-header, .site-footer { padding: 1.5rem clamp(1rem, 3vw, 2rem); opacity: 0.9; }
.site-header {
  display: flex; 
  align-items: center; 
  gap: 1rem; 
  justify-content: space-between;
  background: rgba(7, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.brand { 
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500; 
  letter-spacing: 0.3px;
  font-size: 1.2rem;
  background: linear-gradient(135deg, 
    #ffffff 0%, 
    #fff8e8 20%, 
    #fff2d6 40%, 
    #ffe8bd 60%, 
    #ffddaa 80%, 
    #ffd298 100%
  );
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  animation: gradient-shift 3s ease infinite;
  background-size: 200% 200%;
  filter: drop-shadow(0 -6px 8px rgba(255, 245, 215, 0.4)) 
          drop-shadow(0 -10px 16px rgba(255, 240, 210, 0.25));
}
.logo {
  width: 29px;
  height: 29px;
  filter: drop-shadow(0 0 8px rgba(255, 245, 215, 0.5));
  color: #fff2d6;
}
.tagline { color: var(--text); font-size: 0.95rem; font-weight: 400; }

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.social-link {
  color: var(--muted);
  transition: color var(--t-fast) ease;
}

.social-link:hover,
.social-link:focus-visible {
  color: var(--text);
  outline: none;
}

.social-icon {
  width: 24px;
  height: 24px;
  display: block;
}

/* Accessibility helper */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Hero */
.hero {
  position: relative;
  background: linear-gradient(180deg, var(--bg-0), var(--bg-1));
  overflow: hidden;
  /* Let the content and controls define the height */
}
/* Smaller, centered scene box */
.scene-wrap {
  position: relative;
  width: 95%;  /* Slightly smaller to compensate for removing scale */
  max-width: 1080px;  /* 1200px * 0.9 */
  aspect-ratio: 1000 / 600;
  margin: 0 auto;
  /* No transform needed */
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  overflow: hidden;
}
.scene {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}

/* Animate lighting layer opacities */
#lighting-off,
#lighting-glare,
#lighting-unglare,
#glare-leak,
#fixture-unglare,
#ceiling-bounce,
#plant, #maskScope { transition: opacity var(--t-med) ease, filter var(--t-med) ease; }

#maskScope { filter: none; }
/* Table front overlay transition */
#table-front { transition: opacity var(--t-med) ease; }

/* Eye top lid transition (element inside SVG <defs>) */
#topLid { transition: transform var(--t-fast) ease; }

/* State styles */
.hero.state-off {
  /* Move the top lid far above the viewport so the mask is fully open */
  --lid-y: -320px; --lid-blink: 0px;
}
.hero.state-glare {
  /* Partially closed eye */
  --lid-y: 210px; /* amount of downward lid motion */
}
.hero.state-unglare {
  /* Fully open eye */
  --lid-y: -320px; --lid-blink: 0px;
}

/* Map states to layer opacity */
.hero.state-off #lighting-off { opacity: 1; }
.hero.state-off #lighting-glare { opacity: 0; }
.hero.state-off #lighting-unglare { opacity: 0; }
.hero.state-off #glare-leak { opacity: 0; }

.hero.state-glare #lighting-off { opacity: 0.1; }
.hero.state-glare #lighting-glare { opacity: 1; }
.hero.state-glare #maskScope { animation: noise-surge 0.8s linear infinite; filter: url(#horror-noise); }

#tentacle-1, #tentacle-2, #tentacle-3 { transform-origin: 900px center; }
#tentacle-4, #tentacle-5, #tentacle-6 { transform-origin: 950px center; }

.hero.state-glare #tentacle-1 { animation: horizontal-jiggle-1 0.4s ease-in-out infinite; }
.hero.state-glare #tentacle-2 { animation: horizontal-jiggle-2 0.5s ease-in-out infinite; }
.hero.state-glare #tentacle-3 { animation: horizontal-jiggle-1 0.45s ease-in-out infinite reverse; }
.hero.state-glare #tentacle-4 { animation: horizontal-jiggle-2 0.4s ease-in-out infinite; }
.hero.state-glare #tentacle-5 { animation: horizontal-jiggle-1 0.5s ease-in-out infinite; }
.hero.state-glare #tentacle-6 { animation: horizontal-jiggle-2 0.45s ease-in-out infinite reverse; }
.hero.state-glare #lighting-unglare { opacity: 0; }
.hero.state-glare #glare-leak { opacity: 1; }

.hero.state-unglare #lighting-off { opacity: 0; }
.hero.state-unglare #lighting-glare { opacity: 0; }
.hero.state-unglare #lighting-unglare { opacity: 1; }
.hero.state-unglare #glare-leak { opacity: 0; }
/* Reveal table overlay only in Unglare */
.hero.state-off #table-front,
.hero.state-glare #table-front { opacity: 0; }

/* Glitch effect on click */
.hero.glitched {
  background: #000;
}
.hero.glitched > * {
  visibility: hidden;
}

/* Jumpscare styles */
.hero.static-scream #maskScope {
  animation: scream-buildup 4s ease-in forwards !important;
}

@keyframes noise-intensity {
  0% { opacity: 0.05; }
  50% { opacity: 0.25; }
  100% { opacity: 0.18; }
}

.noise-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
}

.hero.static-scream .noise-overlay {
  animation: noise-intensity 4s ease-in forwards;
}

#slenderman.lunge {
  animation: lunge 4s ease-in forwards;
}

#slenderman.lunge [id^="tentacle-"] {
  animation-duration: 0.1s !important; /* Faster jiggle */
}
.hero.state-unglare #table-front { opacity: 1; }

/* New elements visibility by state */
.hero.state-off #fixture-unglare,
.hero.state-glare #fixture-unglare { opacity: 0; }
.hero.state-unglare #fixture-unglare { opacity: 1; }

.hero.state-off #ceiling-bounce,
.hero.state-glare #ceiling-bounce { opacity: 0; }
.hero.state-unglare #ceiling-bounce { opacity: 1; }

/* Plant styling and state-dependent appearance */
#plant { transition: opacity var(--t-med) ease, filter var(--t-med) ease; }
#plant .stem { fill: #5aa447; }
#plant .pot-rim { fill: #4a3a30; }

#plant {
  cursor: pointer;
}

.plant-disabled #plant {
  cursor: default;
}

.hero.state-off #plant { opacity: 0.08; filter: saturate(0) brightness(0.55); }
.hero.state-glare #plant { opacity: 0.35; filter: saturate(0.25) brightness(0.8); }
.hero.state-unglare #plant { opacity: 1; filter: none; }

/* CTA */
.cta {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
  z-index: 2; /* above svg */
}
.cta[hidden] { display: none; }
.cta-link {
  display: inline-block; padding: 0.75rem 1rem; border-radius: 999px;
  background: rgba(255, 228, 163, 0.15);
  border: 1px solid rgba(255, 228, 163, 0.3);
  color: var(--text); text-decoration: none; backdrop-filter: blur(6px);
}
.cta-link:hover, .cta-link:focus-visible {
  outline: none; box-shadow: 0 0 0 2px rgba(255, 213, 138, 0.5);
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 clamp(1rem, 4vw, 2rem);
  margin-top: 2rem; /* Spacing below the scene */
  margin-bottom: 2rem;
}

/* Segmented 3-state control */
.segmented {
  pointer-events: auto;
  display: inline-flex; align-items: stretch;
  background: rgba(20, 26, 33, 0.7);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.segmented [role="radio"] {
  appearance: none;
  background-color: transparent; border: 0; color: var(--text);
  padding: 0.5rem 0.9rem; min-width: clamp(96px, 18vw, 160px); min-height: 44px;
  font: inherit; cursor: pointer; pointer-events: auto; position: relative;
}
.segmented [role="radio"]:not(:first-child) { border-left: 1px solid rgba(255,255,255,0.06); }
.segmented [role="radio"]:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.segmented [role="radio"]:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.segmented [role="radio"][aria-checked="true"] { background: rgba(255, 213, 138, 0.15); }
.segmented [role="radio"]:disabled { color: #555; cursor: not-allowed; background: transparent; }
.segmented [role="radio"]:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35); }
.switch {
  pointer-events: auto;
  position: relative; display: inline-flex; align-items: center; gap: 0.5rem;
  min-width: clamp(104px, 24vw, 132px); min-height: 46px; padding: 0.3rem 0.7rem 0.3rem 0.7rem;
  font: inherit; color: var(--text); background: rgba(20, 26, 33, 0.7);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.switch:hover { background: rgba(28, 34, 42, 0.85); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }

.switch[hidden] { display: none; }
.switch[aria-pressed="true"] { border-color: rgba(255, 213, 138, 0.45); background: rgba(255, 213, 138, 0.15); }
.switch-label { font-size: clamp(0.9rem, 1.2vw, 1rem); letter-spacing: 0.2px; }
.switch-knob {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 30% 30%, #fff, #ccd3dd 60%, #aab5c4 100%);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25), 0 1px 1px rgba(0,0,0,0.2);
  transform: translateX(0);
  transition: transform var(--t-fast) ease;
}
/* When a switch is on, move its knob to the right for both */
.switch[aria-pressed="true"] .switch-knob { transform: translateX(28px); }

/* Content section */
.content { flex-grow: 1; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem); }
.copy { max-width: 60ch; margin: 0 auto; text-align: center; }
.copy h2 { margin: 0 0 0.5rem; font-size: clamp(1.4rem, 4vw, 2rem); }
.copy p { margin: 0 auto; color: var(--muted); }

/* Girl animation */
#girl {
  transform-origin: center center;
  transition: opacity 0.5s ease;
}

#girl.enter {
  animation: girl-enter 4s ease-out forwards;
  cursor: pointer;
}

/* Speech Bubble animation */
#speech-bubble {
  transition: opacity 0.4s ease-in-out;
  pointer-events: none; /* Don't block clicks when hidden */
}

#speech-bubble.show {
  opacity: 1;
  animation: hover-bubble 3s ease-in-out infinite;
}

@keyframes hover-bubble {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes girl-enter {
  0% {
    opacity: 0;
    transform: translateX(0) scale(1.1);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateX(-420px) translateY(-15px) scale(0.9);
  }
}

/* Mobile: remove dead space between scene and controls */
@media (max-width: 640px), (max-height: 700px) {
  main { 
    min-height: auto; 
  }
  .scene-wrap {
    margin: 0.5rem auto; /* Add some vertical margin on mobile */
  }
  .controls {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
  }
  /* Make segmented control fit narrow widths gracefully */
  .segmented { max-width: 100%; }
  /* Reduce content section padding on mobile */
  .content { 
    padding: 1.5rem 1rem; 
  }
}

/* Reduced motion: limit transitions and remove micro-blink impact visually */
@media (prefers-reduced-motion: reduce) {
  #lighting-off,
  #lighting-glare,
  #lighting-unglare,
  #glare-leak,
  #fixture-unglare,
  #ceiling-bounce,
  #plant,
  #topLid,
  .switch-knob,
  .cta-link { transition: none !important; }
}

/* Plant Emoticon Styles */
.emoticon {
  font-size: 48px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  /* Default hidden */
  visibility: hidden;
}

#plant-sad {
  fill: #ff6b6b;
}

#plant-happy {
  fill: #51f589;
  filter: drop-shadow(0 0 4px #51f589) drop-shadow(0 0 8px #51f589);
}

.emoticon.show-sad {
  visibility: visible;
  animation: popup-sad 1.2s ease-out forwards;
}

.emoticon.show-happy {
  visibility: visible;
  animation: popup-happy 1.5s ease-out forwards;
}

@keyframes popup-sad {
  0% {
    opacity: 0;
    transform: translate(0, 5px) scale(0.5);
  }
  30% {
    opacity: 1;
    transform: translate(5px, -15px) scale(1.1);
  }
  80% {
    opacity: 1;
    transform: translate(10px, -20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(12px, -22px) scale(0.9);
  }
}

@keyframes soft-flash {
  50% {
    background-color: rgba(255, 213, 138, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 213, 138, 0.4);
  }
}

.flash-prompt {
  animation: soft-flash 1.5s ease-in-out infinite;
}

@keyframes popup-happy {
  0% {
    opacity: 0;
    transform: translate(0, 5px) scale(0.5);
  }
  30% {
    opacity: 1;
    transform: translate(5px, -15px) scale(1.1);
  }
  80% {
    opacity: 1;
    transform: translate(10px, -20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(12px, -22px) scale(0.9);
  }
}

.cookie-message {
  position: fixed;
  bottom: 8px;
  left: 12px;
  font-size: 0.7rem;
  font-style: italic;
  color: #4a4a4a;
  opacity: 0.6;
  z-index: 1000;
  pointer-events: none;
}
