/* =============================================
   WIMMY v2 — Biomarker-Aware Breathwork Guide
   Mobile-first · Dark beach sunset · Orb UI
   ============================================= */

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

:root {
  --font-body: 'Satoshi', sans-serif;
  --color-text: #e8e0d4;
  --color-text-muted: rgba(232, 224, 212, 0.45);
  --color-bubble-bg: rgba(12, 10, 7, 0.78);
  --color-bubble-border: rgba(232, 224, 212, 0.07);
  --color-accent: #c2885a;
  --color-breath-inhale: #5ab8c2;
  --color-breath-hold: #c2885a;
  --color-breath-exhale: #7b6aad;
  --color-recommended: #5ab8c2;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--color-text);
  background: #0b0d1a;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

/* =============================================
   ANIMATED BEACH SCENE
   ============================================= */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    #0b0d1a 0%,
    #1a1040 12%,
    #3d1854 24%,
    #7a2e6e 35%,
    #c44900 48%,
    #e8741a 55%,
    #f4a534 61%,
    #f7cc6a 66%,
    #1b3a4b 78%,
    #0d1b2a 100%
  );
}

.stars {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 40%;
  background-image:
    radial-gradient(1px 1px at 10% 8%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 25% 15%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 40% 5%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1.2px 1.2px at 55% 12%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 70% 3%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.3px 1.3px at 85% 18%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 15% 22%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 60% 20%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 90% 8%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.2px 1.2px at 35% 25%, rgba(255,255,255,0.5), transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}

.stars--2 {
  background-image:
    radial-gradient(1px 1px at 8% 12%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.3px 1.3px at 32% 8%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 52% 18%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1.2px 1.2px at 75% 10%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 88% 25%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1.5px 1.5px at 18% 16%, rgba(255,255,255,0.5), transparent);
  animation: twinkle 5s ease-in-out infinite alternate-reverse;
  animation-delay: -2s;
}

@keyframes twinkle {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

.sun {
  position: absolute;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff5d4 0%, #f4a534 40%, #e8741a 70%, transparent 100%);
  top: 46%; left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 40px 15px rgba(244,165,52,0.35), 0 0 80px 30px rgba(232,116,26,0.15);
  animation: sunPulse 6s ease-in-out infinite;
}

@keyframes sunPulse {
  0%, 100% { box-shadow: 0 0 40px 15px rgba(244,165,52,0.35), 0 0 80px 30px rgba(232,116,26,0.15); }
  50% { box-shadow: 0 0 50px 20px rgba(244,165,52,0.45), 0 0 100px 40px rgba(232,116,26,0.2); }
}

.ocean {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 42%;
  overflow: hidden;
}

.wave {
  position: absolute;
  width: 200%; left: -50%;
  height: 100%;
  border-radius: 40% 40% 0 0;
  opacity: 0.5;
}

.wave--1 { bottom: 0; background: rgba(27,58,75,0.6); animation: waveMove 8s ease-in-out infinite; }
.wave--2 { bottom: -5%; background: rgba(13,27,42,0.7); animation: waveMove 10s ease-in-out infinite reverse; animation-delay: -2s; }
.wave--3 { bottom: -10%; background: rgba(27,58,75,0.5); animation: waveMove 12s ease-in-out infinite; animation-delay: -4s; }
.wave--4 { bottom: -15%; background: rgba(13,27,42,0.8); animation: waveMove 7s ease-in-out infinite reverse; animation-delay: -1s; }

@keyframes waveMove {
  0%, 100% { transform: translateX(-5%) translateY(0); }
  50% { transform: translateX(5%) translateY(-6px); }
}

.beach {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 18%;
  background: linear-gradient(180deg, transparent 0%, rgba(42,33,24,0.4) 20%, rgba(42,33,24,0.7) 50%, rgba(30,22,14,0.9) 100%);
  z-index: 1;
}

.beach-gradient {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(180deg, transparent 0%, transparent 55%, rgba(11,13,26,0.5) 80%, rgba(11,13,26,0.85) 100%);
  z-index: 2;
}

/* =============================================
   APP — Full viewport, no scroll
   ============================================= */
.app {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  max-width: 420px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 0;
  padding-top: env(safe-area-inset-top, 0.75rem);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Avatar — compact */
.avatar-container {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto 0.35rem;
  flex-shrink: 0;
}

.avatar {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 15%;
  border-radius: 50%;
  border: 2px solid rgba(194,136,90,0.25);
  position: relative;
  z-index: 2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.avatar-glow {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194,136,90,0.2), transparent 70%);
  z-index: 1;
  animation: avatarGlow 4s ease-in-out infinite;
}

@keyframes avatarGlow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

/* =============================================
   BREATHING ORB
   ============================================= */
.orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-shrink: 0;
}

.orb {
  width: 100px; height: 100px;
  border-radius: 50%;
  border: 2px solid rgba(90,184,194,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.6s ease, box-shadow 0.6s ease;
  box-shadow: 0 0 30px 8px rgba(90,184,194,0.1), inset 0 0 20px 4px rgba(90,184,194,0.05);
}

.orb-inner {
  width: 90%; height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(90,184,194,0.2) 0%, transparent 70%);
  position: absolute;
  transition: transform 0.1s linear, background 0.6s ease;
  transform: scale(0.35);
}

.orb-text {
  position: relative; z-index: 2;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text);
  opacity: 0.9;
}

