/* ============================================================================
   theme.css — Design system for the CEPS09 C208 briefing suite
   "EFB Day-Mode" — an electronic-flight-bag / approach-chart aesthetic.
   Shared by index, perf-decollage, briefing-demi-journee and centrage
   (the last via ../centrage_c208/_write_html.py). Single source of truth:
   tokens + base + reusable components. Page-specific layout stays inline
   in each page but consumes these tokens, so the suite reads as one tool.

   Type   : IBM Plex superfamily — Sans (body), Sans Condensed (instrument
            labels / headings, tracked uppercase), Mono (every readout /
            number, tabular figures — numbers read like cockpit gauges).
   Light by default (sunlight-readable at the airfield). A dark scope
   (:root[data-theme="dark"]) reskins the same components for the landing
   hero / night use.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Condensed:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

/* ---- Tokens ------------------------------------------------------------- */
:root {
  /* type */
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* surfaces — cool "chart paper" */
  --paper:     #e9eef4;
  --paper-2:   #dfe6ee;
  --surface:   #ffffff;
  --surface-2: #f4f7fb;   /* inset / readout face */
  --surface-3: #eaf0f7;

  /* ink */
  --ink:    #102639;   /* primary text — aviation ink */
  --ink-2:  #3a5571;
  --muted:  #6a7d92;

  /* rules */
  --line:   #d6dfe9;   /* hairline */
  --line-2: #c1cedb;   /* stronger rule / control border */

  /* brand + accents */
  --navy:   #173a5e;
  --navy-2: #1f4f7d;
  --amber:  #e8a020;   /* attention / caution — brand accent */
  --amber-d:#c5820e;
  --amber-ink:#3a2706;
  --cyan:   #0d8aa3;   /* approach-plate / active instrument accent */
  --cyan-d: #0a6e82;

  /* avionics status */
  --ok:      #1f9d57;  --ok-bg:#e2f4ea;  --ok-ink:#10623a;  --ok-line:#aaddc0;
  --warn:    #d98a0b;  --warn-bg:#fcf1da; --warn-ink:#8a5806; --warn-line:#efd49a;
  --danger:  #c0392b;  --danger-bg:#fbe4e0; --danger-ink:#8f261b; --danger-line:#eeb2aa;
  --info-bg: #e1f1f6;  --info-line:#b6dde7;

  /* radius / depth */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16,38,57,.06), 0 1px 3px rgba(16,38,57,.07);
  --shadow:    0 2px 6px rgba(16,38,57,.07), 0 8px 22px rgba(16,38,57,.07);
  --shadow-lg: 0 14px 40px rgba(16,38,57,.16);

  /* spacing */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:22px; --sp-6:32px;

  --focus: 0 0 0 3px rgba(232,160,32,.32);
  --grid-ink: rgba(23,58,94,.045);   /* faint chart-paper grid */
}

/* ---- Dark scope (landing hero / night) ---------------------------------- */
:root[data-theme="dark"] {
  --paper:     #091523;
  --paper-2:   #0c1a2b;
  --surface:   #122439;
  --surface-2: #16304b;
  --surface-3: #1c3551;
  --ink:    #e9eff7;
  --ink-2:  #b3c4d8;
  --muted:  #8296ad;
  --line:   #243c5a;
  --line-2: #2f4c70;
  --navy:   #1f4f7d;
  --navy-2: #2a6299;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 6px 22px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
  --info-bg:#10303c; --info-line:#1d5666;
  --grid-ink: rgba(120,170,220,.05);
}

/* ---- Reset / base ------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--paper);
  /* chart-paper grid + soft top glow */
  background-image:
    radial-gradient(1100px 520px at 78% -12%, rgba(23,58,94,.06), transparent 70%),
    linear-gradient(var(--grid-ink) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-ink) 1px, transparent 1px);
  background-size: 100% 100%, 30px 30px, 30px 30px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
:root[data-theme="dark"] body {
  background-image:
    radial-gradient(1200px 600px at 72% -10%, rgba(64,128,196,.18), transparent 68%),
    linear-gradient(var(--grid-ink) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-ink) 1px, transparent 1px);
}
a { color: var(--cyan-d); text-decoration: none; }
a:hover { color: var(--cyan); }
h1, h2, h3 { line-height: 1.15; }

