* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  overflow: hidden;
  background: #191919;
  font-family: "Poppins", ui-sans-serif, system-ui, sans-serif;
  color: #2c2822;
}

/* Sans WebGL, la scène disparaît et le texte prend toute la page : mieux
   vaut un volet en moins qu'un chargement bloqué. */
body.no-webgl {
  display: block;
  overflow-y: auto;
}

body.no-webgl #stage {
  display: none;
}

body.no-webgl #panel {
  min-height: 100%;
  border-left: 0;
}

/* Parcours clavier : le contour par défaut disparaissait sur fond sombre. */
a:focus-visible,
img:focus-visible {
  outline: 2px solid #9aa1a9;
  outline-offset: 3px;
  border-radius: 0.3rem;
}

/* --- Volet gauche : la scène -------------------------------------------- */
#stage {
  position: relative;
  overflow: hidden;
  /* Le canvas est transparent (il est percé à l'emplacement de la dalle) :
     ce dégradé est donc le fond réellement visible de la scène. Il est
     accordé à celui du loader, pour que le fondu ne vire pas de teinte. */
  background: radial-gradient(120% 110% at 50% 0%, #f6f6f7 0%, #e9e9ec 100%);
}

/* Vignettage. Le post-processing est exclu ici (un EffectComposer reboucherait
   le trou de la dalle), mais une couche CSS par-dessus le canvas donne le même
   assombrissement des coins pour rien. */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(
    125% 105% at 50% 42%,
    transparent 54%,
    rgba(26, 22, 18, 0.26) 100%
  );
}

/* La couche CSS3D est sous le canvas : le canvas est percé (alpha 0) à
   l'emplacement de la dalle, ce qui laisse apparaître l'iframe. */
#css3d {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

#webgl {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#webgl:active {
  cursor: grabbing;
}

.screen-holder {
  /* La dalle est décorative : elle ne capte aucun événement, le canvas garde
     la main sur toute la surface pour la rotation. */
  pointer-events: none;
  /* La garde noire du holder prolonge le bezel : elle déborde du trou et
     reste cachée sous le canvas. */
  box-sizing: border-box;
  background: #06070a;
  overflow: hidden;
}

.screen-holder iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* --- Volet droit : le texte --------------------------------------------- */
#panel {
  position: relative;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 3.5rem;
  color: #e9e9ee;
  /* Gris neutres : le halo n'est plus qu'un voile blanc très dilué, juste de
     quoi garder du relief sans réintroduire de teinte. */
  background:
    radial-gradient(85% 55% at 100% 0%, rgba(255, 255, 255, 0.05) 0%, transparent 62%),
    linear-gradient(165deg, #191919 0%, #131313 55%, #0e0e0e 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}

/* Dans le flux, pas en absolu : le titre finissait par passer dessous dès que
   le volet se resserrait. Il pousse maintenant le texte au lieu de le mordre. */
.portrait {
  flex: none;
  align-self: flex-end;
  margin-bottom: 2.2rem;
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0.7rem 1.8rem rgba(0, 0, 0, 0.5);
}

.panel-inner {
  max-width: 34rem;
}

.eyebrow {
  margin: 0 0 1.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9aa1a9;
}

#panel h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.4rem, 4.6vw, 4.1rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
  color: #fff;
}

#panel h1 em {
  font-style: normal;
  color: #98a0a9;
}

.lead {
  margin: 0 0 1.8rem;
  font-size: 1rem;
  line-height: 1.68;
  color: rgba(233, 233, 238, 0.62);
}

.lead code,
#panel kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.38em;
  border-radius: 0.3em;
  background: rgba(255, 255, 255, 0.07);
  color: #c6cbd2;
}

.facts {
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(233, 233, 238, 0.72);
}

.facts li {
  position: relative;
  padding-left: 1.4rem;
}

.facts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: #6e757e;
}

.hint {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 2.2rem;
  font-size: 0.85rem;
  color: rgba(233, 233, 238, 0.5);
}

.hint .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0.25rem rgba(74, 222, 128, 0.15);
}

#panel kbd {
  padding: 0.12em 0.45em;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* --- Liens --------------------------------------------------------------- */
.links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  /* Sans cadre, les liens ont besoin d'air pour rester distincts. */
  gap: 1.5rem;
  margin-bottom: 2.6rem;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(233, 233, 238, 0.74);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.links a:hover {
  color: #fff;
}

.links a:active {
  transform: translateY(1px);
}

/* « Écrire » garde son cadre : c'est l'action attendue de la page. */
.links a.ghost {
  margin-left: 0.3rem;
  padding: 0.62rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 0.6rem;
  color: #e9e9ee;
}

.links a.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.42);
}

.links svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
  flex: none;
}

.links svg.stroked {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-foot {
  font-size: 0.78rem;
  color: rgba(233, 233, 238, 0.32);
  padding-top: 1.4rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Écran de chargement ------------------------------------------------ */
/* Il ne couvre que la scène : le texte reste lisible pendant le chargement. */
#loader {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: radial-gradient(120% 110% at 50% 0%, #f6f6f7 0%, #e9e9ec 100%);
  transition: opacity 0.6s ease;
}

body.ready #loader {
  opacity: 0;
  pointer-events: none;
}

#loader .ring {
  position: absolute;
  width: 132px;
  height: 132px;
  transform: rotate(-90deg);
}

#loader .track {
  fill: none;
  stroke: rgba(40, 40, 46, 0.12);
  stroke-width: 3;
}

#loader .value {
  fill: none;
  stroke: #3c3c42;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

#loader .readout {
  display: flex;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  color: #2b2b30;
}

#loader .readout b {
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

#loader .readout i {
  font-style: normal;
  font-size: 15px;
  margin-left: 2px;
  opacity: 0.55;
}

#loader-label {
  position: absolute;
  margin: 0;
  transform: translateY(105px);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: rgba(60, 60, 68, 0.55);
}

/* --- Format vertical : la scène passe au-dessus, le texte dessous ------- */
@media (orientation: portrait), (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 56vh auto;
    /* svh ignore la barre d'URL mobile, qui ferait sauter la hauteur. */
    grid-template-rows: 56svh auto;
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  #panel {
    overflow: visible;
    padding: 2.25rem 1.75rem 3.5rem;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
  }

  .portrait {
    margin-bottom: 1.6rem;
    width: 4.6rem;
    height: 4.6rem;
  }

  .panel-inner {
    max-width: 38rem;
  }

  #panel h1 {
    font-size: clamp(2.1rem, 9vw, 3.2rem);
  }
}
