:root{
  /* Couleurs & Layout */
  --bg0:#0b0f14;
  --bg1:#0f151d;
  --text:#f2efe6;
  --gold:#d6b36a;
  --gold-light: #e8c94f;
  --line:rgba(214,179,106,.18);
  --shadow: 0 18px 55px rgba(0,0,0,.45);
  --shadowSoft: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
  --maxw: 1120px;

  /* ambiance dynamique (mise à jour en JS) */
  --ambient: rgba(214,179,106,.10);
  --ambient2: rgba(120,170,255,.08);

  /* ========== TYPOGRAPHIE — Hiérarchie 4.1 ========== */
  --type-h1-size: clamp(1.75rem, 6vw, 3rem);
  --type-h1-weight: 600;
  --type-h1-lh: 1.2;
  
  --type-h2-size: clamp(1.35rem, 4vw, 2rem);
  --type-h2-weight: 500;
  --type-h2-lh: 1.3;
  
  --type-h3-size: clamp(1.1rem, 3vw, 1.5rem);
  --type-h3-weight: 500;
  --type-h3-lh: 1.3;
  
  --type-body-size: clamp(0.95rem, 2vw, 1.1rem);
  --type-body-weight: 400;
  --type-body-lh: 1.7;
  
  --type-ui-size: 0.95rem;
  --type-ui-weight: 500;
  --type-ui-lh: 1.4;

  /* ========== ESPACEMENTS — Rythme cinématographique 4.1 ========== */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;
  --space-scene-gap: 2.5rem;
  --space-para-gap: 1.5rem;
  --space-section-gap: 3.5rem;

  /* ========== TRANSITIONS — Harmonisation 4.2 ========== */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  
  --duration-instant: 100ms;
  --duration-quick: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
}

:root[data-theme="light"] {
  --bg0: #f3f5f9;
  --bg1: #e8edf5;
  --text: #1f2a37;
  --line: rgba(31,42,55,.20);
  --shadow: 0 18px 55px rgba(31,42,55,.20);
  --shadowSoft: 0 10px 30px rgba(31,42,55,.16);
  --ambient: rgba(157,122,47,.10);
  --ambient2: rgba(85,125,190,.10);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* scroll possible, scrollbar invisible */
  overflow-y: auto;
  scrollbar-width: none;
}
body::-webkit-scrollbar{ width:0; height:0; }

