/* ------------------------------------------------------------------
   La Veille IA — édition du matin, pensée pour l'iPad mini
   ------------------------------------------------------------------ */

:root {
  --paper: #F3F5F8;
  --paper-raised: #FFFFFF;
  --rule: #DDE2EA;
  --ink: #121B2B;
  --ink-soft: #3F4A5C;
  --ink-mute: #6E788A;

  --t1: #0E7C7B;   /* usages */
  --t2: #4B3FC4;   /* modèles */
  --t3: #A86200;   /* hardware */
  --t4: #B0283F;   /* infra & politique */

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", -apple-system, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --col: 41rem;
  --gutter: max(1rem, env(safe-area-inset-left));
  --gutter-r: max(1rem, env(safe-area-inset-right));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E131C;
    --paper-raised: #151C28;
    --rule: #232C3A;
    --ink: #E7EBF2;
    --ink-soft: #B3BCCB;
    --ink-mute: #7C879A;
    --t1: #3FB8B6;
    --t2: #9A92F2;
    --t3: #E3A43A;
    --t4: #EF6A80;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 3px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- En-tête ---------- */

.masthead {
  padding: calc(env(safe-area-inset-top) + 1.75rem) var(--gutter-r) 1rem var(--gutter);
}

.masthead__inner {
  max-width: var(--wrap, var(--col));
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.masthead__title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.4rem, 7vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 72;
}

.masthead__title span {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 700;
  font-size: 0.38em;
  letter-spacing: 0.08em;
  vertical-align: 0.9em;
  margin-left: 0.15em;
}

.masthead__meta {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: right;
  display: flex;
  flex-direction: column;
}

.masthead__maj { color: var(--ink-mute); }

/* ---------- Barre de filtres ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--rule);
  padding: calc(env(safe-area-inset-top) * 0) var(--gutter-r) 0 var(--gutter);
}

.toolbar__inner {
  max-width: var(--wrap, var(--col));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  font-family: var(--sans);
}

.topics {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1 1 auto;
  min-width: 0;
}
.topics::-webkit-scrollbar { display: none; }

.topic {
  flex: none;
  appearance: none;
  border: 0;
  background: none;
  font: 500 0.9rem/1 var(--sans);
  color: var(--ink-soft);
  padding: 0.7rem 0.6rem 0.6rem;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.topic__dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--c, var(--ink));
}

.topic[aria-selected="true"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--c, var(--ink));
}

.toolbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
  background: var(--paper-raised);
}

.seg button {
  appearance: none;
  border: 0;
  background: none;
  font: 500 0.8rem/1 var(--sans);
  color: var(--ink-soft);
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 2.4rem;
}

.seg button[aria-checked="true"] {
  background: var(--ink);
  color: var(--paper);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search svg {
  position: absolute;
  left: 0.65rem;
  width: 1rem; height: 1rem;
  fill: none; stroke: var(--ink-mute); stroke-width: 1.8; stroke-linecap: round;
  pointer-events: none;
}

.search input {
  font: 400 0.95rem/1 var(--sans);   /* ≥ 16px réel sur iOS pour éviter le zoom */
  font-size: max(16px, 0.95rem);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.5rem 0.8rem 0.5rem 2rem;
  width: 9.5rem;
  transition: width 0.2s ease;
  -webkit-appearance: none;
}
.search input:focus { width: 13rem; outline: none; border-color: var(--ink-mute); }
.search input::placeholder { color: var(--ink-mute); }

/* ---------- Fil ---------- */

.fil {
  padding: 0 var(--gutter-r) 3rem var(--gutter);
}

.jour {
  max-width: var(--col);
  margin: 0 auto;
  padding-top: 2.25rem;
}

.jour__tete {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1.5px solid var(--ink);
}

.jour__nom {
  margin: 0;
  font: 700 0.8rem/1.2 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.jour__nom small {
  display: block;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-mute);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

/* Le pouls du jour : une barre par article, hauteur = score, couleur = sujet */
.pouls {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pouls li { height: 100%; display: flex; align-items: flex-end; }

.pouls a {
  display: block;
  width: 6px;
  height: calc(var(--s) * 20%);
  background: var(--c);
  border-radius: 1.5px;
  opacity: 0.9;
  transform-origin: bottom;
  animation: monte 0.5s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i) * 25ms);
  position: relative;
}
.pouls a::after { /* zone tactile plus large que la barre */
  content: ""; position: absolute; inset: -0.5rem -2px;
}
.pouls a:hover { opacity: 1; }