.orb-progress {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

/* =============================================
   DIALOGUE — fills available space
   ============================================= */
.dialogue {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.25rem 0;
  scroll-behavior: smooth;
  min-height: 0;
  -ms-overflow-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(194,136,90,0.15) transparent;
}

.dialogue::-webkit-scrollbar { width: 2px; }
.dialogue::-webkit-scrollbar-thumb { background: rgba(194,136,90,0.15); border-radius: 4px; }

/* Messages */
.message {
  max-width: 88%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.45;
  animation: messageIn 0.35s var(--ease-out) both;
  word-wrap: break-word;
}

.message--wimmy {
  align-self: flex-start;
  background: var(--color-bubble-bg);
  border: 1px solid var(--color-bubble-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.message--wimmy .message-name {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
  display: block;
}

.message--breath {
  align-self: center;
  background: rgba(90,184,194,0.08);
  border: 1px solid rgba(90,184,194,0.15);
  color: var(--color-breath-inhale);
  font-weight: 600;
  text-align: center;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  padding: 0.35rem 1rem;
}

.message--breath.exhale {
  color: var(--color-breath-exhale);
  background: rgba(123,106,173,0.08);
  border-color: rgba(123,106,173,0.15);
}

.message--breath.hold {
  color: var(--color-breath-hold);
  background: rgba(194,136,90,0.08);
  border-color: rgba(194,136,90,0.15);
}

.message--player {
  align-self: flex-end;
  background: rgba(194,136,90,0.1);
  border: 1px solid rgba(194,136,90,0.18);
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.typing {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0.7rem;
  align-self: flex-start;
}

.typing-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* =============================================
   CONTROLS — pinned to bottom
   ============================================= */
.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem 0 0.35rem;
  flex-shrink: 0;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-bubble-border);
  background: var(--color-bubble-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background 150ms var(--ease-out), transform 150ms var(--ease-out), border-color 150ms var(--ease-out);
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
  background: rgba(30,25,18,0.9);
}

.btn--recommended {
  border-color: rgba(90,184,194,0.25);
  background: rgba(90,184,194,0.06);
}

.btn--recommended:active {
  background: rgba(90,184,194,0.12);
}

.btn--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.4rem;
  text-align: center;
}

.btn-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}

.btn-label {
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge-recommended {
  display: inline-block;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-recommended);
  background: rgba(90,184,194,0.12);
  border: 1px solid rgba(90,184,194,0.2);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  line-height: 1.4;
}

.btn-desc {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-weight: 400;
  line-height: 1.3;
}

.btn-note {
  font-size: 0.6rem;
  color: rgba(194, 90, 90, 0.6);
  font-weight: 400;
  line-height: 1.3;
  font-style: italic;
}

.btn--stop {
  border-color: rgba(194,90,90,0.25);
  background: rgba(194,90,90,0.07);
}
.btn--stop:active {
  background: rgba(194,90,90,0.15);
}

/* Recommendation reason */
.rec-reason {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  padding: 0.25rem 0.15rem;
  text-align: center;
}

/* Chat input */
.chat-input-container {
  display: flex;
  gap: 0.3rem;
  width: 100%;
}

.chat-input {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-bubble-border);
  background: var(--color-bubble-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.8rem;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 150ms var(--ease-out);
}

.chat-input::placeholder { color: var(--color-text-muted); }
.chat-input:focus { border-color: rgba(194,136,90,0.35); }

.chat-send {
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(194,136,90,0.25);
  background: rgba(194,136,90,0.1);
  color: var(--color-accent);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 150ms var(--ease-out);
}

.chat-send:active { transform: scale(0.95); }

/* =============================================
   DEBUG PANEL (hidden by default)
   ============================================= */
.debug-panel {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.92);
  border-top: 1px solid rgba(90,184,194,0.2);
  z-index: 100;
  padding: 0.75rem;
}

.debug-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.debug-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-recommended);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.debug-close {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid rgba(232,224,212,0.1);
  border-radius: 0.25rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  font-family: var(--font-body);
}

.debug-content {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.6rem;
  line-height: 1.6;
  color: rgba(90,184,194,0.8);
  white-space: pre-wrap;
  word-break: break-all;
}

/* =============================================
   FOOTER
   ============================================= */
.footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  flex-shrink: 0;
}

.footer a {
  font-size: 0.58rem;
  color: var(--color-text-muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* =============================================
   RESPONSIVE
   ============================================= */

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

/* Very short phones (SE, etc) */
@media (max-height: 600px) {
  .avatar-container { width: 56px; height: 56px; margin-bottom: 0.2rem; }
  .orb { width: 72px; height: 72px; }
  .message { font-size: 0.78rem; padding: 0.4rem 0.6rem; }
  .btn { padding: 0.4rem 0.65rem; }
  .controls { padding-top: 0.3rem; }
  .btn-label { font-size: 0.75rem; }
  .btn-desc { font-size: 0.6rem; }
}

/* Tablet+ widths */
@media (min-width: 500px) {
  .app { max-width: 440px; padding: 1rem 1rem 0.25rem; }
  .avatar-container { width: 100px; height: 100px; margin-bottom: 0.5rem; }
  .orb { width: 120px; height: 120px; }
  .message { font-size: 0.88rem; }
}
