/* Histoire de la musique · affichage PC */
body.history-module-page {
  --history-width: min(1760px, 100%);
  --history-ink: #192d46;
  --history-paper: #fbfaf7;
  --history-line: #dcdedc;
  margin: 0;
  min-height: 100dvh;
  height: auto;
  padding: 10px clamp(18px, 2.6vw, 50px) 16px;
  background: linear-gradient(165deg, #edece8, #e8eef1 75%) fixed;
  overflow: auto;
}

body.history-module-page.lightbox-open { overflow: hidden; }

body.history-module-page > .notalix-global-topbar,
body.history-module-page > .shell { width: var(--history-width); }

body.history-module-page > .shell { height: auto !important; }

body.history-module-page #app {
  width: 100%;
  margin-top: 6px;
  overflow: visible;
  scrollbar-gutter: auto;
}

.history-module-page .panel {
  padding: clamp(16px, 1.5vw, 26px);
  border-color: var(--history-line);
  border-radius: 20px;
  background: var(--history-paper);
}

/* Panorama des périodes */
.panel-home {
  min-height: calc(100dvh - 98px);
  height: auto;
  overflow: visible;
  gap: clamp(12px, 1.3vw, 22px);
}

.panel-home:has(.other-worlds) { min-height: 0; }

.hero-history {
  grid-template-columns: minmax(0, 1fr) minmax(238px, 25%);
  align-items: center;
  gap: 24px;
}

.hero-copy { padding: 0; }
.hero-copy h1 { font-size: clamp(30px, 3.2vw, 54px); color: var(--history-ink); }
.hero-copy p { font-size: clamp(13px, 1vw, 16px); }
.how-it-works {
  padding: 11px 14px;
  border: 0;
  border-left: 2px solid #d5b37c;
  border-radius: 0 10px 10px 0;
  background: #f3eee5;
}

