/* Mon carnet de sommeil — Kiffe ton Cycle */

@font-face {
  font-family: 'Raleway';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/raleway-latin-wght-normal.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'Raleway';
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/raleway-latin-wght-italic.woff2') format('woff2-variations');
}

:root {
  --bg: #FDFBE9;
  --card-bg: #ffffff;
  --text: #2c2a20;
  --text-soft: #6b6857;
  --accent: #DC000C;
  --accent-deep: #A80E16;
  --accent-soft: #FCE7F0;
  --border: #ECE8D0;
  --radius: 20px;
  --radius-sm: 12px;
  --chart-grid: #ECE8D0;
  --chart-faint: #E7A9B4;
  /* Niveaux de nuit sur la bande des jours (léger -> fort) */
  --lvl-1: #FCE7F0;
  --lvl-2: #F0929E;
  --lvl-3: #A80E16;
}

* { box-sizing: border-box; }
html { font-size: 100%; } /* Modifié par le réglage de taille du texte (A- / A+) */
html, body { margin: 0; padding: 0; }

/* Accessibilité : focus clavier très visible (basse vision, navigation clavier).
   Anneau foncé avec décalage, lisible aussi bien sur crème que sur rouge. */
:focus-visible {
  outline: 3px solid #111111;
  outline-offset: 2px;
  border-radius: 4px;
}
a:focus-visible, button:focus-visible, [role="radio"]:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 3px solid #111111;
  outline-offset: 2px;
}

/* Respecte la préférence système « réduire les animations ». */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  font-family: 'Raleway', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.page {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
}

/* Réglage de la taille du texte (accessibilité) */
.a11y-bar { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; z-index: 5; }
.a11y-btn {
  font-family: inherit; font-weight: 800; font-size: 0.95rem; line-height: 1;
  width: 42px; height: 42px; border-radius: 10px;
  border: 2px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.a11y-btn .a11y-plus { font-size: 1.25em; }
.a11y-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.a11y-btn:disabled { opacity: 0.35; cursor: default; }

.site-header { text-align: center; padding: 4px 0 18px; }
.site-header .logo { height: 42px; width: auto; }

h1 { font-size: 1.55rem; font-weight: 800; margin: 0 0 8px; text-align: center; line-height: 1.25; }

/* Bandeau confidentialité */
.privacy-banner {
  background: var(--accent-soft);
  border: 1px solid #F3C9D8;
  color: var(--accent-deep);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
}

/* Boutons */
.btn {
  font-family: inherit; font-weight: 700; font-size: 0.98rem;
  border-radius: 999px; border: none; padding: 13px 24px; cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(220,0,12,0.25); }
.btn-block { width: 100%; margin: 4px 0 20px; }
.btn-ghost { background: transparent; color: var(--accent-deep); border: 2px solid var(--border); padding: 10px 18px; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-back { border-color: transparent; padding-left: 6px; }
.local-note { color: var(--text-soft); font-size: 0.82rem; text-align: center; margin: 4px auto 0; max-width: 46ch; }
.empty { color: var(--text-soft); text-align: center; padding: 22px 8px; background: var(--card-bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); }

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.cycle-heading { font-size: 1.15rem; font-weight: 800; margin: 0; text-align: center; flex: 1; }

/* Bande des jours */
.date-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 12px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.date-chip {
  position: relative; flex: 0 0 auto; min-width: 48px; padding: 7px 4px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 12px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px; scroll-snap-align: center;
}
.date-chip .chip-dow { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; color: var(--text-soft); }
.date-chip .chip-dom { font-size: 1rem; font-weight: 800; line-height: 1; }
.date-chip.has-data.lvl-1 { background: var(--lvl-1); }
.date-chip.has-data.lvl-2 { background: var(--lvl-2); }
.date-chip.has-data.lvl-3 { background: var(--lvl-3); color: #fff; }
.date-chip.has-data.lvl-3 .chip-dow { color: rgba(255,255,255,0.85); }
.date-chip.has-data.lvl-0 { background: #fff; border-style: dashed; }
.date-chip.is-today { border-color: var(--accent); }
.date-chip.is-active { border: 2px solid var(--accent-deep); }
.chip-regles {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent-deep); color: #fff; font-size: 0.6rem; font-weight: 800;
  width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* Navigation par jour + repère de cycle */
.entry-daynav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 14px; }
.entry-date { text-align: center; flex: 1; }
.entry-date-label { display: block; font-weight: 800; font-size: 1.1rem; }
.cycle-badge { display: inline-block; margin-top: 5px; font-size: 0.82rem; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; }
.nav-arrow {
  font-family: inherit; font-size: 1.6rem; line-height: 1; font-weight: 700;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; color: var(--accent-deep); cursor: pointer;
}
.nav-arrow:disabled { opacity: 0.3; cursor: default; }
.tap-hint { color: var(--text-soft); font-size: 0.82rem; text-align: center; margin: 2px 0 14px; }

/* Cartes de champ (saisie) */
.field-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px 16px; margin-bottom: 12px;
}
.field-title {
  font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-deep); margin: 0 0 10px;
}
.field-sublabel { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; }

/* Échelle 1..5 */
.scale { display: flex; gap: 6px; }
.scale-btn {
  flex: 1; min-height: 48px; font-family: inherit; font-weight: 800; font-size: 1.05rem;
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  border-radius: 12px; cursor: pointer;
}
.scale-btn:hover { border-color: var(--accent); }
.scale-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale-ends { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.76rem; color: var(--text-soft); }

/* Choix (endormissement, réveils) */
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-btn {
  flex: 1 1 auto; min-height: 44px; font-family: inherit; font-weight: 700; font-size: 0.92rem;
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: 8px 16px; cursor: pointer;
}
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Bascules (facteurs, glaire, règles) */
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-chip {
  font-family: inherit; font-weight: 700; font-size: 0.9rem; min-height: 44px;
  border: 1.5px solid var(--border); background: #fff; color: var(--text);
  border-radius: 999px; padding: 9px 16px; cursor: pointer;
}
.toggle-chip:hover { border-color: var(--accent); }
.toggle-chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }
.toggle-chip.is-on::before { content: '✓ '; font-weight: 800; }