/* Fond + halos (dont ambiance) */
body::before{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 20% -10%, var(--ambient), transparent 55%),
    radial-gradient(900px 550px at 90% 10%, var(--ambient2), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.wrap{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(22px, 3vw, 44px);
}

header{
  position: relative;
  padding: 10px 0 26px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: clamp(18px, 2.5vw, 34px);
}

.header-bar{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.kicker{
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 12px;
  color: rgba(214,179,106,.9);
  margin: 0 0 10px;
}

h1{
  font-family: Cinzel, serif;
  font-size: var(--type-h1-size);
  font-weight: var(--type-h1-weight);
  line-height: var(--type-h1-lh);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
}

h2 {
  font-family: Cinzel, serif;
  font-size: var(--type-h2-size);
  font-weight: var(--type-h2-weight);
  line-height: var(--type-h2-lh);
  letter-spacing: -0.01em;
  margin: var(--space-lg) 0 var(--space-md);
}

h3 {
  font-family: Cinzel, serif;
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  line-height: var(--type-h3-lh);
  margin: var(--space-md) 0 var(--space-sm);
}

.subtitle{
  max-width: 70ch;
  color: rgba(242,239,230,.78);
  font-weight: var(--type-body-weight);
  font-size: var(--type-body-size);
  line-height: var(--type-body-lh);
  margin: 0 0 var(--space-lg);
}

.header-controls{
  display:flex;
  align-items:center;
  gap: 12px;
  padding-top: 4px;
  flex-shrink: 0;
}

.btn{
  appearance: none;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
  color: var(--text);
  font-family: inherit;
  font-weight: var(--type-ui-weight);
  font-size: var(--type-ui-size);
  letter-spacing: .02em;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  /* Transitions harmonisées 4.2 */
  transition: 
    background var(--duration-normal) var(--ease-standard),
    color var(--duration-normal) var(--ease-standard),
    border-color var(--duration-normal) var(--ease-standard),
    box-shadow var(--duration-normal) var(--ease-standard),
    transform var(--duration-quick) var(--ease-bounce),
    outline var(--duration-quick) var(--ease-standard);
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
  white-space: nowrap;
  outline: 2px solid transparent;
  outline-offset: 2px;
  user-select: none;
}
/* État hover */
.btn:hover{
  transform: translateY(-2px);
  background: rgba(255,255,255,.08);
  border-color: rgba(214,179,106,.40);
  box-shadow: 0 14px 34px rgba(0,0,0,.32);
}
/* État active */
.btn:active{ 
  transform: translateY(0px);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
/* État focus (navigaton clavier) */
.btn:focus-visible{
  outline-color: var(--gold);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(214,179,106, 0.2), 0 14px 34px rgba(0,0,0,.32);
}
/* État disabled */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-gold{
  border-color: var(--gold);
  background: rgba(214, 179, 106, 0.15);
  box-shadow: 0 10px 24px rgba(214,179,106,.12), 0 0 0 rgba(0,0,0,.30);
}
.btn-gold:hover{
  background: rgba(214, 179, 106, 0.25);
  color: #fff;
  border-color: var(--gold-light);
  box-shadow: 0 14px 34px rgba(214,179,106,.20), 0 0 16px rgba(214,179,106,.15);
}
.btn-gold:focus-visible {
  outline-color: var(--gold-light);
}
.btn-ghost{
  background: transparent;
  border-color: rgba(255,255,255,.12);
  text-decoration: none;
  color: rgba(242,239,230,.85);
  box-shadow: none;
}
.btn-ghost:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.20);
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 8px 16px rgba(0,0,0,.2);
}
.btn-ghost:active {
  background: rgba(255,255,255,.04);
  box-shadow: none;
  text-decoration: none;
}

/* ========== ACCESSIBILITÉ & FOCUS — Harmonisation globale 4.2 ========== */
a, button, [role="button"], input, select, textarea {
  transition-property: background, color, border-color, box-shadow, outline, transform;
  transition-duration: var(--duration-normal);
  transition-timing-function: var(--ease-standard);
}

/* Focus visible sur tous les éléments interactifs */
a:focus-visible, 
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.avatar{
  width: 46px;
  height: 46px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(214,179,106,.25);
  box-shadow: 0 14px 34px rgba(0,0,0,.35), 0 0 22px rgba(214,179,106,.10);
  background: rgba(255,255,255,.03);
}

@media (max-width: 820px){
  .header-bar{ flex-direction: column; align-items: stretch; }
  .header-controls{ justify-content: space-between; padding-top: 10px; }
}

/* ============ Galerie: Œuvre unique ============ */
.gallery{ display: grid; gap: clamp(18px, 2.5vw, 28px); }

.piece{
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: clamp(18px, 3vw, 44px);
  padding: clamp(16px, 2.2vw, 22px);
  border-radius: calc(var(--radius) + 6px);
  background: rgba(17,24,36,.46);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: var(--shadowSoft);
  position: relative;
  overflow: hidden;

  opacity: 0;
  transform: translateY(18px);
  transition: opacity .8s ease, transform .8s ease;
}
.piece::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(600px 240px at 15% 10%, rgba(214,179,106,.10), transparent 55%),
    radial-gradient(500px 220px at 90% 20%, rgba(120,170,255,.08), transparent 60%);
  opacity:.7;
}
.piece.is-visible{ opacity: 1; transform: translateY(0); }

.piece-left{ display:flex; flex-direction:column; gap: 12px; z-index: 1; }
.card{
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}
.card-media{ aspect-ratio: 9 / 16; width: 100%; position: relative; }

.card-media img{
  width: 100%;
  height: 100%;
  display:block;
  object-fit: cover;
  transform: scale(1);
  /* Transitions harmonisées avec nouvelles variables 4.2 */
  transition: 
    transform var(--duration-slow) var(--ease-standard), 
    filter var(--duration-slow) var(--ease-standard),
    box-shadow var(--duration-normal) var(--ease-standard);
  will-change: transform;
  cursor: pointer;  /* Remplacé de zoom-in par pointer (4.1-4.2) */
}
/* Hover interactif sur image galerie */
.card:hover img{ 
  transform: scale(1.02); 
  filter: brightness(1.05) contrast(1.02);
}
.card:focus-within img {
  filter: brightness(1.08) contrast(1.04);
}

