/* ══════════════════════════════════════════════════════════════
   MATRIX TRAINING // INTERVAL TIMER
   ══════════════════════════════════════════════════════════════ */

@font-face{
  font-family:'DotMatrix';
  src:url('../fonts/dotmatrix.ttf') format('truetype');
  font-weight:400;font-style:normal;font-display:swap;
}
@font-face{
  font-family:'DotMatrix';
  src:url('../fonts/dotmatrix-bold.ttf') format('truetype');
  font-weight:700;font-style:normal;font-display:swap;
}
@font-face{
  font-family:'Alvera';
  src:url('../fonts/alvera-square.ttf') format('truetype');
  font-weight:400;font-style:normal;font-display:swap;
}

:root{
  --bg:#040806;
  --bg-2:#07110c;
  --panel:rgba(14,32,22,.42);
  --line:rgba(68,240,106,.28);
  --line-soft:rgba(68,240,106,.14);

  --green:#44f06a;
  --green-hi:#9cffb7;
  --green-dim:rgba(68,240,106,.42);
  --green-ghost:rgba(68,240,106,.13);
  --amber:#ffb648;
  --amber-ghost:rgba(255,182,72,.14);
  --red:#ff4242;
  --red-ghost:rgba(255,66,66,.16);

  --accent:var(--green);
  --accent-ghost:var(--green-ghost);

  --ui:'Alvera','Eurostile','Bahnschrift',ui-monospace,'SF Mono',Menlo,monospace;
  --jpf:'Hiragino Sans','Yu Gothic','Noto Sans JP','Meiryo',sans-serif;

  --sat:env(safe-area-inset-top,0px);
  --sab:env(safe-area-inset-bottom,0px);
  --sal:env(safe-area-inset-left,0px);
  --sar:env(safe-area-inset-right,0px);
}

*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}

html,body{height:100%}
body{
  background:var(--bg);
  color:var(--green);
  font-family:var(--ui);
  overflow:hidden;
  overscroll-behavior:none;
  letter-spacing:.06em;
  -webkit-font-smoothing:antialiased;
  user-select:none;-webkit-user-select:none;
}
body::before{
  content:'';position:fixed;inset:0;z-index:0;pointer-events:none;
  background:
    radial-gradient(120% 80% at 50% 0%,rgba(68,240,106,.10),transparent 60%),
    radial-gradient(130% 100% at 50% 120%,rgba(68,240,106,.07),transparent 60%),
    var(--bg-2);
}

#rain{position:fixed;inset:0;z-index:1;opacity:.3;pointer-events:none;transition:opacity .4s}
body.running #rain{opacity:.17}

.crt{
  position:fixed;inset:0;z-index:60;pointer-events:none;
  background:repeating-linear-gradient(to bottom,rgba(0,0,0,0) 0 2px,rgba(0,0,0,.28) 2px 3px);
  mix-blend-mode:multiply;opacity:.55;
}
.crt::after{
  content:'';position:absolute;inset:0;
  background:radial-gradient(110% 80% at 50% 50%,transparent 45%,rgba(0,0,0,.65) 100%);
}

