/* ==========================================================================
   Design System & Styling — didyoubreathe?
   Living Alpine Dawn Breathing Sanctuary with Animated Water & Tree Wind
   ========================================================================== */

:root {
  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Color System */
  --bg-deep: #05070a;
  --accent-gold: #f6c878;
  --accent-gold-glow: rgba(246, 200, 120, 0.4);
  --accent-cyan: #7be5d8;
  --accent-cyan-glow: rgba(123, 229, 216, 0.35);

  /* Alpine Dawn Water-Glass System */
  --glass-surface: rgba(14, 20, 32, 0.28);
  --glass-surface-hover: rgba(22, 32, 48, 0.45);
  --glass-surface-active: rgba(30, 42, 62, 0.6);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.24);
  --glass-blur: blur(20px);
  --glass-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.32), inset 0 1px 1px rgba(255, 255, 255, 0.18);

  /* Text Hierarchy */
  --text-pure: #ffffff;
  --text-primary: #f0f4fc;
  --text-secondary: #c2cbd9;
  --text-tertiary: #8794a8;

  /* Dynamic Breath Properties (Driven by JS) */
  --breath-scale: 0;

  /* Motion Curves */
  --ease-organic: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-breath: cubic-bezier(0.45, 0, 0.55, 1);
}

/* Reset & Viewport Constraints */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

/* Landscape Viewport Container */
.landscape-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 0;
}

/* Base Photorealistic Photographic Landscape */
.landscape-image {
  position: absolute;
  inset: -3.5%;
  width: 107%;
  height: 107%;
  /* Fallback for legacy browsers */
  background-image: url('/sanctuary_dawn_lake.jpg');
  /* WebKit prefix for older Safari */
  background-image: -webkit-image-set(
    url('/sanctuary_dawn_lake.avif') type('image/avif'),
    url('/sanctuary_dawn_lake.webp') type('image/webp'),
    url('/sanctuary_dawn_lake.jpg') type('image/jpeg')
  );
  /* Standard modern image-set */
  background-image: image-set(
    url('/sanctuary_dawn_lake.avif') type('image/avif'),
    url('/sanctuary_dawn_lake.webp') type('image/webp'),
    url('/sanctuary_dawn_lake.jpg') type('image/jpeg')
  );
  background-position: center 36%;
  background-size: cover;
  background-repeat: no-repeat;
  will-change: transform, filter;
  transform: scale(calc(1 + 0.028 * var(--breath-scale, 0)));
  filter: brightness(calc(0.88 + 0.22 * var(--breath-scale, 0))) contrast(1.04) saturate(calc(0.95 + 0.22 * var(--breath-scale, 0)));
}

/* Volumetric Sunrise God Rays & Atmospheric Bloom (100% GPU Composited) */
.sunlight-bloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: 
    radial-gradient(circle at 71% 25%, rgba(255, 235, 175, 0.46) 0%, rgba(255, 195, 105, 0.24) 32%, transparent 65%),
    radial-gradient(circle at 50% 65%, rgba(123, 229, 216, 0.10) 0%, transparent 55%);
  mix-blend-mode: screen;
  will-change: opacity;
  opacity: calc(0.38 + 0.62 * var(--breath-scale, 0));
}

/* Cinematic Vignette for Depth & Readability */
.cinematic-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 48%, transparent 42%, rgba(5, 7, 10, 0.42) 80%, rgba(5, 7, 10, 0.72) 100%);
}

/* Canvas Overlay for Particle Mist, Light Shimmer & Focus Halo */
#breath-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  display: block;
}

/* UI Structure */
.app-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 28px) env(safe-area-inset-right, 28px) env(safe-area-inset-bottom, 28px) env(safe-area-inset-left, 28px);
  pointer-events: none;
}

.interactive {
  pointer-events: auto;
}

/* Zen Fade Transition */
.zen-dimmable {
  transition: opacity 1.2s var(--ease-organic), transform 1.2s var(--ease-organic);
}

body.zen-active .zen-dimmable {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  opacity: 0.72;
  transition: opacity 0.5s var(--ease-organic);
}

.app-header:hover,
.app-header:focus-within {
  opacity: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  outline: none;
  border-radius: 8px;
  padding: 2px 4px;
  transition: opacity 0.25s ease;
}