.card::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.35));
  opacity: .9;
  transition: opacity .55s ease-in-out;
}
.card:hover::before{ opacity: .78; }

.card::after{
  content:"";
  position:absolute;
  inset:-1px;
  pointer-events:none;
  border-radius: var(--radius);
  border: 1px solid rgba(214,179,106,.18);
  opacity: 0;
  transition: opacity .55s ease-in-out;
  box-shadow: 0 0 0 rgba(214,179,106,0);
}
.card:hover::after{ opacity: 1; box-shadow: 0 0 26px rgba(214,179,106,.10); }

/* Ken Burns subtil (uniquement quand activé via JS) */
.kenburns{
  animation: kenburns 12s ease-in-out forwards;
}
@keyframes kenburns{
  from { transform: scale(1); }
  to   { transform: scale(1.04); }
}

.title{
  text-align:center;
  font-family: Cinzel, serif;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--text);
  margin: -20px 0 0;
  font-size: 16px;

  opacity: 0;
  transform: translateY(6px);
  transition: opacity .6s ease, transform .6s ease;
}
.title.is-revealed{ opacity: 1; transform: translateY(0); }
.title span{ position: relative; padding-bottom: 6px; }
.title span::after{
  content:"";
  position:absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 34px;
  height: 1px;
  background: var(--line);
}

.piece-right{ z-index: 1; display:flex; flex-direction: column; justify-content: center; gap: 16px; }
.desc{
  max-width: 80ch;
  color: rgba(242,239,230,.82);
  line-height: 1.78;
  font-weight: 300;
  margin: 0;
  font-size: 15.5px;

  opacity: 0;
  transform: translateY(6px);
  transition: opacity .6s ease, transform .6s ease;
}
.desc.is-revealed{ opacity: 1; transform: translateY(0); }

/* ============ Boutons de vote ============ */
.vote-buttons{
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-top: 6px;
}

.vote-btn{
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 10px 16px;
  color: rgba(242,239,230,.7);
  cursor: pointer;
  /* Transitions harmonisées 4.2 */
  transition: 
    background var(--duration-normal) var(--ease-standard),
    border-color var(--duration-normal) var(--ease-standard),
    color var(--duration-normal) var(--ease-standard),
    transform var(--duration-quick) var(--ease-bounce);
  font-family: inherit;
  font-size: var(--type-ui-size);
  font-weight: var(--type-ui-weight);
  outline: 2px solid transparent;
  outline-offset: 2px;
  user-select: none;
}

.vote-btn:hover{
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.20);
  color: var(--text);
  transform: translateY(-1px);
}

.vote-btn:focus-visible{
  outline-color: var(--gold);
  outline-offset: 3px;
}

.vote-btn:active {
  transform: translateY(0);
}

.vote-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.vote-btn.is-active.vote-like{
  background: rgba(76, 175, 80, .15);
  border-color: rgba(76, 175, 80, .4);
  color: #81c784;
}

.vote-btn.is-active.vote-dislike{
  background: rgba(244, 67, 54, .15);
  border-color: rgba(244, 67, 54, .4);
  color: #e57373;
}

.vote-btn.vote-share{
  padding-inline: 12px;
}

.vote-btn svg{
  flex-shrink: 0;
}

.vote-count{
  font-weight: 500;
  min-width: 1ch;
}

.piece-nav{
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  width: 100%;
  margin-top: -12px;
  z-index: 1;
}

.piece-nav .btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  font-size: 18px;
  line-height: 1;
}

.piece .vote-btn {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 13px;
  gap: 8px;
}

.piece .vote-btn svg {
  width: 16px;
  height: 16px;
}

.piece .vote-count {
  font-size: 13px;
}

.all-works-view {
  display: grid;
  gap: 16px;
}

.all-works-view[hidden],
#immersiveHeader[hidden],
#browseHeader[hidden] {
  display: none !important;
}

