/* ========== Variables ========== */
/* Palette officielle Feu Sacré (Grande Nuit du MAJ) */
:root {
  --phenix:    #3D0712;  /* bordeaux fumée (le plus sombre) */
  --braise:    #6B0F18;  /* bordeaux ember */
  --kimono:    #9E0E18;  /* rouge velours soie */
  --speakeasy: #E81F2A;  /* rouge néon */
  --albatre:   #EFE7D6;  /* crème naturelle */

  --bg:        #1A0408;  /* fond très sombre teinté bordeaux */
  --bg-deep:   #0B0103;  /* coins du dégradé */
  --ink:       var(--albatre);
  --ink-dim:   #B89E92;  /* crème désaturée */
  --gold:      #C9A65A;  /* doré chaud (liserés) */
  --gold-dim:  #8A6E37;
  --ember:     #FFB347;
  --rule:      rgba(201, 166, 90, 0.22);
  --serif:     "EB Garamond", "Cormorant Garamond", "Hoefler Text", Garamond, "Times New Roman", serif;
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--braise) 0%, transparent 65%),
    radial-gradient(ellipse at center, var(--bg) 0%, var(--bg-deep) 100%);
  background-color: var(--bg-deep);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; }

/* ========== Mobile : création de chandelle ========== */
.shell {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 22px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  text-align: center;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 22px;
  margin-bottom: 26px;
}
.brand .eyebrow {
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--speakeasy);
  display: block;
  margin-bottom: 14px;
  font-style: italic;
}
.brand h1 {
  font-size: 44px;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  font-style: italic;
  text-transform: uppercase;
  color: var(--albatre);
  line-height: 1;
}
.brand h1 .small {
  display: block;
  font-size: 14px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-style: normal;
  color: var(--gold);
  margin-top: 14px;
  font-family: "EB Garamond", serif;
}
.brand .sub {
  font-size: 13px;
  color: var(--ink-dim);
  margin-top: 14px;
  font-style: italic;
  letter-spacing: 0.05em;
}

.counter {
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  margin-bottom: 22px;
  font-style: italic;
}
.counter strong {
  color: var(--speakeasy);
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.preview {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 260px;
  margin: 6px 0 26px;
  position: relative;
}
.preview::before {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 18px;
  background: radial-gradient(ellipse, rgba(255, 138, 60, 0.22) 0%, transparent 70%);
  filter: blur(4px);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.field label .val {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.05em;
}

/* sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  outline: none;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--rule);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--gold);
  margin-top: -11px;
  box-shadow: 0 0 12px rgba(212, 160, 74, 0.5);
  cursor: grab;
}
input[type="range"]::-moz-range-track { height: 1px; background: var(--rule); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); border: 1px solid var(--gold);
  box-shadow: 0 0 12px rgba(212, 160, 74, 0.5);
}

/* titres de section */
.section-title {
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--speakeasy);
  margin: 8px 0 -8px;
  font-weight: 400;
  font-style: italic;
  text-align: center;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
}
.section-title:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

/* palettes couleur */
.palette {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

/* chips (forme, texture) */
.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.chips-tex {
  grid-template-columns: repeat(4, 1fr);
}
.chip {
  background: transparent;
  border: 1px solid rgba(244, 234, 213, 0.18);
  color: var(--ink-dim);
  padding: 10px 4px 8px;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.chip svg { color: currentColor; opacity: 0.85; }
.chip span {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.chip[aria-checked="true"] {
  border-color: var(--gold);
  color: var(--ink);
  background: rgba(212, 160, 74, 0.08);
}
.chip[aria-checked="true"] svg { opacity: 1; }
.swatch {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 1px solid rgba(244, 234, 213, 0.15);
  position: relative;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.swatch.selected {
  border-color: var(--gold);
  transform: scale(1.08);
  box-shadow: 0 0 14px rgba(212, 160, 74, 0.4);
}

/* bouton envoyer */
.send {
  margin-top: 36px;
  background: transparent;
  color: var(--albatre);
  border: 1px solid var(--speakeasy);
  padding: 20px 28px;
  font-size: 14px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-family: var(--serif);
  font-style: italic;
  border-radius: 0;
  transition: background 0.3s, color 0.3s, letter-spacing 0.3s, box-shadow 0.3s;
  box-shadow: 0 0 0 rgba(232, 31, 42, 0);
}
.send:hover, .send:focus {
  background: var(--speakeasy);
  color: var(--albatre);
  letter-spacing: 0.38em;
  box-shadow: 0 0 28px rgba(232, 31, 42, 0.45);
}
.send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  letter-spacing: 0.3em;
  background: transparent;
  color: var(--ink-dim);
  border-color: var(--rule);
  box-shadow: none;
}

/* messages */
.toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-deep);
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 14px 22px;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.foot {
  margin-top: auto;
  padding-top: 30px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.2em;
  font-style: italic;
  opacity: 0.6;
}

/* ========== Écran : gâteau ========== */
body.cake-body {
  overflow: hidden;
  cursor: none;
}
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Layout 3 colonnes pour la page /cake - responsive 4K */
.stage-3col {
  display: grid;
  grid-template-columns: clamp(240px, 18vw, 560px) 1fr clamp(240px, 18vw, 560px);
  gap: clamp(20px, 2vw, 80px);
  padding: clamp(20px, 3vh, 80px) clamp(20px, 2vw, 80px);
  align-items: stretch;  /* panneaux latéraux à la hauteur de la toile */
}

.cake-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  position: relative; /* pour l'overlay cérémoniel en absolute */
}

/* Panneaux latéraux : occupent toute la hauteur de la toile,
   contenu distribué entre haut, milieu et bas */
.side-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  gap: clamp(16px, 2vh, 50px);
  color: var(--ink);
  font-family: var(--serif);
  padding: clamp(8px, 1vh, 24px) 0;
}
.side-left { align-items: flex-start; }
.side-right { align-items: flex-end; text-align: right; }

/* Groupes haut/bas pour distribuer le contenu */
.panel-top,
.panel-mid,
.panel-bottom {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.5vh, 32px);
  width: 100%;
}
.side-right .panel-top,
.side-right .panel-mid,
.side-right .panel-bottom {
  align-items: flex-end;
}
.side-left .panel-top,
.side-left .panel-mid,
.side-left .panel-bottom {
  align-items: flex-start;
}

