/* ===========================================================================
   OK-ia Markdown Viewer — slideshow ("Diaporama") styles
   Full-screen deck: one slide centered at a time, auto-fitted, with a thin
   progress line, transparent navigation arrows and an end button.
   =========================================================================== */

/* « html » n'est verrouillé que pendant le diaporama : cette feuille est aussi chargée par
   le lecteur, où un overflow:hidden sur la racine empêchait de faire défiler le document.
   La classe est posée par le script à l'ouverture, retirée à la fermeture ; la page
   dédiée du diaporama la porte d'emblée. */
html.present-html, body.present-body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
}

/* ===========================================================================
   THEMES — chosen from the ⚙ menu; override the OK-ia palette inside the deck.
   A theme class is always applied to <body> (default .theme-light), so the
   chosen theme wins over the OS colour scheme.
   =========================================================================== */
/* Each palette is tuned for comfortable contrast: body text ≳ 10:1, secondary
   (muted) text ≳ 4.5:1, accent legible. */
body.present-body.theme-light {
  --bg: #FAFAF8; --fg: #131313; --noir: #131313; --muted: #5c5c54;
  --rule: #E4E2DC; --card-bg: #FFFFFF; --code-bg: #f0eee8; --gris-clair: #EAE8E2;
  --orange: #E8972E;
}
body.present-body.theme-dark {
  --bg: #14141a; --fg: #EDEBE4; --noir: #FFFFFF; --muted: #ABABA0;
  --rule: #33333b; --card-bg: #1e1e25; --code-bg: #24242c; --gris-clair: #2b2b34;
  --orange: #F2AE54;
}
body.present-body.theme-console {
  --bg: #07100a; --fg: #5BE88C; --noir: #9DFFC2; --muted: #4FB377;
  --rule: #18421f; --card-bg: #0c1a0f; --code-bg: #0a160d; --gris-clair: #103018;
  --orange: #4DF58E;
}
body.present-body.theme-sepia {
  --bg: #F3EAD6; --fg: #3F3120; --noir: #2F2415; --muted: #6A5A41;
  --rule: #DBCBAE; --card-bg: #FBF6E9; --code-bg: #EADDC4; --gris-clair: #E6D6B4;
  --orange: #A85416;
}
body.present-body.theme-ocean {
  --bg: #0C1A2B; --fg: #E3EAF3; --noir: #F4F8FD; --muted: #93A8BD;
  --rule: #233A50; --card-bg: #13283A; --code-bg: #0F2233; --gris-clair: #1B3149;
  --orange: #5BC8F5;
}

/* Make themed elements follow --fg/--bg regardless of the OS colour scheme. */
body.present-body[class*="theme-"] .slide-inner :is(h1, h2, h3, h4, h5, h6) { color: var(--fg); }
body.present-body[class*="theme-"] .slide-inner th { background: var(--gris-clair); color: var(--fg); }
body.present-body[class*="theme-"] .slide-inner tr:nth-child(even) td {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}
body.present-body[class*="theme-"] .slide-inner blockquote {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  color: var(--muted);
}
/* Links: blend the accent toward the text colour so link text stays legible
   on every theme (the brand orange alone is too low-contrast on the light bg);
   the underline keeps the accent hue. */
body.present-body[class*="theme-"] .slide-inner a {
  color: color-mix(in srgb, var(--orange) 58%, var(--fg));
  border-bottom-color: color-mix(in srgb, var(--orange) 50%, transparent);
}
/* Inline code follows the theme. */
body.present-body[class*="theme-"] .slide-inner :not(pre) > code { color: var(--fg); }