body.gallery-mode-immersive #allWorksView,
body.gallery-mode-immersive #browseHeader,
body.gallery-mode-browse #piece,
body.gallery-mode-browse #immersiveHeader {
  display: none !important;
}

.all-works-title {
  margin: 0;
}

.all-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.all-work-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(17,24,36,.46);
  box-shadow: var(--shadowSoft);
  transition: transform var(--duration-normal) var(--ease-standard), box-shadow var(--duration-normal) var(--ease-standard), border-color var(--duration-normal) var(--ease-standard);
}

.all-work-image {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-standard), filter var(--duration-normal) var(--ease-standard);
}

.all-work-card:hover {
  transform: translateY(-3px);
  border-color: rgba(214,179,106,.30);
  box-shadow: 0 18px 40px rgba(0,0,0,.34);
}

.all-work-card:hover .all-work-image {
  transform: scale(1.06);
  filter: brightness(1.05) contrast(1.03);
}

.all-work-meta {
  padding: 8px 10px 10px;
}

.all-work-name {
  margin: 0;
  font-family: Cinzel, serif;
  font-size: 14px;
  line-height: 1.35;
}

.all-work-desc {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(242,239,230,.70);
}

:root[data-theme="light"] .all-work-card {
  background: rgba(255,255,255,.78);
  border-color: rgba(31,42,55,.10);
}

:root[data-theme="light"] .all-work-card:hover {
  border-color: rgba(157,122,47,.36);
  box-shadow: 0 16px 34px rgba(31,42,55,.20);
}

:root[data-theme="light"] .all-work-desc {
  color: rgba(31,42,55,.74);
}

/* Empêche le "clignotement" du cartel pendant la transition couloir */
.title.is-resetting,
.desc.is-resetting{
  transition: none !important;
  opacity: 0 !important;
  transform: translateY(6px) !important;
}


@media (max-width: 820px){
  .piece{ grid-template-columns: 1fr; }
  .piece-right{ align-items: flex-start; }
  .desc{ font-size: 15px; }
  .vote-buttons{ margin-top: 4px; }
  .piece-nav{ margin-top: -6px; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce){
  .piece, .card-media img, .card::before, .card::after, .title, .desc {
    transition: none !important;
  }
  .piece{ opacity: 1 !important; transform: none !important; }
  .kenburns{ animation: none !important; }
}

/* ============ Transition "couloir" ============ */
.transition-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  pointer-events: none;
  z-index: 800;
  transition: background .55s ease;
}
.transition-overlay.is-on{
  background: rgba(0,0,0,.78);
}

/* ============ Lightbox (agrandissement + téléchargement) ============ */
.lightbox{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vw, 28px);
  background: rgba(5,8,12,.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 999;
}
.lightbox.is-open{ display: flex; }

.lightbox-panel{
  width: min(980px, 100%);
  max-height: calc(100vh - 28px);
  background: rgba(17,24,36,.72);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0,0,0,.60);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.lightbox-topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(0,0,0,.12), transparent);
}
.lightbox-counter{
  font-size: 12px;
  color: rgba(214,179,106,.7);
  font-weight: 500;
  letter-spacing: .05em;
  min-width: 45px;
}
.lightbox-media{
  padding: 14px;
  display:flex;
  align-items: center;
  justify-content:center;
  flex: 1;
}
.lightbox-media img{
  height: min(78vh, 860px);
  width: auto;
  max-width: 92vw;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 18px 55px rgba(0,0,0,.45);
  background: rgba(0,0,0,.18);
}

/* ============ Overlays (entrée / sortie) ============ */
.overlay{
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 28px);
  background: rgba(6,10,14,.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1200;
}
.overlay[hidden]{ display: none; }

.overlay-card{
  width: min(760px, 100%);
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(17,24,36,.72);
  box-shadow: 0 30px 90px rgba(0,0,0,.60);
  padding: clamp(18px, 3.2vw, 28px);
  position: relative;
  overflow: hidden;
}
.overlay-card::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(620px 260px at 15% 10%, rgba(214,179,106,.14), transparent 55%),
    radial-gradient(560px 240px at 90% 20%, rgba(120,170,255,.10), transparent 60%);
  opacity: .7;
}
.overlay-inner{ position: relative; z-index: 1; }

