/* =========================================================================
   Milankovitch — feuille de style (même thème que La Radiothèque)
   ========================================================================= */

:root {
  --bg:            #ece6d9;
  --bg-grad-a:     #e9e2d3;
  --bg-grad-b:     #f3eee3;
  --surface:       #fbf8f1;
  --surface-2:     #f1ebdd;
  --ink:           #20201c;
  --ink-soft:      #423f36;
  --muted:         #756f60;
  --line:          #e0d8c5;
  --line-strong:   #cabfa6;

  --primary:       #1c6b5a;
  --primary-600:   #14503f;
  --primary-050:   #e4efe8;
  --accent:        #a8632f;

  --ok:    #1c6b5a;
  --warn:  #a8632f;
  --danger:#a8473d;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(40,34,20,.06), 0 6px 20px rgba(40,34,20,.07);
  --shadow-lg: 0 12px 34px rgba(40,34,20,.16);
  --ring:      0 0 0 3px rgba(28,107,90,.22);

  --maxw: 1200px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia", "Times New Roman", serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg:          #121614;
  --bg-grad-a:   #10140f;
  --bg-grad-b:   #161c19;
  --surface:     #1a2120;
  --surface-2:   #212a28;
  --ink:         #ecf1ee;
  --ink-soft:    #c3cdc8;
  --muted:       #8a948e;
  --line:        #2b3633;
  --line-strong: #3a4742;
  --primary:     #4cbf9e;
  --primary-600: #62d0b0;
  --primary-050: #15302a;
  --accent:      #cc8a4e;
  --shadow:      0 1px 2px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.4);
  --shadow-lg:   0 14px 46px rgba(0,0,0,.55);
  --ring:        0 0 0 3px rgba(76,191,158,.32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 82% -10%, rgba(28,107,90,.10), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); }
h1, h2 { font-family: var(--font-serif); font-weight: 600; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); letter-spacing: -.005em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 1.1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-family: var(--font-serif); font-size: 1.12rem; }
.brand__text em { font-style: normal; font-size: .76rem; color: var(--muted); }

.nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.nav a[data-nav] {
  color: var(--ink-soft); font-weight: 600; font-size: .94rem;
  padding: .5rem .8rem; border-radius: 999px;
}
.nav a[data-nav]:hover { background: var(--surface-2); text-decoration: none; }
.nav a[data-nav].is-active { color: var(--primary); background: var(--primary-050); }

.theme-toggle {
  margin-left: .4rem; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
}
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.nav-toggle { display: none; }

/* ---------- Layout ---------- */
.app { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.1rem 3rem; }

