/* Terrae Caravelli — Root Network. Abstract transmission beneath the surface. */

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(ellipse at 49% 41%, #111510 0%, #0c100d 52%, #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-root,
.terrae-root * {
  box-sizing: border-box;
}

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

.terrae-root__canvas,
.terrae-root__fallback,
.terrae-root__internal-light,
.terrae-root__vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

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

.terrae-root--webgl .terrae-root__canvas {
  opacity: 1;
}

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

.terrae-root__fallback-material {
  position: absolute;
  inset: -4%;
  background-color: var(--tc-terra-ombra, #2b211a);
  background-image:
    linear-gradient(180deg, rgba(16, 36, 29, .32) 0%, rgba(43, 33, 26, .55) 58%, rgba(8, 9, 7, .82) 100%),
    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.13) saturate(.53) brightness(.52);
  transform: scale(1.035);
}

.terrae-root__fallback-surface {
  position: absolute;
  top: -22%;
  right: -7%;
  left: -7%;
  width: 114%;
  height: 82%;
  object-fit: cover;
  opacity: 0;
  filter: brightness(.78) saturate(.7);
  mix-blend-mode: screen;
}

.terrae-root__fallback-depth {
  position: absolute;
  z-index: 1;
  top: 52%;
  right: -8%;
  bottom: -18%;
  left: -8%;
  overflow: hidden;
  opacity: 0;
  mask-image: linear-gradient(180deg, transparent 0%, #000 13%, #000 100%);
}

.terrae-root__fallback-depth img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112vh;
  height: 150vw;
  max-width: none;
  object-fit: cover;
  mix-blend-mode: screen;
  transform-origin: center;
}

.terrae-root__fallback-depth img:first-child {
  opacity: .35;
  filter: brightness(.72) saturate(.75);
  transform: translate(-50%, -50%) rotate(89deg) scale(.76, 1.12);
}

.terrae-root__fallback-depth img:last-child {
  opacity: .1;
  filter: brightness(.52) saturate(.42);
  transform: translate(-50%, -50%) rotate(94deg) scale(.84, 1.05);
}

.no-js .terrae-root__fallback,
.terrae-root--fallback .terrae-root__fallback {
  opacity: 1;
}

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

.no-js .terrae-root__fallback-surface,
.terrae-root--fallback.terrae-root--running .terrae-root__fallback-surface {
  animation: terraeRootSurface 12s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 800ms both;
}

.no-js .terrae-root__fallback-depth,
.terrae-root--fallback.terrae-root--running .terrae-root__fallback-depth {
  animation: terraeRootDepth 14s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 4s both;
}

.terrae-root__internal-light {
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at 50% 58%, rgba(142, 116, 88, .12), transparent 18%),
    linear-gradient(180deg, transparent 42%, rgba(142, 116, 88, .055) 59%, transparent 86%);
  mix-blend-mode: screen;
}

.terrae-root--running .terrae-root__internal-light,
.no-js .terrae-root__internal-light {
  animation: terraeRootInternalLight 16s var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 5.2s both;
}

.terrae-root__vignette {
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 17%, rgba(8, 9, 7, .14) 60%, rgba(8, 9, 7, .82) 100%),
    linear-gradient(180deg, rgba(8, 9, 7, .42), transparent 22%, transparent 69%, rgba(8, 9, 7, .72));
}

.terrae-root__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-root--running .terrae-root__header,
.no-js .terrae-root__header {
  animation: terraeRootInterface 1200ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 500ms both;
}

.terrae-root__kicker,
.terrae-root__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-root__index {
  color: rgba(142, 116, 88, .84);
  font-size: var(--cv-typo-current-fs, 9px);
  letter-spacing: var(--cv-typo-current-ls, .25em);
}

.terrae-root__depth-scale {
  position: absolute;
  z-index: 7;
  top: 24%;
  bottom: 17%;
  left: max(30px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  color: rgba(232, 227, 216, .4);
  font-size: var(--cv-typo-current-fs, 7px);
  letter-spacing: var(--cv-typo-current-ls, .22em);
  opacity: 0;
  writing-mode: vertical-rl;
}

.terrae-root__depth-scale i {
  width: 1px;
  min-height: 34px;
  flex: 1;
  background: linear-gradient(180deg, rgba(142, 116, 88, .12), rgba(142, 116, 88, .55), rgba(142, 116, 88, .12));
}

.terrae-root--running .terrae-root__depth-scale,
.no-js .terrae-root__depth-scale {
  animation: terraeRootInterface 1400ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 4400ms both;
}

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

.terrae-root__monogram {
  width: clamp(132px, 15vw, 220px);
  height: auto;
  opacity: 0;
  filter:
    saturate(.78)
    drop-shadow(0 1px 0 rgba(232, 227, 216, .08))
    drop-shadow(0 18px 44px rgba(8, 9, 7, .58));
  transform: scale(.985);
}

.terrae-root--running .terrae-root__monogram,
.no-js .terrae-root__monogram {
  animation: terraeRootSeal 5800ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 13200ms both;
}

.terrae-root__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-root--running .terrae-root__caption,
.no-js .terrae-root__caption {
  animation: terraeRootCaption 1800ms var(--tc-ease, cubic-bezier(.2, .65, .2, 1)) 15800ms both;
}

.terrae-root__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, .66);
}

.terrae-root__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);
}

