/* ============================================================
   Breath Canvas
   Quiet, cinematic, minimal. Dark-dominant with per-mode
   atmosphere. Pill controls for direct interaction.
   ============================================================ */

:root {
  --ink: #f4f5f7;
  --ink-soft: #b9bec7;
  --ink-mute: #767d88;
  --ink-faint: #565c66;
  --line: #23262c;
  --surface: #14161a;

  /* Mode atmosphere — overridden per data-mode */
  --bg-0: #0a0e14;
  --bg-1: #101722;
  --accent: #7fb2d9;
  --accent-soft: rgba(127, 178, 217, 0.16);
  --orb-glow: rgba(127, 178, 217, 0.42);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --pad: clamp(20px, 5vw, 40px);
}

/* Per-mode palettes */
body[data-mode="calm"] {
  --bg-0: #0a1018;
  --bg-1: #12212e;
  --accent: #7fb2d9;
  --accent-soft: rgba(127, 178, 217, 0.16);
  --orb-glow: rgba(120, 176, 220, 0.45);
}
body[data-mode="focus"] {
  --bg-0: #101114;
  --bg-1: #1c1f24;
  --accent: #b8bec9;
  --accent-soft: rgba(184, 190, 201, 0.14);
  --orb-glow: rgba(198, 204, 214, 0.34);
}
body[data-mode="sleep"] {
  --bg-0: #060912;
  --bg-1: #0d1428;
  --accent: #6d7ec2;
  --accent-soft: rgba(109, 126, 194, 0.16);
  --orb-glow: rgba(96, 112, 190, 0.4);
}

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

html, body { height: 100%; }

body {
  font-family: "Inter", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.18px;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 1.2s var(--ease);
}

/* ---------- Atmosphere ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 50% 8%, var(--bg-1) 0%, var(--bg-0) 60%);
  transition: background 1.2s var(--ease);
}
.atmosphere-glow {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(78vw, 620px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
  filter: blur(28px);
  transition: background 1.2s var(--ease), opacity 1.2s var(--ease);
}

/* ---------- Screen system ---------- */
.screen { display: none; }
.screen.is-active { display: flex; }

.screen--home {
  flex-direction: column;
  min-height: 100dvh;
  padding: clamp(48px, 9vh, 96px) var(--pad) 40px;
  max-width: 560px;
  margin: 0 auto;
  gap: clamp(40px, 7vh, 72px);
}

/* ---------- Masthead ---------- */
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.wordmark {
  margin-top: 20px;
  font-size: clamp(34px, 9vw, 48px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -1.4px;
  color: var(--ink);
}
.tagline-jp {
  margin-top: 18px;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--ink-faint);
}

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: clamp(26px, 4vh, 36px); }
.control-block { display: flex; flex-direction: column; gap: 14px; }

.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.chips { display: flex; gap: 10px; }
.chips--duration { gap: 10px; }

.chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: border-color 0.35s var(--ease), color 0.35s var(--ease),
              background 0.35s var(--ease), transform 0.2s var(--ease);
}
.chip--sm { padding: 13px 12px; }
.chip-name { font-size: 15px; }
.chip-meta {
  font-size: 11px;
  font-weight: 450;
  letter-spacing: 1px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip:active { transform: scale(0.98); }
.chip[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}
.chip[aria-checked="true"] .chip-meta { color: var(--accent); }

.mode-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-mute);
  min-height: 20px;
  transition: opacity 0.3s var(--ease);
}

/* ---------- CTA ---------- */
.cta {
  margin-top: 4px;
  padding: 19px;
  background: var(--ink);
  color: #0a0d12;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.cta:hover { opacity: 0.9; }
.cta:active { transform: scale(0.985); }

/* ---------- About ---------- */
.about { border-top: 1px solid var(--line); }
.about-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.about-chevron { font-size: 18px; color: var(--ink-mute); transition: transform 0.3s var(--ease); }
.about-toggle[aria-expanded="true"] .about-chevron { transform: rotate(45deg); }
.about-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.about-body p { font-size: 13.5px; line-height: 1.6; color: var(--ink-mute); }
.about-jp { color: var(--ink-faint) !important; font-size: 12.5px !important; }
.about-stat { color: var(--ink-soft) !important; }
.about-stat span { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
.site-footer { margin-top: auto; padding-top: 8px; }
.safety { font-size: 12px; line-height: 1.55; color: var(--ink-faint); max-width: 44ch; }
.safety-jp { margin-top: 8px; opacity: 0.75; }

/* ============================================================
   SESSION SCREEN
   ============================================================ */
.screen--session {
  position: fixed;
  inset: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 6vh, 56px) var(--pad);
  z-index: 10;
}

.session-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.session-mode {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.session-total {
  font-size: 13px;
  letter-spacing: 0.4px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.orb {
  position: absolute;
  width: min(72vw, 340px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.62);
  will-change: transform;
}
.orb-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, var(--orb-glow) 0%, transparent 70%);
  border: 1px solid var(--accent-soft);
  box-shadow: 0 0 60px var(--accent-soft), inset 0 0 60px var(--accent-soft);
  transition: box-shadow 0.6s var(--ease), border-color 0.6s var(--ease);
}
.orb.is-hold .orb-core {
  box-shadow: 0 0 90px var(--orb-glow), inset 0 0 70px var(--accent-soft);
  border-color: var(--accent);
}

.readout {
  position: relative;
  z-index: 2;
  text-align: center;
  pointer-events: none;
}
.phase {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.count {
  margin-top: 10px;
  font-size: clamp(56px, 16vw, 76px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -2px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.paused-hint {
  display: none;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.screen--session.is-paused .paused-hint { display: block; }
.screen--session.is-paused .orb-core { opacity: 0.6; transition: opacity 0.6s var(--ease); }

.session-controls { display: flex; gap: 12px; justify-content: center; }

.pill {
  min-width: 128px;
  padding: 16px 28px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease), background 0.3s var(--ease);
}
.pill:active { transform: scale(0.97); }
.pill--primary { background: var(--ink); color: #0a0d12; border: none; }
.pill--primary:hover { opacity: 0.9; }
.pill--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.pill--ghost:hover { border-color: var(--ink-mute); color: var(--ink); }

/* ============================================================
   COMPLETE SCREEN
   ============================================================ */
.screen--complete {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  z-index: 10;
}
.complete-inner { text-align: center; max-width: 380px; }
.complete-title {
  margin-top: 18px;
  font-size: clamp(30px, 8vw, 40px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -1.1px;
}
.complete-breaths {
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-mute);
}
.complete-controls { margin-top: 40px; display: flex; gap: 12px; justify-content: center; }

/* ---------- Focus visibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
.chip:focus-visible, .cta:focus-visible, .pill:focus-visible { border-radius: 999px; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *:not(.orb) { transition-duration: 0.001ms !important; }
  .atmosphere, body { transition: none; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 380px) {
  .chip { padding: 14px 6px; font-size: 14px; }
  .pill { min-width: 0; flex: 1; padding: 16px 18px; }
  .session-controls { width: 100%; }
}

/* ---------- Landscape / short screens ---------- */
@media (max-height: 560px) and (orientation: landscape) {
  .orb { width: min(38vh, 220px); }
  .count { font-size: clamp(40px, 10vh, 60px); }
}
