/* TutoMoteur — styles communs des tutoriels (thème par défaut : atelier façon Dressmaker).
   Un tuto peut surcharger les variables :root dans sa propre page. */
/* Look inspiré du jeu : papier peint vert à rayures, parchemin, bois, laiton, boutons orange. */
:root {
  --wall: #3d4b35;
  --wall-2: #364330;
  --wood: #5a3a24;
  --wood-dark: #2e1d13;
  --wood-light: #8a6240;
  --brass: #b8904f;
  --paper: #f5ead3;
  --paper-2: #eadbbb;
  --paper-line: #c9aa7a;
  --ink: #3a2818;
  --ink-soft: #6e5640;
  --orange: #dc6f2e;
  --orange-dark: #8c3f14;
  --gold: #f0cf7e;
  --wine: #8e2f3a;
  --sage: #5c7a4c;
  --cream: #f3e6c8;
  --cream-muted: #d5c6a3;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  /* alias utilisés dans le contenu */
  --lilac: var(--wine);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  font-family: var(--serif);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,240,200,0.10), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,0.45), transparent 60%),
    repeating-linear-gradient(90deg, var(--wall) 0 26px, var(--wall-2) 26px 30px, var(--wall) 30px 52px, #42513a 52px 54px);
  background-attachment: fixed;
  background-color: var(--wall);
  color: var(--cream);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 16px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 16px calc(env(safe-area-inset-bottom, 20px) + 84px);
}