.overlay-title{
  font-family: Cinzel, serif;
  font-weight: 600;
  font-size: clamp(22px, 2.5vw, 34px);
  margin: 0 0 10px;
  line-height: 1.2;
}
.overlay-text{
  margin: 0 0 18px;
  color: rgba(242,239,230,.82);
  line-height: 1.75;
  font-weight: 300;
  max-width: 62ch;
}
.overlay-actions{
  display:flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}

/* ============ Menu haut (Galerie / Histoires) ============ */
.top-nav{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  pointer-events: auto;
  background: rgba(7,10,14,.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.top-nav-inner{
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px clamp(14px, 3vw, 44px);
  display:flex;
  align-items:center;
  justify-content: flex-end;
  gap: 10px;
}
.nav-btn{
  text-decoration: none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.14);
  color: rgba(242,239,230,.88);
  font-size: 12.5px;
  letter-spacing: .02em;
  font-weight: 500;
  transition: transform .18s ease, background .25s ease, border-color .25s ease, opacity .25s ease;
  opacity: .92;
  white-space: nowrap;
  cursor: pointer;
}
.nav-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.06);
  border-color: rgba(214,179,106,.26);
  opacity: 1;
}
.nav-btn.is-active{
  border-color: rgba(214,179,106,.35);
  color: var(--text);
  opacity: 1;
}

.nav-lang-btn{
  min-width: 52px;
  font-weight: 600;
}

.nav-theme-btn{
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
}

:root[data-theme="light"] .top-nav {
  background: rgba(255,255,255,.70);
  border-bottom-color: rgba(31,42,55,.10);
}

:root[data-theme="light"] .nav-btn {
  background: rgba(255,255,255,.85);
  border-color: rgba(31,42,55,.16);
  color: rgba(31,42,55,.90);
}

:root[data-theme="light"] .nav-btn:hover {
  background: rgba(157,122,47,.12);
  border-color: rgba(157,122,47,.35);
}

:root[data-theme="light"] .piece,
:root[data-theme="light"] .story-card,
:root[data-theme="light"] .overlay-card,
:root[data-theme="light"] .lightbox-panel,
:root[data-theme="light"] .card,
:root[data-theme="light"] .story-thumbnail,
:root[data-theme="light"] .reading-image {
  background: rgba(255,255,255,.76);
  border-color: rgba(31,42,55,.10);
}

:root[data-theme="light"] .lightbox,
:root[data-theme="light"] .overlay,
:root[data-theme="light"] .transition-overlay.is-on {
  background: rgba(233,238,246,.82);
}

:root[data-theme="light"] .btn {
  border-color: rgba(31,42,55,.14);
  background: rgba(255,255,255,.78);
  color: rgba(31,42,55,.90);
  box-shadow: 0 8px 24px rgba(31,42,55,.14);
}

:root[data-theme="light"] .btn-ghost {
  background: rgba(255,255,255,.64);
  border-color: rgba(31,42,55,.14);
  color: rgba(31,42,55,.84);
}

:root[data-theme="light"] .btn-ghost:hover {
  background: rgba(157,122,47,.12);
  border-color: rgba(157,122,47,.35);
}

:root[data-theme="light"] .btn-gold {
  border-color: rgba(157,122,47,.58);
  background: rgba(157,122,47,.14);
  color: rgba(31,42,55,.95);
}

:root[data-theme="light"] .subtitle,
:root[data-theme="light"] .desc,
:root[data-theme="light"] .overlay-text,
:root[data-theme="light"] .story-excerpt,
:root[data-theme="light"] .reading-text,
:root[data-theme="light"] .reading-ending-text,
:root[data-theme="light"] .moral-text,
:root[data-theme="light"] .reading-progress,
:root[data-theme="light"] .story-meta-value,
:root[data-theme="light"] .story-tag,
:root[data-theme="light"] .filter-tag,
:root[data-theme="light"] .vote-btn,
:root[data-theme="light"] .legal-footer a {
  color: rgba(31,42,55,.78);
}

:root[data-theme="light"] .story-tag,
:root[data-theme="light"] .filter-tag,
:root[data-theme="light"] .vote-btn {
  background: rgba(157,122,47,.08);
  border-color: rgba(157,122,47,.22);
}