/* ─────────── structure ─────────── */
#app{position:relative;z-index:10;height:100dvh;height:100vh}
@supports (height:100dvh){#app{height:100dvh}}

.screen{
  position:absolute;inset:0;
  display:none;flex-direction:column;
  padding:calc(10px + var(--sat)) calc(14px + var(--sar)) calc(10px + var(--sab)) calc(14px + var(--sal));
  gap:10px;
}
.screen.is-active{display:flex;animation:boot .34s ease-out}
@keyframes boot{from{opacity:0;transform:translateY(6px) scale(.995)}to{opacity:1;transform:none}}

.jp{font-family:var(--jpf);letter-spacing:.14em;font-weight:400}
.dot{font-family:'DotMatrix',var(--ui)}

/* ─────────── barre de titre ─────────── */
.bar{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;flex:0 0 auto}
.bar-title h1{
  font-size:clamp(14px,4.2vw,19px);font-weight:400;line-height:1;
  letter-spacing:.14em;color:var(--green-hi);
  text-shadow:0 0 12px rgba(68,240,106,.45);
}
.bar-title .jp{font-size:10px;opacity:.6;margin-top:4px;display:block}
.bar::after{content:none}

.bar-tools{display:flex;gap:8px}
.icon-btn{
  width:34px;height:34px;display:grid;place-items:center;
  background:var(--panel);border:1px solid var(--line);border-radius:7px;
  color:var(--green);cursor:pointer;
}
.icon-btn svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.icon-btn .ico-sound-off{display:none}
.icon-btn[aria-pressed="false"]{color:var(--green-dim);border-color:var(--line-soft)}
.icon-btn[aria-pressed="false"] .ico-sound-on{display:none}
.icon-btn[aria-pressed="false"] .ico-sound-off{display:block}

.bar-round{text-align:right;line-height:1}
.round-val{font-family:'DotMatrix',var(--ui);font-size:clamp(20px,6vw,28px);display:block;color:var(--accent);text-shadow:0 0 14px var(--accent-ghost)}
.round-val i{font-style:normal;opacity:.4;margin:0 2px}
.round-val span{opacity:.55}
.bar-round .lbl{font-size:8px;opacity:.55;letter-spacing:.2em;display:block;margin-top:5px}
.bar-round .lbl .jp{font-size:8px;margin-left:4px}

/* ─────────── panneaux ─────────── */
.panel{
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:10px;
  padding:10px 12px;
  position:relative;
  backdrop-filter:blur(2px);
}
.panel::before,.panel::after{
  content:'';position:absolute;width:7px;height:7px;border:1px solid var(--accent);opacity:.55;
}
.panel::before{top:-1px;left:-1px;border-right:0;border-bottom:0}
.panel::after{bottom:-1px;right:-1px;border-left:0;border-top:0}

.lbl{font-size:9px;letter-spacing:.22em;opacity:.65}
.preview-head,.picker-head,.next-head{
  display:flex;align-items:baseline;gap:7px;
  border-bottom:1px dashed var(--line-soft);padding-bottom:6px;margin-bottom:8px;
}
.preview-head .jp,.next-head .jp{font-size:9px;opacity:.45}

/* ═══════════════ ACCUEIL ═══════════════ */
.home-body{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:10px}
.home-right{display:flex;flex-direction:column;gap:10px;min-height:0;flex:0 1 auto}

/* molettes */
.pickers{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;padding:10px 8px;flex:1 1 auto;min-height:0}
.picker{position:relative;display:flex;flex-direction:column;min-height:0}
.picker .picker-head{justify-content:center;gap:5px;flex-wrap:wrap;margin-bottom:6px;border:0;padding:0}
.picker .picker-head .lbl{font-size:9px;opacity:.8}
.picker .picker-head .jp{font-size:8px;opacity:.45}

.picker-stage{position:relative;flex:1 1 auto;min-height:112px}
.picker-wheel{
  position:absolute;inset:0;
  overflow-y:scroll;scroll-snap-type:y mandatory;
  scrollbar-width:none;-ms-overflow-style:none;
  touch-action:pan-y;outline:none;
  -webkit-mask-image:linear-gradient(to bottom,transparent,#000 24%,#000 76%,transparent);
  mask-image:linear-gradient(to bottom,transparent,#000 24%,#000 76%,transparent);
}
.picker-wheel::-webkit-scrollbar{display:none}
.picker-wheel:focus-visible{box-shadow:0 0 0 1px var(--accent)}
.picker-list{list-style:none}
.picker-list li{
  height:var(--item-h,42px);
  display:flex;align-items:center;justify-content:center;
  scroll-snap-align:center;scroll-snap-stop:always;
  font-family:'DotMatrix',var(--ui);
  font-size:21px;line-height:1;color:var(--green);
  opacity:.22;transform:scale(.8);
  transition:opacity .16s,transform .16s,color .16s,text-shadow .16s;
  cursor:pointer;white-space:nowrap;
}
.picker-list li.n1{opacity:.45;transform:scale(.9)}
.picker-list li.n2{opacity:.3;transform:scale(.84)}
.picker-list li.sel{
  opacity:1;transform:scale(1.22);color:var(--green-hi);
  text-shadow:0 0 14px rgba(68,240,106,.7),0 0 34px rgba(68,240,106,.3);
}
.picker-window{
  position:absolute;left:-3px;right:-3px;top:50%;height:var(--item-h,42px);
  transform:translateY(-50%);
  border-top:1px solid var(--line);border-bottom:1px solid var(--line);
  background:linear-gradient(90deg,var(--green-ghost),transparent 18%,transparent 82%,var(--green-ghost));
  pointer-events:none;
}
.picker-window::before,.picker-window::after{
  content:'';position:absolute;top:50%;width:5px;height:5px;margin-top:-2.5px;
  background:var(--green);box-shadow:0 0 8px var(--green);
}
.picker-window::before{left:2px}
.picker-window::after{right:2px}

/* aperçu */
.preview{flex:0 0 auto}
.preview-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.dot-sm{font-family:'DotMatrix',var(--ui);font-size:clamp(17px,5.4vw,23px);color:var(--green-hi);text-shadow:0 0 12px rgba(68,240,106,.4)}
.preview-total{display:flex;align-items:center;gap:6px;font-size:12px;opacity:.75}
.preview-total .ico{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round}
#pv-bar{margin-top:9px}

/* barres à segments */
.segbar{display:flex;gap:3px;height:9px}
.segbar i{
  flex:1 1 0;background:var(--green-ghost);border-radius:1px;
  box-shadow:inset 0 0 0 1px rgba(68,240,106,.1);
}
.segbar i.on{background:var(--accent);box-shadow:0 0 7px var(--accent-ghost),0 0 2px var(--accent)}
.segbar i.blink{animation:seg .55s steps(1,end) infinite}
@keyframes seg{0%,49%{background:var(--accent);box-shadow:0 0 9px var(--accent)}50%,100%{background:var(--green-ghost);box-shadow:none}}
.segbar i.amber{background:var(--amber);box-shadow:0 0 7px var(--amber-ghost)}
#screen-run.warn .segbar i.blink{animation-name:segred}
@keyframes segred{0%,49%{background:var(--red);box-shadow:0 0 10px var(--red)}50%,100%{background:var(--red-ghost);box-shadow:none}}
#screen-run.warn .clock{color:var(--red);text-shadow:0 0 20px rgba(255,66,66,.55),0 0 60px rgba(255,66,66,.25)}
.segbar.big{height:15px;gap:4px}
.segbar.big i{border-radius:2px}
.segbar.thin{height:7px;gap:2px}

/* CTA */
.cta{
  flex:0 0 auto;width:100%;
  background:linear-gradient(180deg,rgba(68,240,106,.17),rgba(68,240,106,.07));
  border:1px solid var(--green);border-radius:10px;
  color:var(--green-hi);font-family:var(--ui);
  padding:14px 10px;cursor:pointer;
  display:flex;flex-direction:column;align-items:center;gap:4px;
  box-shadow:0 0 22px rgba(68,240,106,.16),inset 0 0 18px rgba(68,240,106,.08);
  position:relative;overflow:hidden;
}
.cta::after{
  content:'';position:absolute;top:0;left:-60%;width:40%;height:100%;
  background:linear-gradient(90deg,transparent,rgba(156,255,183,.18),transparent);
  animation:sweep 3.4s ease-in-out infinite;
}
@keyframes sweep{0%{left:-60%}55%,100%{left:120%}}
.cta:active{transform:translateY(1px);background:rgba(68,240,106,.26)}
.cta-main{font-size:clamp(15px,4.6vw,19px);letter-spacing:.2em;text-shadow:0 0 14px rgba(68,240,106,.55)}
.cta .jp{font-size:9px;opacity:.6}
.cta.slim{padding:11px 10px}
.cta.ghost{background:transparent;border-color:var(--line);color:var(--green);box-shadow:none}
.cta.ghost::after{display:none}

/* historique */
.history{flex:0 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.history .preview-head{justify-content:space-between}
.mini-btn{
  margin-left:auto;background:transparent;border:1px solid var(--line-soft);
  color:var(--green-dim);font-family:var(--ui);font-size:8px;letter-spacing:.16em;
  padding:3px 7px;border-radius:4px;cursor:pointer;
}
.mini-btn:active{color:var(--red);border-color:var(--red)}
.history-stats{display:flex;gap:14px;font-size:10px;opacity:.7;margin-bottom:7px;flex-wrap:wrap}
.history-stats b{font-family:'DotMatrix',var(--ui);font-size:14px;color:var(--green-hi);margin-right:4px}
.history-list{list-style:none;overflow-y:auto;scrollbar-width:thin;display:flex;flex-direction:column;gap:5px}
.history-list li{
  display:flex;align-items:center;gap:8px;font-size:10px;
  padding:5px 7px;border:1px solid var(--line-soft);border-radius:5px;opacity:.85;
}
.history-list li .h-date{font-family:'DotMatrix',var(--ui);font-size:12px;opacity:.85}
.history-list li .h-f{margin-left:auto;opacity:.6}
.history-list li.partial{border-style:dashed;color:var(--amber);border-color:rgba(255,182,72,.3)}
.history-empty{font-size:10px;opacity:.4;padding:4px 0}

.foot{
  flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;gap:10px;
  font-size:8px;letter-spacing:.18em;opacity:.35;padding-top:2px;
}
.foot .jp{font-size:8px}

/* ═══════════════ SÉANCE ═══════════════ */
#screen-run[data-phase="prep"]{--accent:var(--green-hi);--accent-ghost:rgba(156,255,183,.16)}
#screen-run[data-phase="work"]{--accent:var(--green);--accent-ghost:var(--green-ghost)}
#screen-run[data-phase="rest"]{--accent:var(--amber);--accent-ghost:var(--amber-ghost)}
#screen-run[data-phase="done"]{--accent:var(--red);--accent-ghost:var(--red-ghost)}
#screen-run{color:var(--accent);transition:color .3s}
#screen-run .panel{border-color:color-mix(in srgb,var(--accent) 30%,transparent)}

.run-grid{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:12px}
.run-main{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;justify-content:center;gap:12px}
.run-side{flex:0 0 auto;display:flex;flex-direction:column;gap:12px}

.phase-card{display:flex;align-items:center;gap:11px;padding:11px 13px}
.phase-ico{width:28px;height:28px;flex:0 0 auto;color:var(--accent);filter:drop-shadow(0 0 7px var(--accent-ghost))}
.phase-ico svg{width:100%;height:100%;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.phase-ico.sm{width:21px;height:21px}
.phase-txt{display:flex;flex-direction:column;gap:2px;min-width:0}
.phase-txt b{font-size:clamp(15px,4.4vw,19px);font-weight:400;letter-spacing:.18em;text-shadow:0 0 12px var(--accent-ghost)}
.phase-txt i{font-size:10px;opacity:.55;font-style:normal}
.phase-dur{margin-left:auto;font-family:'DotMatrix',var(--ui);font-size:19px;opacity:.85}

.clock-wrap{
  display:flex;justify-content:center;align-items:center;min-height:0;position:relative;
}
.clock-wrap::before{
  content:'';position:absolute;inset:-14% -6%;pointer-events:none;
  background:radial-gradient(60% 60% at 50% 50%,rgba(4,8,6,.92),rgba(4,8,6,.55) 55%,transparent 78%);
}
.clock{position:relative}
.clock{
  font-size:clamp(66px,23vw,150px);line-height:.92;letter-spacing:.02em;
  color:var(--accent);
  text-shadow:0 0 18px var(--accent-ghost),0 0 55px var(--accent-ghost),0 0 3px rgba(255,255,255,.22);
  font-variant-numeric:tabular-nums;
}
.clock.pulse{animation:cpulse .5s steps(1,end) infinite}
@keyframes cpulse{0%,54%{opacity:1}55%,100%{opacity:.34}}
#screen-run.paused .clock{animation:cpulse 1.1s steps(1,end) infinite}

.meta-row{display:flex;align-items:flex-end;justify-content:space-between;gap:10px}
.meta-row.tight{margin-top:7px}
.meta-lbl{display:flex;flex-direction:column;gap:1px}
.meta-lbl b{font-size:10px;font-weight:400;letter-spacing:.2em;opacity:.8}
.meta-lbl i{font-size:9px;opacity:.42;font-style:normal}
.meta-val{display:flex;align-items:baseline;gap:5px}
.meta-val b{font-family:'DotMatrix',var(--ui);font-size:22px;font-weight:400}
.meta-val i{font-size:10px;opacity:.45;font-style:normal}

.next-card .next-body{display:flex;align-items:center;gap:9px}
.next-card .phase-txt b{font-size:14px}
.next-card .phase-dur{font-size:16px}
.next-card.hidden{visibility:hidden}

/* commandes */
.controls{display:grid;grid-template-columns:1fr 1.25fr 1fr;gap:10px;align-items:center}
.ctrl{
  display:flex;flex-direction:column;align-items:center;gap:3px;
  background:var(--panel);border:1px solid var(--line);border-radius:10px;
  color:var(--green);font-family:var(--ui);padding:9px 4px;cursor:pointer;
}
.ctrl .ctrl-ico{width:26px;height:26px;display:grid;place-items:center}
.ctrl svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.ctrl svg rect,.ctrl .ico-play path{fill:currentColor;stroke:none}
.ctrl .ctrl-lbl{font-size:9px;letter-spacing:.16em}
.ctrl .jp{font-size:8px;opacity:.45}
.ctrl.primary{
  color:var(--accent);border-color:var(--accent);
  background:linear-gradient(180deg,var(--accent-ghost),transparent);
  box-shadow:0 0 16px var(--accent-ghost);padding:13px 4px;
}
.ctrl.primary svg{width:27px;height:27px}
.ctrl:active{background:var(--green-ghost)}
.ctrl .ico-play{display:none}
#screen-run.paused .ctrl .ico-play{display:block}
#screen-run.paused .ctrl .ico-pause{display:none}
#btn-stop.arm{color:var(--red);border-color:var(--red);box-shadow:0 0 14px var(--red-ghost);animation:cpulse .6s steps(1,end) infinite}

/* ═══════════════ FIN ═══════════════ */
#screen-done{--accent:var(--red);--accent-ghost:var(--red-ghost);align-items:center;justify-content:center}
.done-body{display:flex;flex-direction:column;align-items:center;gap:16px;width:100%;max-width:460px}
.done-head{
  font-size:clamp(54px,19vw,118px);line-height:1;color:var(--red);
  text-shadow:0 0 20px rgba(255,66,66,.45),0 0 60px rgba(255,66,66,.22);
}
.done-h{
  font-size:clamp(13px,4vw,17px);font-weight:400;letter-spacing:.22em;
  display:flex;flex-direction:column;align-items:center;gap:5px;color:var(--green-hi);
}
.done-h .jp{font-size:10px;opacity:.5;font-style:normal}
.done-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;width:100%;text-align:center;color:var(--green)}
.done-stats .stat{display:flex;flex-direction:column;gap:3px;padding:4px 2px}
.done-stats b{font-family:'DotMatrix',var(--ui);font-size:clamp(22px,7vw,32px);font-weight:400;color:var(--green-hi);text-shadow:0 0 14px rgba(68,240,106,.35)}
.done-stats .lbl{font-size:8px}
.done-stats .jp{font-size:8px;opacity:.4;font-style:normal}
.done-actions{display:flex;flex-direction:column;gap:9px;width:100%}

/* ═══════════════ PAYSAGE ═══════════════ */
@media (orientation:landscape) and (max-height:560px){
  .screen{padding-top:calc(8px + var(--sat));padding-bottom:calc(8px + var(--sab));gap:8px}
  .bar-title .jp{display:none}

  .home-body{flex-direction:row;gap:12px}
  .pickers{flex:1 1 56%;grid-template-columns:repeat(3,1fr)}
  .picker-stage{min-height:0}
  .home-right{display:flex;flex-direction:column;gap:9px;flex:1 1 44%;min-width:0}
  .foot{display:none}

  .run-grid{flex-direction:row;align-items:stretch;gap:14px}
  .run-main{flex:1 1 58%;justify-content:center;gap:9px}
  .run-side{flex:1 1 42%;justify-content:space-between;min-width:0}
  .clock{font-size:min(15vw,21vh)}
  .controls{grid-template-columns:1fr 1.2fr 1fr}
  .ctrl .jp{display:none}

  .done-body{max-width:none;display:grid;grid-template-columns:1fr 1fr;align-items:center;gap:10px 22px}
  .done-head{grid-column:1;font-size:min(13vw,17vh)}
  .done-h{grid-column:1}
  .done-stats{grid-column:2;grid-row:1/3}
  .done-actions{grid-column:1/3;flex-direction:row}
}

/* petits écrans */
@media (max-height:680px) and (orientation:portrait){
  .history{display:none}
  .foot{font-size:7px}
}
@media (max-height:560px) and (orientation:portrait){
  .preview .segbar{display:none}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important}
  .segbar i.blink,.clock.pulse{opacity:1}
}