.how-it-works h2 { margin-bottom: 5px; font-size: 14px; }
.how-it-works ol { gap: 3px; }
.how-it-works li { gap: 7px; padding: 1px 0; background: none; font-size: 12px; }
.how-it-works strong { width: 19px; height: 19px; background: #e9dcc5; color: #624a27; font-size: 10px; }
.timeline, .timeline.other-worlds {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: none;
  grid-auto-rows: 1fr;
  gap: clamp(9px, 1vw, 17px);
}

.period-card {
  grid-template-columns: 38% minmax(0, 1fr);
  min-height: 208px;
  border-radius: 14px;
  border-color: #d9dad7;
  box-shadow: 0 4px 11px #27374a0a;
}

.period-card::after { left: 38%; height: 3px; }
.period-visual { position: relative; }
.period-visual img { position: absolute; inset: 0; }
.period-card-body { padding: clamp(11px, 1.15vw, 20px); }
.period-dot { width: 25px; height: 25px; font-size: 11px; box-shadow: none; }
.period-count { color: #57677b; }
.period-card h2 { margin-top: 9px; font-size: clamp(20px, 1.6vw, 29px); color: var(--history-ink); letter-spacing: -.025em; }
.period-card p { color: #47586a; font-size: clamp(12px, .85vw, 14px); }
.period-card .chip-row { gap: 4px; }
.period-card .chip { padding: 4px 7px; font-size: 10.5px; border-color: #e0e4e5; }
.footer-note { color: #56667a; }
.other-worlds .period-card { min-height: clamp(240px, 24vw, 370px); }

/* Périodes, fiches et présentation */
.period-page .section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 30%);
  align-items: center;
  margin-bottom: 14px;
}

.period-page .section-head-copy { max-width: 76ch; }
.period-page .section-head h1 { color: var(--history-ink); }
.period-page .section-head-side { align-items: stretch; gap: 6px; }
.period-page .period-banner-button img { height: clamp(90px, 8vw, 146px); }
.period-page .back-btn { align-self: flex-end; }
.period-context { margin-bottom: 13px; padding: 12px; background: #f0f3f4; }
.period-context-grid article { border-radius: 9px; box-shadow: none; }
.period-context-grid p { color: #43546a; }
.composer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.composer-card { display: grid; grid-template-columns: minmax(92px, 26%) minmax(0, 1fr); border-radius: 12px; }
.composer-card .portrait-wrap { position: relative; height: auto; }
.composer-card .portrait-wrap img { position: absolute; inset: 0; }
.composer-card .composer-body { padding: 12px; gap: 6px; }
.composer-card .composer-body h3 { color: var(--history-ink); }
.composer-card .composer-hook { color: #46586c; }
.composer-card .composer-actions button { min-height: 38px; }

.composer-page {
  grid-template-columns: minmax(300px, .9fr) minmax(0, 1.2fr);
  grid-template-areas: "toolbar toolbar" "profile details" "activities activities";
  align-items: stretch;
}

.composer-toolbar { grid-area: toolbar; }
.composer-hero-card {
  grid-area: profile;
  grid-template-columns: minmax(128px, 39%) minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 1.4vw, 23px);
  padding: clamp(14px, 1.5vw, 25px);
  border-radius: 15px;
  background: #f1eee7;
  box-shadow: none;
}

.composer-hero-card::before { width: 4px; background: #bc985d; }
.composer-hero-portrait { grid-row: 1; grid-column: 1; border: 0; padding: 0; background: transparent; }
.composer-hero-portrait .profile-image { background: #e4ddd1; border-color: #d6c9b8; }
.composer-hero-portrait .profile-image img { aspect-ratio: 4 / 5; max-height: 46vh; object-fit: contain; object-position: center; }
.composer-hero-copy { padding: 0; }
.composer-hero-copy h1 { font-size: clamp(28px, 2.5vw, 44px); color: var(--history-ink); overflow-wrap: anywhere; }
.composer-hero-hook { margin-top: 9px; font-size: clamp(14px, 1.1vw, 17px); }
.composer-details-grid { grid-area: details; grid-template-columns: 1fr; gap: 10px; }
.learn-panel, .listening-panel, .activity-final { padding: clamp(12px, 1.2vw, 20px); border-radius: 13px; box-shadow: none; }
.goal-grid { gap: 6px; }
.goal-item p { font-size: 14px; }
.listening-grid { grid-template-columns: 1fr; gap: 6px; }
.listening-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: baseline; gap: 10px; padding: 9px 11px; }
.listening-card h3 { margin: 0; }
.listening-card p { font-size: 13px; color: #48586c; }
.activity-final { grid-area: activities; }
.activity-choice { min-height: 66px; padding-block: 9px; }
.activity-choice.escape-choice {
  border-color: #bca37a;
  background: #f4ecdc;
  color: #60451e;
}
.activity-choice.escape-choice::before { background: #9c7137; }

.story-shell { max-width: none; }
.story-top { margin-bottom: 9px; padding-block: 8px; }
.rich-story-card {
  grid-template-columns: minmax(250px, 36%) minmax(0, 1fr);
  align-items: start;
  gap: clamp(14px, 1.7vw, 29px);
  min-height: 0;
  padding: clamp(14px, 1.6vw, 26px);
  background: var(--history-paper);
}
.story-image img { aspect-ratio: 4 / 3; max-height: 52vh; object-position: center 28%; }
.story-content h1 { color: var(--history-ink); }
.scene-text { max-width: 79ch; }
.story-shell .story-actions { margin-top: 7px; }
.score-host { --history-score-compact: 1; min-height: 0; }

@media (min-width: 1280px) {
  .composer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1580px) {
  .composer-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-height: 760px) {
  .history-module-page .panel { padding: 14px; }
  .panel-home { gap: 10px; }
  .hero-history { gap: 14px; }
  .hero-copy h1 { margin-block: 5px; font-size: clamp(28px, 2.65vw, 38px); }
  .hero-copy p { max-width: none; font-size: 13px; line-height: 1.4; }
  .home-mode-switch button { padding: 6px 8px; }
  .how-it-works { padding-block: 6px; }
  .how-it-works strong { width: 16px; height: 16px; }
  .period-card { grid-template-columns: 34% minmax(0, 1fr); min-height: 176px; }
  .period-card::after { left: 34%; }
  .period-card-body { padding: 8px 11px; }
  .period-dot { width: 21px; height: 21px; }
  .period-card h2 { margin-top: 5px; }
  .period-card .tag { margin-top: 4px; padding-block: 3px; }
  .period-card p { margin-block: 5px; }
  .period-card .chip { padding: 2px 6px; }
}

@media (min-width: 1200px) and (max-height: 760px) {
  .hero-copy {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 11px;
  }
  .hero-copy .home-mode-switch { grid-area: 1 / 2; }
  .hero-copy h1 { margin: 0; }
  .hero-copy p { grid-column: 1 / -1; }
}

/* Escape */
body.history-module-page.notalyr-ui:has(.escape-shell) {
  /* La charte commune applique un fond !important aux modules. */
  background: radial-gradient(ellipse at 50% 8%, #364354, #121d2c 77%) fixed !important;
}

.escape-shell {
  --archive-gold: #f0ce8c;
  --archive-border: #344355;
  display: grid;
  grid-template-columns: minmax(315px, .76fr) minmax(0, 1.24fr);
  grid-template-rows: 1fr auto auto;
  grid-template-areas: "archive puzzle" "locks puzzle" "actions actions";
  gap: 12px;
  min-height: min(710px, calc(100dvh - 100px));
  max-width: 1510px;
  padding: clamp(12px, 1.2vw, 20px);
  border-radius: 20px;
  background: #101a29;
  box-shadow: 0 16px 36px #182b462b;
}

.escape-header, .victory {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--archive-border);
  background: #202c39;
  color: #fff6e6;
}

.archive-art[hidden] {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: block !important;
  pointer-events: none;
}

.archive-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.archive-art::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(160deg, #101a29ed 4%, #192431a8 52%, #101a29f5 92%);
}

.escape-header {
  grid-area: archive;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: clamp(16px, 2vw, 30px);
  border-radius: 14px;
  text-align: left;
}

#app .escape-header .eyebrow { background: #101a29ee; color: var(--archive-gold); border-color: #8d744b; }
.escape-header h1 { margin: 0; color: #fff6e6; font-size: clamp(29px, 2.7vw, 48px); }
.escape-header p { margin: 0; max-width: 44ch; color: #f0e8dd; font-size: clamp(12px, .9vw, 14px); }
.escape-header .recap-row { justify-content: flex-start; margin: 0; }
.escape-shell .chip { border-color: #89775a; background: #101a29ed; color: #f5e7d1; }
.escape-shell .chip .glossary-term { color: #f6d79e; border-color: #c7a773; }

.locks {
  grid-area: locks;
  gap: clamp(4px, .55vw, 9px);
  margin: 0;
}

.lock, .lock.open, .lock.current {
  flex-direction: column;
  gap: 4px;
  height: 58px;
  border-color: #415065;
  border-radius: 9px;
  background: #202d3e;
  color: #d6dfeb;
  box-shadow: none;
  font-size: clamp(9px, .7vw, 12px);
}

.lock.open, .lock.current.unlocked { background: #18372f; border-color: #537e6d; color: #b8e6cf; }
.lock.current { background: #3d3124; border-color: #be995c; color: #ffe1a6; }

.escape-shell .puzzle:not(.victory) {
  grid-area: puzzle;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: clamp(15px, 2vw, 32px);
  border: 1px solid #dbc9ab;
  border-radius: 14px;
  background: #fbf8f1;
}

.escape-shell .puzzle:not(.victory)::before { height: 3px; background: #b68b4e; }
.puzzle-number { margin: 0; font-size: 12px; color: #785221; }
.puzzle h2 { margin-block: 8px 14px; font-size: clamp(23px, 2.2vw, 36px); color: #23344a; }
.escape-shell .choices { gap: 7px; }
.escape-shell .answer { min-height: 46px; border-radius: 8px; }
.escape-shell .answer:not(.correct, .wrong) { border-color: #ddd3c3; }
.escape-shell .answer:disabled { cursor: default; transform: none; }
.escape-shell .feedback { margin-top: 9px; border-radius: 8px; }
.escape-shell .escape-music { margin: 0 0 11px; }
.escape-shell > .story-actions { grid-area: actions; margin: 0; padding: 0; }
.escape-shell > .story-actions .secondary,
.escape-shell .victory .secondary,
.escape-shell .victory .escape-btn {
  min-height: 42px;
  border-color: #566478;
  background: #202d3e;
  color: #f3efe6;
}
.escape-shell > .story-actions .secondary:hover,
.escape-shell .victory .secondary:hover,
.escape-shell .victory .escape-btn:hover { border-color: #c7a773; }

/* Le coffre est décoratif. Les serrures et les réponses portent l’état du jeu. */
.archive-chest[hidden] {
  position: relative;
  display: block !important;
  flex: none;
  align-self: center;
  width: clamp(138px, 13vw, 221px);
  aspect-ratio: 2 / 1;
  margin: auto 0;
  isolation: isolate;
  filter: drop-shadow(0 14px 13px #03060bac);
}

.chest-lid, .chest-base {
  position: absolute;
  inset-inline: 0;
  border: 2px solid;
  box-shadow: inset 0 0 12px #22140f;
}

.chest-lid {
  z-index: 1;
  top: 0;
  height: 46%;
  border-bottom-width: 4px;
  transform-origin: 25% 100%;
}

.chest-base { bottom: 0; height: 56%; border-radius: 4px 4px 10px 10px; }
.chest-latch {
  position: absolute;
  z-index: 2;
  inset: -8% 41% auto;
  height: 58%;
  border: 1px solid;
  border-radius: 5px 5px 9px 9px;
}

.chest-latch::after {
  position: absolute;
  inset: 33% 38% 23%;
  content: "";
  border-radius: 50% 50% 20% 20%;
  background: #241a14;
}

.chest-glow {
  position: absolute;
  inset: -110% -33% 37%;
  background: radial-gradient(ellipse at 50% 85%, #fff2bc 0%, #f8bc59a6 25%, transparent 67%);
  opacity: 0;
  pointer-events: none;
}

.escape-complete {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto;
  grid-template-areas: none;
}

.victory::before { display: none; }
.victory .archive-art::after { background: radial-gradient(ellipse at 50% 39%, #30292091, #0d1726f5 72%); }
.victory .primary { border-color: #f7daa0; background: #edca87; color: #292015; }
.victory .primary:hover { background: #ffe3ad; }

@media (max-height: 740px) {
  .escape-shell:not(.escape-complete) {
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "locks puzzle" "archive puzzle" "actions actions";
  }
  .escape-header { padding: 14px; }
  .escape-shell .puzzle:not(.victory) { padding: 15px; }
  .escape-shell .answer { min-height: 42px; padding-block: 8px; }
}

@media (min-width: 1200px) and (max-height: 740px) {
  .escape-shell .puzzle:has(.escape-music) .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .escape-shell .escape-music { padding-block: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .escape-shell[data-escape-step]:not([data-escape-step="1"]) { animation: none; }
  .escape-shell .puzzle.card-animate { animation: none; }
  .escape-shell[data-escape-step] .puzzle-number { animation: archive-label .3s ease-out both; }
  .escape-shell .escape-music { animation: archive-clue .45s ease-out both; }
  .escape-shell .answer.wrong { animation: archive-resist .28s ease-out; }
  .escape-shell .lock.current { animation: archive-unlock .46s ease-out both; }
}

@keyframes archive-label { from { opacity: 0; transform: translateX(-6px); } }
@keyframes archive-clue { from { opacity: 0; transform: translateY(6px); } }
@keyframes archive-resist { 25% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
@keyframes archive-unlock { 45% { box-shadow: 0 0 0 4px #e1b67045; } }
