/* mobile_ios_webview.css */

/* =========================
   iOS-ish palette + base
   ========================= */
:root{
  --bg: #f2f2f7;          /* iOS grouped background */
  --card: #ffffff;
  --text: #111827;        /* near-black */
  --muted: #4b5563;       /* dark gray */
  --hairline: rgba(60,60,67,.18);
  --accent: #0a84ff;      /* iOS blue */
  --accent-soft: rgba(10,132,255,.10);
  --radius: 14px;
  --maxw: 980px;

  --gallery-maxw: 800px;

  /* ✅ coins arrondis images */
  --img-radius: 0px;

  /* ✅ Split : largeur colonne image (par défaut) */
  --split-media: 28%;

  /* ✅ Marges “page” (PORTRAIT par défaut) */
  --page-pad-top: 5px;
  --page-pad-right: 5px;
  --page-pad-bottom: 5px;   /* ✅ FIX: au lieu de 50px */
  --page-pad-left: 5px;

  /* ✅ Décalage captions (garde text-align:center mais décale visuellement) */
  --figcaption-shift: 0px;            /* figures “normales” */
  --gallery-caption-shift: 8px;      /* gallery */
  --gallery-caption-shift-sm: 7px;    /* petit écran */
}

/* ✅ iPhone : colonne image un peu plus large => texte plus étroit */
@media (max-width: 520px){
  :root{ --split-media: 35%; }
}

/* ✅ iPad : colonne image un peu plus étroite => texte plus large */
@media (min-width: 768px) and (max-width: 1024px){
  :root{ --split-media: 25%; }
}

*{ box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.center{ text-align: center; }

/* Links */
a{ color: var(--accent); text-decoration:none; }
a:hover{ text-decoration: underline; }

/* =========================
   Container + Card
   ========================= */
.page{
  max-width: var(--maxw);
  margin: 0 auto;

  /* ✅ FIX: portrait = pas de env(safe-area-inset-bottom)
     (SwiftUI gère déjà la safe-area du bas => sinon double padding) */
  padding:
    calc(var(--page-pad-top) + env(safe-area-inset-top))
    calc(var(--page-pad-right) + env(safe-area-inset-right))
    var(--page-pad-bottom)
    calc(var(--page-pad-left) + env(safe-area-inset-left));
}

.sheet{
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 16px;
}

/* Header */
.lesson-header{
  padding-bottom: 10px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--accent);
}
.lesson-title{
  margin:0;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--accent);
}
.lesson-subtitle{
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: .98rem;
}

/* Section titles */
.section{ margin: 18px 0 26px; }
.section-title{
  margin: 0 0 10px;
  font-size: 1.18rem;
  color: var(--accent);
}
.block-title{
  margin: 14px 0 8px;
  font-size: 1.05rem;
  color: var(--accent);
}

/* Paragraphs */
p{
  margin: 0 0 10px;
  color: var(--text);

  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.small{ font-size: 1rem; color: var(--muted); }

.progress{
  font-weight: 700;
  color: var(--accent);
}
strong{ font-weight: 700; }

/* =========================
   Callout
   ========================= */
.callout{
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
}
.callout p{ margin: 0 0 8px; }
.callout p:last-child{ margin-bottom: 0; }

/* =========================
   Images / Figures
   ========================= */
img{
  max-width: 100%;
  max-height: 100%;
  height: auto;
  display: block;
  border: 0;
  outline: none;
  margin-left: auto;
  margin-right: auto;

  /* ✅ bords arrondis pour TOUTES les images */
  border-radius: var(--img-radius);
}

/* si jamais tu utilises <img class="imgseule"> */
img.imgseule{ max-height: 300px; }

/* (au cas où tu avais déjà un tag custom <imgseule> dans tes HTML) */
imgseule{
  max-height: 300px;
  display: block;
  border: 0;
  outline: none;
  margin-left: auto;
  margin-right: auto;
  border-radius: var(--img-radius);
}

figure{ margin: 12px 0; }

.figure-frame{
  border-radius: var(--img-radius);
  overflow: hidden;                 /* ✅ indispensable pour clipper */
  background: #fff;
  -webkit-transform: translateZ(0); /* ✅ fix Safari iOS clipping */
  display: flex;
  justify-content: center;
  align-items: center;
}

.figure-frame img{
  max-height: 400px;
}

figcaption{
  margin-top: 8px;
  font-size: .92rem;
  color: var(--muted);
  text-align: center;

  /* ✅ décale le texte tout en restant centré */
  padding-left: 0;
  transform: translateX(var(--figcaption-shift));
  will-change: transform;
}

/* Image alignment helpers */
figure.center{ text-align: center; }
figure.left{ text-align: left; }
figure.right{ text-align: right; }

img.left{ margin-left: 0; margin-right: auto; }
img.right{ margin-left: auto; margin-right: 0; }
img.center{ margin-left: auto; margin-right: auto; }

/* Limit image width when needed */
img.w-80{ width: 80%; }
img.w-70{ width: 70%; }
img.w-60{ width: 60%; }

/* =========================
   Split layout (text + image side)
   ========================= */
.split{ display: block; gap: 16px; }

@media (min-width: 760px){
  .sheet{ padding: 18px; }
  .split{ display: flex; align-items: flex-start; }
  .split > .split-text{ flex: 1.15; }
  .split > .split-media{ flex: 0.85; }

  .split.right .split-text{ order: 1; }
  .split.right .split-media{ order: 2; }
  .split.left  .split-text{ order: 2; }
  .split.left  .split-media{ order: 1; }
}

/* =========================
   iOS bullets
   ========================= */
ul{
  list-style: none;
  margin: 10px 0 14px;
  padding: 0;
}
ul li{
  position: relative;
  padding-left: 20px;
  margin: 8px 0;
  color: var(--text);
}
ul li::before{
  content: "";
  position: absolute;
  left: 0;
  top: 0.80em;
  transform: translateY(-50%);
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,132,255,.12);
}

