/* Pointage — feuille d'heures personnelle */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url(fonts/barlow-condensed-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url(fonts/barlow-condensed-latin-600-normal.woff2) format("woff2"); }

:root {
  --bg: #edf0f2;
  --surface: #ffffff;
  --ink: #18212c;
  --muted: #5e6a78;
  --line: #d5dbe1;
  --blue: #1d5fa6;      /* basse pression : arrivée, progression */
  --blue-soft: #e3ecf6;
  --red: #b83a2c;       /* haute pression : fin, dépassement */
  --red-soft: #f8e6e3;
  --ok: #2f7a4b;
  --focus: #1d5fa6;
  --radius-s: 6px;
  --radius-l: 14px;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171e;
    --surface: #19212b;
    --ink: #e5eaf0;
    --muted: #93a0ae;
    --line: #2b3643;
    --blue: #6ea8e6;
    --blue-soft: #1c2c3f;
    --red: #e8796a;
    --red-soft: #3a2220;
    --ok: #6cc38e;
    --focus: #6ea8e6;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 "Barlow", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--blue); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
small { font-size: .82em; }
code { font-size: .92em; }

/* ---------- Barre du haut ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--cond); font-weight: 600; font-size: 1.35rem; letter-spacing: .01em;
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  position: relative; display: inline-block; width: 1.25rem; height: 1.25rem;
  border: 2px solid var(--ink); border-radius: 50%;
}
.brand-mark::after {           /* aiguille de manomètre */
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 2px; height: 45%; background: var(--red);
  transform-origin: 50% 0; transform: translateX(-50%) rotate(-135deg);
}
.brand-mark.big { width: 2.6rem; height: 2.6rem; border-width: 3px; margin-bottom: .5rem; }
.brand-mark.big::after { width: 3px; }
.topnav { display: flex; align-items: center; gap: 1.1rem; font-size: .95rem; }
.topnav a { color: var(--ink); text-decoration: none; }
.topnav a:hover { color: var(--blue); }
.topnav form { margin: 0; }

.page { max-width: 880px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.narrow .page { max-width: 420px; padding-top: 12vh; }
.page-title {
  font-family: var(--cond); font-weight: 600;
  font-size: clamp(1.75rem, 4vw, 2.3rem); line-height: 1.1; margin: 0;
}
h2 { font-family: var(--cond); font-weight: 600; font-size: 1.35rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }

/* ---------- Boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.6rem; padding: .45rem 1rem;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
  font: 500 1rem "Barlow", sans-serif; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--blue); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0d1620; } }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.linklike {
  background: none; border: 0; padding: 0; color: var(--ink);
  font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.topnav .linklike { text-decoration: none; }
.topnav .linklike:hover { color: var(--blue); }
.linklike.danger { color: var(--red); }

input[type=text], input[type=password], input[type=date], input[type=time], select {
  width: 100%; min-height: 2.6rem; padding: .4rem .6rem;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
  font: 500 1rem "Barlow", sans-serif; font-variant-numeric: tabular-nums;
}
input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
label { display: block; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
label > input { margin-top: .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--blue); }
.stack { display: grid; gap: 1rem; }

.flash { padding: .7rem .9rem; border-radius: var(--radius-s); border-left: 4px solid var(--ok); background: var(--surface); margin: 0 0 1.25rem; }
.flash-error { border-left-color: var(--red); background: var(--red-soft); }
.flash-warn { border-left-color: #c58a12; }

/* ---------- Connexion ---------- */
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
  padding: 2rem 1.5rem;
}
.auth-card h1 { font-family: var(--cond); font-weight: 600; font-size: 2rem; margin: 0 0 1rem; }
.auth-card form + form { margin-top: 1rem; }
.code-input { font-family: var(--cond); font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; }

/* ---------- Liste des semaines ---------- */
.index-head { margin-bottom: 2rem; }
.new-week {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem;
  margin-top: 1.25rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
}
.new-week label { flex: 1 1 9.5rem; font-weight: 500; }
.new-week .btn { flex: 0 0 auto; }
.index-head .flash { margin-top: 1rem; }