:root[data-theme="light"] .vote-btn:hover {
  background: rgba(157,122,47,.14);
  border-color: rgba(157,122,47,.30);
}

:root[data-theme="light"] .legal-footer {
  background: linear-gradient(to top, var(--bg0) 65%, transparent);
}

/* Espace pour le menu fixe */
body{ padding-top: 56px; }

/* ============ Author Link ============ */
.author-link{
  color: var(--gold);
  text-decoration: none;
  font-weight: 500;
  position: relative;
  transition: color .3s ease;
}
.author-link::after{
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 1px;
  background: var(--gold);
  transition: width .3s ease;
}
.author-link:hover{
  color: #e8d4a8;
}
.author-link:hover::after,
.author-link:focus::after{
  width: 100%;
}
.author-link:focus,
.author-link:focus-visible{
  outline: none;
  color: #e8d4a8;
}

/* ============ Histoires: Liste et lecture ============ */

.stories-list{
  display: grid;
  gap: clamp(18px, 2.5vw, 28px);
  opacity: 1;
  transition: opacity .55s ease;
}
.stories-list.is-hidden{ 
  opacity: 0;
  pointer-events: none;
}

.story-card{
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: clamp(18px, 3vw, 44px);
  padding: clamp(16px, 2.2vw, 22px);
  border-radius: calc(var(--radius) + 6px);
  background: rgba(17,24,36,.46);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: var(--shadowSoft);
  position: relative;
  overflow: hidden;

  opacity: 0;
  transform: translateY(18px);
  transition: opacity .8s ease, transform .8s ease, border-color .25s ease, box-shadow .25s ease;
  will-change: transform;
}
.story-card::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:
    radial-gradient(600px 240px at 15% 10%, rgba(214,179,106,.10), transparent 55%),
    radial-gradient(500px 220px at 90% 20%, rgba(120,170,255,.08), transparent 60%);
  opacity:.7;
}
.story-card.is-visible{ 
  opacity: 1; 
  transform: translateY(0); 
}
.story-card:hover{
  border-color: rgba(214,179,106,.25);
  box-shadow: 0 14px 34px rgba(214,179,106,.08), 0 14px 34px rgba(0,0,0,.30);
}

.story-card-left{ 
  display:flex; 
  flex-direction:column; 
  gap: 12px; 
  z-index: 1; 
}

.story-thumbnail{
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.story-thumbnail img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .92;
  transition: opacity .55s ease, transform .55s ease;
}
.story-card:hover .story-thumbnail img{
  opacity: 1;
  transform: scale(1.02);
}

.story-card-right{
  z-index: 1;
  display:flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.story-title{
  font-family: Cinzel, serif;
  font-weight: 600;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--text);
}

.story-excerpt{
  color: rgba(242,239,230,.78);
  font-weight: 300;
  line-height: 1.65;
  margin: 0 0 12px;
  font-size: 15px;
  max-width: 65ch;
}

.story-meta{
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: auto;
}