@keyframes terraeRootMatter {
  from { opacity: .15; filter: contrast(1.16) saturate(.44) brightness(.18); transform: scale(1.035); }
  to { opacity: 1; filter: contrast(1.13) saturate(.53) brightness(.52); transform: scale(1); }
}

@keyframes terraeRootSurface {
  0% { opacity: 0; transform: translateY(11%); }
  40% { opacity: .29; }
  100% { opacity: .18; transform: translateY(-5%); }
}

@keyframes terraeRootDepth {
  0% { opacity: 0; clip-path: inset(0 0 100%); }
  100% { opacity: .48; clip-path: inset(0); }
}

@keyframes terraeRootInternalLight {
  0% { opacity: 0; transform: translateY(-4%); }
  60% { opacity: .48; }
  100% { opacity: .26; transform: translateY(4%); }
}

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

@keyframes terraeRootSeal {
  0% { opacity: 0; transform: scale(.985); }
  66% { opacity: .52; }
  100% { opacity: .7; transform: scale(1); }
}

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

@media (max-width: 700px) {
  .terrae-root__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-root__kicker {
    font-size: var(--cv-typo-current-fs, 9px);
    letter-spacing: var(--cv-typo-current-ls, .27em);
  }

  .terrae-root__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-root__depth-scale {
    top: 20%;
    bottom: 20%;
    left: max(15px, env(safe-area-inset-left));
    font-size: var(--cv-typo-current-fs, 6px);
  }

  .terrae-root__monogram {
    width: min(38vw, 168px);
  }

  .terrae-root__caption {
    right: max(20px, env(safe-area-inset-right));
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 54px));
    left: max(20px, env(safe-area-inset-left));
  }

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

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

  .terrae-root__fallback,
  .terrae-root__fallback-material,
  .terrae-root__fallback-surface,
  .terrae-root__fallback-depth,
  .terrae-root__header,
  .terrae-root__depth-scale,
  .terrae-root__monogram,
  .terrae-root__caption {
    opacity: 1;
  }

  .terrae-root__fallback-surface {
    opacity: .18;
  }

  .terrae-root__fallback-depth {
    opacity: .48;
    clip-path: inset(0);
  }

  .terrae-root__header,
  .terrae-root__monogram,
  .terrae-root__caption {
    transform: none;
  }

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

/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   ÉLÉVATION DU 19/09/2026 — « Les racines » : le réseau du relief pousse en or.
   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-root--webgl .terrae-root__internal-light,
.terrae-root--webgl .terrae-luxury9-light--roots { display: none; }

.terrae-root--webgl .terrae-root__monogram,
.terrae-root--webgl .terrae-root__seal::before,
.terrae-root--webgl .terrae-root__seal::after { display: none; }

.terrae-root--webgl .terrae-root__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-root--webgl .terrae-root__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-root--webgl .terrae-root__caption { --terrae-phrase: 8000ms; }
/* Dans le récit : la matière d'abord, la phrase ensuite, tenue jusqu'au raccord. */
.terrae-root--webgl.terrae-root--story .terrae-root__caption { --terrae-phrase: 3200ms; }
.terrae-root--webgl.terrae-root--running .terrae-root__caption { animation-delay: var(--terrae-phrase); animation-duration: 900ms; }
.terrae-root--story.terrae-root--running .terrae-root__header { animation-delay: 300ms; }

.terrae-root--webgl .terrae-root__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-root--webgl .terrae-root__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-root--webgl.terrae-root--running .terrae-root__caption h1 { animation: terraeRootTitre 2600ms cubic-bezier(.16, .7, .2, 1) var(--terrae-phrase, 0ms) both; }
.terrae-root--webgl .terrae-root__caption p { position: relative; border-top: 0; }
.terrae-root--webgl .terrae-root__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-root--webgl.terrae-root--running .terrae-root__caption p::before { animation: terraeRootFilet 1800ms cubic-bezier(.3, .6, .2, 1) calc(var(--terrae-phrase, 0ms) + 700ms) both; }
.terrae-root--webgl.terrae-root--running .terrae-root__caption p { animation: terraeRootBasse 1600ms ease-out calc(var(--terrae-phrase, 0ms) + 1300ms) both; }

@keyframes terraeRootTitre {
  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 terraeRootFilet { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes terraeRootBasse { from { opacity: 0; } to { opacity: 1; } }

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

@media (max-width: 700px) {
  .terrae-root--webgl .terrae-root__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-root--webgl .terrae-root__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-root--webgl .terrae-root__caption p { letter-spacing: var(--cv-typo-current-ls, .26em); }
}

@media (max-height: 520px) {
  .terrae-root--webgl .terrae-root__caption { width: min(56vw, 440px); }
  .terrae-root--webgl .terrae-root__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-root { 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-root__fallback-material { background-image: none; }

.terrae-root--fallback .terrae-root__fallback-material { background-image: linear-gradient(180deg, rgba(16, 36, 29, .32) 0%, rgba(43, 33, 26, .55) 58%, rgba(8, 9, 7, .82) 100%), 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-root__fallback-material { background-image: linear-gradient(180deg, rgba(16, 36, 29, .32) 0%, rgba(43, 33, 26, .55) 58%, rgba(8, 9, 7, .82) 100%), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Brume_1800.jpg"), url("/assets/prologue-caravelli/terrae/03_PATTERNS/TC_Texture_Terre_1800.jpg"); }
}
