/* La mécanique des éclipses — thème sombre « espace », sans dépendance. */

:root {
  --bg: #0b1020;
  --bg2: #0e1530;
  --surface: #121a33;
  --surface-2: #1c2540;
  --border: #26304f;
  --text: #e9edf8;
  --muted: #9aa5c3;
  --sun: #ffcf5c;
  --sun-deep: #ff9f1c;
  --earth: #5aa7ff;
  --node: #ff6b9d;
  --north: #46c2a5;
  --south: #a98bff;
  --ok: #46c2a5;
  --bad: #ff7b72;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(1100px 700px at 72% -8%, #182450 0%, rgba(11, 16, 32, 0) 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

/* ---------- entête ---------- */

.site-header { max-width: 880px; margin: 0 auto; padding: 40px 20px 26px; text-align: center; }
.kicker { margin: 0; color: var(--sun); font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.site-header h1 { margin: .25em 0 .3em; font-size: clamp(1.9rem, 4.5vw, 2.7rem); line-height: 1.15; }
.tagline { margin: 0 auto; max-width: 62ch; color: var(--muted); }

main { max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }

.panel {
  background: linear-gradient(180deg, var(--surface), var(--bg2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { color: var(--muted); font-weight: 400; font-size: .78em; }
.muted { color: var(--muted); font-size: .85rem; }

/* ---------- simulateur ---------- */

.sim-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(300px, 5fr); gap: 16px; }
@media (max-width: 960px) { .sim-grid { grid-template-columns: 1fr; } }

.canvas-panel { padding: 12px; }
.canvas-title { font-size: .85rem; color: var(--muted); margin: 2px 4px 10px; }
.canvas-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #070b17; }
.ratio-square { aspect-ratio: 1 / 1; }
.ratio-wide { aspect-ratio: 16 / 10; }
.ratio-3d { aspect-ratio: 16 / 9; max-height: 540px; }
/* repli pour navigateurs sans aspect-ratio (Safari iOS < 15) : hauteurs fixes */
@supports not (aspect-ratio: 1 / 1) {
  .ratio-square { height: min(92vw, 560px); }
  .ratio-wide { height: min(58vw, 320px); }
  .ratio-3d { height: min(56vw, 540px); }
}
.canvas-wrap canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; display: block; }

.panel-3d { margin-top: 16px; }
#view-3d { touch-action: none; cursor: grab; }
#view-3d:active { cursor: grabbing; }

/* plein écran de la vue 3D (natif :fullscreen, ou repli .fs-fallback pour iOS) */
.fs-btn {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  background: rgba(7, 11, 23, .62); border: 1px solid var(--border); border-radius: 10px;
}
.fs-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.fs-btn:hover svg { stroke: var(--text); }
.fs-controls {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 5;
  display: none; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px;
  padding: 12px 18px; max-width: calc(100% - 24px);
  background: rgba(7, 11, 23, .74); border: 1px solid var(--border); border-radius: 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.fs-controls .scrub { flex: 1; min-width: 220px; }
.canvas-wrap.is-fs .fs-controls { display: flex; }
.canvas-wrap:fullscreen { aspect-ratio: auto; max-height: none; }
.canvas-wrap.fs-fallback {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60;
  aspect-ratio: auto; height: auto; max-height: none; border-radius: 0;
}
.sw { display: inline-block; width: 14px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw-ecl { background: rgba(160, 175, 220, .28); border: 1px solid rgba(160, 175, 220, .55); }
.sw-lun { background: rgba(169, 139, 255, .25); border: 1px solid rgba(169, 139, 255, .6); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 10px 4px 0; padding: 0; font-size: .8rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot-sun { background: var(--sun); }
.dot-earth { background: var(--earth); }
.dot-moon { background: #d8dde8; }
.dot-node { background: var(--node); height: 4px; width: 14px; border-radius: 2px; vertical-align: 2px; }
.dot-north { background: var(--north); }
.dot-south { background: var(--south); }
.dot-city { background: #ffffff; }
.dot-face { background: #ff5d5d; }
.legend .note { font-style: italic; opacity: .75; }

.side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.toggle { display: flex; gap: 7px; align-items: center; font-size: .83rem; color: var(--muted); cursor: pointer; margin-top: 10px; }
.toggle input { accent-color: var(--sun); }

/* bannière d'éclipse */
.banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  max-width: calc(100% - 24px); text-align: center;
  background: linear-gradient(180deg, #3a2d05, #241c04);
  border: 1px solid var(--sun-deep); color: var(--sun);
  padding: 10px 18px; border-radius: 12px; font-weight: 700;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .55);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.banner.show { opacity: 1; }

/* panneau d'état */
.status-panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.date-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#sim-date { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.phase-row { display: flex; gap: 14px; align-items: center; }
.phase-row canvas { width: 76px; height: 76px; flex: none; }
.phase-name { font-weight: 600; }

.readout-label { font-size: .85rem; color: var(--muted); margin-bottom: 5px; }
.readout-label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.gauge { position: relative; height: 10px; background: #0a0f22; border: 1px solid var(--border); border-radius: 6px; }
.gauge-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #5c6f9e; border-radius: 6px; transition: width .1s linear; }
.gauge-bar.hot { background: linear-gradient(90deg, var(--sun), var(--sun-deep)); }
.gauge-limit { position: absolute; left: var(--limit); top: -3px; bottom: -3px; width: 2px; background: var(--node); border-radius: 1px; }
.gauge-caption { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); margin-top: 4px; }

.stats { display: grid; gap: 7px; margin: 0; }
.stats > div { display: flex; justify-content: space-between; gap: 10px; }
.stats dt { color: var(--muted); font-size: .85rem; }
.stats dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }

.conditions { border-top: 1px dashed var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.cond { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: .9rem; }
.cond-mark { font-weight: 700; color: var(--bad); width: 1.1em; flex: none; }
.cond.ok { color: var(--text); }
.cond.ok .cond-mark { color: var(--ok); }
.verdict {
  margin-top: 4px; padding: 10px 12px; border-radius: 10px; text-align: center;
  background: #0a0f22; border: 1px solid var(--border);
  color: var(--muted); font-weight: 600; font-size: .9rem;
}
.verdict.eclipse {
  background: linear-gradient(180deg, #3a2d05, #241c04);
  border-color: var(--sun-deep); color: var(--sun);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { filter: brightness(1.3); } }

/* contrôles */
.controls { margin-top: 16px; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.controls-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.jump-title { color: var(--muted); font-size: .85rem; }

button {
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; cursor: pointer;
  transition: filter .15s, transform .05s;
}
button:hover { filter: brightness(1.25); }
button:active { transform: translateY(1px); }
button.primary { background: #243158; border-color: #3b4c86; min-width: 112px; }
button.accent { background: linear-gradient(180deg, #4a3a0d, #332807); border-color: var(--sun-deep); color: var(--sun); }
button.accent-lunar { background: linear-gradient(180deg, #2b1e52, #1c1433); border-color: #5f43b3; color: var(--south); }
button.mini { padding: 3px 10px; font-size: .78rem; border-radius: 8px; }

.speed { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
#speed-label { min-width: 52px; color: var(--text); font-variant-numeric: tabular-nums; }
.scrub { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); }
.scrub input { width: 100%; }
input[type="range"] { accent-color: var(--sun); }

/* journal */
.log-panel { margin-top: 16px; padding: 14px 18px; }
.log-panel h2 { font-size: 1rem; margin: 0 0 10px; }
.log { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .75rem; font-weight: 700; margin-right: 8px; }
.tag-solar { background: #3a2d05; color: var(--sun); border: 1px solid var(--sun-deep); }
.tag-lunar { background: #1c1433; color: var(--south); border: 1px solid #5f43b3; }

/* ---------- explications ---------- */

.explain { margin-top: 48px; display: grid; gap: 18px; }
.explain > h2 { font-size: 1.5rem; margin: 0 0 2px; }
.explain article { background: linear-gradient(180deg, var(--surface), var(--bg2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; }
.explain h3 { margin: 0 0 10px; font-size: 1.12rem; color: var(--sun); }
.explain p { margin: .55em 0; color: #c9d2ea; }
.explain strong { color: var(--text); }
.explain figure { margin: 18px 0 4px; }
.explain figure svg { width: 100%; height: auto; display: block; }
.explain figcaption { font-size: .8rem; color: var(--muted); margin-top: 6px; text-align: center; }

/* figures SVG */
.f-sun { fill: var(--sun); }
.f-glow { fill: var(--sun); opacity: .16; }
.f-moon { fill: #d8dde8; }
.f-moon-red { fill: #c96a4a; }
.f-earth { fill: var(--earth); }
.f-pen { fill: #9aa5c3; opacity: .13; }
.f-umbra { fill: #04060f; opacity: .88; stroke: rgba(150, 165, 210, .3); stroke-width: 1; }
.f-ray { stroke: var(--sun); opacity: .3; stroke-width: 1; fill: none; }
.f-label { fill: var(--muted); font-size: 13px; font-family: system-ui, sans-serif; }
.f-lead { stroke: var(--muted); opacity: .5; stroke-width: 1; }

/* ---------- pied de page ---------- */

.site-footer { max-width: 1180px; margin: 40px auto 0; padding: 22px 20px 34px; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; }
.site-footer a { color: var(--sun); }

@media (prefers-reduced-motion: reduce) {
  .verdict.eclipse { animation: none; }
  .banner { transition: none; }
  html { scroll-behavior: auto; }
}