.brand:focus-visible {
  outline: 1.5px solid var(--accent-gold);
  outline-offset: 2px;
}

.brand-gem {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 calc(10px + 10px * var(--breath-scale, 0)) var(--accent-gold-glow);
  transform: scale(calc(1 + 0.25 * var(--breath-scale, 0)));
  transition: transform 0.15s linear, box-shadow 0.15s linear;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 380;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  text-transform: lowercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Minimalist Language Switcher */
.lang-nav {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  margin-right: 2px;
}

.lang-link {
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  padding: 3px 5px;
  border-radius: 4px;
  transition: all 0.25s var(--ease-organic);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  outline: none;
}

.lang-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.lang-link.active {
  color: var(--accent-gold);
  font-weight: 600;
  text-shadow: 0 0 10px var(--accent-gold-glow), 0 1px 3px rgba(0, 0, 0, 0.7);
}

.lang-link:focus-visible {
  outline: 1.5px solid var(--accent-gold);
  outline-offset: 2px;
}

.lang-sep {
  color: rgba(255, 255, 255, 0.18);
  font-size: 0.65rem;
  user-select: none;
}

/* Header Action Buttons — Pure Borderless Ghost Icons */
.glass-btn {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  padding: 0;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease-organic);
  box-shadow: none;
  outline: none;
  position: relative;
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: scale(1.08);
}

.glass-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.14);
}

.glass-btn:focus-visible {
  outline: 1.5px solid var(--accent-gold);
  outline-offset: 2px;
}

/* Hide text label so only pure, elegant ghost icons display in the sky */
.glass-btn .btn-label {
  display: none;
}

/* Sound Active State: Crystalline glow, no background block */
.glass-btn.active {
  background: transparent;
  border: none;
  color: var(--accent-gold);
}

.glass-btn.active:hover {
  background: rgba(255, 255, 255, 0.08);
}

.glass-btn.active .sound-bar {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.icon-svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  transition: stroke 0.3s ease, filter 0.3s ease;
}

.glass-btn:hover .icon-svg {
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

/* Sound Wave Equalizer */
.sound-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 16px;
  width: 18px;
}

.sound-bar {
  width: 2.5px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 1.5px;
  height: 3.5px;
  transition: height 0.3s ease, background 0.3s ease;
}

.glass-btn:hover .sound-bar {
  background: rgba(255, 255, 255, 0.9);
}

.glass-btn.active .sound-bar {
  background: var(--accent-gold);
}

.glass-btn.active .sound-bar:nth-child(1) { animation: sound-bounce 1.1s infinite ease-in-out 0.1s; }
.glass-btn.active .sound-bar:nth-child(2) { animation: sound-bounce 1.1s infinite ease-in-out 0.3s; }
.glass-btn.active .sound-bar:nth-child(3) { animation: sound-bounce 1.1s infinite ease-in-out 0.2s; }

@keyframes sound-bounce {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

/* Center Breath Guidance Display */
.center-overlay {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  z-index: 3;
  padding: 24px 36px;
}

.breath-phase-text {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6.2vw, 4.6rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #121926;
  /* Option A: Pure print definition over sunrise mist — delicate light rim, zero dark shadows */
  text-shadow: 
    0 1px 1px rgba(255, 255, 255, 0.65),
    0 0 24px rgba(255, 248, 220, 0.35);
  transition: opacity 0.4s var(--ease-organic), transform 0.4s var(--ease-organic), color 0.8s ease;
  will-change: transform, opacity;
  margin-bottom: 12px;
}

/* Pure, elegant floating subtitle — no chips, no boxes, deep alpine slate */
.breath-sub-text {
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 1.5vw, 1.05rem);
  font-weight: 550;
  color: #243042;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.6);
  opacity: 0.92;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.center-prompt {
  margin-top: 26px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #16202e;
  letter-spacing: 0.04em;
  pointer-events: auto;
  cursor: pointer;
  padding: 8px 20px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 24px -6px rgba(18, 25, 38, 0.12), 0 1px 2px rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
}

.center-prompt:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.95);
  color: #0b111a;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -6px rgba(18, 25, 38, 0.18);
}

