/* Terrae Caravelli — Living Map. An abstract patrimonial network, never a geographic map. */

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(ellipse at 43% 47%, #111510 0%, #0c100d 54%, #080907 100%);
}

body {
  overflow: hidden;
  color: var(--tc-craie, #e8e3d8);
  font-family: var(--cv-typo-current-ff, var(--tc-font-ui, Arial, sans-serif));
  font-synthesis: var(--cv-typo-synthesis, none);
}

.terrae-map,
.terrae-map * {
  box-sizing: border-box;
}

.terrae-map {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 420px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 43% 47%, #111510 0%, #0c100d 54%, #080907 100%);
}

.terrae-map__canvas,
.terrae-map__fallback,
.terrae-map__museum-light,
.terrae-map__vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.terrae-map__canvas {
  z-index: 1;
  display: block;
  opacity: 0;
  transition: opacity 1200ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1));
}

.terrae-map--webgl .terrae-map__canvas {
  opacity: 1;
}

.terrae-map__fallback {
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  background: #0c100d;
}

.terrae-map__fallback-material {
  position: absolute;
  inset: -4%;
  background-color: var(--tc-terra-ombra, #2b211a);
  background-image:
    linear-gradient(112deg, rgba(8, 9, 7, .74) 4%, rgba(43, 33, 26, .48) 44%, rgba(142, 116, 88, .09) 58%, rgba(8, 9, 7, .78) 94%),
    url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Brume_1800.jpg"),
    url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Terre_1800.jpg");
  background-position: center;
  background-size: cover;
  background-blend-mode: multiply, soft-light, normal;
  filter: contrast(1.12) saturate(.54) brightness(.55);
  transform: scale(1.035);
}

.terrae-map__fallback-lines {
  position: absolute;
  inset: -10% -7%;
  width: 114%;
  height: 120%;
  object-fit: cover;
  opacity: 0;
  mix-blend-mode: screen;
}

.terrae-map__fallback-lines--bronze {
  filter: brightness(.76) saturate(.72);
  transform: scale(1.035) translate3d(-1.2%, .8%, 0);
}

.terrae-map__fallback-lines--craie {
  opacity: 0;
  filter: brightness(.54) saturate(.5);
  mix-blend-mode: soft-light;
  transform: scale(1.075) translate3d(2.2%, -1.4%, 0);
}

.no-js .terrae-map__fallback,
.terrae-map--fallback .terrae-map__fallback {
  opacity: 1;
}

.no-js .terrae-map__fallback-material,
.terrae-map--fallback.terrae-map--running .terrae-map__fallback-material {
  animation: terraeMapMatter 10s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) both;
}

.no-js .terrae-map__fallback-lines--bronze,
.terrae-map--fallback.terrae-map--running .terrae-map__fallback-lines--bronze {
  animation: terraeMapBronze 13s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 1.8s both;
}

.no-js .terrae-map__fallback-lines--craie,
.terrae-map--fallback.terrae-map--running .terrae-map__fallback-lines--craie {
  animation: terraeMapCraie 13s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 4.8s both;
}

.terrae-map__museum-light {
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(108deg,
      transparent 15%,
      rgba(232, 227, 216, .016) 31%,
      rgba(142, 116, 88, .13) 49%,
      rgba(232, 227, 216, .04) 58%,
      transparent 76%);
  mix-blend-mode: screen;
  transform: translate3d(-28%, 0, 0);
}

.terrae-map--running .terrae-map__museum-light,
.no-js .terrae-map__museum-light {
  animation: terraeMapMuseumLight 18s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 1s both;
}

.terrae-map__vignette {
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 49%, transparent 18%, rgba(8, 9, 7, .12) 59%, rgba(8, 9, 7, .8) 100%),
    linear-gradient(180deg, rgba(8, 9, 7, .44), transparent 23%, transparent 72%, rgba(8, 9, 7, .68));
}