.score-field { display: flex; align-items: center; gap: 10px; }
.score-input {
  width: 120px; font-family: inherit; font-size: 1.1rem; font-weight: 700; color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: #fff; text-align: center;
}
.score-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.score-suffix { font-weight: 700; color: var(--text-soft); }

.reperes-hint { color: var(--text-soft); font-size: 0.78rem; margin: 8px 0 12px; }
.startdate-field { margin: 4px 0 12px; }
.date-input {
  font-family: inherit; font-size: 0.95rem; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  background: #fff; width: 100%; max-width: 280px;
}
.date-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.start-hint { color: var(--text-soft); font-size: 0.78rem; margin: 6px 0 0; }
.note-input {
  width: 100%; font-family: inherit; font-size: 0.95rem; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; resize: vertical;
}
.note-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.entry-footer { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.entry-footer .btn { flex: 1 1 auto; }

/* Bilan */
.bilan-scope { color: var(--text-soft); text-align: center; margin: 0 0 14px; font-size: 0.9rem; }
.bilan-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 20px; margin-bottom: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.03); }
.bilan-h { font-size: 1.05rem; font-weight: 800; margin: 0 0 8px; }
.bilan-synthese { font-weight: 700; color: var(--accent-deep); margin: 0 0 12px; }
.soft { color: var(--text-soft); font-size: 0.88rem; margin: 0 0 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart-legend { font-size: 0.8rem; color: var(--text-soft); text-align: center; margin: 8px 0 0; }
.legend-avg, .legend-faint { display: inline-block; width: 18px; height: 3px; vertical-align: middle; border-radius: 2px; }
.legend-avg { background: var(--accent); }
.legend-faint { background: var(--chart-faint); }

.compare { display: flex; gap: 12px; margin-top: 12px; }
.compare-box { flex: 1; text-align: center; border-radius: var(--radius-sm); padding: 16px 10px; background: var(--bg); border: 1px solid var(--border); }
.compare-box.strong { background: var(--accent-soft); border-color: #F3C9D8; }
.compare-num { display: block; font-size: 2rem; font-weight: 800; color: var(--accent-deep); }
.compare-cap { font-size: 0.8rem; color: var(--text-soft); }

/* Ce qui a pu jouer */
.factor-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.factor-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.factor-label { font-weight: 700; font-size: 0.95rem; }
.factor-vals { font-size: 0.8rem; color: var(--text-soft); grid-column: 1 / 2; }
.factor-delta { font-size: 0.82rem; font-weight: 800; grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; white-space: nowrap; }
.factor-delta.down { color: var(--accent); }
.factor-delta.up { color: #1a7a4b; }
.factor-delta.flat { color: var(--text-soft); }

/* Endormissement et réveils */
.habits { display: flex; gap: 12px; flex-wrap: wrap; }
.habit { flex: 1 1 140px; text-align: center; border-radius: var(--radius-sm); padding: 16px 10px; background: var(--bg); border: 1px solid var(--border); }
.habit-num { display: block; font-size: 1.7rem; font-weight: 800; color: var(--accent-deep); }
.habit-cap { font-size: 0.8rem; color: var(--text-soft); }

.bilan-disclaimer { color: var(--text-soft); font-size: 0.85rem; text-align: center; margin: 6px auto 0; max-width: 48ch; }
.site-footer { color: var(--text-soft); font-size: 0.78rem; text-align: center; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Impression / PDF */
@media print {
  body { background: #fff; }
  .topbar, .btn, .entry-footer, .date-strip, .entry-daynav .nav-arrow, .tap-hint,
  .site-header, .privacy-banner, .local-note, .a11y-bar { display: none !important; }
  .bilan-section { break-inside: avoid; box-shadow: none; }
  .page { max-width: 100%; padding: 0; }
  .site-footer { border: none; }
}