.panel-eyebrow {
  font-size: clamp(14px, 1.15vw, 30px);
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--speakeasy);
  font-style: italic;
  margin-bottom: 4px;
}

/* QR - plus prominent maintenant qu'on a plus de hauteur */
.qr-frame {
  width: clamp(200px, 15vw, 500px);
  height: clamp(200px, 15vw, 500px);
  padding: clamp(14px, 1.2vw, 32px);
  background: rgba(239, 231, 214, 0.04);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-frame img {
  width: 100%;
  height: 100%;
  display: block;
}

.instructions {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.instructions li {
  counter-increment: step;
  font-size: clamp(19px, 1.55vw, 42px);
  color: var(--ink);
  font-style: italic;
  padding-left: clamp(34px, 2.4vw, 60px);
  position: relative;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.instructions li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--gold);
  font-size: clamp(14px, 1.1vw, 26px);
  font-family: "EB Garamond", serif;
  font-style: normal;
  letter-spacing: 0.1em;
  width: clamp(24px, 1.9vw, 48px);
  height: clamp(24px, 1.9vw, 48px);
  border: 1px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.panel-quote {
  font-size: clamp(16px, 1.35vw, 34px);
  color: var(--ink-dim);
  font-style: italic;
  letter-spacing: 0.04em;
  line-height: 1.5;
  margin-top: 8px;
  max-width: clamp(280px, 18vw, 520px);
}

/* Carte œuvre (droite) */
.artwork-title {
  font-size: clamp(34px, 3vw, 84px);
  font-weight: 400;
  font-style: italic;
  margin: 0;
  letter-spacing: 0.01em;
  color: var(--albatre);
  line-height: 1.05;
}
.artwork-meta {
  font-size: clamp(17px, 1.4vw, 36px);
  color: var(--ink-dim);
  margin: 0;
  line-height: 1.7;
  letter-spacing: 0.04em;
}
.artwork-meta .painter {
  color: var(--gold);
  font-size: clamp(20px, 1.6vw, 42px);
  font-style: italic;
}
.artwork-meta .years {
  font-family: "SF Mono", Menlo, monospace;
  font-size: clamp(14px, 1.1vw, 28px);
  letter-spacing: 0.18em;
}
.artwork-meta .origin {
  font-style: italic;
  font-size: clamp(16px, 1.25vw, 32px);
}
.artwork-desc {
  font-size: clamp(16px, 1.3vw, 34px);
  color: var(--ink-dim);
  line-height: 1.55;
  margin: 0;
  letter-spacing: 0.02em;
  max-width: clamp(280px, 18vw, 520px);
}
.artwork-public {
  font-size: clamp(13px, 1vw, 26px);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin: 0;
}
.stage-title {
  position: absolute;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
}
.stage-title .eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--speakeasy);
  margin-bottom: 14px;
  font-style: italic;
}
.stage-title h1 {
  font-size: clamp(54px, 7vw, 96px);
  font-weight: 400;
  font-style: italic;
  margin: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--albatre);
  line-height: 0.95;
}
.stage-title .date {
  display: block;
  font-size: 11px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 16px;
  font-style: normal;
}