/* tabular mono numbers wherever wanted */
.mono, .tnum { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* instrument label / eyebrow */
.eyebrow, .label-instr {
  font-family: var(--font-cond);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .74rem;
  font-weight: 600;
  color: var(--cyan-d);
}

/* ---- App header (tool pages) ------------------------------------------- */
.app-header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 22px;
  color: #eaf2fb;
  background: linear-gradient(180deg, #1e4c79, #143352);
  border-bottom: 2px solid var(--amber);
  box-shadow: var(--shadow-sm);
}
.app-header .logo { flex: none; display: inline-flex; }
.app-header h1 {
  font-family: var(--font-cond); font-weight: 600; font-size: 1.16rem;
  letter-spacing: .015em; margin: 0; color: #fff;
}
.app-header .badge {
  font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .08em;
  font-weight: 600; font-size: .7rem;
  background: var(--amber); color: var(--amber-ink);
  padding: 3px 10px; border-radius: 999px;
}
.app-header .spacer { flex: 1; }
.app-header a.home {
  color: #bdd6ef; font-family: var(--font-cond); text-transform: uppercase;
  letter-spacing: .07em; font-size: .8rem; white-space: nowrap;
}
.app-header a.home:hover { color: #fff; }

/* ---- Layout helpers ----------------------------------------------------- */
.wrap { max-width: 1500px; margin: 0 auto; padding: 18px 22px; }
.row  { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }
.stack{ display: flex; flex-direction: column; gap: var(--sp-3); }
.spacer { flex: 1; }

/* ---- Card --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* section header as instrument label: accent tick + hairline rule */
.card > h2, .section-title {
  font-family: var(--font-cond);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 600;
  font-size: .84rem;
  color: var(--navy);
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
:root[data-theme="dark"] .card > h2,
:root[data-theme="dark"] .section-title { color: #cfe0f2; }
.card > h2::before, .section-title::before {
  content: ""; flex: none; width: 9px; height: 9px; border-radius: 2px;
  background: var(--amber); box-shadow: 0 0 0 3px rgba(232,160,32,.18);
}
.card > h2 .sub, .section-title .sub {
  margin-left: auto; font-family: var(--font-sans); text-transform: none;
  letter-spacing: 0; font-weight: 500; font-size: .72rem; color: var(--muted);
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .05em;
  font-weight: 600; font-size: .82rem;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--navy); color: #fff; cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .08s ease, box-shadow .14s ease;
}
.btn:hover { background: var(--navy-2); }
.btn:active { transform: translateY(1px); }
.btn.accent { background: var(--amber); color: var(--amber-ink); }
.btn.accent:hover { background: var(--amber-d); }
.btn.ghost { background: var(--surface); color: var(--navy); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--cyan); color: var(--cyan-d); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
:root[data-theme="dark"] .btn.ghost { color: #cfe0f2; }

/* ---- Form controls ------------------------------------------------------ */
input[type=number], input[type=text], input[type=date], input[type=time],
input[type=password], select, textarea {
  font-family: var(--font-sans); font-size: .92rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
  transition: border-color .14s ease, box-shadow .14s ease;
}
/* numbers entered read like instrument entries */
input[type=number], input[type=date], input[type=time] {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--amber); box-shadow: var(--focus);
}
input[readonly] { background: var(--surface-3); color: var(--ink-2); cursor: not-allowed; }
label { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .05em;
  font-size: .72rem; font-weight: 600; color: var(--ink-2); }

/* ---- Form layout helpers (shared by perf + briefing) -------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status { font-size: .82rem; color: var(--muted); min-height: 1.1em; }

/* ---- Instrument readout (the signature panel) --------------------------- */
.readout {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px 11px;
  display: flex; flex-direction: column; gap: 2px;
}
.readout::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--line-2);
}
.readout .lbl {
  font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .07em;
  font-size: .68rem; font-weight: 600; color: var(--muted);
}
.readout .val {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
  font-size: 1.5rem; font-weight: 600; color: var(--navy); line-height: 1.05;
}
:root[data-theme="dark"] .readout .val { color: #dce9f7; }
.readout .unit { font-size: .66rem; color: var(--muted); }
.readout.hl  { background: var(--info-bg); border-color: var(--info-line); }
.readout.hl::before  { background: var(--cyan); }
.readout.hl2 { background: var(--warn-bg); border-color: var(--warn-line); }
.readout.hl2::before { background: var(--amber); }
.readout.ok::before     { background: var(--ok); }
.readout.warn::before   { background: var(--warn); }
.readout.danger::before { background: var(--danger); }

/* ---- Status bar + pills (avionics semantics) ---------------------------- */
.status-bar {
  font-family: var(--font-sans); font-weight: 600; font-size: .86rem;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.status-ok     { background: var(--ok-bg);     color: var(--ok-ink);     border-color: var(--ok-line); }
.status-warn   { background: var(--warn-bg);   color: var(--warn-ink);   border-color: var(--warn-line); }
.status-danger { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger-line); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; font-size: .73rem; padding: 4px 11px; border-radius: 999px;
  border: 1px solid transparent;
}
.pill.ok     { background: var(--ok-bg);     color: var(--ok-ink);     border-color: var(--ok-line); }
.pill.warn   { background: var(--warn-bg);   color: var(--warn-ink);   border-color: var(--warn-line); }
.pill.danger { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger-line); }
.pill.info   { background: var(--info-bg);   color: var(--cyan-d);     border-color: var(--info-line); }

/* ---- Segmented toggle --------------------------------------------------- */
.toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface); }
.toggle button {
  font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600; font-size: .82rem; color: var(--ink-2);
  padding: 7px 14px; border: none; background: transparent; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.toggle button + button { border-left: 1px solid var(--line); }
.toggle button:hover { background: var(--surface-2); }
.toggle button.active { background: var(--navy); color: #fff; }

/* ---- Hairline table ----------------------------------------------------- */
.t-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.t-table th, .t-table td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: right; }
.t-table th { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .05em;
  font-size: .7rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.t-table td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.t-table td:first-child, .t-table th:first-child { text-align: left; }

/* ---- Footer ------------------------------------------------------------- */
.app-footer, footer.app-footer {
  text-align: center; padding: 18px; font-size: .76rem; color: var(--muted);
  line-height: 1.6;
}
.app-footer code, footer code {
  font-family: var(--font-mono); color: var(--ink-2);
  background: rgba(23,58,94,.07); padding: .1rem .4rem; border-radius: 5px;
}

/* ---- Lightbox ----------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; background: rgba(8,18,30,.88);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 95%; max-height: 95%; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); }

/* ---- Motion: staggered load reveal (opt-in via .reveal) ----------------- */
@keyframes instr-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; animation: instr-rise .5s cubic-bezier(.22,.61,.36,1) forwards; }
  .reveal:nth-child(1){animation-delay:.04s}.reveal:nth-child(2){animation-delay:.10s}
  .reveal:nth-child(3){animation-delay:.16s}.reveal:nth-child(4){animation-delay:.22s}
  .reveal:nth-child(5){animation-delay:.28s}.reveal:nth-child(6){animation-delay:.34s}
}

