/* ==========================================================================
   Design System & Styling — didyoubreathe?
   ========================================================================== */

/* Google Fonts */
:root {
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Premium Light-Theme Color Palette (Soft, Warm, Organic) */
  --bg-app: #faf8f5;           /* Warm ivory/cream */
  --bg-card: rgba(255, 255, 255, 0.75); /* Frosted glass card */
  
  --text-main: #1c252c;         /* Crisp charcoal */
  --text-main-hover: #27333d;   /* Hover primary charcoal shade */
  --text-muted: #5e6b75;        /* Soft slate */
  
  /* Systemic Border Token */
  --border-soft: rgba(28, 37, 44, 0.08); /* Derived from Crisp Charcoal */
  
  /* Soothing Accent Colors */
  --accent-sage: #5ba38e;       /* Calm sage green (visual aura / shapes) */
  --accent-sage-text: #377363;  /* High-contrast sage green (for WCAG AA compliant text on cream) */
  --accent-sage-glow: rgba(91, 163, 142, 0.15);
  --accent-sage-light: #f1f7f5;
  
  --accent-sky: #6392c9;        /* Tranquil sky blue */
  --accent-sky-glow: rgba(99, 146, 201, 0.15);
  --accent-sky-light: #f2f6fa;
  
  --accent-peach: #d98877;      /* Gentle peach warning color */
  --accent-peach-light: #fcf4f2;
  
  /* Shadows & Radius */
  --shadow-premium: 
    0 4px 30px rgba(0, 0, 0, 0.012),
    0 20px 50px rgba(91, 163, 142, 0.05);
  --shadow-active: 
    0 10px 40px rgba(91, 163, 142, 0.10);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.03);
  
  --radius-card: 16px;          /* Clean visual system structure (no over-rounded tell) */
  --radius-button: 14px;
  --radius-pill: 50px;
  
  --transition-smooth: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-quick: all 0.2s ease;
}

/* Base Styles & Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Scenic Watercolor Blurs (Ambient Background Decorative Elements) */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.45;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-sage-glow) 0%, rgba(255,255,255,0) 70%);
  top: -100px;
  right: -100px;
}

.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-sky-glow) 0%, rgba(255,255,255,0) 70%);
  bottom: -150px;
  left: -150px;
}

/* App Container Layout */
.container {
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  padding: 40px 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 30px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

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

.logo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent-sage);
  box-shadow: 0 0 10px var(--accent-sage-glow);
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
}

/* Agitation Level Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--accent-peach-light);
  border: 1px solid rgba(217, 136, 119, 0.15);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  color: #ad4936;
  transition: var(--transition-smooth);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-peach);
}

.status-dot.pulsing {
  animation: alarm-pulse 1.5s infinite ease-in-out;
}

/* Calmer state for the pill */
.status-pill.calm {
  background-color: var(--accent-sage-light);
  border-color: rgba(91, 163, 142, 0.15);
  color: var(--accent-sage-text);
}

.status-pill.calm .status-dot {
  background-color: var(--accent-sage);
  animation: calm-pulse 3s infinite ease-in-out;
}

/* Main Grid Layout */
.main-content {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
  width: 100%;
  margin: auto 0;
}

@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 24px 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    gap: 20px;
  }
  
  .main-content {
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 12px;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .variation-chips {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Micro-screen layout adjustments (e.g. 320px viewports) */
@media (max-width: 360px) {
  .breather-container {
    height: 240px;
  }
  
  .breathing-ring-outer {
    width: 160px;
    height: 160px;
  }
  
  .breathing-ring-inner {
    width: 130px;
    height: 130px;
  }
  
  /* Prevent large text wrapping in the breather core */
  #breath-action {
    font-size: 1.1rem;
  }
}

/* Tactile Active Scaling Trigger Feedback */
.btn:active,
.chip:active {
  transform: translateY(0) scale(0.97);
}

/* LEFT COLUMN: Breathing Interactivity */
.breathing-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.main-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.2;
  letter-spacing: -1px;
  margin-bottom: 12px;
  text-wrap: balance;
}

.main-title .highlight {
  color: var(--accent-sage-text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 540px;
  margin-bottom: 40px;
}

/* The Core Breathing Ring */
.breather-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 280px;
  margin-bottom: 30px;
}

.breathing-ring-outer {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-premium);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: transform 4s cubic-bezier(0.33, 1, 0.68, 1), box-shadow 4s ease, border-color 0.5s ease;
  user-select: none;
}

/* Adding an outer aura circle */
.breathing-ring-outer::before {
  content: '';
  position: absolute;
  top: -15px;
  left: -15px;
  right: -15px;
  bottom: -15px;
  border-radius: 50%;
  border: 1px solid rgba(91, 163, 142, 0.08);
  opacity: 0;
  transform: scale(0.9);
  transition: var(--transition-smooth);
}

.breathing-ring-inner {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-inner);
  transition: var(--transition-smooth);
}

#breath-action {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-main);
  transition: var(--transition-quick);
}

#breath-timer {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 1px;
}

/* Interactive Breathing States (Driven by Javascript) */
.breathing-ring-outer.inhale {
  transform: scale(1.4);
  box-shadow: 
    0 10px 40px var(--accent-sage-glow),
    0 0 0 15px rgba(91, 163, 142, 0.06);
  border-color: rgba(91, 163, 142, 0.2);
}