.stage-counter {
  text-align: center;
  font-size: clamp(17px, 1.4vw, 36px);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-style: italic;
}
.stage-counter strong {
  color: var(--speakeasy);
  font-weight: 400;
  font-size: clamp(28px, 2.3vw, 56px);
  font-style: normal;
  letter-spacing: 0.1em;
  margin-right: 4px;
  font-family: "EB Garamond", serif;
}
.stage-counter .sep {
  color: var(--gold-dim);
  margin: 0 6px;
}

.cake-svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 82vh;
  display: block;
}

/* ========== CÉRÉMONIE À 50 CHANDELLES ========== */
/* Intensification des flammes : les chandelles grossissent doucement */
.cake-body.ceremony .candle-inner {
  transform: scale(1.22);
  transform-origin: center bottom;
  transform-box: fill-box;
  transition: transform 3.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.cake-body.ceremony .flame-halo {
  transform: scale(1.55);
  transform-origin: center;
  transform-box: fill-box;
  transition: transform 3.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.cake-body.ceremony .flame-grp {
  /* Garde les keyframes existants mais base un peu plus chaude */
  filter: brightness(1.15) saturate(1.1);
  transition: filter 3s;
}

/* Overlay texte cérémoniel */
.ceremony-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 2s ease-in;
}
.ceremony-overlay.show {
  opacity: 1;
}
.ceremony-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(38px, 4.5vw, 64px);
  font-weight: 400;
  color: var(--albatre);
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.15;
  max-width: 80%;
  text-shadow:
    0 0 18px rgba(255, 179, 71, 0.45),
    0 0 60px rgba(255, 138, 60, 0.25);
  opacity: 0;
  transition: opacity 1.8s ease;
}
.ceremony-text.fade-in {
  opacity: 1;
}
.ceremony-text small {
  display: block;
  font-size: 0.4em;
  font-style: normal;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 18px;
  text-shadow: none;
}

/* ========== Flamme dansante (3 animations en couches) ========== */
/* 1. La flamme principale : scale chaotique + légère rotation */
@keyframes flame-dance {
  0%   { transform: scale(1.00, 1.00) rotate(0deg); }
  9%   { transform: scale(0.95, 1.08) rotate(-1.8deg); }
  18%  { transform: scale(1.04, 0.94) rotate(1.2deg); }
  27%  { transform: scale(0.96, 1.04) rotate(-0.4deg); }
  36%  { transform: scale(1.02, 0.97) rotate(2.0deg); }
  45%  { transform: scale(0.91, 1.10) rotate(-2.2deg); }
  54%  { transform: scale(1.07, 0.93) rotate(0.8deg); }
  63%  { transform: scale(0.94, 1.06) rotate(-1.4deg); }
  72%  { transform: scale(1.03, 0.96) rotate(1.6deg); }
  81%  { transform: scale(0.97, 1.03) rotate(-0.6deg); }
  90%  { transform: scale(1.05, 0.95) rotate(1.0deg); }
  100% { transform: scale(1.00, 1.00) rotate(0deg); }
}
/* 2. Le noyau brillant : pulsation différée */
@keyframes flame-core-pulse {
  0%, 100% { transform: scale(1, 1); opacity: 0.88; }
  20%      { transform: scale(0.82, 1.14); opacity: 0.96; }
  45%      { transform: scale(1.18, 0.84); opacity: 0.7; }
  70%      { transform: scale(0.9, 1.06); opacity: 0.92; }
}
/* 3. Le halo : respiration plus lente */
@keyframes halo-breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  35%      { opacity: 0.62; transform: scale(0.92); }
  65%      { opacity: 1.05; transform: scale(1.05); }
}
/* 4. Inclinaison horizontale ("vent") sur un autre groupe */
@keyframes flame-tilt {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  30%      { transform: translateX(-0.6px) rotate(-1.2deg); }
  55%      { transform: translateX(0.9px) rotate(1.5deg); }
  80%      { transform: translateX(-0.3px) rotate(-0.5deg); }
}

.flame-tilt {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: flame-tilt var(--tilt-dur, 1.4s) ease-in-out infinite;
}
.flame-grp {
  transform-box: fill-box;
  transform-origin: center bottom;
}
.flame-grp.flicker {
  animation: flame-dance var(--dance-dur, 0.55s) ease-in-out infinite;
}
.flame-core {
  transform-box: fill-box;
  transform-origin: center;
  animation: flame-core-pulse var(--core-dur, 0.7s) ease-in-out infinite;
}
.flame-halo {
  transform-box: fill-box;
  transform-origin: center;
  animation: halo-breathe var(--halo-dur, 1.1s) ease-in-out infinite;
}

@keyframes candleAppear {
  0% { opacity: 0; transform: translateY(20px) scale(0.6); }
  60% { opacity: 1; transform: translateY(-4px) scale(1.08); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.candle-appear {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: candleAppear 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
