/* =========================================================================
   vie-sous-marine.photo — système de design « Atlas »
   Thème océan. Serif éditorial pour les titres et noms d'espèces, sans propre
   pour l'interface. Clair + sombre, pilotés par tokens.
   ========================================================================= */

:root {
  --abyss:   #0c2b33;
  --deep:    #0f3a44;
  --lagoon:  #157a8c;
  --lagoon-2:#1f97ab;
  --foam:    #7fd0c8;
  --coral:   #d8613f;
  --sand:    #b6a37c;

  --ground:   #f4f2ec;
  --surface:  #ffffff;
  --surface-2:#eceee7;
  --ink:      #16242a;
  --ink-2:    #40525a;
  --muted:    #74848a;
  --line:     #dcdfd6;
  --accent:   var(--lagoon);
  --accent-ink:#0d5666;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono:  "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,40,46,.06), 0 8px 30px rgba(16,40,46,.07);
  --wrap: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:   #0a1518;
    --surface:  #102227;
    --surface-2:#163036;
    --ink:      #e8efec;
    --ink-2:    #b2c3c0;
    --muted:    #7d918d;
    --line:     #20383f;
    --accent:   #2ba7bd;
    --accent-ink:#8fe0e0;
    --coral:    #e8785a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 34px rgba(0,0,0,.35);
  }
}
:root[data-theme="light"] {
  --ground:#f4f2ec; --surface:#fff; --surface-2:#eceee7; --ink:#16242a; --ink-2:#40525a;
  --muted:#74848a; --line:#dcdfd6; --accent:#157a8c; --accent-ink:#0d5666; --coral:#d8613f;
  --shadow: 0 1px 2px rgba(16,40,46,.06), 0 8px 30px rgba(16,40,46,.07);
}
:root[data-theme="dark"] {
  --ground:#0a1518; --surface:#102227; --surface-2:#163036; --ink:#e8efec; --ink-2:#b2c3c0;
  --muted:#7d918d; --line:#20383f; --accent:#2ba7bd; --accent-ink:#8fe0e0; --coral:#e8785a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 34px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }
.narrow { max-width: 760px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.14; text-wrap: balance; }
h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 .4em; }
h2 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 .5em; }
.sci { font-style: italic; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }

/* ---------- Header / nav ---------- */
.site-head {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(1.4) blur(10px);
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 26px; height: 62px; }
.brand { display: flex; align-items: baseline; gap: 10px; font-family: var(--serif); font-size: 21px; font-weight: 600; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.nav { display: flex; gap: 20px; margin-left: auto; font-size: 15px; }
.nav a { color: var(--ink-2); font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--accent-ink); text-decoration: none; }
.nav a.active { border-bottom: 2px solid var(--accent); padding-bottom: 3px; }