/* Bottom Control Dock */
.bottom-dock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 24px;
  opacity: 0.68;
  transition: opacity 0.5s var(--ease-organic);
}

.bottom-dock:hover,
.bottom-dock:focus-within {
  opacity: 1;
}

.dock-left, .dock-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.dock-right {
  justify-content: flex-end;
}

.dock-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Master Play/Pause Button — Celestial Water Droplet */
.master-play-btn {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(180, 140, 75, 0.45);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #faf2e4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 
    0 10px 30px rgba(0, 0, 0, 0.45), 
    0 0 18px rgba(246, 200, 120, 0.18),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
  transition: all 0.35s var(--ease-organic);
  outline: none;
  position: relative;
}

.master-play-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(246, 200, 120, 0.15);
  opacity: 0;
  transform: scale(0.92);
  transition: all 0.35s var(--ease-organic);
}

.master-play-btn:hover {
  transform: scale(1.06);
  border-color: rgba(246, 200, 120, 0.9);
  box-shadow: 
    0 12px 36px rgba(0, 0, 0, 0.55), 
    0 0 28px rgba(246, 200, 120, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
  color: #ffffff;
}

.master-play-btn:hover::before {
  opacity: 1;
  transform: scale(1.08);
}

.master-play-btn:active {
  transform: scale(0.96);
}

.master-play-btn svg {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

/* Metric / Counter — Borderless Editorial Waterline Mark */
.stat-pill {
  font-family: var(--font-body);
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  cursor: default;
}

.stat-pill .highlight {
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7), 0 0 12px rgba(246, 200, 120, 0.25);
}

.stat-pill span:not(.highlight) {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Keyboard Hints — Borderless Whisper Caption */
.key-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.06em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.kbd-badge {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  padding: 2px 5px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.02em;
}

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

/* Interactive Focus States */
.master-play-btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
}

.center-prompt:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .app-container {
    padding-top: max(10px, env(safe-area-inset-top, 10px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
  }

  .app-header {
    padding: 6px 4px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
    padding: 4px 2px;
  }

  .brand-title {
    font-size: 0.84rem;
    letter-spacing: 0.06em;
  }

  .header-actions {
    gap: 4px;
  }

  .lang-nav {
    gap: 2px;
    font-size: 0.7rem;
    margin-right: 0;
  }

  .lang-link {
    padding: 6px 5px;
    min-width: 26px;
    text-align: center;
    border-radius: 4px;
  }

  .lang-sep {
    display: none;
  }

  .center-overlay {
    padding: 16px 18px;
  }

  .breath-phase-text {
    font-size: clamp(2.3rem, 9.5vw, 3.8rem);
    letter-spacing: 0.06em;
    margin-bottom: 8px;
  }

  .breath-sub-text {
    font-size: clamp(0.76rem, 3.2vw, 0.95rem);
    letter-spacing: 0.16em;
  }
  
  .bottom-dock {
    padding: 6px 4px;
    gap: 8px;
  }

  .key-hint {
    display: none;
  }

  .glass-btn {
    width: 38px;
    height: 38px;
  }

  .master-play-btn {
    width: 52px;
    height: 52px;
  }

  .master-play-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Micro-screen support (narrower than 360px) */
@media (max-width: 350px) {
  .brand-title {
    display: none;
  }
}

/* Mobile Landscape Orientation */
@media (max-height: 520px) and (orientation: landscape) {
  .app-container {
    padding-top: max(6px, env(safe-area-inset-top, 6px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    padding-left: max(16px, env(safe-area-inset-left, 16px));
    padding-right: max(16px, env(safe-area-inset-right, 16px));
  }

  .app-header {
    padding: 4px 10px;
  }

  .bottom-dock {
    padding: 4px 10px;
  }

  .center-overlay {
    top: 50%;
    padding: 6px 16px;
  }

  .breath-phase-text {
    font-size: 2.1rem;
    margin-bottom: 4px;
  }

  .breath-sub-text {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
  }

  .center-prompt {
    margin-top: 14px;
    padding: 6px 16px;
    font-size: 0.8rem;
  }

  .master-play-btn {
    width: 44px;
    height: 44px;
  }

  .master-play-btn svg {
    width: 16px;
    height: 16px;
  }
}
