/* Mandala Maker - feuille de style unique
   Version 5.0 : design "interface fina-finall" (cadres déformés selon leur place, guirlande de couleurs en jeu,
   papier en surimpression sur tout le site, cadre de dessin blanc, aucune ombre).
   Principe : tout est positionné en "pixels du design" (1030 x 700) via --x --y --w --h, multipliés par --u. */

/* ---------- Typographie : Yatra One, pour tout le site (Catherine Leigh Schmidt, Google Fonts, licence SIL OFL) ----------
   Lettrage peint au pinceau, latin taillé avec l'angle de plume du devanagari (l'écriture du népali).
   Une seule graisse (400) : pas de faux gras. Fichiers : assets/fonts/yatra-one/ */
@font-face { font-family: "Yatra One"; font-weight: 400; font-display: swap; src: url("../assets/fonts/yatra-one/yatra-one-latin-ext-400-normal.woff2") format("woff2"), url("../assets/fonts/yatra-one/yatra-one-latin-ext-400-normal.woff") format("woff");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Yatra One"; font-weight: 400; font-display: swap; src: url("../assets/fonts/yatra-one/yatra-one-latin-400-normal.woff2") format("woff2"), url("../assets/fonts/yatra-one/yatra-one-latin-400-normal.woff") format("woff");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
:root { --font: "Yatra One", cursive; }
.empty-hint, .toast { font-weight: 400; letter-spacing: .02em; }

/* ---------- Variables ---------- */
:root {
  --pad: clamp(10px, 3vmin, 34px);                       /* marge autour de l'interface : rien ne touche les bords */
  --dw: 1148; --dh: 718; --oy: 5;                       /* format du design (paysage) : contenu de y 71 à 679, recadré avec 10 px de marge ; voir le portrait plus bas */
  --u: min(calc((100vw - 2 * var(--pad)) / var(--dw)), calc((100vh - 2 * var(--pad)) / var(--dh)));   /* 1 pixel du design */
  --ink: #1d1d1b;
  --red: #e30d17; --yellow: #f0b64f; --green: #00794f;
  /* Survol (v8) : contour décalé, net (aucun flou), épais : deux décalages enchaînés forment une bande pleine.
     Jaune sur les cadres ; encre sur les éléments colorés (cases Couleur / Contour, drapeaux). */
  --hov: drop-shadow(calc(2.2 * var(--u)) calc(1.8 * var(--u)) 0 var(--yellow)) drop-shadow(calc(1.8 * var(--u)) calc(1.5 * var(--u)) 0 var(--yellow));
  --hov-ink: drop-shadow(calc(2 * var(--u)) calc(1.7 * var(--u)) 0 var(--ink)) drop-shadow(calc(1.6 * var(--u)) calc(1.4 * var(--u)) 0 var(--ink));
  --paper-c: #d9d0bd;
  --paper: url("../assets/paper.webp");                  /* papier scanné : fond de l'interface */
  --paper-grain: url("../assets/paper-overlay.webp");    /* grain clair posé par-dessus tout le site */
  --workspace: #e6dfd3;                                  /* fond du plan de travail : crème des rouleaux */
  --paper-size: calc(980 * var(--u)) calc(996 * var(--u));
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; display: flex; overflow: hidden; padding: var(--pad);
  background: var(--paper-c) var(--paper) 0 0 / var(--paper-size) fixed;   /* fond de l'interface = papier */
  color: var(--ink); font: 400 calc(14 * var(--u)) var(--font); line-height: 1; font-synthesis: none;   /* Yatra One n'a qu'une graisse : jamais de gras / italique simulé */
}
h1, h2, p { margin: 0; }
img { display: block; -webkit-user-drag: none; user-select: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, strong, b { font-weight: 400; }   /* une seule graisse (Yatra One) */

.app { position: relative; flex: none; margin: auto; width: calc(var(--dw) * var(--u)); height: calc(var(--dh) * var(--u)); }
.a { position: absolute; left: calc(var(--x, 0) * var(--u)); top: calc((var(--y, 0) - var(--oy, 0)) * var(--u)); width: calc(var(--w, 0) * var(--u)); height: calc(var(--h, 0) * var(--u)); }
.a > img, .ib > img { width: 100%; height: 100%; object-fit: contain; }   /* icônes interchangeables : ajustées dans leur case */
img.slot-img { object-fit: contain; }                                       /* logo : sa taille vient de --w / --h */
img.a:not([style*="--h"]) { height: auto; }     /* hauteur déduite du ratio natif du SVG */
.roller { position: absolute; inset: 0; pointer-events: none; }
.roller > *, .topbar > * { pointer-events: auto; }
img { pointer-events: none; }

/* Boutons-icônes : aucun cadre, le SVG fourni EST le bouton */
.ib { padding: 0; border: 0; background: none; cursor: pointer; }
.ib:focus-visible { outline: calc(2 * var(--u)) dashed var(--ink); outline-offset: calc(2 * var(--u)); }
.ib:hover:not(:disabled) > img { filter: var(--hov); }
.ib:active:not(:disabled) { transform: translate(calc(1 * var(--u)), calc(1 * var(--u))); }
.ib:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Canevas ---------- */
.stage-wrap { margin: 0; background: var(--workspace); }   /* plan de travail crème (le grain du papier passe par-dessus, voir .paper-overlay) */
/* Papier en surimpression sur TOUT le site, y compris la visite guidée (comme le calque "papier" en produit du fina-finall).
   Calque fixe en « multiply », au-dessus de tout (z-index max), qui ne capte aucun clic. Le plan de travail n'a donc plus
   besoin de son propre grain (sinon il serait doublé). */
.paper-overlay { position: fixed; inset: 0; z-index: 1000; pointer-events: none; background: var(--paper-grain) 0 0 / var(--paper-size); mix-blend-mode: multiply; }
.stage-frame { width: 100%; height: 100%; container-type: size; display: flex; align-items: center; justify-content: center; }
svg#stage { --stage-max: 100000px; display: block; width: min(100cqw, 100cqh, var(--stage-max)); height: min(100cqw, 100cqh, var(--stage-max)); }
#stage #paper { display: none; }       /* le papier de la page transparaît ; le fond papier de l'export PNG reste géré par renderer.js */
.frame { pointer-events: none; z-index: 2; }
.frame-gold { pointer-events: none; z-index: 0; }
.layer-group { cursor: grab; }
.layer-group:active { cursor: grabbing; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { transform-box: view-box; transform-origin: 500px 500px; animation: spin var(--dur, 40s) linear infinite; animation-delay: var(--delay, 0s); }
.spinning.reverse { animation-direction: reverse; }
.empty-hint { z-index: 1; display: grid; place-items: center; text-align: center; font-weight: 400; font-size: calc(19 * var(--u)); line-height: 1.25; opacity: .45; pointer-events: none; transition: opacity .25s; }
.empty-hint.off { opacity: 0; }

/* ---------- Divers ---------- */
.hidden-picker { position: fixed; left: 50%; top: 50%; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toast { position: absolute; left: calc(842 * var(--u)); top: calc(92 * var(--u));   /* centré sur le cadre, sous son bord haut */ transform: translateX(-50%); padding: calc(4 * var(--u)) calc(14 * var(--u)); background: var(--yellow); border: calc(2 * var(--u)) solid var(--ink); font-weight: 700; font-size: calc(13 * var(--u)); opacity: 0; pointer-events: none; z-index: 5; transition: opacity .2s; white-space: nowrap; }
.toast.show { opacity: 1; }

/* ---------- Contrôles d'origine : masqués visuellement, restés accessibles (clavier / lecteurs d'écran) ---------- */
.legacy-controls { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; font-size: 14px; }
.legacy-controls:focus-within { width: 18rem; height: auto; max-height: 100vh; overflow: auto; clip-path: none; white-space: normal; background: #fff; z-index: 99; padding: .6rem; border: 2px solid var(--ink); }
.legacy-controls label { display: block; margin-top: .5rem; font-size: .8rem; }
.legacy-controls .btn { padding: .3rem .5rem; border: 2px solid var(--ink); background: #fff; font-size: .8rem; cursor: pointer; }
.legacy-controls .segment { display: flex; gap: .4rem; margin-top: .4rem; }
.legacy-controls .btn.on { background: var(--yellow); }
.legacy-controls input[type="range"] { display: block; width: 100%; }
.legacy-controls .val-input { width: 3.2rem; }
.legacy-controls #layers { font-size: 12px; }
.selection-color-picker { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.legacy-controls .selection-colors-list { display: none; }
/* liste des calques cachée : lignes simples (elle n'est plus un rouleau) */
#layers .layer { position: relative; display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 6px; border: 1px solid var(--ink); margin-top: 3px; background: #fff; cursor: pointer; }
#layers .layer.selected { background: var(--yellow); }
#layers .layer > img.bub, #layers .layer .shade, #layers .layer .grip { display: none; }
#layers .layer .thumb { display: grid; place-items: center; width: 24px; height: 24px; }
#layers .layer .thumb svg { max-width: 100%; max-height: 100%; }
#layers .layer button { position: static; padding: 0 4px; border: 1px solid var(--ink); background: #fff; cursor: pointer; font-size: 11px; }
#layers .layer button img { width: 12px; height: 12px; display: inline-block; }

/* ============ ROULEAUX QUI TOURNENT (bande des lunes, bibliothèque) ============
   Chaque élément = des calques SVG déformés en matrix3d par skin.js (le cadre morphe selon sa place). Aucune ombre :
   le repérage (valeur lue, survol, clavier) colore l'intérieur du cadre en jaune. */
.cyl { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; outline: none; }
.cyl.grabbing { cursor: grabbing; }
.cyl:focus-visible::after { content: ""; position: absolute; inset: calc(2 * var(--u)); border: calc(2 * var(--u)) dashed var(--ink); border-radius: calc(14 * var(--u)); pointer-events: none; }
.cyl .it { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.cyl .ly { position: absolute; left: 0; top: 0; display: block; transform-origin: 0 0; overflow: visible; }
.hl { display: none; }                                  /* (ancien fond jaune, remplacé par le contour décalé) */
.cyl .it.hov, .cyl .it.kb { filter: var(--hov); }       /* survol d'une forme / d'une lune, ou curseur clavier */
.cyl .it.pop { filter: var(--hov-ink); }
.cyl.dim { opacity: .5; }

/* ============ ROULEAUX : décor + pièces posées en unités du SVG (--vx / --vy / --vw / --vh, converties par --k puis --u) ============ */
.rset { --k: calc(var(--w) / 289); }
.rbib { --k: calc(var(--w) / 270); }
.rbase { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.rset .v, .rbib .v { position: absolute; left: calc(var(--vx) * var(--k) * var(--u)); top: calc(var(--vy) * var(--k) * var(--u));
  width: calc(var(--vw) * var(--k) * var(--u)); height: calc(var(--vh) * var(--k) * var(--u)); }
.rset .v0 { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 2; pointer-events: none; }
.rcells { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.rcell, .rcase, .rflag, .rbtn { padding: 0; margin: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; border-radius: 0; }
.rcell svg, .rcase svg, .rflag svg, .rbtn svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rcell .ico, .rbtn .ico { position: absolute; object-fit: contain; pointer-events: none; }
.rcell:focus-visible, .rcase:focus-visible, .rflag:focus-visible, .rbtn:focus-visible { outline: calc(2 * var(--u)) dashed var(--ink); outline-offset: calc(2 * var(--u)); }

/* Survol / case choisie = l'intérieur du cadre se colore en jaune (pas d'ombre). */
.rcell:hover, .rcell.on { filter: var(--hov); }        /* la case du réglage choisi garde le contour décalé */
/* Cases Couleur / Contour : la case active est pleine, l'autre est estompée */
.rcase { --c: var(--yellow); transition: opacity .15s; }
.rcase:not(.on) { opacity: .5; }
.rcase:not(.on):hover { opacity: .8; }
.rcase:hover { filter: var(--hov-ink); }
/* Guirlande = couleurs en jeu (communes à Couleur et Contour). Le drapeau de la couleur active est soulevé. */
.rflags { z-index: 1 !important; }                      /* la cordelette passe sous les cases Couleur / Contour */
.rrope { pointer-events: none; transition: opacity .15s; }
.rrope.off { opacity: .35; }                                  /* cordelette en transparence avec les drapeaux */
.rflag { --c: #faf5e8; }
.rflag:hover:not(:disabled), .rflag.on { filter: var(--hov-ink); }   /* survol et couleur active : contour décalé, sans déplacement */
.rflag:disabled { cursor: default; opacity: .35; }                 /* aucun calque sélectionné : drapeaux en transparence */
/* Boutons du bas : calque au-dessus / en dessous / supprimer / annuler */
.rbtn:hover:not(:disabled) { filter: var(--hov); }
.rbtn:active:not(:disabled) { transform: translate(calc(1 * var(--u)), calc(1 * var(--u))); }
.rbtn:disabled { cursor: default; opacity: .35; }

/* Rouleau de lunes et rouleau de formes : une fenêtre qui coupe ce qui sort */
.rmoon-wrap, .rlib-wrap { z-index: 2; overflow: hidden; }
.rmoon-wrap > .cyl, .rlib-wrap > .cyl { position: absolute; inset: 0; }
.rset .dim { opacity: .5; }

/* ============ RESPONSIVE : format portrait (téléphone, tablette debout, fenêtre étroite) ============
   Le design se réorganise sur une colonne de 560 x 1230 : logo et boutons en haut, plan de travail,
   puis les deux rouleaux côte à côte. Les positions remplacent celles écrites dans index.html. */
@media (max-aspect-ratio: 1/1) {
  :root { --dw: 560; --dh: 1300; --oy: 0; }
  #info     { --x: 385 !important; --y: 29 !important; --w: 36 !important; --h: 36 !important; }
  #logo     { --x: 27 !important;  --y: 18 !important; --w: 380 !important; --h: 58 !important; font-size: calc(44 * var(--u)); line-height: calc(58 * var(--u)); }
  #credits  { --x: 22 !important;  --y: 1256 !important; --w: 516 !important; --h: 30 !important; text-align: center; }
  #animate  { --x: 425 !important; --y: 29 !important; --w: 36 !important; --h: 36 !important; }
  #download { --x: 465 !important; --y: 29 !important; --w: 36 !important; --h: 36 !important; }
  #share    { --x: 505 !important; --y: 29 !important; --w: 36 !important; --h: 36 !important; }
  #frameGold { --x: 27 !important; --y: 84 !important; --w: 506 !important; --h: 506 !important; }
  .frame    { --x: 39 !important;  --y: 97 !important; --w: 482 !important; --h: 480 !important; }
  .stage-wrap, #emptyHint { --x: 44 !important; --y: 101 !important; --w: 472 !important; --h: 472 !important; }
  #rset     { --x: 22 !important;  --y: 626 !important; }
  #rbib     { --x: 295 !important; --y: 625.55 !important; }
}

/* Yatra One n'a qu'une graisse : pas de faux gras */
.empty-hint, .toast { font-weight: 400; }

/* ---------- Titre et crédits (v11) ---------- */
.title { margin: 0; font-family: var(--font); font-weight: 400; font-size: calc(46 * var(--u)); line-height: calc(48 * var(--u));
  white-space: nowrap; color: var(--ink); letter-spacing: .01em; }
.credits { margin: 0; font-family: var(--font); font-weight: 400; font-size: calc(8.6 * var(--u)); line-height: 1.45; letter-spacing: .04em; color: var(--ink); opacity: .8; text-align: center; }
.credits p { margin: 0; white-space: nowrap; }
@media (max-aspect-ratio: 1/1) { .toast { left: 50%; top: calc(100 * var(--u)); } }
@media (max-aspect-ratio: 1/1) { .credits p { white-space: normal; } }

/* ---------- Visite guidée (bouton Informations) : même langage que l'interface ----------
   Aucun rectangle parfait : la zone éclairée, la carte et les boutons ont un cadre tracé à la main (svg .ob-hand,
   dessiné par js/onboarding.js à leur taille exacte). Survol = contour jaune décalé, comme partout. */
.onboarding { position: fixed; inset: 0; z-index: 100; --obf: clamp(14px, calc(15 * var(--u)), 18px); }
.ob-hand { position: absolute; left: 0; top: 0; z-index: -1; pointer-events: none; }   /* sous le texte, jamais en dehors de la boîte */
.ob-dim { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ob-spot { position: fixed; pointer-events: none; }
.ob-card { position: fixed; width: min(92vw, calc(330 * var(--u) + 90px)); padding: calc(1.3 * var(--obf)) calc(1.4 * var(--obf)) calc(1.1 * var(--obf));
  isolation: isolate; color: var(--ink); font-family: var(--font); font-size: var(--obf); }   /* le fond crème est dessiné par le cadre (svg) */
.ob-count { margin: 0 0 calc(.35 * var(--obf)); font-weight: 400; font-size: .82em; opacity: .65; }
.ob-title { margin: 0 0 calc(.45 * var(--obf)); font-family: var(--font); font-weight: 400; font-size: 1.55em; line-height: 1.1; }
.ob-text { margin: 0 0 calc(1 * var(--obf)); line-height: 1.4; }
.ob-nav { display: flex; align-items: center; gap: calc(.6 * var(--obf)); }
.ob-nav span { flex: 1; }
.ob-nav button { position: relative; isolation: isolate; font: 400 .95em var(--font); padding: .35em .85em; border: 0; border-radius: 0; background: none; color: var(--ink); cursor: pointer; }
.ob-nav .ob-next { filter: var(--hov); }                     /* bouton principal : contour jaune décalé en permanence (comme la case choisie) */
.ob-nav button:hover:not(:disabled) { filter: var(--hov); }
.ob-nav .ob-next:hover { filter: var(--hov-ink); }
.ob-nav .ob-skip { background: none; padding-inline: 0; text-decoration: underline; text-underline-offset: 3px; }
.ob-nav .ob-skip:hover { filter: none; text-decoration-thickness: 2px; }
.ob-nav button:active:not(:disabled) { transform: translate(1px, 1px); }
.ob-nav button:disabled { opacity: .35; cursor: default; }
.ob-nav button:focus-visible { outline: none; filter: var(--hov); }   /* focus clavier = contour jaune décalé, comme le survol (pas de rectangle pointillé) */