.breathing-ring-outer.inhale::before {
  opacity: 1;
  transform: scale(1.1);
  border-color: rgba(91, 163, 142, 0.15);
}

.breathing-ring-outer.inhale .breathing-ring-inner {
  background: white;
}

.breathing-ring-outer.hold-in {
  transform: scale(1.4);
  box-shadow: 
    0 10px 40px var(--accent-sky-glow),
    0 0 0 25px rgba(99, 146, 201, 0.08);
  border-color: rgba(99, 146, 201, 0.2);
}

.breathing-ring-outer.hold-in .breathing-ring-inner {
  background: var(--accent-sky-light);
}

.breathing-ring-outer.exhale {
  transform: scale(1.0);
  box-shadow: var(--shadow-premium);
  border-color: var(--border-soft);
}

.breathing-ring-outer.hold-out {
  transform: scale(1.0);
  box-shadow: var(--shadow-premium);
  border-color: var(--border-soft);
}

/* Prompt Display Card - Pure soft shadow-bound boundary */
.prompt-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 20px 30px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-premium);
  max-width: 500px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 36px;
  transition: var(--transition-smooth);
}

#intervention-prompt {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-main);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: prompt-fade-in 0.4s ease;
}

/* Buttons and Controls */
.controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 16px 28px;           /* Expanded padding to ensure height >= 48px for mobile compliance */
  border-radius: var(--radius-button);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-quick);
  box-shadow: var(--shadow-premium);
  min-height: 48px;             /* Strictly enforce 48px minimum height */
}

.btn:focus,
.chip:focus,
.checkbox-container input:focus {
  outline: none;
}

.btn:focus-visible,
.chip:focus-visible,
.checkbox-container input:focus-visible ~ .custom-checkbox {
  outline: 2px solid var(--accent-sage-text);
  outline-offset: 3px;
}

.btn svg {
  transition: var(--transition-quick);
}

.btn-primary {
  background-color: var(--text-main);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(28, 37, 44, 0.15);
  background-color: var(--text-main-hover);
}

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

.btn-secondary {
  background-color: white;
  border: 1px solid var(--border-soft);
  color: var(--text-main);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-active);
  border-color: rgba(91, 163, 142, 0.2);
}

.btn-secondary.active {
  background-color: var(--accent-sage-light);
  border-color: rgba(91, 163, 142, 0.3);
  color: var(--accent-sage-text);
}

.btn-tertiary {
  background-color: var(--accent-sage-text); /* Changed to accent-sage-text (#377363) to achieve perfect WCAG AA contrast (5.5:1) with white text */
  color: white;
  width: 100%;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(91, 163, 142, 0.15);
}

.btn-tertiary:hover {
  background-color: #498a77;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(91, 163, 142, 0.25);
}

.hide {
  display: none !important;
}

/* RIGHT COLUMN: Interactive Cards */
.meta-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Frosted Layout Shell - Pure shadow-bound boundaries */
.interactive-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 30px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-premium);
  transition: var(--transition-smooth);
}

.interactive-card:hover {
  box-shadow: var(--shadow-active);
  transform: translateY(-2px);
}

.interactive-card h2 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Checklist Styling */
.checklist-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.checkbox-container {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  position: relative;
  user-select: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
  padding: 12px 0;              /* Increased vertical padding to create 48px minimum touch target height */
}

/* Hidden default input */
.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkbox {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;            /* Optical vertical alignment adjustment */
  border-radius: 6px;
  background-color: white;
  border: 1.5px solid var(--border-soft);
  box-shadow: var(--shadow-inner);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-quick);
}

/* Checked state */
.checkbox-container input:checked ~ .custom-checkbox {
  background-color: var(--accent-sage-text);
  border-color: var(--accent-sage-text);
}

.checkbox-container:hover input ~ .custom-checkbox {
  border-color: var(--accent-sage);
}

/* Custom Checkmark */
.custom-checkbox::after {
  content: "";
  display: none;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.checkbox-container input:checked ~ .custom-checkbox::after {
  display: block;
}

/* Line-through completed labels */
.checkbox-container input:checked ~ .checkbox-label {
  color: var(--text-muted);
  text-decoration: line-through;
  transition: var(--transition-quick);
}

.checklist-feedback {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-sage-text);
  background-color: var(--accent-sage-light);
  padding: 10px 16px;
  border-radius: 10px;
  text-align: center;
  transition: var(--transition-smooth);
}

/* Share Card Styles */
.share-copy-box {
  background-color: rgba(0, 0, 0, 0.015);
  border: 1px dashed var(--border-soft);
  padding: 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.share-preview-text {
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--text-muted);
  word-break: break-word;
}

.share-variations .label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.variation-chips {
  display: flex;
  gap: 12px;                  /* Generous horizontal separation to avoid mis-tap overlap */
}

/* Enlarged Chip Touch Targets (compliant to WCAG 44px guideline) */
.chip {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 12px 20px;         /* Generous padding for high-end feel */
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  background-color: white;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition-quick);
  min-height: 48px;           /* Strictly enforce 48px touch target vertical height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip:hover {
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text-main);
}

.chip.active {
  background-color: var(--text-main);
  color: white;
  border-color: var(--text-main);
}

/* Footer styling */
.app-footer {
  text-align: center;
  padding: 20px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
}

/* Animations */
@keyframes alarm-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.6; box-shadow: 0 0 10px var(--accent-peach); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes calm-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; box-shadow: 0 0 6px var(--accent-sage); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes prompt-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