@keyframes monte { from { transform: scaleY(0); } }

/* ---------- Article ---------- */

.article {
  padding: 1.35rem 0 1.4rem;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 4.5rem;
}
.article:last-child { border-bottom: 0; }

.kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  font: 500 0.75rem/1.2 var(--sans);
  color: var(--ink-mute);
  margin-bottom: 0.45rem;
}

.kicker__sujet {
  color: var(--c);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 0.7rem;
}
.score i {
  width: 3px;
  background: var(--rule);
  border-radius: 1px;
}
.score i:nth-child(1) { height: 30%; }
.score i:nth-child(2) { height: 47%; }
.score i:nth-child(3) { height: 64%; }
.score i:nth-child(4) { height: 82%; }
.score i:nth-child(5) { height: 100%; }
.score i.on { background: var(--c); }

.titre {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 36;
  text-wrap: balance;
}

.titre a {
  text-decoration: none;
  background-image: linear-gradient(var(--c), var(--c));
  background-size: 0 1.5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease;
}
.titre a:hover, .titre a:focus-visible { background-size: 100% 1.5px; }

.resume {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.origine {
  margin: 0.6rem 0 0;
  font: 400 0.78rem/1.4 var(--sans);
  color: var(--ink-mute);
}
.origine a { color: var(--ink-soft); text-underline-offset: 2px; text-decoration-color: var(--rule); }

/* L'article en tête de l'édition la plus récente */
.article--une { padding-top: 1.6rem; }
.article--une .titre {
  font-size: clamp(1.75rem, 4.2vw, 2.35rem);
  line-height: 1.1;
  font-weight: 560;
  letter-spacing: -0.018em;
  font-variation-settings: "opsz" 72;
}
.article--une .resume {
  font-size: 1.18rem;
  color: var(--ink);
}

/* ---------- États ---------- */

.etat {
  max-width: var(--col);
  margin: 4rem auto;
  text-align: center;
  color: var(--ink-mute);
  font-style: italic;
}

.vide {
  max-width: var(--col);
  margin: 3.5rem auto;
  text-align: center;
}
.vide p { margin: 0 0 1rem; color: var(--ink-soft); }

.bouton {
  appearance: none;
  font: 600 0.9rem/1 var(--sans);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
}

.plus {
  max-width: var(--col);
  margin: 2.5rem auto 0;
  text-align: center;
}

.pied {
  max-width: var(--col);
  margin: 0 auto;
  padding: 1.5rem var(--gutter-r) 2.5rem var(--gutter);
  font: 400 0.8rem/1.5 var(--sans);
  color: var(--ink-mute);
  border-top: 1px solid var(--rule);
}
.pied p { margin: 0; }

/* ---------- iPad paysage et grands écrans : le jour passe dans la marge ---------- */

@media (min-width: 960px) {
  :root { --wrap: 58rem; }

  .jour {
    max-width: var(--wrap);
    display: grid;
    grid-template-columns: 13rem minmax(0, var(--col));
    column-gap: 3rem;
    justify-content: center;
  }

  .jour__tete {
    grid-column: 1;
    grid-row: 1 / span 999;
    align-self: start;
    position: sticky;
    top: 5.25rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 0;
    border-top: 1.5px solid var(--ink);
    padding: 0.8rem 0 0;
  }

  .pouls { flex-wrap: wrap; height: auto; min-height: 2.25rem; row-gap: 6px; }
  .pouls a { height: calc(var(--s) * 0.45rem); }

  .jour .article { grid-column: 2; }
  .jour .article:first-of-type { padding-top: 0.6rem; }
}

/* ---------- iPad portrait et téléphone : filtres sur deux lignes ---------- */

@media (max-width: 959px) {
  .toolbar__inner { flex-wrap: wrap; gap: 0.15rem 0.5rem; padding-bottom: 0.55rem; }
  .topics { flex-basis: 100%; }
  .toolbar__right { flex-basis: 100%; }
  .search { flex: 1; }
  .search input, .search input:focus { width: 100%; }
}

@media (max-width: 620px) {
  .titre { font-size: 1.25rem; }
  .masthead__meta { text-align: left; }
}

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