﻿/* ══════════════════════════════════════════════════════
   MINUTEUR.CSS — PhysEdBoard
   Layout : le timer dicte sa taille (pleine largeur),
            la cellule s'adapte à sa hauteur.
══════════════════════════════════════════════════════ */
:root {
  --bg:         #061428;
  --panel:      #0d2040;
  --panel2:     #112548;
  --panel-rgb:  13,32,64;
  --border:     #1a3a60;
  --border-hi:  #2a5282;
  --accent:     #ffd43b;
  --accent-rgb: 255,212,59;
  --accent-dim: #d1ab20;
  --red:        #ff3c3c;
  --text:       #ffffff;
  --text-mid:   rgba(255,255,255,0.70);
  --text-dim:   rgba(255,255,255,0.42);
  --dim:        #3a608a;
  --input-rgb:  4,14,32;
  --tr:         0.22s cubic-bezier(0.4, 0, 0.2, 1);

  --bar-h:   clamp(60px, 10vh, 96px);
  --gap:     clamp(6px, 0.8vw, 12px);
  --cell-px: clamp(12px, 2vw, 28px);
  --cell-py: clamp(12px, 2vw, 28px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; touch-action: manipulation; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  height: 100dvh;
  overflow: hidden;
}

/* ── Background layers ── */
.bg-layer    { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.bg-main     {
  background:
    radial-gradient(ellipse 130% 70% at 50% 115%, rgba(0,80,200,0.18) 0%, transparent 65%),
    radial-gradient(ellipse 60% 50% at 10% 0%,    rgba(0,50,130,0.12) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 0%,    rgba(0,50,130,0.12) 0%, transparent 55%),
    linear-gradient(180deg, #04101e 0%, #061428 40%, #091a34 100%);
}
.bg-vignette  { background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 35%, rgba(0,0,0,0.55) 100%); }
.bg-scanlines { background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.05) 2px, rgba(0,0,0,0.05) 4px); opacity: 0.4; }

/* ── App shell ── */
.app {
  position: relative; z-index: 2;
  width: 100%; height: 100dvh;
  display: flex; flex-direction: column;
}

/* ── Stage ── */
.stage {
  flex: 1; min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
   Largeur fixe, hauteur auto (dictée par le timer).
═══════════════════════════════════════════════════════ */
.min-layout {
  width: min(92vw, 1000px);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ═══════════ TIMER CELL ═══════════
   Hauteur auto — enveloppe le timer + progress + status.
   Padding réduit sur Y pour serrer au maximum.
═══════════════════════════════════ */
.min-timer-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: clamp(10px, 1.2vw, 18px);
  background: rgba(var(--panel-rgb), 0.60);
  border: 1px solid var(--border);
  border-top-color: var(--border-hi);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset;
  padding: var(--cell-py) var(--cell-px);
  gap: clamp(4px, 0.8vh, 10px);
  overflow: hidden;
}

/* ── Wrap : laisse le timer prendre toute la largeur ── */
.min-timer-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ══════════════════════════════════════════════
   LE GRAND TIMER
   font-size calculé par JS pour remplir exactement
   la largeur du wrap (moins le padding de la cellule).
   line-height serré = la cellule est juste assez haute.
══════════════════════════════════════════════ */
#time {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20vw;          /* valeur initiale — JS override immédiat */
  line-height: 0.88;
  letter-spacing: 0.04em;
  color: #ffffff;
  user-select: none;
  white-space: nowrap;
  display: block;
  text-align: center;
  text-shadow: 0 3px 0 rgba(0,0,0,0.70);
  transition: color 0.25s;
}
#time.warning {
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(0,0,0,0.65);
}
#time.danger {
  color: var(--red);
  text-shadow: 0 3px 0 rgba(0,0,0,0.65);
  animation: pulseFast 0.45s infinite alternate;
}
#time.done {
  color: var(--dim);
  text-shadow: 0 3px 0 rgba(0,0,0,0.5);
  animation: none;
}