/* ---------- Recherche (header) ---------- */
.site-search-wrap { position: relative; margin-left: 16px; }
#site-search {
  font: inherit; font-size: 14px; width: 210px; max-width: 40vw;
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); transition: width .2s, box-shadow .2s;
}
#site-search:focus { outline: none; width: 260px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
#site-search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 340px; max-width: 80vw;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; display: none; z-index: 60;
}
#site-search-results:not(:empty) { display: block; }
.ss-item { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ss-item:last-child { border-bottom: none; }
.ss-item:hover, .ss-item.is-active { background: var(--surface-2); }
.ss-type { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); min-width: 54px; }
.ss-label { color: var(--ink); font-size: 14px; }
@media (max-width: 720px) { .site-search-wrap { display: none; } }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #eafcf8;
  background: linear-gradient(165deg, var(--abyss), #0a2a33 55%, #08222a);
}
.hero .wrap { padding: 68px 22px 60px; position: relative; z-index: 2; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 60% at 12% -10%, rgba(43,167,189,.28), transparent 60%),
    radial-gradient(70% 50% at 100% 120%, rgba(127,208,200,.18), transparent 60%);
}
.hero h1 { color: #f2fdfa; max-width: 16ch; }
.hero p.lede { font-size: clamp(17px, 2.2vw, 20px); color: #c7e6e1; max-width: 56ch; margin: 0; }

/* ---------- Hero « mur de la collection » ---------- */
.hero-atlas {
  position: relative; overflow: hidden; isolation: isolate;
  /* Hauteur bornée : garantit que la grille de tuiles remplit tout l'espace. */
  height: clamp(520px, 84vh, 760px);
  background: var(--abyss);
}
.hero-mosaic {
  position: absolute; inset: 0; z-index: 0;
  display: grid; gap: 3px;
  grid-template-columns: repeat(auto-fill, minmax(clamp(104px, 11vw, 172px), 1fr));
  grid-auto-rows: clamp(104px, 11vw, 172px);
  background: var(--abyss);
}
.hm-tile { overflow: hidden; opacity: 0; transform: translateY(10px) scale(1.05);
  animation: hmIn .7s cubic-bezier(.2,.7,.2,1) forwards; animation-delay: calc(var(--i) * 13ms); }
.hm-tile img { width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(1.05) brightness(.92); }
@keyframes hmIn { to { opacity: 1; transform: none; } }

/* Voile de profondeur : clair en haut (surface), abysse en bas (lisibilité du texte). */
.hero-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(90% 55% at 50% -12%, rgba(127,208,200,.28), transparent 60%),
    linear-gradient(180deg,
      rgba(6,30,36,.10) 0%, rgba(6,28,34,.22) 38%,
      rgba(8,26,32,.72) 70%, rgba(5,18,24,.97) 100%);
}
.hero-body { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-end;
  background: radial-gradient(115% 85% at 22% 108%, rgba(4,16,20,.62), transparent 58%); }
.hero-body .wrap { padding-bottom: clamp(48px, 8vh, 92px); }
.hero-atlas .eyebrow { color: #86e0d3; }
.hero-atlas h1 {
  color: #f4fdfa; font-size: clamp(32px, 5.2vw, 60px); line-height: 1.05;
  max-width: 20ch; margin: 0 0 16px; text-shadow: 0 2px 24px rgba(3,16,20,.5);
}
.hero-atlas .lede { color: #d3ebe6; font-size: clamp(16px, 2.1vw, 20px); max-width: 52ch;
  margin: 0; text-shadow: 0 1px 12px rgba(3,16,20,.5); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.btn-hero-ghost { background: rgba(255,255,255,.08); color: #eafcf8;
  border: 1px solid rgba(230,250,246,.4); backdrop-filter: blur(4px); }
.btn-hero-ghost:hover { background: rgba(255,255,255,.16); text-decoration: none; }
.hero-stats-wrap { margin-top: -34px; position: relative; z-index: 5; }
@media (prefers-reduced-motion: reduce) {
  .hm-tile { opacity: 1; transform: none; animation: none; }
}

/* ---------- Stat row ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stats .cell { background: var(--surface); padding: 18px 16px; }
.stats .n { font-family: var(--serif); font-size: clamp(22px, 3vw, 30px); font-weight: 600; color: var(--accent-ink);
  font-variant-numeric: tabular-nums; line-height: 1; }
.stats .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Sections ---------- */
.section { padding: 52px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head a.more { font-size: 14px; font-weight: 500; white-space: nowrap; }

/* ---------- Gallery (justified-ish grid) ---------- */
.grid-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: block; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); aspect-ratio: 4 / 3; box-shadow: var(--shadow);
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.tile:hover img { transform: scale(1.05); }
.tile figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 9px; color: #fff;
  font-size: 13px; line-height: 1.3; background: linear-gradient(transparent, rgba(6,24,28,.82));
  opacity: 0; transition: opacity .25s; }
.tile:hover figcaption, .tile:focus-within figcaption { opacity: 1; }
.tile figcaption .sci { display: block; opacity: .82; font-size: 12px; }
.badge-video { position: absolute; top: 8px; right: 8px; background: rgba(6,24,28,.7); color: #cdeae4;
  border-radius: 20px; padding: 2px 9px; font-size: 11px; font-family: var(--mono); }

/* ---------- Photo du jour (bandeau accueil) ---------- */
.potd-band { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); text-decoration: none; }
.potd-band:hover { text-decoration: none; }
.potd-img { min-height: 260px; background: var(--surface-2); }
.potd-img img { width: 100%; height: 100%; object-fit: cover; }
.potd-txt { padding: 28px 30px; display: flex; flex-direction: column; justify-content: center; }
.potd-txt h3 { color: var(--ink); }
@media (max-width: 720px) { .potd-band { grid-template-columns: 1fr; } .potd-img { min-height: 220px; } }

/* ---------- Cards / atlas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 34px rgba(16,40,46,.14); }
.card .cover { aspect-ratio: 3 / 2; background: var(--surface-2); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 14px 16px; }
.card .body h3 { font-size: 18px; margin: 0 0 3px; }
.card .body .meta { font-size: 13px; color: var(--muted); }

/* ---------- Species page ---------- */
.species-hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 30px; align-items: center; }
@media (max-width: 820px) { .species-hero { grid-template-columns: 1fr; } }
.breadcrumb { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb a { color: var(--ink-2); }
.breadcrumb span.sep { opacity: .5; }
.blurb { font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.pill { font-size: 12.5px; font-family: var(--mono); background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; }
.pill.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 15px; font-weight: 550;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Footer ---------- */
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 34px 0 60px; color: var(--muted); font-size: 14px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 26px; align-items: center; }
.site-foot .credit { font-family: var(--serif); font-style: italic; color: var(--ink-2); }
.site-foot .theme-toggle { margin-left: auto; }

/* ---------- Theme toggle ---------- */
.theme-toggle { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 20px; padding: 5px 12px; font-size: 13px; cursor: pointer; font: inherit; }

/* ---------- Map ---------- */
#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }

/* ---------- Lightbox ---------- */
.lb-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(6,18,22,.92); display: none;
  align-items: center; justify-content: center; }
.lb-backdrop.open { display: flex; }
.lb-backdrop img { max-width: 92vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lb-cap { position: fixed; bottom: 18px; left: 0; right: 0; text-align: center; color: #d7ece7; font-size: 14px; }
.lb-close { position: fixed; top: 16px; right: 20px; color: #cfe6e1; font-size: 30px; cursor: pointer; background: none; border: none; }

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .6s cubic-bezier(.2,.7,.2,1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
}