/* Console theme → monospace typography. */
body.present-body.theme-console .slide-inner,
body.present-body.theme-console .slide-inner :is(h1, h2, h3, h4, h5, h6) {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Diagrams adapt to dark themes: the OK-ia Mermaid palette renders light (white
   nodes, dark text), so on dark backgrounds we flip node graphs to dark while
   preserving the accent hues (invert + hue-rotate). Light themes keep the
   original. Charts (xychart/pie/quadrant/gantt) have filled areas that vanish
   under invert, so they sit on a light "figure" card instead. */
body.present-body.theme-dark .slide-inner pre.mermaid:not(.mermaid-keeplight) svg,
body.present-body.theme-console .slide-inner pre.mermaid:not(.mermaid-keeplight) svg,
body.present-body.theme-ocean .slide-inner pre.mermaid:not(.mermaid-keeplight) svg {
  filter: invert(1) hue-rotate(180deg);
}
body.present-body.theme-dark .slide-inner pre.mermaid.mermaid-keeplight,
body.present-body.theme-console .slide-inner pre.mermaid.mermaid-keeplight,
body.present-body.theme-ocean .slide-inner pre.mermaid.mermaid-keeplight {
  background: #FAFAF8;
  border-radius: 14px;
  padding: 16px 18px;
}

/* The deck fills the safe area; each slide stacks on top, only one is visible.
   `deck-3d` enables a perspective for the 3-D flip transition. */
.deck {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.deck.deck-3d { perspective: 1800px; }

/* Slides stack; transitions are driven inline by JS (transform + opacity), so no
   base CSS transition here. Only the active slide is shown (and interactive). */
.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  backface-visibility: hidden;
  transform-origin: center center;
}
.slide.active {
  opacity: 1;
  pointer-events: auto;
}

/* Fixed 16:9 design canvas (1280×720). It is uniformly scaled by JS (transform)
   to fill the screen — like a real presentation, every slide uses all the room. */
.slide-canvas {
  flex: 0 0 auto;
  width: 1280px;
  height: 720px;
  box-sizing: border-box;
  padding: 48px 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transform-origin: center center;
}

/* Content block inside the canvas. Only scaled DOWN (transform) when it would
   overflow the canvas; otherwise it sits at design size, centred in the canvas. */
.slide-inner {
  width: 100%;
  max-width: none;          /* override .markdown-body's reading-column cap */
  margin: 0;
  padding: 0;
  transform-origin: center center;
  text-align: left;
}

.slide-inner > h1:first-child,
.slide-inner > h2:first-child { margin-top: 0; }
.slide-inner > :last-child { margin-bottom: 0; }

/* Media fills the canvas as much as possible (sizes relative to the 720px frame). */
.slide-inner img {
  display: block;
  margin: 0.4em auto;
  max-width: 100%;
  max-height: 600px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.slide-inner pre.mermaid {
  background: transparent;
  border: none;
  margin: 0.4em auto;
  display: flex;
  justify-content: center;
}
.slide-inner pre.mermaid svg {
  max-width: 100%;
  max-height: 560px;
  height: auto;
}
.slide-inner pre.mermaid[data-rendered="1"]::after { content: none; }

/* Design typography for the 1280px canvas (large, slide-grade). */
.slide-inner h1 { font-size: 3rem; }
.slide-inner h2 { font-size: 2.4rem; }
.slide-inner h3 { font-size: 1.9rem; }
.slide-inner p,
.slide-inner li { font-size: 1.5rem; line-height: 1.5; }
.slide-inner table { font-size: 1.35rem; }
.slide-inner blockquote { font-size: 1.5rem; }

/* ---- map slides: full-bleed (maps can't be transform-scaled) ------------- */
.slide.slide-map .slide-canvas {
  width: 100%;
  height: 100%;
  /* Reserve top room so the opaque map never sits under the top controls
     (gear/overview at top-left, end button at top-right). */
  padding: max(64px, calc(env(safe-area-inset-top) + 52px))
           clamp(12px, 1.6vw, 26px) 16px;
  transform: none !important;
}
.slide.slide-map .slide-inner {
  width: 100%;
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  transform: none !important;
}
/* Compact title so the map takes nearly all the room. */
.slide.slide-map .slide-inner > h1,
.slide.slide-map .slide-inner > h2 {
  flex: 0 0 auto;
  margin: 0 0 0.25em;
  padding-bottom: 0.15em;
  font-size: 1.9rem;
}
.slide.slide-map .okia-map {
  flex: 1 1 auto;
  height: auto !important;
  min-height: 40vh;
  margin: 0;
  width: 100%;
  border-radius: 10px;
}

/* ---- progress line (2 mm) ----------------------------------------------- */
.present-progress {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 2mm;
  background: rgba(120, 120, 120, 0.18);
  z-index: 30;
}
.present-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--orange);
  box-shadow: 0 0 6px color-mix(in srgb, var(--orange) 60%, transparent);
  transition: width 0.28s ease;
}

