/* Les matériaux et les silhouettes des accessoires suivent la période de la fiche. */
.escape-shell {
  --stone: #9a9282;
  --metal: #b9a17a;
  --timber: #654938;
  --planks: repeating-linear-gradient(90deg, transparent 0 13%, #2c1d1888 14%, #f9e6bc36 15%, transparent 16%);
  --door-panel: linear-gradient(125deg, #e5d5af36, #211a1a47);
  --chest-panel: linear-gradient(145deg, #eee0b536, #241b164d);
  --door-curve: 49% 49% 0 0 / 30% 30% 0 0;
}

.escape-shell[data-era="moyen-age"] {
  --stone: #aaa095;
  --metal: #a79c82;
  --timber: #634738;
  --door-curve: 0;
  --door-shape: polygon(50% 0, 70% 10%, 85% 21%, 95% 35%, 100% 49%, 100% 100%, 0 100%, 0 49%, 5% 35%, 15% 21%, 30% 10%);
  --door-panel: repeating-linear-gradient(0deg, transparent 0 24%, #1c1c23 25% 31%, #aaa287 32% 33%, transparent 34% 56%);
  --chest-curve: 7px 7px 0 0;
  --chest-panel: repeating-linear-gradient(90deg, transparent 0 18%, #29211b6e 19%, #cead7b59 21%, transparent 23%);
}

.escape-shell[data-era="renaissance"] {
  --stone: #b7a585;
  --metal: #cbae6d;
  --timber: #664129;
  --door-curve: 2px;
  --door-crown: polygon(50% 0, 100% 78%, 100% 100%, 0 100%, 0 78%);
  --door-panel: linear-gradient(0deg, #754e2f 0 45%, #c99959 46% 48%, #624329 49% 100%);
  --chest-curve: 4px 4px 0 0;
  --chest-panel: repeating-conic-gradient(from 45deg, #a96c3f 0 25%, #66422c 0 50%) center / 12px 12px;
}

.escape-shell[data-era="baroque"] {
  --stone: #c0a078;
  --metal: #e3ba64;
  --timber: #64332b;
  --door-panel: radial-gradient(ellipse at 50% 28%, #b477424a 0 21%, #d9ab626e 22% 26%, transparent 27%), linear-gradient(145deg, #9b573e, #412728);
  --door-panel-curve: 46% 46% 24% 24% / 24% 24% 12% 12%;
  --chest-curve: 34% 34% 0 0 / 75% 75% 0 0;
  --chest-panel: radial-gradient(ellipse, #a96839 24%, #d9a757 26% 34%, #60362c 36%);
}

.escape-shell[data-era="classicisme"] {
  --stone: #a7b0ad;
  --metal: #d1bb82;
  --timber: #3c5361;
  --door-curve: 1px;
  --door-crown: polygon(2% 22%, 98% 22%, 98% 53%, 92% 53%, 92% 100%, 8% 100%, 8% 53%, 2% 53%);
  --door-panel: repeating-linear-gradient(0deg, #354955 0 16%, #657981 18% 20%, #455e6a 22% 48%);
  --chest-curve: 3px 3px 0 0;
  --chest-panel: linear-gradient(90deg, #4c6872, #7a8d8b 48%, #4c6872);
}

.escape-shell[data-era="romantisme"] {
  --stone: #9f9097;
  --metal: #d4ae8d;
  --timber: #643b44;
  --door-curve: 48% 48% 0 0 / 18% 18% 0 0;
  --door-panel: repeating-conic-gradient(from -30deg at 50% 0, #c8a18a69 0 13deg, transparent 13deg 28deg), linear-gradient(#846d78, #4d2f3c);
  --door-panel-curve: 48% 48% 3px 3px / 22% 22% 3px 3px;
  --chest-panel: repeating-conic-gradient(from 45deg, #a56873 0 25%, #85505e 0 50%) center / 14px 14px;
}

.escape-shell[data-era="modernites"], .escape-shell[data-era="jazz"] {
  --stone: #a69066;
  --metal: #e0bf80;
  --timber: #303b50;
  --planks: linear-gradient(110deg, #ffdc8825, #0a142e52);
  --door-curve: 0;
  --door-crown: polygon(6% 100%, 6% 60%, 18% 60%, 18% 35%, 33% 35%, 33% 0, 67% 0, 67% 35%, 82% 35%, 82% 60%, 94% 60%, 94% 100%);
  --door-panel: repeating-conic-gradient(from -29deg at 50% 105%, #ceb4749e 0 5deg, #2b3449 6deg 14deg);
  --chest-curve: 0;
  --chest-panel: repeating-linear-gradient(135deg, #40394d 0 8px, #b99c6f 9px 10px, #40394d 11px 16px);
}

.escape-shell[data-era="jazz"] {
  --stone: #ac795b;
  --timber: #553143;
  --door-panel: repeating-linear-gradient(90deg, #823f42 0 12%, #ddac68 13% 16%, #542f40 17% 26%);
}

.escape-shell[data-era="interpretes"] {
  --stone: #9c8683;
  --metal: #c29a83;
  --timber: #4e343b;
  --door-curve: 2px;
  --door-panel: repeating-linear-gradient(90deg, #553343 0 11%, #985762 13% 16%, #583347 18%);
  --chest-panel: repeating-linear-gradient(0deg, #6c454e 0 6px, #a77d7d 7px 8px, #6c454e 9px 12px);
}

.escape-shell[data-era="trad"] {
  --stone: #a3926d;
  --metal: #a9a58b;
  --timber: #536148;
  --door-curve: 3px;
  --door-crown: polygon(50% 2%, 100% 78%, 94% 100%, 50% 36%, 6% 100%, 0 78%);
  --door-panel: linear-gradient(42deg, transparent 44%, #aba176 45% 53%, transparent 54%), linear-gradient(-42deg, transparent 44%, #aba176 45% 53%, transparent 54%), #455442;
  --chest-curve: 3px 3px 0 0;
  --chest-panel: repeating-linear-gradient(0deg, #556349 0 7px, #72795c 8px 9px, #556349 10px 14px);
}

.archive-door {
  position: relative;
  isolation: isolate;
  width: 105px;
  aspect-ratio: .86;
  margin-inline: auto;
  filter: drop-shadow(0 8px 9px #13102172);
}

.door-surround {
  position: absolute;
  inset: 10% 5% 3%;
  border: 2px solid var(--metal);
  border-radius: var(--door-curve);
  clip-path: var(--door-shape, none);
  background:
    repeating-linear-gradient(0deg, #2b22273b 0 1px, transparent 2px 10px),
    linear-gradient(110deg, var(--stone), color-mix(in srgb, var(--stone) 58%, #332b2c));
  box-shadow: inset 0 0 0 3px #30231d55, inset 0 0 0 6px #fff5da37;
}

.door-crown {
  position: absolute;
  z-index: 1;
  inset: 0 0 auto;
  height: 17%;
  clip-path: var(--door-crown, inset(100%));
  background: linear-gradient(180deg, var(--metal) 0 68%, #f9ead3 70% 79%, var(--stone) 80% 88%, var(--metal) 89%);
}

.door-opening {
  position: absolute;
  inset: 7% 10% 0;
  isolation: isolate;
  overflow: hidden;
  perspective: 360px;
  border: 2px solid color-mix(in srgb, var(--metal) 60%, #291c1a);
  border-radius: inherit;
  clip-path: var(--door-shape, none);
  background: #241915;
}

.door-opening::before {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, #ffd287 0 2%, #a87241 3% 5%, #ffde9c 6% 9%, #c99457 10% 12%, transparent 13%),
    radial-gradient(ellipse at 50% 74%, #fff6d4 5%, #f3ca7a 40%, #805040 78%, #322029);
  opacity: 0;
  content: "";
}

.door-leaf {
  position: absolute;
  inset-block: 0;
  width: 50.5%;
  border: 1px solid #281d1b;
  backface-visibility: hidden;
  background: var(--planks), linear-gradient(100deg, var(--timber), color-mix(in srgb, var(--timber) 74%, black));
  box-shadow: inset 0 0 0 1px #fff3cb35, inset 0 0 12px #20141175;
}

.door-left { left: 0; transform-origin: left; --door-swing: 76deg; }
.door-right { right: 0; transform-origin: right; --door-swing: -76deg; }
.door-leaf::before {
  position: absolute;
  inset: 25% 13% 11%;
  border: 1px solid var(--metal);
  border-radius: var(--door-panel-curve, 2px);
  background: var(--door-panel);
  box-shadow: inset 0 0 0 2px #2b201e75, 0 0 0 1px #211613a1;
  content: "";
}
.door-leaf::after {
  position: absolute;
  top: 58%;
  right: 8%;
  width: 12%;
  height: 8%;
  border: 1px solid var(--metal);
  border-radius: 60% 60% 44% 44%;
  background: linear-gradient(135deg, var(--metal), #63451f);
  content: "";
}
.door-right::after { right: auto; left: 8%; }

.door-threshold {
  position: absolute;
  z-index: -1;
  inset: auto -7% -9%;
  height: 32%;
  transform: perspective(100px) rotateX(34deg);
  background: radial-gradient(ellipse at 50% 12%, #ffeac8b5, #e7a95c4d 42%, transparent 72%);
  opacity: 0;
}

.door-open .door-leaf { transform: rotateY(var(--door-swing)); }
.door-open .door-opening::before, .door-open .door-threshold { opacity: 1; }
.archive-stage[hidden]:has(.archive-door) { display: grid !important; place-items: center; margin-block: 7px; }
.treasure-stage .archive-door { margin-bottom: 8px; width: 120px; }
.archive-door .archive-key { display: none; }

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .archive-stage[hidden]:has(.archive-door) { margin: 0; padding: 0 0 7px; }
  .archive-door { width: clamp(125px, 13vw, 214px); }
  .door-surround, .door-opening { border-width: 3px; }
  .door-leaf::before { border-width: 2px; }
  .archive-door .archive-key { display: block; top: 55%; left: 21%; transform-origin: right center; }
  .archive-door .joined-key { top: 10%; left: auto; right: -19%; transform: rotate(-25deg) scale(1.22); }
  .archive-door .door-key { opacity: 0; }
  .treasure-stage .archive-door { width: clamp(164px, 16vw, 251px); margin-bottom: 15px; }

  .chest-lid, .chest-base {
    border-color: var(--metal);
    background:
      radial-gradient(circle, var(--metal) 0 1px, #251e1b 2px, transparent 3px) left center / 10% 13px repeat-y,
      radial-gradient(circle, var(--metal) 0 1px, #251e1b 2px, transparent 3px) right center / 10% 13px repeat-y,
      var(--planks),
      linear-gradient(145deg, var(--timber), color-mix(in srgb, var(--timber) 68%, #1c1718));
  }
  .chest-lid { border-radius: var(--chest-curve, 25% 25% 3px 3px / 65% 65% 3px 3px); }
  .chest-lid::before, .chest-base::before {
    position: absolute;
    inset: 15% 12%;
    border: 1px solid var(--metal);
    border-radius: inherit;
    background: var(--chest-panel);
    box-shadow: inset 0 0 5px #2a1a1a66;
    content: "";
  }
  .chest-latch {
    border-color: var(--metal);
    background: linear-gradient(125deg, var(--metal), #76552e);
  }
  .archive-chest[data-chest="2"] { --metal: color-mix(in srgb, var(--quest-brass) 65%, #b5c3c7); }
  .archive-chest[data-chest="3"] { --metal: color-mix(in srgb, var(--quest-brass) 56%, #b96b4d); }
  .archive-chest[data-chest="4"] { --metal: color-mix(in srgb, var(--quest-brass) 84%, #f3e4bd); }
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) and (max-height: 740px) {
  .archive-stage .archive-door { width: clamp(120px, 11vw, 157px); }
  .treasure-stage .archive-door { width: clamp(155px, 14vw, 205px); }
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .door-open .door-key { animation: quest-key-turn .65s ease-in-out both; }
  .door-open .door-leaf { animation: quest-door-swing .85s .44s cubic-bezier(.25,.6,.3,1) both; }
  .door-open .door-right { animation-delay: .52s; }
  .door-open .door-opening::before, .door-open .door-threshold { animation: quest-door-light 1s .48s ease-out both; }
}

@keyframes quest-door-swing { from { transform: none; } }
@keyframes quest-door-light { from { opacity: 0; } }