/* ── Barre de progression ── */
.progress-track {
  width: 100%; height: 5px; flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  border-radius: 4px; overflow: visible; position: relative;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 4px;
  transition: width 0.12s linear, background 0.3s;
  position: relative;
  box-shadow: 0 0 10px rgba(var(--accent-rgb),0.5);
}
.progress-fill::after {
  content: ''; position: absolute; right: -4px; top: 50%;
  transform: translateY(-50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 22px rgba(var(--accent-rgb),0.4);
}
.progress-fill.warning        { background: var(--accent); }
.progress-fill.danger         { background: var(--red); box-shadow: 0 0 8px rgba(255,60,60,0.6); }
.progress-fill.danger::after  { background: var(--red); box-shadow: 0 0 12px var(--red); }

/* ── Status ── */
.min-status-row {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 100%;
}
.status-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: clamp(11px, 1.4vw, 15px); font-weight: 700;
  letter-spacing: 0.36em; text-transform: uppercase;
  color: var(--text-dim);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.status-dot.running {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(var(--accent-rgb), 0.35);
  animation: blink 1.1s infinite;
}
.status-dot.done { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ═══════════ BARRE DU BAS ═══════════ */
.min-bottom-row {
  display: flex;
  align-items: stretch;
  gap: var(--gap);
  height: var(--bar-h);
}

/* Spinner min/sec */
.min-spin {
  position: relative;
  flex: 1;
}
.min-spin input {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(24px, 4vw, 56px);
  line-height: 1;
  width: 100%; height: 100%;
  text-align: center;
  background: rgba(var(--input-rgb), 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  padding: clamp(4px, 1vh, 10px) clamp(28px, 3.5vw, 46px) clamp(4px, 1vh, 10px) 4px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield; appearance: textfield;
}
.min-spin input::-webkit-outer-spin-button,
.min-spin input::-webkit-inner-spin-button { -webkit-appearance: none; }
.min-spin input:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.07);
}
.spin-btns {
  position: absolute; top: 0; right: 0; bottom: 0; width: clamp(26px, 2.8vw, 40px);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  overflow: hidden;
  border-radius: 0 9px 9px 0;
}
.spin-btn {
  flex: 1;
  background: none; border: none; border-bottom: 1px solid var(--border); cursor: pointer;
  color: var(--text-dim); font-size: clamp(10px, 1.2vw, 15px); padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.14s, background 0.14s;
}
.spin-btn:last-child { border-bottom: none; }
.spin-btn:hover  { color: var(--accent); background: rgba(var(--accent-rgb), 0.10); }
.spin-btn:active { color: var(--accent); background: rgba(var(--accent-rgb), 0.20); }

.min-sep {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(18px, 3vw, 46px);
  color: rgba(255,255,255,0.22);
  flex-shrink: 0;
  line-height: 1;
  display: flex; align-items: center;
}

/* Boutons */
.btn {
  flex: 1;
  font-size: clamp(14px, 1.8vw, 24px);
  border-radius: clamp(7px, 0.8vw, 12px);
  padding: 0;
  height: 100%;
  cursor: pointer; transition: var(--tr); border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
}
.btn:active { transform: scale(0.97) translateY(1px) !important; }

.btn-set {
  background: transparent;
  color: var(--text-mid);
  border-color: var(--border-hi);
}
.btn-set:hover {
  border-color: rgba(var(--accent-rgb), 0.55);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.06);
}

.btn-main {
  background: var(--accent); color: #000;
  box-shadow: 0 3px 18px rgba(var(--accent-rgb),0.35), 0 1px 0 rgba(255,255,255,0.3) inset;
}
.btn-main:hover { filter: brightness(1.08); transform: translateY(-2px); }
.btn-main.is-running {
  background: rgba(18,34,66,0.95); color: rgba(255,255,255,0.78);
  border-color: rgba(255,255,255,0.12); box-shadow: none;
}
.btn-main.is-running:hover {
  background: rgba(28,50,90,0.95); color: #fff;
  border-color: rgba(255,255,255,0.22); filter: none; transform: translateY(-2px);
}
.btn-main.is-paused {
  background: transparent; color: var(--accent);
  border-color: rgba(var(--accent-rgb),0.48);
}
.btn-main.is-paused:hover {
  background: rgba(var(--accent-rgb),0.07);
  border-color: rgba(var(--accent-rgb),0.7); transform: translateY(-2px);
}
.btn-reset {
  background: transparent; color: var(--text-dim);
  border-color: var(--border);
}
.btn-reset:hover {
  background: rgba(255,60,60,0.08); color: var(--red);
  border-color: rgba(255,60,60,0.35); transform: translateY(-2px);
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — portrait / mobile
══════════════════════════════════════════════════════ */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  .min-layout { width: min(96vw, 600px); }

  :root { --bar-h: clamp(54px, 9vh, 80px); }

  .min-bottom-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: var(--gap);
  }
  .min-sep { display: none; }

  .min-spin input {
    font-size: clamp(20px, 6vw, 42px);
    padding: clamp(6px, 1.2vh, 10px) clamp(22px, 7vw, 36px) clamp(6px, 1.2vh, 10px) 4px;
  }
  .spin-btns { width: clamp(22px, 6.5vw, 34px); }
  .btn { font-size: clamp(16px, 4.5vw, 26px); }
}

@media (max-width: 380px) { .min-layout { width: 98vw; } }

@media (max-height: 460px) and (orientation: landscape) {
  :root { --bar-h: clamp(44px, 8vh, 58px); --gap: 5px; }
}

/* ══════════════════════════════════════════════════════
   INTRO OVERLAY 3-2-1-GO
══════════════════════════════════════════════════════ */
#introOverlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10,10,10,0.95);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(24px);
}
#introOverlay.visible { display: flex; animation: fadeIn 0.15s ease; }
#introRing {
  position: absolute;
  width: clamp(200px, 32vw, 460px); height: clamp(200px, 32vw, 460px);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.10);
}
#introRing.spin { animation: ringExpandFade 0.9s ease-out; }
#introNumber {
  font-family: 'Teko', sans-serif; font-weight: 700;
  font-size: clamp(180px, 30vw, 420px);
  color: var(--accent); line-height: 1;
  position: relative; z-index: 1;
  opacity: 0; transition: opacity 0.12s;
}
#introNumber.pop { color: var(--accent); animation: numPop 0.38s cubic-bezier(0.34,1.56,0.64,1) both; }
#introNumber.go  { color: #fff;          animation: numGo  0.44s cubic-bezier(0.34,1.3,0.64,1)  both; }

