/* ==========================================================================
   Les Trésors du Mycélium — page d'accueil
   ========================================================================== */

@font-face {
  font-family: "Jost";
  src: url("assets/fonts/jost-300.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Jost";
  src: url("assets/fonts/jost-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --nuit:      #050504;  /* le noir du logo */
  --humus:     #0f0c07;  /* chaleur au centre de la page */
  --or:        #c8a35a;  /* or principal */
  --or-clair:  #ecd29b;  /* reflets, liens */
  --or-texte:  #b8a37b;  /* texte courant */
  --or-discret:#8c7a56;  /* pied de page */
  --filet:     rgba(200, 163, 90, .26);

  --ease-out:  cubic-bezier(.2, .7, .2, 1);
  --font:      "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--nuit);
  color: var(--or-texte);
  font-family: var(--font);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(ellipse 70% 60% at 50% 44%, var(--humus) 0%, var(--nuit) 70%);
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }

::selection { background: rgba(200, 163, 90, .3); color: #fff4dc; }

:focus-visible {
  outline: 1px solid var(--or-clair);
  outline-offset: 5px;
  border-radius: 1px;
}

/* --------------------------------------------------------------------------
   Réseau de mycélium (canvas) — masqué au centre pour laisser respirer le logo
   -------------------------------------------------------------------------- */
.mycelium {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 3s ease;
  --cx: 50%;
  --cy: 45%;
  --r0: 180px;
  --r1: 420px;
  -webkit-mask-image: radial-gradient(circle at var(--cx) var(--cy), transparent var(--r0), #000 var(--r1));
          mask-image: radial-gradient(circle at var(--cx) var(--cy), transparent var(--r0), #000 var(--r1));
}
.mycelium.is-visible { opacity: .9; }

/* --------------------------------------------------------------------------
   Header et footer : deux bandeaux fins qui encadrent la scène
   -------------------------------------------------------------------------- */
.header,
.footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem 1.5rem;
  padding-inline: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left));
}

/* Filet doré qui s'estompe vers les bords */
.header::after,
.footer::before {
  content: "";
  position: absolute;
  left: clamp(1rem, 4vw, 2.5rem);
  right: clamp(1rem, 4vw, 2.5rem);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--filet) 18%, var(--filet) 82%, transparent);
}

.header {
  padding-block: max(1rem, env(safe-area-inset-top)) 1rem;
  background: linear-gradient(to bottom, rgba(5, 5, 4, .9), rgba(5, 5, 4, 0));
}
.header::after { bottom: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--or-clair);
  text-decoration: none;
  min-width: 0;
}
.brand__mark {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
}
.brand__name {
  font-weight: 400;
  font-size: .9375rem;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex: none;
}

.header__icon {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--or);
  transition: color .4s ease;
}
.header__icon:hover,
.header__icon:focus-visible { color: var(--or-clair); }

.header__link,
.status__link {
  flex: none;
  padding: .35rem .1rem .45rem;
  color: var(--or-clair);
  font-weight: 400;
  font-size: .9375rem;
  letter-spacing: .06em;
  text-decoration: none;
  background: linear-gradient(var(--or), var(--or)) 50% 100% / 1.25rem 1px no-repeat;
  transition: background-size .6s var(--ease-out), color .4s ease;
}
.header__link:hover,
.header__link:focus-visible,
.status__link:hover,
.status__link:focus-visible {
  color: #fff1d2;
  background-size: 100% 1px;
}

.footer {
  flex-wrap: wrap;
  padding-block: .9rem max(.9rem, env(safe-area-inset-bottom));
  font-size: .8125rem;
  letter-spacing: .03em;
  color: var(--or-discret);
  background: linear-gradient(to top, rgba(5, 5, 4, .9), rgba(5, 5, 4, 0));
}
.footer::before { top: 0; }
.footer p { margin: 0; }

.footer__link {
  padding: .4rem 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color .4s ease;
}
.footer__link:hover { color: var(--or-clair); }