/* Panneau parchemin à double filet (comme les cadres du jeu) */
.tip, .toc a, .continue, .ch-nav a, .search input {
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--wood-light);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--paper-line), 0 3px 0 var(--wood-dark), 0 6px 14px rgba(0,0,0,0.30);
}
/* Bouton bois (Menu / Sommaire en haut d'un chapitre) */
.back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px;
  border-radius: 10px; background: linear-gradient(#6b4529, var(--wood));
  border: 2px solid var(--wood-dark); box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 3px 0 var(--wood-dark);
  color: var(--cream); text-decoration: none; font-size: 15px; font-weight: 700;
}
/* Bouton principal orange (comme « Buy » / « Take Photo ») */
.btn-primary, .to-top, .viewer-bar .close, .ch-nav a.next {
  background: linear-gradient(#e8833f, #c95e20) !important;
  border: 2px solid var(--orange-dark) !important;
  color: #fff6e6 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 0 var(--orange-dark), 0 6px 14px rgba(0,0,0,0.3) !important;
}

/* ---------- En-tête ---------- */
.hero { text-align: center; margin: 14px 0 20px; }
.hero .emoji { font-size: 46px; line-height: 1; }
.hero h1 {
  display: inline-block; margin-top: 10px; padding: 6px 26px 8px;
  font-size: 34px; font-weight: 700; letter-spacing: 1px; color: var(--gold);
  background: linear-gradient(#6b4529, #43291a); border: 2px solid var(--brass); border-radius: 10px;
  box-shadow: inset 0 0 0 3px #43291a, inset 0 0 0 4px rgba(240,207,126,0.5), 0 4px 0 var(--wood-dark), 0 8px 18px rgba(0,0,0,0.4);
  text-shadow: 0 2px 0 rgba(0,0,0,0.5);
}
.hero p { color: var(--cream-muted); margin-top: 10px; font-style: italic; font-size: 17px; }

/* ---------- Recherche ---------- */
.search { position: relative; margin-bottom: 14px; }
.search input {
  width: 100%; min-height: 54px; padding: 0 48px 0 46px; border-radius: 12px;
  font-family: var(--serif); font-size: 17px; outline: none;
  user-select: text; -webkit-user-select: text;
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search input::placeholder { color: var(--ink-soft); font-style: italic; }
.search input:focus { border-color: var(--orange); }
.search .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-size: 18px; pointer-events: none; }
.search .clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: none; color: var(--ink-soft);
  font-size: 20px; cursor: pointer; display: none;
}
.search.has-text .clear { display: block; }
/* Suggestions : visibles seulement quand on touche la recherche (champ vide) */
.suggest { display: none; flex-wrap: wrap; gap: 6px; margin: -4px 0 16px; }
.search:focus-within + .suggest { display: flex; }
.search.has-text + .suggest { display: none; }
.suggest span { color: var(--cream-muted); font-size: 14px; font-style: italic; align-self: center; margin-right: 2px; }
/* Étiquettes brunes comme les tags de tissus du jeu */
.chip {
  min-height: 36px; padding: 0 12px; border-radius: 7px;
  border: 1px solid var(--wood-dark); background: linear-gradient(#6b4529, var(--wood)); color: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
  font-family: var(--serif); font-size: 14px; cursor: pointer;
}
.chip:active { transform: scale(0.96); }
.result-count { color: var(--cream-muted); font-size: 15px; font-style: italic; margin: -6px 0 14px; display: none; }
body.searching .result-count { display: block; }
body.no-result .result-count { display: none; }

/* ---------- Sommaire ---------- */
.toc-title {
  font-size: 15px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--gold);
  margin-bottom: 10px; text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}
.toc {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  margin-bottom: 28px;
}
.toc a {
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 12px;
  border-radius: 10px; text-decoration: none; font-size: 15px; font-weight: 700; line-height: 1.2;
}
.toc a .n { font-size: 20px; }
.toc a.fav-link { background: #f8e7b8; }
body.searching .toc, body.searching .toc-title, body.searching .continue, body.searching #favoris { display: none; }

.continue {
  display: none; align-items: center; gap: 10px; width: 100%; min-height: 54px; margin-bottom: 18px;
  padding: 10px 14px; border-radius: 12px; font-family: var(--serif); font-size: 16px; text-align: left; cursor: pointer;
}
.continue.show { display: flex; }
.continue b { color: var(--orange-dark); }

/* ---------- Sections ---------- */
section { margin-bottom: 30px; }
/* Titre de chapitre : plaque en bois aux lettres dorées (comme l'enseigne « Emporium ») */
section h2 {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 14px;
  font-size: 21px; font-weight: 700; color: var(--gold); line-height: 1.2;
  background: linear-gradient(#6b4529, #43291a); border: 2px solid var(--brass); border-radius: 10px;
  box-shadow: inset 0 0 0 3px #43291a, inset 0 0 0 4px rgba(240,207,126,0.45), 0 3px 0 var(--wood-dark), 0 6px 14px rgba(0,0,0,0.35);
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}
section h2 .n { font-size: 26px; }
section .intro { color: var(--cream); margin: 0 2px 14px; font-size: 16px; font-style: italic; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.tip {
  position: relative;
  border-radius: 10px; padding: 16px 52px 16px 18px; margin-bottom: 12px;
}
.tip h3 { font-size: 19px; font-weight: 700; margin-bottom: 4px; color: var(--ink); }
.tip p, .tip li { font-size: 16px; color: var(--ink); }
.tip p + p, .tip p + ul, .tip ul + p { margin-top: 6px; }
.tip ul { padding-left: 20px; }
.tip li { margin: 3px 0; }
.tip b { color: #22160c; }
.tip.pro { border-left: 6px solid #c9962e; }
.tip.warn { border-left: 6px solid var(--wine); }
.tip.fun { border-left: 6px solid var(--sage); }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 9px; border-radius: 6px; margin-bottom: 6px; font-family: system-ui, -apple-system, sans-serif;
}
.tag.pro { background: #e9c25e; color: #3a2510; }
.tag.warn { background: var(--wine); color: #fbeee0; }
.tag.fun { background: var(--sage); color: #f3f6ea; }
.en { color: var(--wine); font-style: italic; white-space: nowrap; }
kbd {
  display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 5px; text-align: center;
  background: #3a2818; border: 1px solid #1e130b; border-bottom-width: 3px;
  font-family: system-ui, -apple-system, sans-serif; font-size: 13px; font-weight: 700; color: var(--cream);
}
.fav {
  position: absolute; top: 4px; right: 4px; width: 44px; height: 44px;
  border: 0; background: none; font-size: 20px; cursor: pointer;
  filter: grayscale(1) opacity(0.4); transition: transform 0.15s;
}
.fav.on { filter: none; }
.fav:active { transform: scale(1.3); }
mark { background: rgba(240,180,60,0.6); color: inherit; border-radius: 3px; padding: 0 1px; }
.tip a { color: var(--orange-dark); }

/* Étapes */
.steps { counter-reset: s; list-style: none; padding: 0 !important; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 !important; }
.steps li::before {
  content: counter(s); flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: var(--orange); color: #fff6e6; border: 2px solid var(--orange-dark);
  font-weight: 700; font-size: 13px; font-family: system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}

/* Tableau dico */
.dico { width: 100%; border-collapse: collapse; font-size: 16px; }
.dico td { padding: 6px 4px; border-bottom: 1px dashed var(--paper-line); vertical-align: top; color: var(--ink); }
.dico td:first-child { color: var(--wine); font-style: italic; width: 42%; }

.empty { text-align: center; color: var(--cream); padding: 30px 10px; display: none; font-style: italic; }
.empty .e { font-size: 44px; }
body.no-result .empty { display: block; }
.hidden { display: none !important; }

.sources { font-size: 13px; color: var(--cream-muted); margin-top: 30px; line-height: 1.6; font-style: italic; }
.sources a { color: var(--cream-muted); }

/* Captures d'écran annotées */
.shot-frame {
  position: relative; border-radius: 8px; overflow: hidden; cursor: zoom-in;
  background: var(--wood-dark); aspect-ratio: 16 / 9; border: 2px solid var(--wood-dark);
}
.shot-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shot-frame .broken {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 12px; color: var(--cream-muted); font-size: 14px;
}
.pin {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%;
  background: var(--orange); color: #fff6e6; border: 2px solid #fff6e6;
  font-size: 12px; font-weight: 800; font-family: system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.6); pointer-events: none;
}
.pin.hot { background: #f2c14e; color: var(--ink); animation: pulse 1s ease-in-out infinite; z-index: 2; }
@keyframes pulse { 50% { transform: scale(1.35); } }
.credit { font-size: 12px; color: var(--cream-muted); margin-top: 4px; font-style: italic; }
.credit a { color: var(--cream-muted); }
.legend { list-style: none; padding: 0 !important; margin-top: 10px; }
.legend li { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 !important; color: var(--cream); font-size: 16px; }
.legend li .num {
  flex: 0 0 24px; height: 24px; border-radius: 50%; background: var(--orange); color: #fff6e6; border: 2px solid #fff6e6;
  font-size: 12px; font-weight: 800; font-family: system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.legend li.hot { background: rgba(240,207,126,0.16); border: 1px solid rgba(240,207,126,0.5); border-radius: 8px; padding: 6px; margin: 6px -6px !important; }
.legend li.hot .num { background: #f2c14e; color: var(--ink); }
.legend .en { color: var(--gold); }
.legend kbd { background: var(--paper); color: var(--ink); border-color: var(--paper-line); }
/* Bouton secondaire crème (comme « Keep working ») */
.see {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; min-height: 44px; padding: 0 14px;
  border-radius: 8px; border: 2px solid var(--wood-light); background: linear-gradient(#fbf3e2, var(--paper-2));
  box-shadow: 0 2px 0 var(--wood-light);
  color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--serif);
}
.see-inline {
  border: 0; background: none; color: var(--orange-dark); font-size: inherit; cursor: pointer; font-weight: 700;
  padding: 0 2px; text-decoration: underline; text-underline-offset: 3px; font-family: inherit;
}

/* Visite de l'atelier : grille de vignettes (le détail s'ouvre dans la visionneuse) */
.tip.mini {
  display: inline-block; vertical-align: top; width: calc(50% - 5px); margin: 0 0 10px; padding: 8px;
  cursor: pointer;
}
.tip.mini:nth-of-type(odd) { margin-right: 6px; }
.tip.mini h3 { font-size: 15px; line-height: 1.25; margin: 6px 2px 2px; }
.tip.mini .fav, .tip.mini .pin, .tip.mini .credit { display: none; }

/* ---------- Écrans : accueil (sommaire + recherche) / un chapitre ---------- */
body[data-view="chapter"] .home-only { display: none !important; }
body[data-view="home"] .chapter-only { display: none !important; }
body[data-view="home"]:not(.searching) #content > section { display: none; }
body[data-view="chapter"] #content > section:not(.active) { display: none; }
.ch-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px;
}
.ch-pos { color: var(--cream-muted); font-size: 14px; font-style: italic; }
.ch-nav { display: flex; gap: 10px; margin-top: 20px; }
.ch-nav a {
  flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 66px; padding: 8px 12px;
  border-radius: 10px; text-decoration: none; font-size: 15px; font-weight: 700; line-height: 1.25;
}
.ch-nav a small { color: var(--ink-soft); font-size: 13px; font-weight: 400; font-style: italic; margin-bottom: 2px; }
.ch-nav a.next { text-align: right; }
.ch-nav a.next small { color: #ffe7cc; }
.ch-nav a.home { flex: 0 0 auto; align-items: center; }
.open-ch {
  display: none; align-items: center; min-height: 40px; margin: -2px 2px 10px; color: var(--gold);
  font-size: 15px; font-weight: 700; text-decoration: none; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
body.searching[data-view="home"] .open-ch { display: inline-flex; }
body[data-view="home"]:not(.searching) .to-top { display: none; }

/* Visionneuse plein écran (fond bois sombre) */
.viewer {
  position: fixed; inset: 0; z-index: 50;
  background: repeating-linear-gradient(0deg, #2a1a10 0 3px, #26170e 3px 7px), #26170e;
  display: none; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 44px) + 8px) 0 calc(env(safe-area-inset-bottom, 20px) + 8px);
}
.viewer.open { display: flex; }
.viewer-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; }
.viewer-head .back { flex: 0 0 auto; font-family: var(--serif); cursor: pointer; }
.viewer-title { font-weight: 700; font-size: 18px; line-height: 1.2; color: var(--gold); }
.viewer-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; padding: 0 16px 8px; }
.viewer .shot-frame { cursor: default; border-color: var(--brass); }
.zoom-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; border-radius: 8px; }
.viewer-bar { display: flex; gap: 10px; padding: 10px 16px 0; }
.viewer-bar button {
  flex: 1; min-height: 52px; border-radius: 10px; border: 2px solid var(--wood-light);
  background: linear-gradient(#fbf3e2, var(--paper-2)); color: var(--ink);
  box-shadow: 0 3px 0 var(--wood-light);
  font-family: var(--serif); font-size: 16px; font-weight: 700; cursor: pointer;
}
body.viewer-open { overflow: hidden; }
body.viewer-open .to-top { display: none; }

/* Bouton Sommaire toujours visible (en BAS, jamais en haut : notch) */
.to-top {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom, 20px) + 12px);
  height: 52px; padding: 0 18px; border-radius: 10px;
  font-family: var(--serif); font-size: 16px; font-weight: 700;
  cursor: pointer; z-index: 40;
}

/* ---------- Mots anglais : un tap affiche la traduction ---------- */
.en { cursor: help; text-decoration: underline dotted rgba(142,47,58,0.5); text-underline-offset: 3px; }
.legend .en { text-decoration-color: rgba(240,207,126,0.6); }
.gloss-bubble {
  position: absolute; z-index: 60; max-width: 260px; padding: 8px 12px; border-radius: 10px;
  background: var(--wood-dark); color: var(--cream); border: 2px solid var(--brass);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45); font-size: 15px; line-height: 1.35; pointer-events: none;
}
.gloss-bubble b { color: var(--gold); font-style: italic; }

/* ---------- Bouton « écouter » ---------- */
.speak {
  position: absolute; top: 48px; right: 4px; width: 44px; height: 44px;
  border: 0; background: none; font-size: 19px; cursor: pointer; opacity: 0.55;
}
.speak.on { opacity: 1; animation: pulse 1s ease-in-out infinite; }

/* ---------- Checklist ---------- */
.check-progress { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; color: var(--cream); font-size: 16px; }
.check-bar { flex: 1; height: 12px; border-radius: 6px; background: rgba(0,0,0,0.35); border: 1px solid var(--brass); overflow: hidden; }
.check-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7fa35f, #a9c97c); transition: width 0.25s; }
.check-item { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px 52px 12px 14px !important; }
.check-item input { flex: 0 0 26px; width: 26px; height: 26px; margin-top: 1px; accent-color: var(--sage); cursor: pointer; }
.check-item.done h3 { text-decoration: line-through; text-decoration-color: rgba(58,40,24,0.45); color: var(--ink-soft); }
.check-item h3 { font-size: 17px !important; margin: 0 !important; }
.check-item .body { font-size: 15px; color: var(--ink-soft); margin-top: 2px; line-height: 1.4; }
.check-done {
  display: none; text-align: center; padding: 14px; margin-bottom: 12px; border-radius: 10px;
  background: linear-gradient(#7fa35f, #5c7a4c); color: #fff; font-size: 18px; font-weight: 700;
  border: 2px solid #3f5634; box-shadow: 0 3px 0 #3f5634;
}
.check-done.show { display: block; }
.check-reset { margin: 4px 0 0; }

/* ---------- Fiches clientes ---------- */
.stags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 8px; }
.stag {
  display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 13px; font-style: normal !important;
  background: linear-gradient(#6b4529, var(--wood)); color: var(--cream) !important; border: 1px solid var(--wood-dark);
  text-decoration: none !important; white-space: nowrap;
}
.measures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.measures div {
  text-align: center; padding: 6px 4px; border-radius: 8px; background: var(--paper-2); border: 1px solid var(--paper-line);
}
.measures small { display: block; font-size: 12px; color: var(--ink-soft); }
.measures b { font-size: 18px; }
.measures-note { font-size: 13px !important; color: var(--ink-soft) !important; font-style: italic; }
.client-sub { font-style: italic; color: var(--ink-soft) !important; margin-top: -2px; }
.tip h4 { font-size: 15px; margin: 10px 0 2px; color: var(--wine); }

/* ---------- Commandes (dévoilées au toucher) ---------- */
.quest { padding: 0 !important; }
.quest details summary {
  list-style: none; cursor: pointer; padding: 12px 52px 12px 14px; display: flex; gap: 10px; align-items: center;
}
.quest details summary::-webkit-details-marker { display: none; }
.quest .qn {
  flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--wood); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; border: 2px solid var(--brass);
}
.quest .qt { font-weight: 700; color: var(--ink); line-height: 1.25; }
.quest .qt small { display: block; font-weight: 400; font-style: italic; color: var(--ink-soft); }
.quest .qbody { padding: 0 16px 14px 56px; }
.quest .qbody .stags { margin-top: 0; }
.quest .qhint { font-size: 13px; color: var(--ink-soft); font-style: italic; }
.quest details[open] .qhint { display: none; }
.req { background: var(--paper-2) !important; color: var(--ink) !important; border-color: var(--paper-line) !important; }
.quest-group { color: var(--gold); font-weight: 700; font-size: 17px; margin: 18px 2px 8px; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
body.searching .quest-group { display: none; }
