/* ─── Loisir · style system ───────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600&family=Manrope:wght@300;400;500;600;700&display=swap');

:root {
  /* Default palette: Nocturne (manhwa fantasy) */
  --bg-deep:   #0d0709;
  --bg:        #170b13;
  --surface:   #231220;
  --surface-2: #2d1828;
  --line:      rgba(201, 168, 102, 0.18);
  --line-soft: rgba(241, 230, 207, 0.08);

  --ink:       #f1e6cf;     /* parchment cream */
  --ink-mute:  rgba(241, 230, 207, 0.62);
  --ink-fade:  rgba(241, 230, 207, 0.38);

  --gold:      #c9a866;
  --gold-deep: #8a6f3a;
  --rouge:     #a8324a;
  --rouge-deep:#6e1b2b;
  --pink:      #d8a6b2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0a0508;
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 500; /* évite les fontes trop fines sur desktop */
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ─── Lisibilité desktop ─── */
@media (min-width: 601px) {
  body { font-size: 15px; }
  .body-sm { font-size: 14px !important; }
  .bubble-them, .bubble-me { font-size: 15px !important; line-height: 1.55 !important; }
  input, textarea, button { font-weight: 500; }
}

.loisir {
  width: 100%; height: 100%;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(168, 50, 74, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 110%, rgba(201, 168, 102, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  position: relative;
  overflow: hidden;
}

/* subtle noise overlay */
.loisir::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.9' seed='3'/><feColorMatrix values='0 0 0 0 0.95  0 0 0 0 0.9  0 0 0 0 0.81  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

.serif { font-family: 'Cormorant Garamond', serif; }
.italic { font-style: italic; }

/* ─── Buttons ─── */
.btn {
  font-family: 'Manrope', sans-serif;
  font-size: 14px; font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}
.btn:hover { background: rgba(201, 168, 102, 0.1); }
.btn:active { transform: scale(0.98); }
.btn-fill {
  background: var(--gold);
  color: #1c0e0a;
  border-color: var(--gold);
}
.btn-fill:hover { background: #d6b674; }

/* ─── Decorative dividers ─── */
.divider-ornate {
  display: flex; align-items: center; gap: 10px;
  color: var(--gold);
  font-size: 11px; letter-spacing: 0.3em;
  text-transform: uppercase;
}
.divider-ornate::before,
.divider-ornate::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

/* ─── Cards ─── */
.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  position: relative;
}

/* ─── Scrollbars hidden ─── */
.no-scroll::-webkit-scrollbar { display: none; }
.no-scroll { scrollbar-width: none; }

/* ─── Animations ─── */
@keyframes flicker {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes float-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-soft {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.05); opacity: 0.85; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(201, 168, 102, 0.2); }
  50%      { box-shadow: 0 0 30px rgba(201, 168, 102, 0.4); }
}
@keyframes appear {
  from { opacity: 0; transform: translateY(4px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.float-in { animation: float-in 0.5s ease both; }
.appear { animation: appear 0.45s ease both; }

/* ─── Type ─── */
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.h-display {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.01em;
}
.h-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 28px;
  line-height: 1.05;
}
.h-sub {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-mute);
}
.body-sm { font-size: 13px; line-height: 1.55; color: var(--ink-mute); }
.body { font-size: 15px; line-height: 1.55; }

/* ─── Chat bubbles ─── */
.bubble-them {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 18px 18px 18px 4px;
  padding: 12px 14px;
  max-width: 80%;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
.bubble-me {
  background: linear-gradient(135deg, var(--gold-deep), #6a5226);
  border-radius: 18px 18px 4px 18px;
  padding: 12px 14px;
  max-width: 80%;
  margin-left: auto;
  color: #fdf6e3;
  font-size: 15px;
  line-height: 1.45;
}

/* ─── Input ─── */
.input {
  background: rgba(241, 230, 207, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 12px 16px;
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--gold); }
.input::placeholder { color: var(--ink-fade); }

.textarea {
  background: rgba(241, 230, 207, 0.05);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--ink);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 19px;
  line-height: 1.45;
  width: 100%;
  outline: none;
  resize: none;
  transition: border-color 0.2s;
}
.textarea:focus { border-color: var(--gold); }
.textarea::placeholder { color: var(--ink-fade); }

/* ─── Tarot frame for character cards ─── */
.tarot {
  position: relative;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: linear-gradient(180deg, #2a1422, #14080f);
  padding: 14px;
  overflow: hidden;
}
.tarot::before,
.tarot::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 1px solid var(--gold);
}
.tarot::before { top: 4px; left: 4px; border-right: none; border-bottom: none; }
.tarot::after  { bottom: 4px; right: 4px; border-left: none; border-top: none; }

/* ─── Parchment card (Oracle reading) ─── */
.parchment {
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 240, 200, 0.06), transparent 70%),
    linear-gradient(180deg, #1f1018 0%, #160a12 100%);
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 28px 24px 32px;
  position: relative;
  color: var(--ink);
}
.parchment::before {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid rgba(201, 168, 102, 0.25);
  border-radius: 3px;
  pointer-events: none;
}

/* ─── Sparkle ─── */
.sparkle {
  display: inline-block;
  color: var(--gold);
  animation: flicker 2.5s ease-in-out infinite;
}

/* ─── Tab bar ─── */
.tab-pill {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  cursor: pointer;
  border-radius: 999px;
  transition: all 0.2s;
}
.tab-pill.active {
  background: rgba(201, 168, 102, 0.12);
  color: var(--gold);
}

/* ─── Theme variants (Tweaks) ─── */
.theme-rose {
  --bg-deep:   #1a0c10;
  --bg:        #221218;
  --surface:   #2d1820;
  --surface-2: #3a2128;
  --gold:      #e8a8b8;
  --gold-deep: #a96878;
  --rouge:     #c44a6c;
}
.theme-rose .loisir {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(232, 168, 184, 0.16), transparent 55%),
    radial-gradient(ellipse at 80% 110%, rgba(196, 74, 108, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

.theme-ink {
  --bg-deep:   #050505;
  --bg:        #0c0c0e;
  --surface:   #161618;
  --surface-2: #1d1d20;
  --gold:      #c8a86a;
  --rouge:     #b22134;
  --ink:       #ece6da;
}
.theme-ink .loisir {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(178, 33, 52, 0.16), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

.theme-jade {
  --bg-deep:   #050d0c;
  --bg:        #0c1614;
  --surface:   #14201d;
  --surface-2: #1c2a26;
  --gold:      #c9a866;
  --rouge:     #5a8a6f;
}
.theme-jade .loisir {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(90, 138, 111, 0.18), transparent 55%),
    radial-gradient(ellipse at 80% 110%, rgba(201, 168, 102, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

/* ─── New features ───────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%       { opacity: 0.9; transform: scale(1.15); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes dice-shake {
  0%   { transform: rotate(0deg) scale(1); }
  20%  { transform: rotate(-14deg) scale(1.12); }
  40%  { transform: rotate(12deg) scale(1.06); }
  60%  { transform: rotate(-8deg) scale(1.04); }
  80%  { transform: rotate(5deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(1); }
}
@keyframes dice-result-in {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes item-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  65%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes milestone-glow {
  0%,100% { box-shadow: 0 0 0 0 transparent; }
  50%      { box-shadow: 0 0 18px 4px var(--gold); }
}

/* ─── Mode roman (novel view) ─── */
.novel-view {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  line-height: 1.9;
  color: var(--ink);
  padding: 24px 22px 16px;
}
.novel-view p { margin: 0 0 16px 0; }
.novel-view .nv-them { color: var(--ink); }
.novel-view .nv-me   { color: var(--ink-mute); font-style: italic; text-align: right; }
.novel-view .nv-narr {
  color: var(--ink-fade);
  font-style: italic;
  font-size: 16px;
  border-left: 2px solid var(--gold);
  padding-left: 12px;
  margin-left: 4px;
}
.novel-view .nv-dlg { color: var(--ink); }

/* ─── Portrait edit overlay ─── */
.portrait-edit-wrap { position: relative; display: inline-flex; }
.portrait-edit-wrap .portrait-edit-btn {
  position: absolute; bottom: -2px; right: -2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 1px 5px rgba(0,0,0,0.55);
  transition: background 0.15s;
}
.portrait-edit-wrap .portrait-edit-btn:hover { background: #d6b674; }

/* ─── Dice prompt ─── */
.dice-prompt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(201,168,102,0.08);
  border: 1px solid rgba(201,168,102,0.3);
  border-radius: 12px;
  animation: appear 0.4s ease;
}
.dice-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--gold); color: #1c0e0a;
  border: none; border-radius: 999px;
  font-family: 'Manrope', sans-serif;
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.dice-btn:hover { background: #d6b674; }
.dice-btn.rolling { animation: dice-shake 0.55s ease; }
.dice-result { animation: dice-result-in 0.3s ease; }

/* ─── Inventory badge ─── */
.inv-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--rouge); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 1.5px solid var(--bg-deep);
  animation: item-pop 0.4s ease;
}

/* ─── Choix narratifs ─── */
.choice-bar {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 8px 14px 4px;
  animation: appear 0.35s ease;
}
.choice-btn {
  padding: 7px 13px;
  border: 1px solid rgba(201,168,102,0.5);
  border-radius: 999px;
  background: rgba(201,168,102,0.07);
  color: var(--gold);
  font-family: 'Manrope', sans-serif;
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.18s;
  text-align: left; line-height: 1.3;
}
.choice-btn:hover {
  background: rgba(201,168,102,0.18);
  border-color: var(--gold);
  transform: translateY(-1px);
}

/* ─── Ambiance selector ─── */
.ambiance-bar {
  display: flex; gap: 5px; flex-wrap: wrap;
  padding: 6px 14px 2px;
}
.ambiance-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-mute);
  font-family: 'Manrope', sans-serif;
  font-size: 10.5px; letter-spacing: 0.04em;
  cursor: pointer; transition: all 0.15s;
}
.ambiance-pill.active {
  border-color: var(--gold);
  background: rgba(201,168,102,0.15);
  color: var(--gold);
  font-weight: 600;
}

/* ─── Régénérer bouton ─── */
.regen-btn {
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: var(--ink-fade);
  font-size: 11px; padding: 3px 8px;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px; align-self: flex-start;
}
.regen-btn:hover { color: var(--gold); border-color: var(--gold); }

/* ─── TTS bouton ─── */
.tts-btn {
  background: transparent; border: none;
  color: var(--ink-fade); font-size: 13px;
  cursor: pointer; padding: 2px 4px;
  transition: color 0.15s; line-height: 1;
}
.tts-btn:hover { color: var(--gold); }
.tts-btn.speaking { color: var(--gold); animation: pulse 1s ease infinite; }

/* ─── Épilogue ─── */
@keyframes epilogue-in {
  from { opacity: 0; transform: scaleY(0.92); }
  to   { opacity: 1; transform: scaleY(1); }
}
.epilogue-bubble {
  border: 1px solid rgba(201,168,102,0.4) !important;
  background: linear-gradient(135deg, rgba(201,168,102,0.08), rgba(201,168,102,0.03)) !important;
  animation: epilogue-in 0.6s ease !important;
  position: relative;
}
.epilogue-badge {
  font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--gold); opacity: 0.7; margin-bottom: 6px; display: block;
}

/* ─── Journal ─── */
.journal-entry {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.journal-entry:last-child { border-bottom: none; }
.journal-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.journal-text { font-size: 12.5px; color: var(--ink-mute); line-height: 1.45; flex: 1; }
.journal-date { font-size: 10px; color: var(--ink-fade); margin-top: 2px; }

/* ─── Save slots ─── */
.slot-picker {
  display: flex; gap: 7px;
}
.slot-pill {
  flex: 1; padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-mute);
  font-family: 'Manrope', sans-serif;
  font-size: 11px; text-align: center;
  cursor: pointer; transition: all 0.15s;
}
.slot-pill.active {
  border-color: var(--gold);
  background: rgba(201,168,102,0.14);
  color: var(--gold); font-weight: 600;
}
.slot-pill.has-data { color: var(--ink-fade); }
.slot-pill.has-data.active { color: var(--gold); }
