/* Cadence — métronome de course. Port des tokens du design Cadence.dc.html. */

/* ---------- Polices self-hostées (offline) ---------- */
@font-face {
  font-family: 'Saira Condensed'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('./assets/fonts/saira-condensed-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Saira Condensed'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('./assets/fonts/saira-condensed-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Saira Condensed'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('./assets/fonts/saira-condensed-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('./assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('./assets/fonts/ibm-plex-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('./assets/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

/* ---------- Tokens ---------- */
:root {
  --bg: #0a0f12;
  --surface: #16232a;
  --surface-2: #1f2d35;
  --sheet: #0e171c;
  --accent: #ffb648;
  --accent-lit: #ffc98a;
  --dark: #0c1216;
  --text: #f2f5f6;
  --text-2: #9fb0b8;
  --text-3: #8ea0a8;
  --muted: #6b7d85;
  --line: rgba(255, 255, 255, 0.08);
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: 'Saira Condensed', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% -10%, #14232b 0%, var(--bg) 62%) fixed;
  color: var(--text);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Coquille plein écran ---------- */
.app {
  position: relative;
  overflow: hidden;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 14px)
    calc(env(safe-area-inset-right) + 22px)
    calc(env(safe-area-inset-bottom) + 24px)
    calc(env(safe-area-inset-left) + 22px);
}
/* Halo ambre en haut (signature course de nuit) */
.app::before {
  content: '';
  position: absolute;
  top: -150px; left: 50%; transform: translateX(-50%);
  width: 440px; height: 360px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(255, 182, 72, 0.13), rgba(255, 182, 72, 0));
  pointer-events: none;
}

/* ---------- Barre PWA (install / mise à jour) ---------- */
.app-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 10px 12px 10px 14px;
  border-radius: 14px;
  background: #14232b; border: 1px solid rgba(255, 182, 72, 0.35);
}
.app-bar[hidden] { display: none; }
.app-bar-text {
  flex: 1; font-family: var(--mono); font-size: 12px; line-height: 1.35;
  color: var(--text-2);
}
.app-bar-action {
  flex: 0 0 auto; height: 36px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .04em;
  background: var(--accent); color: var(--dark); border: none;
}
.app-bar-action[hidden] { display: none; }
.app-bar-action:disabled { opacity: .6; cursor: default; }
.app-bar-close {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 14px;
}

/* ---------- Topbar : statut + chrono ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px; border-radius: 999px;
  font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .15em;
  white-space: nowrap;
  border: 1px solid rgba(255, 182, 72, 0.45);
  color: #c9d4d8; background: transparent;
}
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  background: transparent; border: 2px solid var(--accent);
}
.app.running .status { color: var(--accent-lit); background: rgba(255, 182, 72, 0.12); }
.app.running .status-dot {
  background: var(--accent); border: none;
  box-shadow: 0 0 10px rgba(255, 182, 72, 0.85);
}
.session { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.session-label { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.session-time { font-family: var(--mono); font-size: 19px; font-weight: 500; color: var(--text-2); margin-top: 4px; }

/* ---------- Centre : appuis L/R + cadence ---------- */
.stage {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; min-height: 0;
}
.pads { display: flex; gap: 18px; }
.pad {
  position: relative;
  width: 130px; height: 112px; border-radius: 26px;
  background: var(--surface); border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.pad-letter { font-family: var(--display); font-weight: 700; font-size: 58px; color: #586a72; line-height: 1; }
.pad-lit {
  position: absolute; inset: 0; opacity: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(72% 72% at 50% 50%, rgba(255, 182, 72, 0.3), rgba(255, 182, 72, 0));
  box-shadow: inset 0 0 0 2px rgba(255, 182, 72, 0.92), 0 0 46px rgba(255, 182, 72, 0.5);
  border-radius: 26px;
}
.pad-lit .pad-letter { color: var(--accent-lit); }

.readout { display: flex; flex-direction: column; align-items: center; }
.cadence {
  font-family: var(--display); font-weight: 700; font-size: 134px; line-height: .8;
  color: var(--text); letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.cadence-unit {
  font-family: var(--mono); font-weight: 500; font-size: 13px; letter-spacing: .34em;
  color: var(--text-3); margin-top: 16px;
}

/* ---------- Bas : contrôles ---------- */
.controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; }

.chips { display: flex; gap: 10px; }
.chip {
  flex: 1; height: 46px; border-radius: 13px;
  font-family: var(--display); font-weight: 600; font-size: 19px; cursor: pointer;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--line);
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.chip.selected {
  background: var(--accent); color: var(--dark); border-color: var(--accent);
  box-shadow: 0 4px 18px rgba(255, 182, 72, 0.3);
}

.adjust-row { display: flex; gap: 10px; }
.step {
  width: 66px; height: 60px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--line); color: #e7edef;
  font-family: var(--display); font-weight: 600; font-size: 34px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.step:active { background: #26363f; }
.tap {
  flex: 1; height: 60px; border-radius: 16px;
  background: var(--surface); border: 1px solid rgba(255, 255, 255, 0.09); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tap-title { font-family: var(--display); font-weight: 600; font-size: 20px; letter-spacing: .12em; color: #e7edef; }
.tap-sub { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: #7f9099; }

.sound-btn {
  height: 54px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
}
.sound-btn-label { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.sound-btn-value { flex: 1; text-align: left; font-family: var(--display); font-weight: 600; font-size: 19px; color: #e7edef; }
.sound-btn-chev { font-family: var(--mono); font-size: 16px; color: #7f9099; }

/* ---------- Bouton transport ---------- */
.start-btn {
  flex: 0 0 auto;
  height: 74px; border-radius: 20px; width: 100%; margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--display); font-weight: 700; font-size: 23px; letter-spacing: .08em;
  cursor: pointer; transition: background .18s, color .18s, box-shadow .18s;
}
.start-btn .start-icon { font-size: 20px; line-height: 1; }
.start-btn.is-idle { background: var(--accent); color: var(--dark); border: none; box-shadow: 0 10px 34px rgba(255, 182, 72, 0.34); }
.start-btn.is-running { background: transparent; color: var(--accent-lit); border: 2px solid var(--accent); box-shadow: none; }

/* ---------- Feuille réglages ---------- */
.scrim {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(4, 7, 9, 0.55);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--sheet);
  border-top-left-radius: 26px; border-top-right-radius: 26px;
  border-top: 1px solid var(--line);
  padding: 12px 22px calc(env(safe-area-inset-bottom) + 30px);
  transform: translateY(108%);
  transition: transform .34s cubic-bezier(.32, .72, .24, 1);
  box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.5);
}
.app.sheet-open .scrim { opacity: 1; pointer-events: auto; }
.app.sheet-open .sheet { transform: translateY(0); }

.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.24); margin: 0 auto 18px; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.sheet-title { font-family: var(--display); font-weight: 700; font-size: 27px; color: var(--text); }
.sheet-ok {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 13px; letter-spacing: .12em; color: var(--accent);
}

.sound-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 14px 16px; border-radius: 14px; margin-bottom: 8px; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid rgba(255, 255, 255, 0.07);
  transition: background .15s, border-color .15s;
}
.sound-row.selected { background: rgba(255, 182, 72, 0.1); border-color: var(--accent); }
.sound-row-info { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.sound-row-name { font-family: var(--display); font-weight: 600; font-size: 19px; color: var(--text-2); }
.sound-row.selected .sound-row-name { color: var(--text); }
.sound-row-desc { font-family: var(--mono); font-size: 12px; color: #7f9099; }
.sound-row-badge { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.sound-row.selected .sound-row-badge { color: var(--accent-lit); }

.divider { height: 1px; background: rgba(255, 255, 255, 0.07); margin: 16px 0; }
.setting-label { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; color: var(--text-3); }

.vol-cells { display: flex; gap: 8px; margin-top: 11px; }
.vol-cell {
  flex: 1; height: 42px; border-radius: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 400;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  transition: background .12s, color .12s, border-color .12s;
}
.vol-cell.filled { background: var(--accent); color: var(--dark); border-color: var(--accent); font-weight: 600; }
.vol-scale { display: flex; justify-content: space-between; margin-top: 6px; }
.vol-scale span { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--muted); }

.patterns { display: flex; gap: 8px; margin-top: 11px; }
.pattern {
  flex: 1; height: 48px; border-radius: 13px; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 18px;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--line);
  transition: background .15s, color .15s, border-color .15s;
}
.pattern.selected { background: var(--accent); color: var(--dark); border-color: var(--accent); }

/* ---------- Petits écrans : réduire le gigantisme ---------- */
@media (max-height: 720px) {
  .cadence { font-size: 104px; }
  .pad { width: 116px; height: 96px; }
  .stage { gap: 18px; }
}
@media (max-height: 620px) {
  .cadence { font-size: 84px; }
  .pad { height: 84px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .start-btn, .chip, .sound-row, .vol-cell, .pattern { transition: none; }
}