.story-meta-item{
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.story-meta-label{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(214,179,106,.7);
  font-weight: 500;
}

.story-meta-value{
  font-size: 14px;
  color: rgba(242,239,230,.88);
  font-weight: 400;
}

.story-tag{
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(214,179,106,.08);
  border: 1px solid rgba(214,179,106,.20);
  font-size: 12.5px;
  color: rgba(242,239,230,.82);
  cursor: pointer;
  transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
}

.story-tag:hover{
  background: rgba(214,179,106,.16);
  border-color: rgba(214,179,106,.35);
  box-shadow: 0 4px 12px rgba(214,179,106,.12);
}

.story-actions{
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.story-actions .story-vote-buttons{
  display: flex;
  gap: 10px;
}

.story-actions .vote-btn{
  padding: 7px 12px;
  font-size: 13px;
}

.story-share-btn{
  margin-left: auto;
  align-self: flex-end;
}

.story-tag.is-active{
  background: rgba(214,179,106,.25);
  border-color: rgba(214,179,106,.5);
  box-shadow: 0 4px 12px rgba(214,179,106,.2);
}

.filter-tag{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(214,179,106,.12);
  border: 1px solid rgba(214,179,106,.3);
  font-size: 13px;
  color: rgba(242,239,230,.88);
  animation: slideIn .25s ease;
}

@keyframes slideIn{
  from{ 
    opacity: 0;
    transform: scale(0.95);
  }
  to{
    opacity: 1;
    transform: scale(1);
  }
}

.filter-tag-remove{
  cursor: pointer;
  font-weight: 600;
  opacity: .7;
  transition: opacity .2s ease;
}

.filter-tag-remove:hover{
  opacity: 1;
}

.filter-reset-btn{
  padding: 6px 12px;
  font-size: 13px;
}

.story-btn{
  margin-top: 12px;
}

@media (max-width: 820px){
  .story-card{ grid-template-columns: 1fr; }
  .story-card-right{ gap: 10px; }
  .story-share-btn{ margin-left: 0; align-self: center; }
}

/* ============ Mode lecture ============ */
.reading-container{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1400;
  background: linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 100%);
  overflow: hidden;
  padding-top: 56px;
}
.reading-container.is-active{
  display: flex;
  flex-direction: column;
}

.reading-main{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: clamp(20px, 4vw, 40px);
  overflow: hidden;
  position: relative;
}

.reading-scene{
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: 1fr;
  gap: clamp(30px, 4vw, 50px);
  max-width: min(1200px, 100%);
  width: 100%;
  height: 100%;
  padding-bottom: 40px;
  align-items: center;
  opacity: 1;
  pointer-events: auto;
  transition: none;
}
.reading-scene.is-active{
  opacity: 1;
  pointer-events: auto;
}

.reading-image{
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 80vh;
  border-radius: var(--radius);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
  transition: none;
}

.reading-image img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: subtleZoom 8s ease-in-out infinite;
}

