/*
 * Il faut que tu respires — sept ambiances, une par jour de la semaine (comme les coloris de SVG-O-Matic).
 * Le décor est peint en plein écran par js/visuels.js ; ici, les couleurs de l'interface. Le jour dans :root, la nuit dans
 * [data-eclairage="nuit"] ; puis, pour chaque ambiance (posée par js/ambiance.js avant l'affichage), sa couleur d'accent
 * et la teinte de la barre du navigateur. Les valeurs de :root sont celles de « Bulle », le cocon.
 */

@font-face {
  font-family: 'Nunito';
  src: url('../fonts/nunito.woff2') format('woff2');
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bg-top: #f6eee4;
  --bg-bottom: #ead8c6;
  --text: #4a3d35;
  --muted: #8a776a;
  --surface: rgba(255, 250, 244, .72);
  --surface-solid: #fffaf4;
  --line: rgba(110, 80, 60, .15);
  --accent: #c27f65;
  --accent-hover: #b06e55;
  --accent-text: #fffaf6;
  --accent-soft: rgba(194, 127, 101, .14);
  --track: rgba(110, 80, 60, .13);
  --ok: #5f8f72;
  --bad: #b5503f;
  --shadow: 0 18px 50px -22px rgba(140, 90, 60, .45);
  --backdrop: rgba(70, 45, 30, .28);
  --halo: rgba(255, 250, 244, .8);
  --moon: block;
  --sun: none;
}

[data-eclairage="nuit"] {
  color-scheme: dark;
  --bg-top: #141827;
  --bg-bottom: #1d2136;
  --text: #e8e4f3;
  --muted: #a29ebc;
  --surface: rgba(34, 38, 60, .72);
  --surface-solid: #23283f;
  --line: rgba(205, 195, 255, .13);
  --accent: #a99bea;
  --accent-hover: #bcb1f2;
  --accent-text: #17142b;
  --accent-soft: rgba(169, 155, 234, .16);
  --track: rgba(205, 195, 255, .14);
  --ok: #8cc7a5;
  --bad: #f09484;
  --shadow: 0 18px 60px -22px rgba(0, 0, 0, .7);
  --backdrop: rgba(5, 6, 15, .55);
  --halo: rgba(4, 6, 18, .75);
  --moon: none;
  --sun: block;
}

/* ---------- ambiances : accent et teinte de la barre du navigateur, le jour puis la nuit (« Bulle » : les valeurs de base) ---------- */
:root[data-ambiance="vague"] {
  --bg-top: #bfe3ea; --bg-bottom: #3f97a5;
  --accent: #2f8f9a; --accent-hover: #257985; --accent-text: #f4fbfb; --accent-soft: rgba(47, 143, 154, .16);
  --text: #173a40; --muted: #2c5a62; --halo: rgba(236, 250, 250, .85);
}
:root[data-ambiance="vague"][data-eclairage="nuit"] {
  --bg-top: #0b1426; --bg-bottom: #061723;
  --accent: #6fd0cc; --accent-hover: #8adbd8; --accent-text: #062022; --accent-soft: rgba(111, 208, 204, .16);
  --text: #e8e4f3; --muted: #a29ebc; --halo: rgba(4, 6, 18, .75);
}
:root[data-ambiance="lac"] {
  --bg-top: #93bde3; --bg-bottom: #3aa5b4;
  --accent: #1f8ea0; --accent-hover: #187b8b; --accent-text: #f2fbfc; --accent-soft: rgba(31, 142, 160, .16);
  --text: #173a40; --muted: #2c5a62; --halo: rgba(236, 250, 250, .85);
}
:root[data-ambiance="lac"][data-eclairage="nuit"] {
  --bg-top: #070a1f; --bg-bottom: #081329;
  --accent: #e8b86a; --accent-hover: #f0c886; --accent-text: #1b1405; --accent-soft: rgba(232, 184, 106, .16);
  --text: #e8e4f3; --muted: #a29ebc; --halo: rgba(4, 6, 18, .75);
}
:root[data-ambiance="orbite"] {
  --bg-top: #e9ecf9; --bg-bottom: #f8eef0;
  --accent: #6c6fcf; --accent-hover: #5b5ec0; --accent-text: #ffffff; --accent-soft: rgba(108, 111, 207, .14);
}
:root[data-ambiance="orbite"][data-eclairage="nuit"] {
  --bg-top: #05081a; --bg-bottom: #140f33;
  --accent: #a99bf0; --accent-hover: #bcb1f5; --accent-text: #120f2b; --accent-soft: rgba(169, 155, 240, .16);
}
:root[data-ambiance="foret"] {
  --bg-top: #2c4634; --bg-bottom: #2d3d29;
  --accent: #e2c766; --accent-hover: #ecd585; --accent-text: #1c1a0c; --accent-soft: rgba(226, 199, 102, .16);
  color-scheme: dark;
  --text: #f1eff6; --muted: #c9cbdc; --halo: rgba(8, 12, 26, .65);
  --surface: rgba(28, 34, 56, .5); --surface-solid: #262c46; --line: rgba(230, 230, 255, .18); --track: rgba(230, 230, 255, .16);
  --backdrop: rgba(5, 6, 15, .5);
}
:root[data-ambiance="foret"][data-eclairage="nuit"] {
  --bg-top: #04100d; --bg-bottom: #0c2420;
  --accent: #e4cf6e; --accent-hover: #eedc8a; --accent-text: #14120a; --accent-soft: rgba(228, 207, 110, .15);
}
:root[data-ambiance="aurore"] {
  --bg-top: #1f3358; --bg-bottom: #7f8fae;
  --accent: #66e3b0; --accent-hover: #86ebc2; --accent-text: #06190f; --accent-soft: rgba(102, 227, 176, .16);
  color-scheme: dark;
  --text: #f1eff6; --muted: #c9cbdc; --halo: rgba(8, 12, 26, .65);
  --surface: rgba(28, 34, 56, .5); --surface-solid: #262c46; --line: rgba(230, 230, 255, .18); --track: rgba(230, 230, 255, .16);
  --backdrop: rgba(5, 6, 15, .5);
}
:root[data-ambiance="aurore"][data-eclairage="nuit"] {
  --bg-top: #030817; --bg-bottom: #101827;
  --accent: #5de0a8; --accent-hover: #7ae9b9; --accent-text: #04170f; --accent-soft: rgba(93, 224, 168, .15);
}
:root[data-ambiance="lune"] {
  --bg-top: #a98fb3; --bg-bottom: #a98fb3;
  --accent: #a0637c; --accent-hover: #8d546b; --accent-text: #fff8fb; --accent-soft: rgba(160, 99, 124, .15);
}
:root[data-ambiance="lune"][data-eclairage="nuit"] {
  --bg-top: #0b0a24; --bg-bottom: #0b0a24;
  --accent: #b7a8f5; --accent-hover: #c9bdf8; --accent-text: #15122e; --accent-soft: rgba(183, 168, 245, .16);
}