.empty { padding: 2rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-l); text-align: center; }

.month { margin-bottom: 1.5rem; }
.month summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .4rem 0; border-bottom: 2px solid var(--ink);
  cursor: pointer; list-style: none;
}
.month summary::-webkit-details-marker { display: none; }
.month summary::before {
  content: ""; align-self: center; flex: none;
  width: .5rem; height: .5rem; margin-right: -.4rem;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.month[open] summary::before { transform: rotate(45deg); }
.month-name { flex: 1; font-family: var(--cond); font-weight: 600; font-size: 1.5rem; }
.month-total { font-family: var(--cond); font-weight: 600; font-size: 1.5rem; }

.week-list { list-style: none; margin: 0; padding: 0; }
.week-row {
  display: grid; grid-template-columns: 3.2rem 1fr minmax(4rem, 9rem) 5.5rem;
  align-items: center; gap: 1rem;
  padding: .85rem .25rem; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.week-row:hover { background: var(--surface); }
.wk-num { font-family: var(--cond); font-weight: 600; font-size: 1.1rem; color: var(--muted); }
.wk-dates { font-weight: 500; }
.wk-dates small { display: block; color: var(--muted); font-weight: 400; }
.wk-total { font-family: var(--cond); font-weight: 600; font-size: 1.35rem; text-align: right; }
.wk-total small { display: block; font-size: .8rem; }
.over { color: var(--red); }

.wk-gauge, .gauge {
  position: relative; display: block; height: 6px; border-radius: 3px;
  background: var(--line); overflow: hidden;
}
.wk-fill, .gauge-fill { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .25s ease; }
.wk-fill.is-over, .gauge-fill.is-over { background: linear-gradient(90deg, var(--blue) 0 82%, var(--red) 82%); }
.p-0{width:0%}
.p-5{width:5%}
.p-10{width:10%}
.p-15{width:15%}
.p-20{width:20%}
.p-25{width:25%}
.p-30{width:30%}
.p-35{width:35%}
.p-40{width:40%}
.p-45{width:45%}
.p-50{width:50%}
.p-55{width:55%}
.p-60{width:60%}
.p-65{width:65%}
.p-70{width:70%}
.p-75{width:75%}
.p-80{width:80%}
.p-85{width:85%}
.p-90{width:90%}
.p-95{width:95%}
.p-100{width:100%}

/* ---------- Une semaine ---------- */
.week-nav { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; margin-bottom: 1.5rem; }
.week-nav a { text-decoration: none; }
.week-head {
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.week-kicker { margin: 0 0 .2rem; color: var(--muted); font-weight: 500; }

/* Le cadran : la seule pièce forte de l'interface */
.readout { display: grid; justify-items: end; gap: .35rem; min-width: 13rem; }
.readout-value {
  font-family: var(--cond); font-weight: 600;
  font-size: clamp(3.2rem, 9vw, 4.6rem); line-height: .9; letter-spacing: -.01em;
}
.readout .gauge { width: 100%; height: 8px; border-radius: 4px; }
.readout .gauge::after {        /* repère de la durée de référence */
  content: ""; position: absolute; right: 0; top: -3px; bottom: -3px; width: 2px; background: var(--ink);
}
.readout-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .2rem .8rem; color: var(--muted); font-size: .92rem; }
.readout-meta .over { font-weight: 500; }

.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
.hours { width: 100%; border-collapse: collapse; }
.hours thead th {
  padding: .7rem .75rem; text-align: left;
  font-weight: 500; font-size: .9rem; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.hours thead th:nth-child(2) { color: var(--blue); }
.hours thead th:nth-child(3) { color: var(--red); }
.hours td, .hours tbody th { padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.hours .num { text-align: right; }
.day-name { text-align: left; font-weight: 600; white-space: nowrap; }
.day-name span { display: block; }
.day-name small { display: block; font-weight: 400; color: var(--muted); }
.is-today .day-name { box-shadow: inset 4px 0 0 var(--blue); }
.hours input[type=time], .hours select { max-width: 8rem; }
.hours select { cursor: pointer; }
.t-start { border-bottom: 2px solid var(--blue) !important; }
.t-end { border-bottom: 2px solid var(--red) !important; }
.day-total { width: 7rem; }
.total-value { display: block; font-family: var(--cond); font-weight: 600; font-size: 1.45rem; }
.save-state { display: block; min-height: 1.1em; font-size: .78rem; color: var(--muted); }
.save-state.is-saved { color: var(--ok); }
.save-state.is-failed { color: var(--red); font-weight: 500; }
.has-error .total-value { color: var(--red); }
.row-error td { padding: .4rem .75rem .6rem; background: var(--red-soft); color: var(--red); font-size: .9rem; border-bottom: 1px solid var(--line); }
.hours tfoot th { padding: .9rem .75rem; text-align: right; font-weight: 500; color: var(--muted); }
.hours tfoot td { border-bottom: 0; padding: .9rem .75rem; text-align: right; font-family: var(--cond); font-weight: 600; font-size: 1.7rem; }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem; }
.sheet-actions p { margin: 0; font-size: .9rem; }
.danger-zone { margin-top: 2.5rem; text-align: right; }

/* ---------- Compte ---------- */
.panel { margin-top: 1.5rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.panel p { margin-top: 0; }
.inline-fields { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); align-items: end; }
.status-on { color: var(--ok); font-weight: 600; }
.status-off { color: var(--red); font-weight: 600; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .6rem; }
.steps small { display: block; }
.secret {
  display: block; margin: .4rem 0; padding: .6rem .8rem;
  font-family: var(--cond); font-size: 1.3rem; letter-spacing: .08em; word-break: break-all;
  background: var(--blue-soft); border-radius: var(--radius-s);
}

/* ---------- Téléphone : chaque jour devient une fiche ---------- */
@media (max-width: 640px) {
  .topnav { gap: .8rem; font-size: .9rem; }
  .week-head { grid-template-columns: 1fr; }
  .readout { justify-items: start; min-width: 0; }
  .readout-meta { justify-content: flex-start; }
  .week-row { grid-template-columns: 2.6rem 1fr 4.5rem; gap: .6rem; }
  .wk-gauge { grid-column: 2 / 4; grid-row: 2; }

  .hours thead { display: none; }
  .hours, .hours tbody, .hours tfoot { display: block; }
  .hours tr.day {
    display: grid; grid-template-columns: repeat(3, 1fr) 4.6rem; gap: .5rem;
    padding: .8rem .75rem; border-bottom: 1px solid var(--line);
  }
  .hours tr.day > * { padding: 0; border: 0; }
  .hours tr.day .day-name { grid-column: 1 / -1; display: flex; align-items: baseline; gap: .5rem; }
  .is-today .day-name { box-shadow: none; }
  .is-today { box-shadow: inset 4px 0 0 var(--blue); }
  .hours td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem; color: var(--muted); margin-bottom: .15rem; }
  .hours input[type=time], .hours select { max-width: none; padding: .35rem .3rem; font-size: .95rem; }
  .day-total { width: auto; align-self: end; }
  .row-error { display: block; }
  .row-error td { display: block; }
  .hours tfoot tr { display: flex; justify-content: space-between; align-items: baseline; }
  .hours tfoot th, .hours tfoot td { display: block; }
  .sheet-actions { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Semaines de cours ---------- */
.new-week .training-check { flex: 1 1 100%; font-weight: 500; }
.training-check small { margin-left: .25rem; }
.tag-training {
  display: inline-block; padding: .05rem .45rem; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue);
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
}
.training-cell { color: var(--muted); font-style: italic; }
.training-toggle { margin-top: 1.5rem; text-align: right; font-size: .95rem; }
.training-toggle + .danger-zone { margin-top: .75rem; }
@media (max-width: 640px) {
  .hours.is-training tr.day { grid-template-columns: 1fr auto; }
  .hours.is-training .training-cell { grid-column: 1; }
}
.hours.is-training thead th { color: var(--muted); }