@media (max-width: 520px) {
  .brand { gap: .6rem; }
  .brand__mark { width: 2rem; height: 2rem; }
  .brand__name,
  .header__link { font-size: .875rem; letter-spacing: .04em; }
  .header__actions { gap: .6rem; }
  .footer { font-size: .75rem; }
  .toast { left: 1rem; right: 1rem; }
}
/* Sur petit écran, le nom est déjà lisible dans le logo central */
@media (max-width: 429px) {
  .brand__name { display: none; }
}

/* --------------------------------------------------------------------------
   Message éphémère (adresse copiée)
   -------------------------------------------------------------------------- */
/* Affiché sous le header, près du lien « Nous écrire » qui l'a déclenché */
.toast {
  position: fixed;
  top: calc(5rem + env(safe-area-inset-top));
  right: clamp(1rem, 4vw, 2.5rem);
  z-index: 5;
  max-width: calc(100% - 2rem);
  padding: .75rem 1.15rem;
  border: 1px solid var(--filet);
  border-radius: 2px;
  background: #0d0b07;
  color: var(--or-texte);
  font-size: .875rem;
  letter-spacing: .02em;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .9);
  opacity: 0;
  visibility: hidden;
  transition: opacity .45s ease, visibility 0s linear .45s;
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity .45s ease, visibility 0s;
}

/* --------------------------------------------------------------------------
   Page 404
   -------------------------------------------------------------------------- */
.notfound {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.5rem, 4vh, 2.25rem);
  padding: 1rem;
}
.notfound::before {
  content: "";
  position: absolute;
  inset: -30% -20%;
  z-index: -1;
  background: radial-gradient(closest-side,
              rgba(200, 163, 90, .12) 0%,
              rgba(200, 163, 90, .04) 45%,
              rgba(200, 163, 90, 0) 75%);
  pointer-events: none;
}
.notfound .logo__img {
  width: clamp(5.5rem, 16vw, 7.5rem);
  height: auto;
}
.status__title {
  margin: 0 0 .35rem;
  font-weight: 300;
  font-size: clamp(1.5rem, 1.15rem + 1.5vw, 2.25rem);
  letter-spacing: .02em;
  line-height: 1.25;
  color: var(--or-clair);
}
.status__link { margin-top: .9rem; }

/* --------------------------------------------------------------------------
   Scène centrale
   -------------------------------------------------------------------------- */
.scene {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.25rem, 3.6vh, 2.5rem);
  padding: clamp(1.5rem, 5vh, 3.5rem) 1rem clamp(1.5rem, 5vh, 3.5rem);
  text-align: center;
  overflow-x: clip; /* le halo déborde du logo sans élargir la page sur mobile */
}
@supports not (overflow: clip) {
  .scene { overflow: hidden; }
}

.logo {
  position: relative;
  margin: 0;
  width: min(540px, 84vw, calc((100vh - 18.5rem) * .95));
  width: min(540px, 84vw, calc((100svh - 18.5rem) * .95));
  min-width: 240px;
  aspect-ratio: 786 / 827;
  font-size: 1rem; /* le titre est porté par l'image */
}

/* Halo doré derrière le logo */
.logo::before {
  content: "";
  position: absolute;
  inset: -38%;
  z-index: -1;
  background: radial-gradient(closest-side,
              rgba(200, 163, 90, .15) 0%,
              rgba(200, 163, 90, .06) 42%,
              rgba(200, 163, 90, 0) 72%);
  pointer-events: none;
}