/* pas de zoom au double toucher : Safari sur iPhone veut la règle sur l'élément touché, pas seulement sur la page */
*, *::before, *::after { box-sizing: border-box; touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; overscroll-behavior: none; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 400 16px/1.5 var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom)) fixed;
  background-color: var(--bg-top);
  -webkit-tap-highlight-color: transparent;
  /* sur téléphone, la page ne défile pas (bloquée dans js/app.js) : glisser change l'ambiance ou l'éclairage */
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

/* ---------- décor : le canevas peint par js/visuels.js, derrière toute la page ---------- */
.scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; display: block; pointer-events: none; }

/* ---------- barre ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  transition: opacity .8s ease;
}
.brand, .guide, .clock, .summary, .foot { text-shadow: 0 0 14px var(--halo), 0 0 3px var(--halo); }
.brand { font-weight: 300; font-size: clamp(.8rem, 4vw, 1.3rem); letter-spacing: .05em; text-transform: lowercase; white-space: nowrap; }
.brand b { font-weight: 700; color: var(--accent); }
.bar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background .2s, transform .2s;
}
.icon-btn:hover { background: var(--surface-solid); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-moon { display: var(--moon); }
.ico-sun { display: var(--sun); }

/* ---------- scène ---------- */
.main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 4px 16px 10px; min-height: 0;
}
.stage {
  width: min(90vw, 48vh, 460px); width: min(90vw, 48dvh, 460px);
  aspect-ratio: 1; user-select: none; -webkit-user-select: none;
}

.guide { margin: 0; min-height: 2.6rem; display: flex; align-items: baseline; justify-content: center; gap: .55em; }
.phase { font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 300; letter-spacing: .02em; }
.count { font-size: 1.05rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1ch; }

