/* Focale — la mise au point sur l'essentiel du jour et de la semaine.
   Un topic à la fois ; le sujet principal du topic en grand sur fond sombre,
   les autres à côté ; une seule couleur d'accent (ambre) pour l'action et le point focal. */

:root {
  --bg: #eef2f5;
  --paper: #f9fbfc;
  --ink: #15212d;
  --ink-soft: #566575;
  --rule: #d3dbe3;
  --band: #172636;
  --band-2: #1f3246;
  --band-ink: #e8eef3;
  --band-soft: #93a6b8;
  --accent: #ffb01f;
  --link: #1d5c99;
  --mark: rgba(255, 176, 31, 0.32);

  --font-ui: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Source Serif 4", Georgia, serif;
  --page: 1440px;
  --gutter: clamp(16px, 2.4vw, 36px);
  --player-h: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e151c;
    --paper: #16202a;
    --ink: #e5ebf0;
    --ink-soft: #96a5b4;
    --rule: #253240;
    --band: #1b2b3b;
    --band-2: #24384c;
    --accent: #ffb84a;
    --link: #8cc0f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body.playing { --player-h: 76px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom));
}

.icons { display: none; }
svg { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; }
a { color: var(--link); text-underline-offset: 0.15em; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--paper); padding: 8px 12px; }

/* --- Barre du haut ------------------------------------------------------ */

.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  max-width: var(--page);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 12px;
}

.brand {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-stretch: 112%;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--band); position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.views {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--rule);
}
.views button {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-weight: 600;
}
.views button[aria-selected="true"] { background: var(--band); color: var(--band-ink); }

.edition { display: flex; align-items: center; gap: 12px; min-width: 0; }
.edition select {
  font-weight: 600; background: transparent; border: 0; padding: 4px 2px; max-width: 100%;
  border-bottom: 1px dashed var(--rule); border-radius: 0;
}
.updated { color: var(--ink-soft); font-size: 0.92rem; white-space: nowrap; }

.tools { margin-left: auto; display: flex; gap: 8px; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); font-weight: 600;
}
.tool.icon-only { width: 40px; padding: 0; justify-content: center; }
.tool:hover { border-color: var(--ink-soft); }

/* --- Bandeau du jour ------------------------------------------------- */