/* Nested UL */
ul ul{
  margin-top: 8px;
  margin-bottom: 8px;
  padding-left: 0;
}
ul ul li{ padding-left: 18px; }
ul ul li::before{
  width: 6px;
  height: 6px;
  background: rgba(60,60,67,.55);
  box-shadow: none;
}

ol{
  margin: 10px 0 14px 20px;
  padding: 0;
}
ol li{ margin: 8px 0; color: var(--text); }

ul.compact li,
ol.compact li{ margin: 5px 0; }

.classic-lists ul{
  list-style: disc;
  margin-left: 18px;
}
.classic-lists ul li{ padding-left: 0; }
.classic-lists ul li::before{ content: none; }

/* =========================
   Footer
   ========================= */
.footer{
  margin-top: 16px;
  text-align: right;
  color: var(--muted);
  font-size: .85rem;
}

/* =========================
   Menu
   ========================= */
.menu-title{ margin:0 0 14px; font-size:1.35rem; color:var(--accent); }

.menu-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px){
  .menu-grid{ grid-template-columns: repeat(2, 1fr); }
}

.menu-card{
  display:block;
  padding: 14px 14px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: #fff;
}
.menu-card:hover{ background: rgba(10,132,255,.06); }
.menu-card h2{
  margin:0 0 4px;
  font-size: 1.05rem;
  color: var(--text);
}
.menu-card p{
  margin:0;
  color: var(--muted);
  font-size: .95rem;
}

/* Inline tiny icons inside paragraphs */
img.icon-inline{
  display: inline-block;
  margin: 0 6px 0 0;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  border-radius: 4px !important;
}

/* =========================
   Note map (A=La etc.)
   ========================= */
.note-map{
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: #fff;
}

.note-map-row{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  text-align: center;
  font-size: 1rem;
}

