/* =========================================================
   NoStash Studio — page de redirection Discord

   Identité visuelle, tirée du logo :
   - palette : violet #5B4FE0 → #2E2570 sur encre #161221 ;
   - formes : les chevrons < > du logo (coins de la carte) ;
   - ton "code" : police monospace pour les petits textes,
     curseur clignotant, grille en fond.

   Les animations ne modifient que transform, opacity ou
   stroke-dashoffset : pas de recalcul de mise en page.
   ========================================================= */

/* ---------- Variables ---------- */
:root {
  /* Couleurs de la marque */
  --violet: #5b4fe0;
  --violet-deep: #2e2570;
  --violet-light: #a99fff;
  --ink: #0e0b16;       /* fond de page */
  --surface: #161221;   /* fond du logo et de la carte */
  --line: #2a2340;      /* bordures */

  /* Texte */
  --text: #ece9f7;
  --muted: #8c86a3;

  /* Polices (système, aucune requête externe) */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;

  --radius: 18px;
  --delay: 5s; /* remplacé par script.js selon data-delay */

  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
}

::selection { background: var(--violet); color: #fff; }

/* ---------- Arrière-plan ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
}

/* Grille fine, estompée vers les bords */
.backdrop__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: center;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 45%, #000 20%, transparent 75%);
}

/* Lueur violette qui "respire" derrière la carte */
.backdrop__glow {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(900px, 140vw);
  aspect-ratio: 1.4;
  translate: -50% -50%;
  background: radial-gradient(closest-side, rgb(91 79 224 / 0.32), rgb(46 37 112 / 0.15) 55%, transparent);
  will-change: opacity, transform;
  animation: breathe 7s ease-in-out infinite alternate;
}

/* ---------- Carte ---------- */
.card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 40px 32px 28px;
  text-align: center;
  background: linear-gradient(180deg, rgb(255 255 255 / 0.025), transparent 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow:
    0 40px 100px -20px rgb(0 0 0 / 0.7),
    0 0 0 1px rgb(0 0 0 / 0.4);
}

/* Coins en équerre, rappel des chevrons du logo */
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--violet);
  pointer-events: none;
}
.card::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: var(--radius);
}
.card::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: var(--radius);
}

/* Apparition en cascade des éléments de la carte */
.card > * {
  opacity: 0;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.card > :nth-child(1) { animation-delay: 0.05s; }
.card > :nth-child(2) { animation-delay: 0.35s; }
.card > :nth-child(3) { animation-delay: 0.45s; }
.card > :nth-child(4) { animation-delay: 0.55s; }
.card > :nth-child(5) { animation-delay: 0.65s; }
.card > :nth-child(6) { animation-delay: 0.75s; }
.card > :nth-child(7) { animation-delay: 0.85s; }

/* ---------- Logo (traits dessinés au chargement) ---------- */
.logo {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
  overflow: visible;
  filter: drop-shadow(0 10px 24px rgb(91 79 224 / 0.35));
}
.logo__bg {
  fill: var(--ink);
  stroke: var(--line);
  stroke-width: 3;
}
.logo__stroke {
  fill: none;
  stroke: url(#logo-grad);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;     /* pathLength="1" => 1 = longueur totale */
  stroke-dashoffset: 1;
  animation: draw 0.7s cubic-bezier(0.65, 0, 0.35, 1) forwards;
  animation-delay: calc(0.25s + var(--i) * 0.25s);
}

/* ---------- Textes ---------- */
.eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--violet-light);
}
/* Chevrons autour du nom du studio : < NOSTASH STUDIO > */
.eyebrow::before { content: "<\00a0"; color: var(--violet); }
.eyebrow::after  { content: "\00a0>"; color: var(--violet); }

.title {
  margin: 0 0 12px;
  font-size: clamp(22px, 6vw, 27px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.title__accent { color: var(--violet-light); }

.caret {
  margin-left: 2px;
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--violet);
  animation: blink 1.1s steps(1) infinite;
}

.message {
  margin: 0 0 28px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Barre de progression ---------- */
.progress { margin: 0 0 22px; }

.progress__label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.progress__count {
  display: inline-block;
  min-width: 1ch;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
/* Petit "pop" à chaque seconde (classe ajoutée par script.js) */
.progress__count.tick { animation: pop 0.35s ease-out; }

.progress__track {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet-deep), var(--violet), var(--violet-light));
  transform-origin: left;
  animation: drain var(--delay) linear forwards;
}

/* État annulé */
.is-cancelled .progress__fill { animation-play-state: paused; background: var(--muted); }
.is-cancelled .progress__count { color: var(--muted); }

/* ---------- Bouton principal ---------- */
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: var(--violet);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.18),
    0 10px 30px -8px rgb(91 79 224 / 0.6);
  transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.button:hover,
.button:focus-visible {
  background: #6a5ff0;
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.2),
    0 16px 40px -8px rgb(91 79 224 / 0.75);
}
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 2px solid var(--violet-light); outline-offset: 3px; }

.button__arrow {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}
.button:hover .button__arrow { transform: translateX(4px); }

/* ---------- Bouton d'annulation ---------- */
.cancel {
  display: block;
  margin: 16px auto 0;
  padding: 4px 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s;
}
.cancel:hover,
.cancel:focus-visible { color: var(--text); }
.cancel[hidden] { display: none; }

/* ---------- Animations ---------- */
@keyframes rise    { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes draw    { to { stroke-dashoffset: 0; } }
@keyframes breathe { from { opacity: 0.7; transform: scale(0.95); } to { opacity: 1; transform: scale(1.05); } }
@keyframes blink   { 50% { opacity: 0; } }
@keyframes drain   { to { transform: scaleX(0); } }
@keyframes pop     { 40% { transform: scale(1.35); } }

/* ---------- Accessibilité : mouvements réduits ----------
   Si l'utilisateur a demandé moins d'animations dans son système,
   on coupe tout ce qui est décoratif. Le compte à rebours reste. */
@media (prefers-reduced-motion: reduce) {
  .backdrop__glow,
  .caret,
  .progress__count.tick { animation: none; }
  .logo__stroke { animation: none; stroke-dashoffset: 0; }
  .card > * { animation-duration: 0.01s; animation-delay: 0s; }
}