.logo__img,
.logo__sheen {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Reflet : copie éclaircie du logo visible seulement dans une bande qui traverse */
.logo__sheen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  filter: brightness(1.25) saturate(.85);
  mix-blend-mode: plus-lighter; /* lumière additive : l'or s'illumine au passage */
  -webkit-mask-image: linear-gradient(100deg, transparent 0 44%, #000 50%, transparent 56% 100%);
          mask-image: linear-gradient(100deg, transparent 0 44%, #000 50%, transparent 56% 100%);
  -webkit-mask-size: 300% 100%;
          mask-size: 300% 100%;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: 100% 0;
          mask-position: 100% 0;
}

/* --------------------------------------------------------------------------
   Statut
   -------------------------------------------------------------------------- */
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  max-width: 34rem;
}
.status p { margin: 0; }

.status__text {
  font-size: clamp(1rem, .95rem + .25vw, 1.125rem);
  letter-spacing: .03em;
  line-height: 1.5;
}

.status__where {
  font-size: .9375rem;
  line-height: 1.6;
  letter-spacing: .02em;
  color: #9c8a63;
  text-wrap: balance;
}

/* --------------------------------------------------------------------------
   Mentions légales (dialog natif)
   -------------------------------------------------------------------------- */
.sheet {
  width: min(40rem, calc(100% - 2rem));
  max-width: none;
  max-height: min(86vh, 50rem);
  max-height: min(86svh, 50rem);
  padding: 0;
  border: 1px solid var(--filet);
  border-radius: 2px;
  background: #0a0906;
  color: var(--or-texte);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 30px 80px -20px rgba(200, 163, 90, .12);
  overscroll-behavior: contain;
}
.sheet::backdrop {
  background: rgba(3, 3, 2, .74);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}

.sheet[open]              { animation: fade-in .45s var(--ease-out) both; }
.sheet[open]::backdrop    { animation: fade-in .45s ease both; }
.sheet.is-closing         { animation: fade-out .3s ease both; }
.sheet.is-closing::backdrop { animation: fade-out .3s ease both; }

.sheet__inner {
  position: relative;
  padding: clamp(1.75rem, 5vw, 2.75rem) clamp(1.25rem, 5vw, 2.75rem) clamp(2rem, 5vw, 2.75rem);
}

.sheet h2 {
  margin: 0 2.5rem 1.75rem 0;
  font-weight: 400;
  font-size: 1.375rem;
  letter-spacing: .04em;
  color: var(--or-clair);
}
.sheet h3 {
  margin: 1.6rem 0 .4rem;
  font-weight: 400;
  font-size: .875rem;
  letter-spacing: .05em;
  color: var(--or);
}
.sheet p {
  margin: 0;
  max-width: 62ch;
  font-size: .9375rem;
  line-height: 1.65;
}
.sheet a { color: var(--or-clair); text-underline-offset: 3px; text-decoration-thickness: 1px; }

.sheet__close {
  position: absolute;
  top: clamp(1.1rem, 4vw, 1.9rem);
  right: clamp(.75rem, 4vw, 1.9rem);
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--or-texte);
  cursor: pointer;
  transition: color .3s ease, border-color .3s ease;
}
.sheet__close:hover { color: var(--or-clair); border-color: var(--filet); }

/* --------------------------------------------------------------------------
   Séquence d'ouverture (fondus) — uniquement si JS actif
   -------------------------------------------------------------------------- */
.js .logo__img,
.js .status,
.js .header,
.js .footer,
.js .logo::before,
.js .notfound::before { opacity: 0; }

/* Le halo apparaît puis respire lentement, en continu */
.is-loaded .logo::before,
.is-loaded .notfound::before { animation: fade-in 2.6s ease .1s both, breathe 7s ease-in-out 2.7s infinite alternate; }
.is-loaded .logo__img    { animation: logo-in 2.2s var(--ease-out) .25s both; }
.is-loaded .header       { animation: fade-in 1.6s ease 1.2s both; }
.is-loaded .status       { animation: soft-in 1.6s ease 1.5s both; }
.is-loaded .footer       { animation: fade-in 1.6s ease 1.8s both; }
/* Le reflet (.logo__sheen) est animé en boucle depuis script.js */

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes breathe  { from { opacity: 1; } to { opacity: .55; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes logo-in {
  from { opacity: 0; filter: blur(12px); transform: scale(.985); }
  to   { opacity: 1; filter: blur(0);    transform: none; }
}

@keyframes soft-in {
  from { opacity: 0; filter: blur(4px); }
  to   { opacity: 1; filter: blur(0); }
}

/* --------------------------------------------------------------------------
   Mouvement réduit : tout est visible d'emblée, pas d'animation
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .logo__img,
  .js .status,
  .js .header,
  .js .footer,
  .js .logo::before,
  .js .notfound::before { opacity: 1; }
  .logo__sheen { display: none; }
  .mycelium.is-visible { opacity: .9; }
}
