/* Lull — 4-4-8-2 breathing guide */

:root {
  color-scheme: dark;
  --bg: #07090d;
  --surface: #11161e;
  --fg: #e9edf2;
  --muted: #7d8795;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #8fe0cb;
  --accent-rgb: 143, 224, 203;
  --accent-ink: #06201a;
  --orb-min: 0.56;
  --ease-breath: cubic-bezier(0.45, 0, 0.55, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    "Segoe UI", Roboto, "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

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

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 22px
    calc(env(safe-area-inset-bottom, 0px) + 26px);
}

/* ---- Top bar ---- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 6px;
}

/* Same mark as icons/icon.svg: the 4-4-8-2 ring (one path unit = one second) around the resting orb. */
.logo-ring {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.72;
  stroke-width: 2.2;
  stroke-linecap: round;
}
.logo-dot { fill: var(--accent); }

.pattern {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
}

.toggles {
  display: flex;
  gap: 2px;
}

.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.2s;
}

.icon-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn[aria-pressed="true"] { color: var(--fg); }
.icon-btn .mute { display: none; }
.icon-btn[aria-pressed="false"] .mute { display: block; }
.icon-btn[aria-pressed="false"] .wave { display: none; }
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Stage ---- */
.stage {
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(32px, 7vh, 56px);
}

.orb-wrap {
  position: relative;
  width: min(68vw, 42vh, 300px);
  width: min(68vw, 42dvh, 300px);
  aspect-ratio: 1;
}

.orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 42%,
    rgba(var(--accent-rgb), 0.62) 0%,
    rgba(var(--accent-rgb), 0.3) 52%,
    rgba(var(--accent-rgb), 0.12) 100%
  );
  box-shadow: 0 0 64px rgba(var(--accent-rgb), 0.14);
  opacity: 0.75;
  transform: scale(var(--orb-min));
  transition-property: transform, opacity;
  transition-timing-function: var(--ease-breath), ease;
  transition-duration: 0ms, 1200ms;
  will-change: transform;
}

.app[data-phase="inhale"] .orb,
.app[data-phase="hold"] .orb { opacity: 1; }
.app[data-phase="exhale"] .orb,
.app[data-phase="rest"] .orb { opacity: 0.8; }
.app[data-phase="done"] .orb { opacity: 0.95; }

/* Faint guide circle marking the orb's full size. */
.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.orb-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.orb-text p { margin: 0; }

.count {
  font-size: clamp(64px, 20vw, 88px);
  font-weight: 200;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  min-height: 1em;
  transition: color 0.6s;
}

.app[data-phase="prep"] .count { color: var(--muted); }

.check {
  display: none;
  fill: none;
  stroke: var(--fg);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app[data-state="idle"] .count,
.app[data-state="done"] .count { display: none; }
.app[data-state="done"] .check { display: block; }

/* ---- Cycle dots ---- */
.cycles {
  list-style: none;
  display: flex;
  gap: 12px;
  padding: 0;
  margin: 0;
}

.cycles li {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition: background-color 0.4s, box-shadow 0.4s;
}

.cycles li[data-state="current"] {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.cycles li[data-state="done"] { background: var(--accent); }

/* ---- Controls ---- */
.controls {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.hint {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.08em;
  min-height: 1.2em;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.4s;
}

.app:not([data-state="idle"]) .hint { opacity: 0; }

.primary {
  appearance: none;
  border: 0;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.15s, background-color 0.25s, color 0.25s, box-shadow 0.25s;
}

.primary:active { transform: scale(0.94); }

.primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.app[data-state="running"] .primary {
  background: var(--surface);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--line);
}

.ic {
  display: none;
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.ic-again {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app[data-state="idle"] .ic-play,
.app[data-state="running"] .ic-stop,
.app[data-state="done"] .ic-again { display: block; }

/* ---- Accessibility / motion ---- */
@media (prefers-reduced-motion: reduce) {
  :root { --orb-min: 0.82; }
}

@media (hover: hover) {
  .icon-btn:hover { color: var(--fg); }
}
