/* ─────────────────────────────────────────────
   BREATHE EASY — Children's Breathing Timer
   Branded for: Wellbeing in Education
   ───────────────────────────────────────────── */

/* === DESIGN TOKENS === */
:root, [data-theme="light"] {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Spacing */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;   --space-20: 5rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-xl: 2rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ── Wellbeing in Education brand palette ── */
  /* Surfaces — soft blush */
  --color-bg:              #FFF4F0;
  --color-surface:         #FFFFFF;
  --color-surface-2:       #FFF9F7;
  --color-border:          #F0D8D0;
  --color-divider:         #F5E4DE;

  /* Text — deep forest green */
  --color-text:            #1a4a3c;
  --color-text-muted:      #3d7a68;
  --color-text-faint:      #8fbfb0;
  --color-text-inverse:    #FFFFFF;

  /* Primary — forest green */
  --color-primary:         #266A5A;
  --color-primary-hover:   #1c5246;
  --color-primary-active:  #143b32;
  --color-primary-light:   #e8f4f1;

  /* Accent — warm coral */
  --color-accent:          #FF8665;
  --color-accent-hover:    #f06e4a;
  --color-accent-light:    #fff0ec;

  /* Success */
  --color-success:         #266A5A;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(38,106,90,0.08);
  --shadow-md: 0 4px 16px rgba(38,106,90,0.12);
  --shadow-lg: 0 12px 40px rgba(38,106,90,0.16);

  /* Belly bear colours — warm honey tones */
  --belly-bear:       #e8a86a;
  --belly-ear-inner:  #f4c99a;
  --belly-face-dark:  #6b3a10;

  /* Hand colours */
  --hand-fill:       #ffd7b8;
  --tip-inactive:    #e8b89a;
  --tracer-color:    #266A5A;

  /* Ring colours */
  --ring-color-1: rgba(38, 106, 90, 0.12);
  --ring-color-2: rgba(38, 106, 90, 0.07);
  --ring-color-3: rgba(38, 106, 90, 0.04);

  /* Fonts — matching site */
  --font-display: 'Lato', 'Nunito', sans-serif;
  --font-body:    'Lato', 'Segoe UI', sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
  --color-bg:              #0f1f1a;
  --color-surface:         #152820;
  --color-surface-2:       #1c332a;
  --color-border:          #284a3c;
  --color-divider:         #1e3a2e;
  --color-text:            #d8f0ea;
  --color-text-muted:      #6db09a;
  --color-text-faint:      #2e6050;
  --color-text-inverse:    #0f1f1a;
  --color-primary:         #4a9e88;
  --color-primary-hover:   #5cb8a0;
  --color-primary-active:  #72ccb6;
  --color-primary-light:   #1a3a2e;
  --color-accent:          #ff9e84;
  --color-accent-hover:    #ffb89e;
  --color-accent-light:    #2a1e18;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --belly-bear:       #d4904a;
  --belly-ear-inner:  #e8b07a;
  --belly-face-dark:  #3a1e00;
  --hand-fill:        #b88060;
  --tip-inactive:     #9a6848;
  --tracer-color:     #4a9e88;
  --ring-color-1: rgba(74, 158, 136, 0.18);
  --ring-color-2: rgba(74, 158, 136, 0.10);
  --ring-color-3: rgba(74, 158, 136, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #0f1f1a;
    --color-surface:         #152820;
    --color-surface-2:       #1c332a;
    --color-border:          #284a3c;
    --color-divider:         #1e3a2e;
    --color-text:            #d8f0ea;
    --color-text-muted:      #6db09a;
    --color-text-faint:      #2e6050;
    --color-text-inverse:    #0f1f1a;
    --color-primary:         #4a9e88;
    --color-primary-hover:   #5cb8a0;
    --color-primary-active:  #72ccb6;
    --color-primary-light:   #1a3a2e;
    --color-accent:          #ff9e84;
    --color-accent-hover:    #ffb89e;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    --belly-bear:       #d4904a;
    --belly-ear-inner:  #e8b07a;
    --belly-face-dark:  #3a1e00;
    --hand-fill:        #b88060;
    --tip-inactive:     #9a6848;
    --tracer-color:     #4a9e88;
    --ring-color-1: rgba(74, 158, 136, 0.18);
    --ring-color-2: rgba(74, 158, 136, 0.10);
    --ring-color-3: rgba(74, 158, 136, 0.05);
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(38,106,90,0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(255,134,101,0.08) 0%, transparent 55%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

img, svg { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
h1,h2,h3 { text-wrap: balance; line-height: 1.15; }
p, li { text-wrap: pretty; }

:focus-visible {
  outline: 2.5px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === HEADER (hidden — embedded in website) === */

/* === MAIN === */
.app-main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4) var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

/* === TECHNIQUE SELECTOR === */
.app-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
  margin-bottom: var(--space-6);
}

.technique-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.technique-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4);
  background: var(--color-surface);
  border: 2.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
  box-shadow: var(--shadow-sm);
}

.technique-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.technique-card.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 4px rgba(38,106,90,0.12), var(--shadow-md);
}