/* ══════════════════════════════════════════════════════
   SETUP MODAL
══════════════════════════════════════════════════════ */
.setup-overlay {
  position: fixed; inset: 0; z-index: 450;
  background: rgba(2,8,20,0.92);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(18px);
}
.setup-overlay.visible { display: flex; animation: fadeIn 0.18s ease; }
.setup-modal {
  background: #061428;
  border: 1px solid rgba(255,255,255,0.07);
  border-top: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  width: min(480px, 94vw); max-height: 92dvh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset, 0 40px 80px rgba(0,0,0,0.9);
  animation: modalIn 0.2s cubic-bezier(0.34,1.4,0.64,1);
  position: relative;
}
.setup-modal::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb),0.35) 40%, rgba(var(--accent-rgb),0.35) 60%, transparent);
}
.setup-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: clamp(12px,2vw,15px) clamp(14px,2.5vw,18px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02); flex-shrink: 0; margin-bottom: 10px;
}
.setup-ttl {
  flex: 1; font-size: clamp(12px, 2vw, 15px); font-weight: 700;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.setup-ttl i { color: var(--accent); opacity: 0.8; font-size: clamp(12px, 2vw, 15px); }
.setup-x {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: rgba(255,255,255,0.22); padding: 4px 10px; cursor: pointer; transition: all 0.15s;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: clamp(12px, 2vw, 15px); font-weight: 700; letter-spacing: 0.1em; min-height: 32px;
}
.setup-x:hover { border-color: var(--red); color: var(--red); }
.setup-body { overflow-y: auto; }
.setup-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; min-height: 52px;
  padding: clamp(8px, 1.5vh, 10px) clamp(14px, 2.5vw, 18px);
}
.setup-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.setup-lbl {
  font-size: clamp(12px, 2vw, 15px); font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text);
}
.setup-sub { font-size: clamp(12px, 2vw, 15px); letter-spacing: 0.06em; color: rgba(255,255,255,0.4); }
.setup-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 10px 0; }
.setup-time-inputs { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.setup-time-inputs .min-spin { width: 80px; }
.setup-time-inputs .min-spin input { font-size: 28px; padding: 4px 30px 4px 4px; }
.setup-sep {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px; color: rgba(255,255,255,0.2); padding: 0 2px;
}
.toggle {
  position: relative; display: inline-block;
  width: 46px; height: 26px; cursor: pointer; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border); border-radius: 26px;
  border: 1px solid rgba(255,255,255,0.08); transition: background 0.22s, border-color 0.22s;
}
.toggle-track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-mid);
  transition: transform 0.22s, background 0.22s; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent-dim); }
.toggle input:checked + .toggle-track::after { transform: translateX(20px); background: #000; }
.setup-ftr {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: clamp(10px,1.8vh,13px) clamp(14px,2.5vw,18px);
  border-top: 1px solid rgba(255,255,255,0.05); flex-shrink: 0; margin-top: 10px;
}
.setup-cancel {
  font-family: 'Barlow Condensed', sans-serif; font-size: clamp(12px, 2vw, 15px); font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  padding: 10px 16px; border-radius: 8px;
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.45); cursor: pointer; transition: all 0.15s; min-height: 40px;
}
.setup-cancel:hover { border-color: rgba(255,255,255,0.3); color: rgba(255,255,255,0.8); }
.setup-apply {
  font-family: 'Barlow Condensed', sans-serif; font-size: clamp(12px, 2vw, 15px); font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  padding: 10px 22px; border-radius: 8px;
  background: var(--accent); color: #000; border: none;
  box-shadow: 0 4px 16px rgba(var(--accent-rgb),0.25);
  cursor: pointer; transition: all 0.15s; min-height: 40px;
}
.setup-apply:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ── Keyframes ── */
@keyframes pulseFast      { from { opacity: 1; }    to { opacity: 0.55; } }
@keyframes blink          { 0%, 100% { opacity: 1; } 50% { opacity: 0.1; } }
@keyframes fadeIn         { from { opacity: 0; }    to { opacity: 1; } }
@keyframes numPop         { from { transform: scale(0.38) rotate(-6deg); filter: blur(14px); opacity: 0; } to { transform: scale(1) rotate(0); filter: none; opacity: 1; } }
@keyframes numGo          { from { transform: scale(0.72); filter: blur(8px); opacity: 0; } to { transform: scale(1); filter: none; opacity: 1; } }
@keyframes ringExpandFade { from { transform: scale(0.6); opacity: 0.8; } to { transform: scale(1.6); opacity: 0; } }
@keyframes modalIn        { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }