/* Avent-ure Studio : socle commun (accueil, créateur, atelier, impression).
   Les pages de lecture ajoutent themes.css par-dessus. */
@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,300..800,50;1,9..144,300..800,50&family=DM+Sans:ital,opsz,wght@0,9..40,400..700;1,9..40,400&family=Caveat:wght@500;700&display=swap");

:root {
  --bg: #fbf7f0;
  --bg-2: #f3ece0;
  --surface: #ffffff;
  --ink: #1d1a2e;
  --muted: #6b6478;
  --line: #e6ddcf;
  --accent: #c2412d;
  --accent-2: #e0663f;
  --accent-ink: #fff8f2;
  --gold: #b9862a;
  --night: #14182b;
  --night-2: #222844;
  --ok: #2f7a55;
  --warn: #b26a00;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(29, 26, 46, .06), 0 8px 24px -12px rgba(29, 26, 46, .18);
  --shadow-l: 0 2px 4px rgba(29, 26, 46, .06), 0 24px 60px -20px rgba(29, 26, 46, .35);
  --f-display: "Fraunces", Georgia, serif;
  --f-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-hand: "Caveat", "Segoe Print", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12131f; --bg-2: #1a1c2c; --surface: #1f2133; --ink: #f1ebe0; --muted: #a49eb2; --line: #33364d;
    --accent: #ff7a5c; --accent-2: #ff9b6b; --accent-ink: #1a0f0b; --gold: #e3b55a; --ok: #6cc596; --warn: #f0a640;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-l: 0 2px 4px rgba(0,0,0,.3), 0 24px 60px -20px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12131f; --bg-2: #1a1c2c; --surface: #1f2133; --ink: #f1ebe0; --muted: #a49eb2; --line: #33364d;
  --accent: #ff7a5c; --accent-2: #ff9b6b; --accent-ink: #1a0f0b; --gold: #e3b55a; --ok: #6cc596; --warn: #f0a640;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  --shadow-l: 0 2px 4px rgba(0,0,0,.3), 0 24px 60px -20px rgba(0,0,0,.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--f-ui);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img, svg, canvas { max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 560; line-height: 1.08; letter-spacing: -.01em; margin: 0; text-wrap: balance; font-variation-settings: "SOFT" 50, "opsz" 96; }
p { margin: 0; text-wrap: pretty; }
.wrap { max-width: 1160px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left)); }
.narrow { max-width: 760px; margin: 0 auto; padding-inline: 16px; }
.eyebrow { font: 600 12px/1 var(--f-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.hand { font-family: var(--f-hand); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; transition: transform .15s ease, background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.btn.small { min-height: 34px; padding: 6px 14px; font-size: 14px; }
.btn.big { min-height: 56px; padding: 14px 28px; font-size: 17px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--surface); padding: 0; flex: none;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* Champs */
.field { display: grid; gap: 6px; }
.field > span, .field > label, .lab { font-weight: 600; font-size: 14.5px; }
.field small, .help { font-size: 13.5px; color: var(--muted); font-weight: 400; }
.input, .textarea, .select {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--radius-s); border: 1.5px solid var(--line);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.with-mic { position: relative; }
.with-mic .input, .with-mic .textarea { padding-right: 52px; }
.mic {
  position: absolute; right: 7px; top: 7px; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); display: grid; place-items: center; padding: 0;
}
.mic svg { width: 18px; height: 18px; }
.mic:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.mic.on { background: var(--accent); color: var(--accent-ink); animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* Choix en tuiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: grid; gap: 6px; align-content: start; text-align: left; padding: 16px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--surface); transition: border-color .15s, transform .15s, box-shadow .15s; cursor: pointer;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile b { font-family: var(--f-display); font-size: 19px; font-weight: 560; }
.tile span { font-size: 14px; color: var(--muted); line-height: 1.45; }
.tile .emo { font-size: 26px; line-height: 1; }
.tile:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.tile:has(input:checked)::after {
  content: ""; position: absolute; right: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/14px no-repeat;
}
.tile:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14.5px; font-weight: 500; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

/* Cartes, puces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--bg-2); color: var(--muted); }
.chip.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.chip.gold { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold); }

/* Fenêtre modale plein écran (éditeurs) */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: rgba(12, 12, 22, .62); backdrop-filter: blur(6px); padding: 12px; animation: fade .2s ease; }
.modal > .box { width: min(1100px, 100%); max-height: calc(100vh - 24px); overflow: auto; background: var(--surface); color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-l); display: grid; }
.modal .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal .head h3 { font-size: 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* Message éphémère */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; z-index: 2000; box-shadow: var(--shadow-l); animation: toast .25s ease; max-width: calc(100vw - 32px); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Coup de pouce (soutien), discret */
.soutien-pill {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: 16px; z-index: 900; display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 600; color: var(--ink); text-decoration: none;
}
.soutien-pill .heart { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.soutien-pill:hover { border-color: var(--accent); }
@media (max-width: 560px) { .soutien-pill .txt { display: none; } .soutien-pill { padding: 9px; } }

/* En-tête et pied de page du studio */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 18px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; white-space: nowrap; font-family: var(--f-display); font-weight: 650; font-size: 22px; letter-spacing: -.02em; }
.logo i { width: 34px; height: 34px; border-radius: 10px; background: var(--night); display: grid; place-items: center; color: #f3c769; font-style: normal; font-size: 17px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.topnav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topnav a:not(.btn) { text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: 15px; color: var(--muted); }
.topnav a:not(.btn):hover { color: var(--ink); background: var(--bg-2); }
@media (max-width: 760px) { .topnav a:not(.btn) { display: none; } }
.footer { border-top: 1px solid var(--line); margin-top: 80px; padding-block: 32px 80px; color: var(--muted); font-size: 14px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