::selection { background: rgba(232,160,32,.28); }

/* ════════════════════════════════════════════════════════════════════════
   Tablette & smartphone — couche responsive ajoutée pour briefing-deco.
   Le thème de base est fluide (flex/grid + clamp) ; on ajoute ici des
   points de rupture qui passent les grilles en une colonne et agrandissent
   les cibles tactiles (≥ 44 px) pour l'usage sur le terrain (gants, soleil).
   ════════════════════════════════════════════════════════════════════════ */

/* Cibles tactiles confortables dès qu'on est sur un écran tactile. */
@media (pointer: coarse) {
  .btn { padding: 12px 18px; font-size: .9rem; min-height: 44px; }
  .toggle button { padding: 11px 16px; min-height: 44px; }
  input[type=number], input[type=text], input[type=date], input[type=time],
  input[type=password], select, textarea { padding: 11px 12px; font-size: 16px; /* ≥16px ⇒ pas de zoom auto iOS */ min-height: 44px; }
  .pill { padding: 6px 13px; }
  .step { min-height: 44px; }
}

/* Tablette portrait & petits écrans. */
@media (max-width: 820px) {
  .wrap { padding: 12px 14px; }
  .app-header { padding: 10px 14px; gap: 10px; }
  .app-header h1 { font-size: 1.02rem; }
  .card { padding: 14px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .tiles { gap: 9px; }
}

/* Smartphone. */
@media (max-width: 560px) {
  .wrap { padding: 10px 11px; }
  .app-header { gap: 8px 10px; }
  .app-header h1 { font-size: .96rem; }
  .app-header .badge { font-size: .62rem; padding: 2px 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1 / -1; }
  .readout .val { font-size: 1.3rem; }
  .btn-row { gap: 7px; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  /* Tables larges : scroll horizontal plutôt que débordement. */
  .t-table, .pf-table { font-size: .8rem; }
  h1 { font-size: 1.4rem; }
}