.technique-card-icon {
  width: 72px;
  height: 72px;
  color: var(--color-primary);
}

.technique-card-icon svg {
  width: 100%;
  height: 100%;
}

.technique-card-label {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.technique-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* === BREATHING PANELS === */
.breathing-panel {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: panelIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.breathing-panel.hidden { display: none; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-inner {
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* === BELLY BREATHING VISUAL === */
.belly-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.belly-visual {
  position: relative;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}

.belly-rings {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.belly-ring {
  position: absolute;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transform: scale(1);
  transition: transform 2.5s ease-in-out;
}

.ring-1 { width: 155px; height: 155px; opacity: 0.09; }
.ring-2 { width: 185px; height: 185px; opacity: 0.06; }
.ring-3 { width: 215px; height: 215px; opacity: 0.03; }

/* Breathing animation states */
.belly-visual.inhale .ring-1 { transform: scale(1.15); }
.belly-visual.inhale .ring-2 { transform: scale(1.12); }
.belly-visual.inhale .ring-3 { transform: scale(1.1); }

.belly-visual.exhale .ring-1 { transform: scale(0.88); }
.belly-visual.exhale .ring-2 { transform: scale(0.90); }
.belly-visual.exhale .ring-3 { transform: scale(0.92); }

.belly-core {
  position: relative;
  z-index: 1;
  width: 140px;
  height: 140px;
  transition: transform 0.1s ease;
  background: transparent;
}

.bear-face {
  width: 100%;
  height: 100%;
  transition: transform 2.5s cubic-bezier(0.45, 0.05, 0.55, 0.95);
  filter: drop-shadow(0 4px 12px rgba(38,106,90,0.15));
}

/* Photo version — Buddy, circular crop */
.puppy-photo {
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
  width: 100%;
  height: 100%;
  box-shadow: 0 6px 24px rgba(38,106,90,0.22);
  border: 4px solid rgba(255,255,255,0.9);
}

.belly-visual.inhale .bear-face { transform: scale(1.18); }
.belly-visual.hold .bear-face   { transform: scale(1.18); }
.belly-visual.exhale .bear-face { transform: scale(0.88); }
.belly-visual.idle .bear-face   {
  transform: scale(1);
  animation: bearBob 3s ease-in-out infinite;
}

@keyframes bearBob {
  0%, 100% { transform: scale(1) translateY(0); }
  50%       { transform: scale(1.03) translateY(-3px); }
}

/* === BREATH INSTRUCTION === */
.breath-instruction {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  text-align: center;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.breath-count-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.breath-count {
  font-weight: 700;
  color: var(--color-text);
}

/* === PHASE BAR === */
.phase-bar-wrap {
  height: 8px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.phase-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-full);
  transition: width linear;
}

/* === CONTROLS === */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.btn-start {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-8);
  background: var(--color-accent);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(255,134,101,0.35);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn-start:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255,134,101,0.45);
}

.btn-start:active { transform: translateY(0); }

.btn-start.is-paused {
  background: var(--color-primary);
  box-shadow: 0 4px 16px rgba(38,106,90,0.35);
}

.btn-reset {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  color: var(--color-text-muted);
  background: var(--color-divider);
  transition: background var(--transition), color var(--transition), opacity var(--transition);
}

.btn-reset:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.btn-rounds {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.btn-rounds:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* Speed toggle */
.speed-toggle {
  display: flex;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}

.speed-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}

.speed-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* === FINGER BREATHING === */
.finger-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

/* Match the belly-visual container size so layout is identical */
.hand-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
}

/* Soft pulsing rings behind the hand — same as belly breathing */
.hand-rings {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.hand-ring {
  position: absolute;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transform: scale(1);
  transition: transform 2.5s ease-in-out;
}

.hand-ring-1 { width: 155px; height: 155px; opacity: 0.09; }
.hand-ring-2 { width: 185px; height: 185px; opacity: 0.06; }
.hand-ring-3 { width: 215px; height: 215px; opacity: 0.03; }

/* Animate rings with breath */
.hand-wrap.inhale .hand-ring-1 { transform: scale(1.15); }
.hand-wrap.inhale .hand-ring-2 { transform: scale(1.12); }
.hand-wrap.inhale .hand-ring-3 { transform: scale(1.1); }
.hand-wrap.exhale .hand-ring-1 { transform: scale(0.88); }
.hand-wrap.exhale .hand-ring-2 { transform: scale(0.90); }
.hand-wrap.exhale .hand-ring-3 { transform: scale(0.92); }

.hand-photo-container {
  position: relative;
  width: 190px;
  height: 190px;
  display: inline-block;
  z-index: 1;
}

.hand-photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  /* Clean drop shadow matching Buddy style */
  filter: drop-shadow(0 4px 12px rgba(38,106,90,0.15));
  transition: transform 2.5s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

/* Breathe animation on the hand photo — subtle scale like Buddy */
.hand-wrap.inhale .hand-photo  { transform: scale(1.08); }
.hand-wrap.exhale .hand-photo  { transform: scale(0.94); }
.hand-wrap.idle .hand-photo    { animation: handBob 3s ease-in-out infinite; }

@keyframes handBob {
  0%, 100% { transform: scale(1) translateY(0); }
  50%       { transform: scale(1.02) translateY(-3px); }
}

.hand-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.hand-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* === INSTRUCTION STEPS === */
.instruction-steps {
  background: var(--color-primary-light);
  border: 1px solid rgba(38,106,90,0.15);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.steps-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-3);
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.steps-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
}

.steps-list em {
  font-style: normal;
  color: var(--color-accent);
  font-weight: 700;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: #FFFFFF;
  font-size: var(--text-xs);
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* === CELEBRATION === */
.celebration {
  position: fixed;
  inset: 0;
  background: rgba(255,244,240,0.88);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fadeIn 0.3s ease both;
}

.celebration.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.celebration-inner {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
  max-width: 380px;
  width: calc(100% - var(--space-8));
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.star-burst {
  font-size: 3.5rem;
  margin-bottom: var(--space-4);
  animation: starSpin 1.5s ease-out both;
}

@keyframes starSpin {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.celebrate-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.celebrate-msg {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  max-width: none;
}

.btn-again {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3) var(--space-8);
  background: var(--color-accent);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 4px 16px rgba(255,134,101,0.35);
}

.btn-again:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
}

/* Confetti */
.confetti-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-burst span {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  animation: confettiFall 1.5s ease-out both;
}

.confetti-burst span:nth-child(1) { background: #FF8665; top: 10%; left: 15%; animation-delay: 0.1s; transform: rotate(45deg); }
.confetti-burst span:nth-child(2) { background: #266A5A; top: 5%; left: 45%; animation-delay: 0.2s; }
.confetti-burst span:nth-child(3) { background: #ffd93d; top: 15%; left: 75%; animation-delay: 0.05s; transform: rotate(20deg); }
.confetti-burst span:nth-child(4) { background: #266A5A; top: 8%; left: 60%; animation-delay: 0.3s; border-radius: 50%; }
.confetti-burst span:nth-child(5) { background: #FF8665; top: 20%; left: 30%; animation-delay: 0.15s; transform: rotate(70deg); }
.confetti-burst span:nth-child(6) { background: #6bcb77; top: 3%; left: 85%; animation-delay: 0.25s; }
.confetti-burst span:nth-child(7) { background: #ffd93d; top: 12%; left: 5%; animation-delay: 0.0s; border-radius: 50%; }
.confetti-burst span:nth-child(8) { background: #FF8665; top: 6%; left: 55%; animation-delay: 0.35s; transform: rotate(55deg); }

@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100px) rotate(360deg); opacity: 0; }
}

/* === FOOTER === */
.app-footer {
  text-align: center;
  padding: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  background: var(--color-primary);
}

.app-footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color var(--transition);
}

.app-footer a:hover { color: rgba(255,255,255,0.9); }

/* === RESPONSIVE === */
@media (max-width: 480px) {
  .panel-inner { padding: var(--space-6) var(--space-4); }
  .belly-visual { width: 180px; height: 180px; }
  .ring-1 { width: 115px; height: 115px; }
  .ring-2 { width: 148px; height: 148px; }
  .ring-3 { width: 175px; height: 175px; }
  .belly-core { width: 108px; height: 108px; }
  .hand-wrap { width: 180px; height: 180px; }
  .hand-ring-1 { width: 115px; height: 115px; }
  .hand-ring-2 { width: 148px; height: 148px; }
  .hand-ring-3 { width: 175px; height: 175px; }
  .hand-photo-container { width: 155px; height: 155px; }
  .technique-cards { gap: var(--space-3); }
}