@media (min-width: 520px){
  .note-map-row{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 820px){
  .note-map-row{ grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* =========================
   Degree box (progressions texte)
   ========================= */
.degree-box{
  margin: 12px 0 14px;
  padding: 12px 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: #fff;
}
.degree-box p{ margin: 6px 0; }
.degree-box strong{ color: var(--text); }

/* =========================
   Note grids (cartes)
   ========================= */
.note-grid{
  margin: 12px 0 14px;
  padding: 12px;
  border: 0px solid var(--hairline);
  border-radius: 12px;
  background: #fff;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  text-align: center;
}

@media (min-width: 520px){
  .note-grid{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 820px){
  .note-grid{ grid-template-columns: repeat(12, minmax(0, 1fr)); }
}

.gamme{ grid-template-columns: repeat(7, minmax(0, 1fr)); }

.note{
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  font-weight: 700;
  user-select: none;
}

.note.in{
  color: var(--text);
  background: rgba(10,132,255,.08);
}
.note.out{
  color: rgba(17,24,39,.35);
  background: rgba(60,60,67,.06);
}

/* 2 accords dans une case : plus petit */
.note-grid.chords .note.small-chord{
  font-size: 0.7em;
  padding: 22px 1px 1px;
  white-space: nowrap;
}

/* Degrés affichés (label en haut à gauche) */
.note-grid.degrees .note{
  position: relative;
  padding-top: 18px;
}
.note-grid.degrees .note::after{
  content: attr(data-deg);
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: .74rem;
  font-weight: 800;
  color: rgba(17,24,39,.55);
}
.note.no-deg::after{ content: ""; }

.note-grid.degrees .note.hilite{
  background: rgba(10,132,255,.16);
  border-color: rgba(10,132,255,.35);
  box-shadow: 0 1px 0 rgba(10,132,255,.10);
}

.note.in.diatonique{
  background: rgba(213,128,56,.16);
  border-color: rgba(213,128,56,1);
  box-shadow: 0 1px 0 rgba(10,132,255,.10);
}

.note.in.tritonique{
  background: rgba(20,255,110,.16);
  border-color: rgba(20,255,110,1);
  box-shadow: 0 1px 0 rgba(10,132,255,.10);
}

.note.in.ds{
  background: rgba(255, 193, 7, .14);
  border-color: rgba(255, 193, 7, .35);
  box-shadow: 0 1px 0 rgba(255, 193, 7, .10);
}

.note-grid.degrees .note.hilite::after{ color: var(--accent); }

.note-grid.degrees .note.hilite-sub{
  background: rgba(52, 199, 89, .14);
  border-color: rgba(52, 199, 89, .35);
  box-shadow: 0 1px 0 rgba(52, 199, 89, .10);
  color: var(--text);
}
.note-grid.degrees .note.hilite-sub::after{ color: rgba(17,24,39,.65); }

.note-grid.degrees .note[data-deg*="DS"]{
  background: rgba(255, 193, 7, .14);
  border-color: rgba(255, 193, 7, .35);
  box-shadow: 0 1px 0 rgba(255, 193, 7, .10);
  color: var(--text);
}
.note-grid.degrees .note[data-deg*="DS"]::after{ color: rgba(176, 120, 0, .95); }

.note-grid.degrees .note.deg-accent{
  background: rgba(255, 45, 85, .12);
  border-color: rgba(255, 45, 85, .28);
  box-shadow: 0 1px 0 rgba(255, 45, 85, .08);
}

/* =========================
   Variantes de grilles (forcer X colonnes)
   ========================= */
.note-grid.note-grid-2{
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}
.note-grid.note-grid-3{
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
}
.note-grid.note-grid-4{
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  max-width: 860px;
  margin: 12px auto;
}

.note-grid-center{
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* =========================
   Cases “accords multiples”
   ========================= */
.note.small-chord{
  font-size: .62em;
  letter-spacing: 0;
  padding: 6px 0;
  white-space: nowrap;
}

.note .stack{
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.note .stack .sub{
  font-size: .84em;
  font-weight: 700;
  opacity: .9;
  margin-top: 2px;
}

/* =========================
   Gamme : steps (tons/demi-tons)
   ========================= */
.note-grid.scale-steps{
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.note-grid.scale-steps .note{
  position: relative;
  padding-top: 18px;
  padding-bottom: 22px;
  background: rgba(60,60,67,.06);
  border-color: rgba(60,60,67,.18);
  color: var(--text);
}
.note-grid.scale-steps .note::after{
  content: attr(data-deg);
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: .72rem;
  font-weight: 800;
  color: rgba(17,24,39,.45);
  text-transform: uppercase;
}
.note-grid.scale-steps .note::before{
  content: "→ " attr(data-step) " ton";
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: .78rem;
  font-weight: 800;
  color: rgba(17,24,39,.50);
  background: rgba(60,60,67,.04);
  border: 1px solid rgba(60,60,67,.12);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.note-grid.scale-steps .note[data-step="1"]::before{ content: "→ 1 ton"; }

/* =========================
   Galleries (images + captions)
   ========================= */
.gallery{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0px;

  width: 100%;
  max-width: var(--gallery-maxw);
  margin: 12px auto;
}

.gallery figure{
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.gallery .figure-frame{
  width: 100%;
  height: 250px;
  margin-top: 12px;

  border-radius: var(--img-radius);
  overflow: hidden;
  background: #fff;
  -webkit-transform: translateZ(0);

  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery .figure-frame img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  margin: 0 !important;
  display: block;
  border-radius: var(--img-radius);
}

.gallery figcaption{
  margin-top: 6px;
  margin-left: 0;
  text-align: center;
  font-weight: 700;
  line-height: 1.15;

  padding-left: 0;
  transform: translateX(var(--gallery-caption-shift));
  will-change: transform;
}

.gallery.gallery-chords-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery.gallery-chords-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery.gallery-chords-4{ grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 520px) and (orientation: portrait){
  .gallery.gallery-chords-3 .figure-frame{ height: 190px; }
  .gallery.gallery-chords-4 .figure-frame{ height: 160px; }

  .gallery .figure-frame{ margin-top: 8px; }
  .gallery figcaption{
    font-size: .88rem;
    transform: translateX(var(--gallery-caption-shift-sm));
  }
}

@media (max-width: 390px) and (orientation: portrait){
  .gallery.gallery-chords-3 .figure-frame{ height: 170px; }
  .gallery.gallery-chords-4 .figure-frame{ height: 145px; }
  .gallery figcaption{ font-size: .84rem; }
}

/* =========================
   Split (force)
   ========================= */
.split.force{
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.split.force.vcenter{ align-items: center; }

.split.force > .split-text{
  flex: 1 1 0;
  min-width: 0;
}
.split.force > .split-media{
  flex: 0 0 var(--split-media);
  max-width: 50%;
}

.split.force .split-media figure{
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.split.force .split-media .figure-frame{
  height: auto;
  max-height: 200px;
  overflow: hidden;
  border-radius: var(--img-radius);
  background: #fff;
  -webkit-transform: translateZ(0);

  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.split.force .split-media .figure-frame img{
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  display: block;
  padding-left: 0;
  border-radius: var(--img-radius);
}

.split.force .split-media figcaption{
  margin-top: 6px;
  line-height: 1.15;
  text-align: center;
}

@media (min-width: 520px){
  .note-grid.note-grid-7{
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  }
}

.callout-soft{
  margin: 0px 0;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(60,60,67,.04);
}
.callout-soft p{ margin: 0; }

/* =========================
   Landscape: full-width layout + margins
   ========================= */
@media (orientation: landscape){
  :root{
    --page-pad-top: 20px;
    --page-pad-right: 20px;
    --page-pad-bottom: 10px;
    --page-pad-left: 20px;
  }

  .page{
    max-width: none;
    margin: 0;
    padding-bottom: calc(var(--page-pad-bottom) + env(safe-area-inset-bottom));
  }

  .sheet{
    border-radius: 10px;
    border-left: 0;
    border-right: 0;
  }
}

/* =========================
   ✅ iPad : éviter que les grilles 2/3/4 prennent TOUTE la largeur
   ========================= */
@media (min-width: 768px){
  .gallery .figure-frame{ height: 300px; }

  .gallery.gallery-chords-2{
    grid-template-columns: repeat(2, minmax(0, 340px));
    justify-content: center;
    gap: 12px;
  }
  .gallery.gallery-chords-3{
    grid-template-columns: repeat(3, minmax(0, 260px));
    justify-content: center;
    gap: 12px;
  }
  .gallery.gallery-chords-4{
    grid-template-columns: repeat(4, minmax(0, 220px));
    justify-content: center;
    gap: 10px;
  }
}

/* =========================
   Lightbox (click -> full screen)
   ========================= */

#lightbox{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;

  align-items: center;
  justify-content: center;

  padding: 14px;
  background: rgba(0,0,0,.55);
}

#lightbox.is-open{ display: flex; }

body.lb-open{ overflow: hidden; }

#lightbox .lb-inner{
  width: 100%;
  max-width: min(94vw, 980px);
  max-height: 92vh;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#lightbox .lb-stage{
  width: 100%;
  flex: 1;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#lightbox .lb-img{
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;

  -webkit-user-drag: none;
  user-select: none;

  cursor: pointer; /* ✅ indique “cliquer pour fermer” */
}

#lightbox .lb-caption{
  color: #fff;
  text-align: center;
  font-size: 14px;
  line-height: 1.25;
  padding: 0 8px;
}

/* Empêche clic sur les crbst_ (si tu veux) */
.gallery img[src^="crbst_"]{
  pointer-events: none;
  cursor: default;
}
.gallery img:not([src^="crbst_"]){
  cursor: zoom-in; /* ici c'est juste “clic possible”, pas zoom */
}

/* ✅ iOS: évite l’auto-agrandissement de texte */
html { -webkit-text-size-adjust: 100%; }

/* ✅ Gamme : note + numéro toujours sur UNE ligne */
.note-grid.gamme .note{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.1;
}

.note-grid.gamme .note img.icon-inline{
  display: block;
  margin: 0 !important;
  width: 18px;
  height: 18px;
}

@media (max-width: 420px){
  .note-grid.gamme .note{
    font-size: clamp(.85rem, 3.4vw, 1rem);
  }
  .note-grid.gamme .note img.icon-inline{
    width: 16px;
    height: 16px;
  }
}