@keyframes subtleZoom {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.reading-text-container{
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  max-width: 100%;
  margin: 0;
}

.reading-text{
  font-size: clamp(16px, 1.8vw, 20px);
  line-height: 1.7;
  color: rgba(242,239,230,.88);
  font-weight: 300;
  margin: 0;
  min-height: 3em;
  letter-spacing: .01em;
}

.reading-text[data-typing="true"]{ position: relative; }
.reading-text[data-typing="true"]::after{
  content: "";
  position: absolute;
  right: -2px;
  width: 2px;
  height: 1.2em;
  background: var(--gold);
  opacity: .7;
  animation: blink .8s ease-in-out infinite;
}
@keyframes blink{
  0%, 49%, 100%{ opacity: .7; }
  50%, 99%{ opacity: 0; }
}

.reading-controls{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding: 0 20px;
  flex-wrap: wrap;
}

.reading-nav{
  display: flex;
  gap: 10px;
  align-items: center;
}

.story-vote-buttons{
  display: flex;
  gap: 12px;
  align-items: center;
}

.story-vote-buttons .vote-btn{
  padding: 8px 12px;
  font-size: 13px;
}

.reading-progress{
  font-size: 12.5px;
  color: rgba(242,239,230,.58);
  white-space: nowrap;
}

.reading-next-btn{ padding: 10px 16px; }
.reading-exit-btn{ padding: 8px 12px; font-size: 12.5px; }

/* ============ Barre supérieure lecture ============ */
.reading-topbar{
  padding: 12px clamp(14px, 3vw, 44px);
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 400px){
  .reading-topbar{
    padding: 10px 12px;
    gap: 6px;
  }
}

/* ============ Fin d'histoire + Morale ============ */
.reading-ending-title{
  font-family: Cinzel, serif;
  font-size: clamp(22px, 4vw, 28px);
  margin: 0 0 12px;
  color: var(--text);
}

.reading-ending-text{
  margin: 0;
  color: rgba(242,239,230,.7);
  font-size: clamp(14px, 2.5vw, 15px);
}
.reading-ending{
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  opacity: 0;
  transition: opacity .8s ease;
}
.reading-ending.is-active{
  display: flex;
  opacity: 1;
}

.ending-button{ margin-top: 28px; padding: 12px 24px; font-size: 14px; }

.moral-panel{
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px clamp(20px, 4vw, 60px);
  opacity: 0;
  transition: opacity .8s ease;
}
.moral-panel.is-active{
  display: flex;
  opacity: 1;
}

.moral-title{
  font-family: Cinzel, serif;
  font-weight: 600;
  font-size: clamp(20px, 2.5vw, 28px);
  margin: 0 0 18px;
  color: var(--gold);
  letter-spacing: .03em;
}

.moral-text{
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 1.8;
  color: rgba(242,239,230,.85);
  font-weight: 300;
  max-width: 75ch;
  margin: 0 0 32px;
  white-space: pre-wrap;
}

.moral-back-btn{ padding: 10px 18px; font-size: 13px; }

.reading-ending,
.moral-panel {
  align-self: center;
}

/* ============ Responsive ============ */
@media (max-width: 820px){
  .reading-scene{ 
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 20px;
    height: auto;
    align-items: start;
  }
  .reading-image{ 
    max-height: 55vh;
    width: auto;
    max-width: 100%;
    aspect-ratio: 9 / 16;
    margin: 0 auto;
  }
  .reading-text-container{
    text-align: center;
    align-items: center;
  }
  .reading-controls{ flex-direction: column; gap: 14px; }
  .reading-nav{ width: 100%; justify-content: center; }
  .reading-main{
    padding: 16px;
    overflow-y: auto;
    justify-content: flex-start;
  }
}

/* ============ Mobile - Mode lecture ============ */
@media (max-width: 620px){
  .reading-container{
    padding-top: 50px;
  }
  .reading-main{
    padding: 12px;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .reading-scene{ 
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 14px;
    padding-bottom: 20px;
    height: auto;
    align-items: start;
  }
  .reading-image{ 
    max-height: 50vh;
    width: auto;
    max-width: 70%;
    aspect-ratio: 9 / 16;
    margin: 0 auto;
  }
  .reading-text-container{
    width: 100%;
    padding: 0 8px;
    text-align: center;
    align-items: center;
  }
  .reading-text{ 
    font-size: 15px; 
    line-height: 1.65;
    text-align: center;
  }
  .reading-controls{ 
    padding: 0; 
    margin-top: 16px;
    width: 100%;
  }
  .reading-progress{
    font-size: 11px;
  }
  .reading-next-btn{
    padding: 10px 14px;
    font-size: 13px;
  }
  .reading-exit-btn{
    padding: 6px 10px;
    font-size: 11px;
  }
  .reading-ending{
    padding: 30px 16px;
  }
  .reading-ending h2{
    font-size: 22px !important;
  }
  .reading-ending p{
    font-size: 14px !important;
  }
  .ending-button{
    padding: 10px 20px;
    font-size: 13px;
  }
  .moral-panel{
    padding: 30px 16px;
  }
  .moral-title{
    font-size: 18px;
  }
  .moral-text{
    font-size: 14px;
    line-height: 1.7;
    max-width: 100%;
  }
  .moral-back-btn{
    padding: 10px 16px;
    font-size: 12px;
  }
}

/* ============ Très petit écran ============ */
@media (max-width: 400px){
  .reading-main{
    padding: 10px;
  }
  .reading-image{
    max-height: 45vh;
    max-width: 65%;
  }
  .reading-text{
    font-size: 14px;
    line-height: 1.6;
  }
}

/* ============ Accessibilité ============ */
@media (prefers-reduced-motion: reduce){
  .story-card, .reading-scene, .reading-ending, .moral-panel, .btn, .nav-btn, .story-thumbnail img {
    transition: none !important;
  }
  .story-card.is-visible{ opacity: 1 !important; transform: none !important; }
  .reading-text[data-typing="true"]::after{ animation: none !important; }
}

button:focus-visible, a:focus-visible{
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ============ Legal Footer ============ */
.legal-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  font-size: 11px;
  background: linear-gradient(to top, var(--bg0) 60%, transparent);
  z-index: 50;
}
.legal-footer a {
  color: rgba(242,239,230,.35);
  text-decoration: none;
  transition: color .3s ease;
}
.legal-footer a:hover {
  color: var(--gold);
}

.kicker-tight {
  margin-bottom: 8px;
}

.tags-filter {
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.story-audio-hidden {
  display: none;
}