.terrae-map__header {
  position: absolute;
  z-index: 7;
  top: max(28px, env(safe-area-inset-top));
  right: max(30px, env(safe-area-inset-right));
  left: max(30px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(232, 227, 216, .15);
  opacity: 0;
  transform: translateY(-6px);
}

.terrae-map--running .terrae-map__header,
.no-js .terrae-map__header {
  animation: terraeMapInterface 1200ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 500ms both;
}

.terrae-map__kicker,
.terrae-map__index {
  margin: 0;
  color: rgba(232, 227, 216, .7);
  font-size: var(--cv-typo-current-fs, 10px);
  font-weight: var(--cv-typo-current-fw, 500);
  line-height: var(--cv-typo-current-lh, 1);
  letter-spacing: var(--cv-typo-current-ls, .31em);
  text-transform: var(--cv-typo-current-tt, uppercase);
}

.terrae-map__index {
  color: rgba(142, 116, 88, .84);
  font-size: var(--cv-typo-current-fs, 9px);
  letter-spacing: var(--cv-typo-current-ls, .25em);
}

.terrae-map__seal {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  pointer-events: none;
}

.terrae-map__monogram {
  width: clamp(128px, 15vw, 220px);
  height: auto;
  opacity: 0;
  filter:
    saturate(.76)
    drop-shadow(0 1px 0 rgba(232, 227, 216, .1))
    drop-shadow(0 18px 42px rgba(8, 9, 7, .55));
  transform: scale(.985);
}

.terrae-map--running .terrae-map__monogram,
.no-js .terrae-map__monogram {
  animation: terraeMapSeal 5600ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 9400ms both;
}

.terrae-map__caption {
  position: absolute;
  right: max(30px, env(safe-area-inset-right));
  bottom: max(42px, calc(env(safe-area-inset-bottom) + 26px));
  left: max(30px, env(safe-area-inset-left));
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
}

.terrae-map--running .terrae-map__caption,
.no-js .terrae-map__caption {
  animation: terraeMapCaption 1800ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 12800ms both;
}

.terrae-map__caption h1 {
  margin: 0;
  color: rgba(232, 227, 216, .84);
  font-family: var(--cv-typo-current-ff, var(--tc-font-editorial, Georgia, serif));
  font-size: var(--cv-typo-current-fs, clamp(19px, 2vw, 29px));
  font-style: var(--cv-typo-current-fst, normal);
  font-weight: var(--cv-typo-current-fw, 400);
  line-height: var(--cv-typo-current-lh, 1.24);
  letter-spacing: var(--cv-typo-current-ls, .025em);
  text-shadow: 0 1px 0 rgba(43, 33, 26, .5), 0 8px 28px rgba(8, 9, 7, .65);
}

.terrae-map__caption p {
  margin: 11px 0 0;
  color: rgba(142, 116, 88, .84);
  font-size: var(--cv-typo-current-fs, 9px);
  font-weight: var(--cv-typo-current-fw, 500);
  line-height: var(--cv-typo-current-lh, 1.4);
  letter-spacing: var(--cv-typo-current-ls, .33em);
  text-transform: var(--cv-typo-current-tt, uppercase);
}

.terrae-map__legend {
  position: absolute;
  z-index: 7;
  bottom: max(35px, calc(env(safe-area-inset-bottom) + 21px));
  left: max(30px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(232, 227, 216, .42);
  font-size: var(--cv-typo-current-fs, 8px);
  letter-spacing: var(--cv-typo-current-ls, .22em);
  opacity: 0;
}

.terrae-map__legend i {
  width: 26px;
  height: 1px;
  background: rgba(142, 116, 88, .38);
}

.terrae-map--running .terrae-map__legend,
.no-js .terrae-map__legend {
  animation: terraeMapInterface 1400ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 5200ms both;
}

@keyframes terraeMapMatter {
  from { opacity: .16; filter: contrast(1.15) saturate(.44) brightness(.2); transform: scale(1.035); }
  to { opacity: 1; filter: contrast(1.12) saturate(.54) brightness(.55); transform: scale(1); }
}

@keyframes terraeMapBronze {
  from { opacity: 0; transform: scale(1.035) translate3d(-1.2%, .8%, 0); }
  to { opacity: .3; transform: scale(1.008) translate3d(0, 0, 0); }
}

@keyframes terraeMapCraie {
  from { opacity: 0; transform: scale(1.075) translate3d(2.2%, -1.4%, 0); }
  to { opacity: .11; transform: scale(1.045) translate3d(0, 0, 0); }
}

@keyframes terraeMapMuseumLight {
  0% { opacity: 0; transform: translate3d(-28%, 0, 0); }
  31% { opacity: .5; }
  72% { opacity: .27; }
  100% { opacity: .18; transform: translate3d(27%, 0, 0); }
}

@keyframes terraeMapInterface {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes terraeMapSeal {
  0% { opacity: 0; transform: scale(.985); }
  65% { opacity: .55; }
  100% { opacity: .72; transform: scale(1); }
}

@keyframes terraeMapCaption {
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  .terrae-map__header {
    top: max(22px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    left: max(20px, env(safe-area-inset-left));
    padding-bottom: 12px;
  }

  .terrae-map__kicker {
    font-size: var(--cv-typo-current-fs, 9px);
    letter-spacing: var(--cv-typo-current-ls, .27em);
  }

  .terrae-map__index {
    max-width: 118px;
    font-size: var(--cv-typo-current-fs, 8px);
    line-height: var(--cv-typo-current-lh, 1.35);
    text-align: right;
  }

  .terrae-map__monogram {
    width: min(37vw, 166px);
  }

  .terrae-map__caption {
    right: max(20px, env(safe-area-inset-right));
    bottom: max(83px, calc(env(safe-area-inset-bottom) + 67px));
    left: max(20px, env(safe-area-inset-left));
  }

  .terrae-map__caption h1 {
    max-width: 330px;
    margin-inline: auto;
    font-size: var(--cv-typo-current-fs, clamp(19px, 5.7vw, 24px));
  }

  .terrae-map__legend {
    bottom: max(27px, calc(env(safe-area-inset-bottom) + 14px));
    left: 50%;
    width: calc(100% - 40px);
    justify-content: center;
    gap: 7px;
    font-size: var(--cv-typo-current-fs, 7px);
    transform: translateX(-50%);
  }

  .terrae-map__legend i {
    width: 14px;
  }

  .terrae-map--running .terrae-map__legend,
  .no-js .terrae-map__legend {
    animation-name: terraeMapLegendMobile;
  }
}

@keyframes terraeMapLegendMobile {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .terrae-map *,
  .terrae-map *::before,
  .terrae-map *::after {
    animation-duration: 200ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 200ms !important;
    scroll-behavior: auto !important;
  }

  .terrae-map__fallback,
  .terrae-map__fallback-material,
  .terrae-map__fallback-lines--bronze,
  .terrae-map__header,
  .terrae-map__monogram,
  .terrae-map__caption,
  .terrae-map__legend {
    opacity: 1;
  }

  .terrae-map__fallback-lines--bronze {
    opacity: .3;
  }

  .terrae-map__fallback-lines--craie {
    opacity: .11;
  }

  .terrae-map__header,
  .terrae-map__monogram,
  .terrae-map__caption {
    transform: none;
  }

  .terrae-map__museum-light {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   ÉLÉVATION DU 19/09/2026 — « Les strates » : le relevé se trace sur le vrai relief.
   Le tableau est rendu par le moteur commun (terrae-matiere.js) : le même terrain que « La terre », réellement éclairé.
   La page lui laisse la place : les lumières peintes en CSS ne doublent plus celle du moteur ; le grand monogramme
   est réservé à la finale du récit ; la phrase, que le récit coupait avant son apparition, arrive à temps,
   dans la fonte réellement chargée par Terrae, posée à gauche dans la réserve calme du cadre.
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

.terrae-map--webgl .terrae-map__museum-light,
.terrae-map--webgl .terrae-luxury9-light--map { display: none; }

.terrae-map--webgl .terrae-map__monogram,
.terrae-map--webgl .terrae-map__seal::before,
.terrae-map--webgl .terrae-map__seal::after { display: none; }

.terrae-map--webgl .terrae-map__vignette {
  background: radial-gradient(ellipse 66% 46% at 10% 92%, rgba(8, 9, 7, .62), transparent 72%), linear-gradient(180deg, rgba(8, 9, 7, .44), transparent 16%, transparent 56%, rgba(8, 9, 7, .66));
}

.terrae-map--webgl .terrae-map__caption {
  top: auto;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 48px));
  right: auto;
  left: max(30px, env(safe-area-inset-left));
  width: min(680px, 46vw);
  text-align: left;
}

.terrae-map--webgl .terrae-map__caption { --terrae-phrase: 6000ms; }
/* Dans le récit : la matière d'abord, la phrase ensuite, tenue jusqu'au raccord. */
.terrae-map--webgl.terrae-map--story .terrae-map__caption { --terrae-phrase: 2600ms; }
.terrae-map--webgl.terrae-map--running .terrae-map__caption { animation-delay: var(--terrae-phrase); animation-duration: 900ms; }
.terrae-map--story.terrae-map--running .terrae-map__header { animation-delay: 300ms; }

.terrae-map--webgl .terrae-map__caption h1 {
  font-family: var(--cv-typo-current-ff, "Cormorant Garamond", var(--tc-font-editorial, Georgia, serif));
  font-size: var(--cv-typo-current-fs, clamp(30px, 3.5vw, 56px));
  line-height: var(--cv-typo-current-lh, 1.1);
  letter-spacing: var(--cv-typo-current-ls, .012em);
  color: rgba(244, 240, 232, .94);
  text-shadow: 0 10px 38px rgba(8, 9, 7, .62);
  word-break: normal;
  overflow-wrap: normal;
  -webkit-hyphens: none;
  hyphens: none;
  text-wrap: balance;
}

.terrae-map--webgl .terrae-map__caption p {
  display: inline-block;
  margin-top: clamp(16px, 2.2vh, 26px);
  padding-top: clamp(14px, 1.9vh, 22px);
  color: rgba(200, 178, 146, .92);
  letter-spacing: var(--cv-typo-current-ls, .34em);
  word-break: normal;
  overflow-wrap: normal;
  -webkit-hyphens: none;
  hyphens: none;
}

/* La phrase se révèle comme un titre de film : les lettres se mettent au point, le filet d'or se trace, la ligne basse suit. */
.terrae-map--webgl.terrae-map--running .terrae-map__caption h1 { animation: terraeMapTitre 2600ms cubic-bezier(.16, .7, .2, 1) var(--terrae-phrase, 0ms) both; }
.terrae-map--webgl .terrae-map__caption p { position: relative; border-top: 0; }
.terrae-map--webgl .terrae-map__caption p::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 1px; background: linear-gradient(90deg, rgba(200, 178, 146, .85), rgba(142, 116, 88, .35)); transform-origin: 0 50%; }
.terrae-map--webgl.terrae-map--running .terrae-map__caption p::before { animation: terraeMapFilet 1800ms cubic-bezier(.3, .6, .2, 1) calc(var(--terrae-phrase, 0ms) + 700ms) both; }
.terrae-map--webgl.terrae-map--running .terrae-map__caption p { animation: terraeMapBasse 1600ms ease-out calc(var(--terrae-phrase, 0ms) + 1300ms) both; }

@keyframes terraeMapTitre {
  from { opacity: 0; filter: blur(9px); transform: translateY(6px); }
  55% { opacity: 1; }
  to { opacity: 1; filter: blur(0); transform: translateY(0); }   /* ni interlettrage ni largeur animés : la phrase ne se recompose jamais */
}
@keyframes terraeMapFilet { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes terraeMapBasse { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .terrae-map--webgl.terrae-map--running .terrae-map__caption h1,
  .terrae-map--webgl.terrae-map--running .terrae-map__caption p,
  .terrae-map--webgl.terrae-map--running .terrae-map__caption p::before { animation: none; }
}

@media (max-width: 700px) {
  .terrae-map--webgl .terrae-map__caption {
    top: auto;
    bottom: max(104px, calc(env(safe-area-inset-bottom) + 88px));
    left: max(20px, env(safe-area-inset-left));
    width: min(76vw, 320px);
  }

  .terrae-map--webgl .terrae-map__caption h1 { max-width: none; margin-inline: 0; font-size: var(--cv-typo-current-fs, clamp(25px, 7.1vw, 34px)); line-height: var(--cv-typo-current-lh, 1.12); }
  .terrae-map--webgl .terrae-map__caption p { letter-spacing: var(--cv-typo-current-ls, .26em); }
}

@media (max-height: 520px) {
  .terrae-map--webgl .terrae-map__caption { width: min(56vw, 440px); }
  .terrae-map--webgl .terrae-map__caption h1 { font-size: var(--cv-typo-current-fs, clamp(21px, 3.3vw, 30px)); }
}

/* Téléphone couché (arbitrage du 19/09) : dans le récit, le plancher de 420 px de la scène coupait le bas de la matière sous un écran de 390 px ; il est levé. */
@media (max-height: 480px) and (min-aspect-ratio: 1/1) {
  body[data-terrae-production] .terrae-map { min-height: 0; }
}

/* Le secours CSS ne charge ses textures que s'il sert : sans script, sans WebGL2, ou contexte perdu (le moteur a ses propres cartes). */
.terrae-map__fallback-material { background-image: none; }

.terrae-map--fallback .terrae-map__fallback-material { background-image: linear-gradient(112deg, rgba(8, 9, 7, .74) 4%, rgba(43, 33, 26, .48) 44%, rgba(142, 116, 88, .09) 58%, rgba(8, 9, 7, .78) 94%), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Brume_1800.jpg"), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Terre_1800.jpg"); }

@media (scripting: none) {
  .terrae-map__fallback-material { background-image: linear-gradient(112deg, rgba(8, 9, 7, .74) 4%, rgba(43, 33, 26, .48) 44%, rgba(142, 116, 88, .09) 58%, rgba(8, 9, 7, .78) 94%), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Brume_1800.jpg"), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Terre_1800.jpg"); }
}