.site-footer { border-top: 1px solid var(--line); margin-top: 1rem; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.site-footer__inner { max-width: var(--maxw); margin: 0 auto; padding: 1.4rem 1.1rem; color: var(--muted); font-size: .88rem; }
.site-footer__inner p { margin: .2rem 0; }
.site-footer__note { font-size: .82rem; }

.section { margin-top: 2.2rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__body { padding: 1.2rem 1.3rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(820px 360px at 86% -25%, rgba(76,191,158,.32), transparent 55%),
    radial-gradient(600px 300px at 8% 120%, rgba(168,99,47,.22), transparent 55%),
    linear-gradient(135deg, #15433a, #0f2a26);
  color: #fff;
  padding: clamp(1.8rem, 4vw, 3rem);
  box-shadow: var(--shadow-lg);
}
.hero h1 { color: #fff; margin: 0 0 .5rem; }
.hero p { color: rgba(255,255,255,.9); max-width: 60ch; margin: 0; font-size: 1.05rem; }
.hero__chips { margin-top: 1.3rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.hero__chips .badge { background: rgba(255,255,255,.16); color: #fff; border-color: rgba(255,255,255,.28); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .01em;
  padding: .25rem .6rem; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--ink-soft);
  background: var(--surface-2); white-space: nowrap;
}

/* ---------- Accueil grid ---------- */
.home-grid {
  display: grid; gap: 1.4rem;
  grid-template-columns: 1.7fr 1fr;
  align-items: start;
  margin-top: 1.6rem;
}
@media (max-width: 880px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-grid > aside { order: -1; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.section-head h2 { margin: 0; }

/* Cartes documentation */
.doc-list { display: grid; gap: .9rem; }
.doc-section-title {
  font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin: 1.2rem 0 .5rem;
}
.doc-section-title:first-child { margin-top: 0; }

.doc-card {
  display: flex; flex-direction: column; gap: .3rem;
  padding: .95rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
  color: inherit; text-decoration: none;
}
.doc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); text-decoration: none; }
.doc-card__title { font-size: 1rem; font-weight: 700; color: var(--ink); margin: 0; }
.doc-card__desc { font-size: .85rem; color: var(--muted); margin: 0; }
.doc-card__cta { margin-top: .3rem; font-weight: 700; font-size: .84rem; color: var(--primary); }

.data-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--ink-soft);
  transition: border-color .12s, background .12s;
}
.data-link:hover { border-color: var(--primary); background: var(--primary-050); text-decoration: none; color: var(--ink); }
.data-link svg { flex-shrink: 0; color: var(--muted); }

/* Card modélisation (aside) */
.model-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.model-card__header {
  padding: 1.4rem 1.4rem 0;
}
.model-card__header h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.model-card__header p { margin: 0 0 1rem; font-size: .9rem; color: var(--muted); }
.model-card__body { padding: 1rem 1.4rem 1.4rem; }
.model-card__preview {
  background: linear-gradient(135deg, #0f2a26, #1a3d35);
  padding: 1rem 2.2rem;
  display: flex; align-items: center; justify-content: center; gap: .8rem;
  color: rgba(255,255,255,.7); font-size: .88rem;
}
.model-card__preview svg { color: rgba(76,191,158,.8); }

.resp-wide { display: inline; }
.resp-narrow { display: none; }
@media (max-width: 840px) {
  .resp-wide { display: none; }
  .resp-narrow { display: inline; }
}

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .88rem; color: var(--ink-soft); }
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: .6rem .7rem; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: .62rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--primary); color: #fff;
  transition: background .12s, transform .08s, box-shadow .12s;
}
.btn:hover { background: var(--primary-600); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn--ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: .4rem .75rem; font-size: .85rem; }
.btn--lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Page modélisation ---------- */
.model-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  align-items: start;
}
@media (max-width: 840px) {
  .model-layout { grid-template-columns: 1fr; }
  .model-col:last-child { display: none; }
}

.model-col { display: flex; flex-direction: column; gap: 1.1rem; }

.form-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.form-card__head {
  background: linear-gradient(135deg, #15433a, #0f2a26);
  color: #fff; padding: .85rem 1.2rem;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.form-card__head h3 { margin: 0; font-size: 1rem; color: #fff; font-family: var(--font); }
.form-card__body { padding: 1.1rem 1.2rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* ---------- Résultats modélisation ---------- */
.plot {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem; text-align: center;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.plot h3 { margin: .2rem 0 .7rem; font-size: .96rem; font-family: var(--font); color: var(--ink-soft); }
.plot a { flex: 1; display: flex; align-items: center; justify-content: center; }
.plot img { max-width: 100%; height: auto; border-radius: var(--radius-sm); cursor: zoom-in; }

.result-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.result-card__head {
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  padding: .6rem 1rem; font-weight: 700; font-size: .88rem; color: var(--ink-soft);
}
.result-card__body { padding: 0; }

/* Tables de résultats */
table.rtable {
  border-collapse: collapse; width: 100%; font-size: .88rem;
  background: var(--surface);
}
table.rtable th, table.rtable td {
  border: 1px solid var(--line); padding: .5rem .8rem;
}
table.rtable thead th {
  background: var(--surface-2); font-weight: 700; font-size: .82rem;
  text-align: left; color: var(--ink-soft);
}
table.rtable td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
table.rtable tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); }

/* ---------- Articles (documentation) ---------- */
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

.article { max-width: 900px; margin: 0 auto; }
.article h1 { margin-top: 0; }
.article h2 { margin-top: 2.2rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.article h3 { font-family: var(--font-serif); font-weight: 600; margin-top: 1.8rem; color: var(--primary); }
.article h4 { margin-top: 1.3rem; color: var(--ink-soft); }
.article p { margin: .7rem 0; }
.article ul { margin: .6rem 0; padding-left: 1.3rem; }
.article li { margin: .35rem 0; }
.article strong { color: var(--ink); }
.article figure { margin: 1.6rem 0; text-align: center; }
.article figure img { width: 100%; max-width: 680px; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); box-shadow: var(--shadow); background: #fff; padding: .4rem; }
.article figcaption { font-size: .82rem; color: var(--muted); margin-top: .4rem; }
.article .table-wrap { margin: 1.4rem 0; }
.formula {
  background: var(--surface-2); border-left: 3px solid var(--primary);
  border-radius: 8px; padding: .6rem .9rem; margin: .8rem 0;
  font-family: var(--mono); font-size: .95rem; overflow-x: auto; text-align: center;
}
.article-img-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.2rem 0;
}
.article-img-grid a { display: block; }
.article-img-grid img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; padding: .3rem; box-shadow: var(--shadow); }
.article-img-single { text-align: center; margin: 1.4rem 0; }
.article-img-single img { max-width: 60%; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; padding: .4rem; box-shadow: var(--shadow); }

/* ---------- Tables (documentation) ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 1.2rem 0; }
table.data { border-collapse: collapse; width: 100%; font-size: .88rem; background: var(--surface); }
table.data th, table.data td { border: 1px solid var(--line); padding: .55rem .7rem; text-align: center; }
table.data thead th { background: var(--surface-2); font-weight: 700; }
table.data td.left, table.data th.left { text-align: left; }
table.data td.small { font-size: .8rem; vertical-align: top; }

/* ---------- Utilitaires / états ---------- */
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: 1rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); font-size: .92rem; }
.notice--warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.notice--error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); color: var(--danger); }