/* ---- navigation arrows (semi-transparent) -------------------------------- */
.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  width: 56px;
  height: 84px;
  border: none;
  border-radius: 14px;
  background: rgba(40, 40, 40, 0.28);
  color: #fff;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0.45;
  transition: opacity 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.nav-arrow:hover { opacity: 0.95; background: rgba(232, 151, 46, 0.55); }
.nav-arrow:disabled { opacity: 0.12; pointer-events: none; }
.nav-prev { left: max(12px, env(safe-area-inset-left)); }
.nav-next { right: max(12px, env(safe-area-inset-right)); }

/* ---- end button ---------------------------------------------------------- */
.present-end {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 40;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.30);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0.5;
  transition: opacity 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.present-end:hover { opacity: 1; background: rgba(232, 151, 46, 0.6); }

/* ---- transitions menu (gear, top-left) ----------------------------------- */
.present-menu-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 41;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.30);
  color: #fff;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0.5;
  transition: opacity 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.present-menu-btn:hover { opacity: 1; background: rgba(232, 151, 46, 0.6); }

.present-menu {
  position: fixed;
  top: max(66px, calc(env(safe-area-inset-top) + 52px));
  left: max(14px, env(safe-area-inset-left));
  z-index: 41;
  min-width: 196px;
  max-height: 78vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  border-radius: 14px;
  background: rgba(28, 28, 30, 0.82);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color: #fff;
}
.present-menu .present-menu-title:not(:first-child) { margin-top: 8px; }
.present-menu[hidden] { display: none; }
.present-menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  padding: 6px 10px 4px;
}
.present-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.present-menu-item:hover { background: rgba(255, 255, 255, 0.10); }
.present-menu-item.selected { background: rgba(232, 151, 46, 0.30); }
.present-menu-item.selected::after {
  content: '✓';
  margin-left: auto;
  color: var(--orange-clair);
  font-weight: 700;
}

/* ---- overview button (grid, top-left next to the gear) ------------------- */
.present-grid-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(68px, calc(env(safe-area-inset-left) + 68px));
  z-index: 41;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.30);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0.5;
  transition: opacity 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.present-grid-btn:hover { opacity: 1; background: rgba(232, 151, 46, 0.6); }

/* ---- overview overlay (slide navigator) ---------------------------------- */
.present-overview {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: rgba(18, 18, 22, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.present-overview[hidden] { display: none; }
.overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
  flex: 0 0 auto;
}
.overview-title { font-size: 17px; font-weight: 700; letter-spacing: 0.01em; }
.overview-close {
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff; font-size: 18px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.overview-close:hover { background: rgba(232, 151, 46, 0.6); }

.overview-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  padding: 6px;
  align-content: start;
}
.overview-item {
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.overview-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}
.overview-item.current .overview-frame {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(232, 151, 46, 0.5);
}
.overview-item:hover .overview-frame { border-color: rgba(232, 151, 46, 0.7); }

/* The stage holds a 1:1 clone of the slide content, scaled by JS (top-left). */
.overview-stage {
  position: absolute;
  top: 0; left: 0;
  transform-origin: top left;
  pointer-events: none;
}
.overview-stage-pad {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 48px 72px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.overview-map-ph {
  flex: 1 1 auto;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 180px;
  background: var(--gris-clair);
  border-radius: 12px;
}
.overview-num {
  position: absolute;
  left: 8px; bottom: 8px;
  z-index: 2;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.overview-label {
  margin-top: 7px;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.88);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.overview-item.current .overview-label { color: var(--orange-clair); font-weight: 700; }

/* ---- slide counter ------------------------------------------------------- */
.present-counter {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: calc(2mm + 10px);
  z-index: 40;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

/* ---- icônes des commandes : des tracés, pas des glyphes ------------------ */
/* Les caractères ✕ ⚙ ▦ manquaient à la police du WebView en simulateur et sortaient en
   « ? » — jusque sur les captures store. Un SVG inline se dessine partout pareil. */
.present-end, .present-menu-btn, .present-grid-btn, .overview-close {
  display: flex;
  align-items: center;
  justify-content: center;
}
.present-end svg, .present-menu-btn svg, .present-grid-btn svg, .overview-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