.today {
  max-width: calc(var(--page) - 2 * var(--gutter));
  margin: 0 auto 10px;
  display: grid;
  grid-template-columns: 1.15fr 1.3fr 1.6fr 1.2fr 1.5fr;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  scrollbar-width: none;
}
.today::-webkit-scrollbar { display: none; }
@media (max-width: 1439px) { .today { margin: 0 var(--gutter) 10px; } }
.today-loading { margin: 0; padding: 14px 18px; color: var(--ink-soft); }
.today-tile { min-width: 0; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.today-tile + .today-tile { border-left: 1px solid var(--rule); }
.today-tile:empty { display: none; }
.today-day { margin: 0; font-weight: 800; font-stretch: 90%; font-size: 1.35rem; line-height: 1.1; letter-spacing: -0.01em; }
.today-label { margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }
.today-sub { margin: 0; font-size: 0.86rem; line-height: 1.35; color: var(--ink-soft); }
.today-sub:empty { display: none; }
.today-note { margin: 2px 0 0; font-size: 0.86rem; line-height: 1.35; font-weight: 600; }
.today-now { display: flex; align-items: center; gap: 10px; }
.today-now svg { width: 34px; height: 34px; }
.today-temp { margin: 0; font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.today-cond { margin: 0; font-weight: 600; font-size: 0.95rem; }
.today-place {
  align-self: flex-start; max-width: 100%; margin-top: 2px; padding: 0; border: 0; background: transparent;
  font-size: 0.8rem; color: var(--ink-soft); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.today-hours { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.today-hours li { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 0.8rem; }
.today-hours li.past { opacity: 0.45; }
.today-hours svg { width: 24px; height: 24px; margin: 2px 0; }
.today-hours .h { color: var(--ink-soft); }
.today-hours .t { font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.today-hours .p { color: var(--link); font-variant-numeric: tabular-nums; }
.today-line { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 0.86rem; }
.moon { width: 20px; height: 20px; flex: none; }
.moon-dark { fill: var(--rule); }
.moon-lit { fill: #e9c75a; }
.today-history {
  margin: 0; font-family: var(--font-text); font-size: 0.92rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.today-history a { color: inherit; text-decoration: none; }
.today-history a:hover { text-decoration: underline; }

.credits { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter) 28px; font-size: 0.78rem; color: var(--ink-soft); }

/* --- Barre des topics ---------------------------------------------- */

.topics {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topic-tabs {
  display: flex;
  gap: 6px;
  max-width: var(--page);
  margin: 0 auto;
  padding: 10px var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.topic-tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--paper); }
.tab[aria-selected="true"] { background: var(--band); color: var(--band-ink); }
.tab-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  display: inline-grid; place-items: center;
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
  background: var(--rule); color: var(--ink);
}
.tab[aria-selected="true"] .tab-count { background: var(--accent); color: #1a1406; }
.tab.empty { opacity: 0.6; }

/* --- Topic affiché ------------------------------------------------------ */

.page { max-width: var(--page); margin: 0 auto; padding: 22px var(--gutter) 28px; }

.topic-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 16px; }
.topic-head h1 { margin: 0; font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; font-stretch: 88%; letter-spacing: -0.02em; line-height: 1.1; }
.topic-head p { margin: 0; color: var(--ink-soft); }
.topic-head .tool { margin-left: auto; align-self: center; }

.stories { display: grid; gap: 16px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); outline: none; }

.story {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 18px 20px 16px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
}
.story-kicker { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.88rem; color: var(--ink-soft); }
.story-kicker .flag { color: var(--ink); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.story-kicker .flag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.story h2 { margin: 0; font-size: 1.22rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
.story h2 button { all: unset; cursor: pointer; }
.story h2 button:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.story h2 button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.story .summary { margin: 0; font-family: var(--font-text); font-size: 1.02rem; line-height: 1.58; }
.story .sources { margin: 0; font-size: 0.88rem; color: var(--ink-soft); }
.story .sources a { font-weight: 600; }
.story .lean { color: var(--ink-soft); }
.story-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

.act {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--rule); background: transparent; font-weight: 600; font-size: 0.92rem;
}
.act svg { width: 1.05em; height: 1.05em; }
.act:hover { border-color: var(--ink-soft); }
.act.on { border-color: var(--accent); }

/* Le sujet principal du topic, en grand */
.story.lead {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "kicker summary" "title summary" "actions sources";
  gap: 12px 36px;
  padding: 26px 30px 24px;
  border: 0;
  border-radius: 16px;
  background: var(--band);
  color: var(--band-ink);
}
.story.lead .story-kicker { grid-area: kicker; }
.story.lead h2 { grid-area: title; }
.story.lead .summary { grid-area: summary; }
.story.lead .sources { grid-area: sources; align-self: end; }
.story.lead .story-actions { grid-area: actions; margin-top: 0; }
.story.lead h2 { font-size: clamp(1.5rem, 2.3vw, 2.05rem); font-weight: 800; font-stretch: 92%; line-height: 1.12; letter-spacing: -0.02em; }
.story.lead .summary { font-size: 1.1rem; }
.story.lead .story-kicker, .story.lead .sources, .story.lead .lean { color: var(--band-soft); }
.story.lead .story-kicker .flag { color: var(--band-ink); }
.story.lead .sources a { color: var(--band-ink); }
.story.lead .act { border-color: rgba(147, 166, 184, 0.45); color: var(--band-ink); }
.story.lead .act:hover { border-color: var(--band-ink); }
.story.lead .act.primary { background: var(--accent); border-color: var(--accent); color: #1a1406; }

.empty-topic { grid-column: 1 / -1; margin: 0; padding: 36px 0; font-family: var(--font-text); font-size: 1.2rem; color: var(--ink-soft); }
.status { grid-column: 1 / -1; margin: 24px 0; color: var(--ink-soft); }

.edition-foot { margin-top: 22px; font-size: 0.86rem; color: var(--ink-soft); }
.edition-foot summary { cursor: pointer; }
.edition-foot ul { margin: 8px 0 0; padding-left: 18px; }

/* --- Panneaux (détail, recherche, voix) ---------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(9, 15, 21, 0.5); cursor: pointer; }

/* Fenêtres flottantes : le site reste visible autour, un clic dessus referme. */
.sheet {
  --free: calc(100dvh - var(--player-h));
  position: fixed;
  z-index: 40;
  left: 50%;
  top: calc(var(--free) / 2);
  transform: translate(-50%, -50%);
  width: 75vw;
  height: min(85dvh, calc(var(--free) - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(9, 15, 21, 0.35);
  animation: pop-in 220ms cubic-bezier(0.3, 0.7, 0.2, 1);
}
.sheet.small { width: min(520px, 92vw); height: auto; max-height: min(80dvh, calc(var(--free) - 40px)); }
@keyframes pop-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
.detail .sheet-head, .detail .sheet-body > * { width: 100%; max-width: 820px; margin-left: auto; margin-right: auto; }
.detail .sheet-head { padding-left: 0; padding-right: 0; border-bottom: 0; }
.detail .sheet-head-wrap { border-bottom: 1px solid var(--rule); padding: 0 30px; }

.sheet-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--rule);
}
.sheet-kicker { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.sheet-title { margin: 0; font-size: 1.15rem; }
.icon-button {
  margin-left: auto; width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: 50%; background: transparent;
}
.sheet-body { flex: 1; overflow-y: auto; padding: 22px 30px 30px; overscroll-behavior: contain; }

.detail h2 { margin: 0 0 10px; font-size: clamp(1.45rem, 2.4vw, 1.95rem); font-weight: 800; font-stretch: 92%; line-height: 1.15; letter-spacing: -0.02em; }
.detail .detail-meta { margin-top: 0; margin-bottom: 16px; color: var(--ink-soft); font-size: 0.92rem; }
.detail .detail-meta a { font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 18px; }
.tabs button {
  border: 1px solid var(--rule); background: transparent; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 0.92rem;
}
.tabs button[aria-selected="true"] { background: var(--band); color: var(--band-ink); border-color: var(--band); }

.reading { font-family: var(--font-text); font-size: 1.12rem; line-height: 1.7; max-width: 68ch; }
.reading p { margin: 0 0 1em; }
.reading .s.current { background: var(--mark); border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.reading-note { margin: 0 0 14px; color: var(--ink-soft); font-size: 0.92rem; }
.detail-listen { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.detail-listen .act.primary { background: var(--band); color: var(--band-ink); border-color: var(--band); }

.field {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--rule); background: var(--bg); font-size: 1rem;
}
.search-results { margin-top: 14px; }
.result { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.result:hover strong { text-decoration: underline; }
.result small { display: block; color: var(--ink-soft); }
.result span { display: block; font-family: var(--font-text); color: var(--ink-soft); font-size: 0.95rem; }

.voice-group { margin: 0 0 22px; border: 0; padding: 0; }
.voice-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.voice-group p { margin: 0 0 10px; color: var(--ink-soft); font-size: 0.92rem; }
.voice-group .voice-tip { color: var(--ink); background: var(--bg); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 6px; }
.voice-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.voice-row label { flex: 1; display: flex; gap: 10px; align-items: center; min-width: 0; }
.voice-row label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-row small { color: var(--ink-soft); }

/* --- Lecteur ------------------------------------------------------------ */

.player {
  position: fixed;
  z-index: 45;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--band);
  color: var(--band-ink);
}
.player-controls, .player-side { display: flex; align-items: center; gap: 4px; }
.pbtn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: transparent; color: var(--band-ink);
}
.pbtn:hover { background: var(--band-2); }
.pbtn.main { width: 50px; height: 50px; background: var(--accent); color: #1a1406; }
.pbtn.main svg { width: 1.45em; height: 1.45em; }
.player-now { min-width: 0; }
.now-title { margin: 0 0 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-meta { margin: 4px 0 0; font-size: 0.82rem; color: var(--band-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { position: relative; height: 8px; border-radius: 8px; background: var(--band-2); cursor: pointer; }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 8px; background: var(--accent); transition: width 200ms linear; }
.progress-ticks { position: absolute; inset: 0; pointer-events: none; }
.progress-ticks i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--band-soft); opacity: 0.7; }
.rate { background: var(--band-2); color: var(--band-ink); border: 0; border-radius: 8px; height: 34px; padding: 0 8px; font-weight: 600; }

/* --- Largeurs ----------------------------------------------------------- */

@media (max-width: 1100px) {
  .today { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .today-tile { flex: 0 0 min(300px, 80vw); scroll-snap-align: start; }
  .stories { --cols: 2 !important; }
  .story.lead { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "kicker" "title" "summary" "sources" "actions"; }
  .sheet { width: 86vw; }
}

@media (max-width: 720px) {
  .today { margin: 0 0 8px; border-radius: 0; border-left: 0; border-right: 0; }
  .top { gap: 10px 10px; }
  .tool span { display: none; }
  .tool { width: 40px; padding: 0; justify-content: center; }
  .views { order: 4; }
  .views button { padding: 6px 13px; }
  .edition { order: 5; width: 100%; justify-content: space-between; }
  .edition select { max-width: 100%; }
  .updated { font-size: 0.82rem; }
  .page { padding-top: 16px; }
  .stories { --cols: 1 !important; gap: 12px; }
  .story.lead { padding: 20px 18px; border-radius: 14px; }
  .story { padding: 16px; }
  .topic-head .tool span { display: none; }
  /* Marges larges autour de la fenêtre : on touche le site visible autour pour la fermer */
  .sheet, .sheet.small { width: 84vw; border-radius: 16px; }
  .sheet { height: calc(var(--free) * 0.78); }
  .sheet.small { max-height: calc(var(--free) * 0.78); }
  .detail .sheet-head-wrap { padding: 0 18px; }
  .sheet-body { padding: 18px 18px 28px; }
  .player { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding-top: 8px; }
  body.playing { --player-h: 118px; }
  .player-now { grid-column: 1 / -1; grid-row: 1; }
  .player-controls { grid-row: 2; }
  .player-side { grid-row: 2; }
  #p-voice { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
  .sheet { animation: none; }
}