.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.loading { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 3rem 1rem; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 2rem);
  background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 999px;
  box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast--error { background: var(--danger); }

.lightbox { position: fixed; inset: 0; background: rgba(8,12,22,.86); display: none; place-items: center; z-index: 200; padding: 1.5rem; cursor: zoom-out; }
.lightbox.show { display: grid; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 10px; box-shadow: var(--shadow-lg); }

/* ---------- Grilles d'images dans les articles ---------- */

/* Image + bloc de texte côte à côte */
.img-text-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem;
  align-items: start; margin: 1.2rem 0;
}
@media (max-width: 620px) { .img-text-grid { grid-template-columns: 1fr; } }

/* 2 images côte à côte */
.img-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.2rem 0;
}
@media (max-width: 540px) { .img-grid-2 { grid-template-columns: 1fr; } }

/* 1 image pleine largeur + 2 images en dessous */
.img-1-2 { margin: 1.2rem 0; display: flex; flex-direction: column; gap: .8rem; }
.img-1-2__row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 540px) { .img-1-2__row { grid-template-columns: 1fr; } }

/* 3 colonnes avec titres (obliquité) */
.img-titled-3 {
  margin: 1.2rem 0;
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem;
}
.img-titled-3__item { display: flex; flex-direction: column; gap: .4rem; }
.img-titled-3__header {
  text-align: center; font-weight: 700; font-size: .84rem;
  color: var(--ink-soft); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .45rem .5rem;
  line-height: 1.4;
}
@media (max-width: 640px) {
  .img-titled-3 { grid-template-columns: 1fr; }
}

/* 4 cartes précession */
.prec-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: .9rem; margin: 1.2rem 0;
}
@media (max-width: 860px) { .prec-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 500px) { .prec-grid { grid-template-columns: 1fr; } }
.prec-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.prec-card__title {
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  padding: .45rem .65rem; font-weight: 700; font-size: .88rem;
  text-align: center; color: var(--ink);
}
.prec-card__imgs { display: flex; flex-direction: column; gap: .35rem; padding: .5rem; }
.prec-card__text {
  padding: .55rem .7rem; font-size: .8rem; color: var(--ink-soft);
  border-top: 1px solid var(--line); flex: 1; line-height: 1.5;
}

/* Image centrée à 50% (petite_img) */
.img-center-half { display: flex; flex-direction: column; align-items: center; margin: 1.4rem 0; }
.img-center-half > a { display: block; max-width: 50%; }
.img-center-half img { max-width: 100%; }
@media (max-width: 600px) { .img-center-half > a { max-width: 85%; } }

/* Style commun pour toutes les images d'articles */
.img-text-grid img,
.img-grid-2 img,
.img-1-2 img,
.img-titled-3__item img,
.prec-card__imgs img,
.img-center-half img,
.article-img-full img {
  width: 100%; display: block;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: #fff; padding: .3rem; box-shadow: var(--shadow);
}

/* ---------- Responsive nav ---------- */
@media (max-width: 720px) {
  .nav-toggle {
    display: inline-flex; flex-direction: column; gap: 5px; margin-left: auto;
    width: 42px; height: 42px; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
  }
  .nav-toggle span { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: .25rem;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: .6rem 1.1rem 1rem; box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a[data-nav] { padding: .7rem .8rem; border-radius: 10px; }
  .theme-toggle { margin: .3rem 0 0; align-self: flex-start; }
}