.visuals { display: flex; gap: 7px; transition: opacity .8s ease; }
.visuals button {
  --size: clamp(34px, calc((100vw - 32px - 42px) / 7), 42px);
  width: var(--size); height: var(--size); display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.visuals button:hover { color: var(--text); }
.visuals button[aria-pressed="true"] { background: var(--surface-solid); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.visuals button:active { transform: scale(.94); }
.visuals svg { width: 58%; height: 58%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.visuals svg .fill { fill: currentColor; stroke: none; }

.session { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.progress { width: min(240px, 52vw); height: 4px; border-radius: 2px; background: var(--track); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); border-radius: 2px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); min-width: 3.2em; }
.summary { margin: 0; font-size: .9rem; color: var(--muted); text-align: center; transition: opacity .8s ease; }

.controls { display: flex; gap: 10px; margin-top: 8px; min-height: 52px; align-items: center; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 11px 22px; font-weight: 700; letter-spacing: .01em;
  transition: background .2s, transform .2s, box-shadow .2s;
}
.btn:hover { background: var(--surface-solid); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); box-shadow: var(--shadow); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 42px; font-size: 1.08rem; }

.foot {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 18px;
  padding: 8px 16px max(14px, env(safe-area-inset-bottom)); font-size: .8rem; color: var(--muted);
  transition: opacity .8s ease;
}
.link { background: none; border: 0; padding: 4px 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link:hover { color: var(--text); text-decoration-color: currentColor; }
.no-contact .js-contact, .no-contact .js-contact-wrap { display: none; }

/* changement d'éclairage ou d'ambiance : l'interface passe d'une couleur à l'autre en même temps que le décor */
html.fondu *, html.fondu *::before, html.fondu *::after {
  transition-property: color, background-color, border-color, box-shadow, text-shadow, fill, stroke !important;
  transition-duration: var(--fondu, 1s) !important; transition-timing-function: ease !important;
}

/* pendant la séance : tout s'efface autour de l'animation, et revient au survol */
body[data-status="running"] .bar,
body[data-status="running"] .foot,
body[data-status="running"] .summary { opacity: .14; }
body[data-status="running"] .visuals { opacity: .45; }
body[data-status="running"] .bar:hover,
body[data-status="running"] .foot:hover,
body[data-status="running"] .visuals:hover,
body[data-status="running"] .bar:focus-within,
body[data-status="running"] .visuals:focus-within { opacity: 1; }

/* ---------- fenêtres ---------- */
dialog.sheet {
  width: min(560px, 100%); max-width: 100%; max-height: 88vh; max-height: 88dvh;
  margin: auto auto 0; padding: 0; border: 0; border-radius: 26px 26px 0 0;
  background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
dialog.sheet[open] { animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 26px; max-height: 84vh; max-height: 84dvh; }
}
.sheet-body { padding: 18px 20px max(22px, env(safe-area-inset-bottom)); }
.sheet-head {
  position: sticky; top: 0; z-index: 1; margin: -18px -20px 6px; padding: 14px 20px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-solid); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.sheet-head .btn { padding: 7px 16px; font-size: .9rem; }
.sheet section { padding: 12px 0 4px; border-bottom: 1px solid var(--line); }
.sheet section:last-of-type { border-bottom: 0; }
.sheet h3 { margin: 6px 0 10px; font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hint { margin: 4px 0 8px; font-size: .86rem; color: var(--muted); }
.sheet-foot { margin: 14px 0 0; text-align: center; font-size: .9rem; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 4px 0 8px; }
.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
  border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.week-day svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.week-day svg .fill { fill: currentColor; stroke: none; }
.week-day b { display: none; }
.week-day small { font-size: .72rem; font-weight: 700; }
.week-day.today small { text-decoration: underline; text-underline-offset: 3px; }
.week-day[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ambiance-name { color: var(--text); font-weight: 600; }
.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.preset {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: transparent;
  transition: background .2s, border-color .2s;
}
.preset b { font-weight: 700; }
.preset small { color: var(--muted); font-size: .8rem; }
.preset[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.preset:disabled { opacity: .5; cursor: default; }

.field { margin: 6px 0 10px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field-head label, .switch-row > span { font-weight: 600; }
.field-head small, .switch-row small { display: inline; font-weight: 400; color: var(--muted); margin-left: 6px; }
.field-head output { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 2px 0 0; background: transparent; cursor: pointer; }
input[type="range"]:disabled { opacity: .45; cursor: default; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--track) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--surface-solid); border: 2px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-solid); border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; cursor: pointer; }
.switch-row small { display: block; margin: 0; }
.switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 48px; height: 28px; margin: 0;
  border-radius: 14px; background: var(--track); cursor: pointer; transition: background .2s;
}
.switch::before {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-solid); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(20px); }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--track); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 18px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* ---------- accueil : une fenêtre comme les autres, ouverte d'elle-même à la première visite ---------- */
.lead { margin: 4px 0 0; color: var(--muted); }
.brand-inline { font-weight: 300; color: var(--text); letter-spacing: .03em; text-transform: lowercase; }
.brand-inline b { font-weight: 700; color: var(--accent); }
.welcome-actions { display: flex; justify-content: center; margin: 22px 0 6px; }
.welcome-foot { text-align: center; margin-top: 10px; }

.prose h3 { margin-top: 18px; }
.prose p, .prose li { font-size: .95rem; }
.plain { margin: 0; padding-left: 1.1em; }
.plain li { margin: 0 0 6px; }

.contact-form label { display: block; margin: 12px 0 4px; font-weight: 600; }
.contact-form textarea, .contact-form input[type="email"] {
  width: 100%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-top); resize: vertical;
}
.pot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.contact-state { min-height: 1.4em; margin: 8px 0; font-size: .9rem; color: var(--ok); }
.contact-state.bad { color: var(--bad); }
.contact-actions { text-align: right; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px;
  background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .92rem;
}

@media (max-height: 640px) {
  .stage { width: min(80vw, 42vh, 460px); width: min(80vw, 42dvh, 460px); }
  .main { gap: 6px; }
  .summary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open] { animation: none; }
}
