:root {
  --bg-0: #0e1518;
  --bg-1: #152228;
  --bg-2: #1c2f37;
  --ink: #e8eef1;
  --ink-muted: rgba(232, 238, 241, 0.72);
  --ink-faint: rgba(232, 238, 241, 0.5);
  --accent: #3db8a6;
  --accent-press: #32a393;
  --ok: #6fcf97;
  --err: #ff8a80;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 85% 65% at 12% 8%, rgba(61, 184, 166, 0.16), transparent 55%),
    radial-gradient(ellipse 70% 55% at 92% 90%, rgba(70, 120, 150, 0.2), transparent 50%),
    linear-gradient(155deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
  background-attachment: fixed;
}

.page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(1.25rem + env(safe-area-inset-top)) calc(1.25rem + env(safe-area-inset-right))
    calc(1.5rem + env(safe-area-inset-bottom)) calc(1.25rem + env(safe-area-inset-left));
}

.panel {
  width: min(100%, 28rem);
  text-align: center;
  animation: rise 0.55s ease-out both;
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 7vw, 2.45rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.welcome {
  margin: 0.85rem 0 1.75rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Illustration : appuyer sur le bouton -> franchir la porte */
.howto {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    "press arrow enter"
    "label1 . label2";
  align-items: center;
  justify-items: center;
  gap: 0.6rem clamp(0.2rem, 2vw, 0.6rem);
  margin: 0 0 2rem;
}

.howto-icon {
  width: clamp(3.5rem, 19vw, 4.75rem);
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--ink);
}

.howto-icon--press {
  grid-area: press;
}

.howto-icon--enter {
  grid-area: enter;
}

.howto-icon .plate {
  fill: rgba(232, 238, 241, 0.1);
  stroke: none;
}

.howto-icon .floor {
  stroke: rgba(232, 238, 241, 0.28);
}

.howto-icon .dot {
  fill: var(--accent);
  stroke: none;
}

.howto-icon .handle {
  fill: var(--ink-faint);
}

.howto-icon .halo {
  fill: var(--accent);
  stroke: none;
  opacity: 0.35;
  transform-box: fill-box;
  transform-origin: center;
  animation: halo 2.4s ease-out infinite;
}

.hand-anim {
  animation: tap 2.4s ease-in-out infinite;
}

.walker {
  color: var(--accent);
}

.walker .solid {
  fill: currentColor;
  stroke: none;
}

.walker .limb {
  stroke: currentColor;
  stroke-width: 4.6;
}

.walker .torso {
  stroke-width: 5.4;
}

.walker .arm {
  stroke-width: 3.8;
}

.howto-arrow {
  grid-area: arrow;
  width: clamp(1.9rem, 10vw, 2.75rem);
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
}

.arrow-line {
  stroke-dasharray: 4 5;
  animation: dash 1.1s linear infinite;
}

.howto-label {
  font-size: clamp(0.68rem, 3vw, 0.78rem);
  line-height: 1.3;
  color: var(--ink-faint);
  max-width: 8.5rem;
}

.howto-label--first {
  grid-area: label1;
}

.howto-label--last {
  grid-area: label2;
}

.open-btn {
  appearance: none;
  border: 0;
  border-radius: 16px;
  min-height: 3.75rem;
  padding: 1rem 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: min(100%, 20rem);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  color: #06201c;
  background: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.open-btn:hover:not(:disabled) {
  background: var(--accent-press);
  transform: translateY(-1px);
}

.open-btn:active:not(:disabled) {
  background: var(--accent-press);
  transform: scale(0.98);
}

.open-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.open-btn.loading .btn-icon {
  animation: spin 0.9s linear infinite;
}

.btn-icon {
  display: inline-flex;
}

.status {
  min-height: 1.5rem;
  margin: 1.25rem 0 0;
  font-size: 0.95rem;
  color: var(--ink-muted);
  transition: color 0.2s ease;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--err);
}

/* Retour d'ouverture plein écran */
.result {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(9, 16, 19, 0.82);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.result.show {
  opacity: 1;
  visibility: visible;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
  opacity: 0;
  transform: scale(0.9);
}

.result.show .result-card {
  animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.35) forwards;
}

.result-mark {
  width: clamp(6.5rem, 38vw, 9rem);
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result.is-ok .result-mark {
  color: var(--ok);
}

.result.is-err .result-mark {
  color: var(--err);
}

.result.is-err.show .result-mark {
  animation: shake 0.5s 0.2s ease-in-out;
}

.result-ring,
.result-check,
.result-cross {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.result-check,
.result-cross {
  opacity: 0;
}

.result.is-ok .result-check,
.result.is-err .result-cross {
  opacity: 1;
}

.result.show .result-ring {
  animation: draw 0.5s ease-out forwards;
}

.result.show.is-ok .result-check,
.result.show.is-err .result-cross {
  animation: draw 0.35s 0.32s ease-out forwards;
}

.result-text {
  margin: 0;
  font-size: clamp(1.15rem, 5.5vw, 1.4rem);
  font-weight: 600;
  color: var(--ink);
  opacity: 0;
}

.result.show .result-text {
  animation: fade-up 0.35s 0.45s ease-out forwards;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tap {
  0%,
  58%,
  100% {
    transform: translateY(0);
  }
  70%,
  84% {
    transform: translateY(2.5px);
  }
}

@keyframes halo {
  0%,
  62% {
    opacity: 0;
    transform: scale(1);
  }
  72% {
    opacity: 0.4;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(2.1);
  }
}

@keyframes dash {
  to {
    stroke-dashoffset: -9;
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pop {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@media (max-height: 620px) {
  .welcome {
    margin-bottom: 1.25rem;
  }

  .howto {
    margin-bottom: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .open-btn,
  .hand-anim,
  .halo,
  .arrow-line,
  .open-btn.loading .btn-icon,
  .result.show .result-card,
  .result.show .result-text,
  .result.show .result-ring,
  .result.show.is-ok .result-check,
  .result.show.is-err .result-cross,
  .result.is-err.show .result-mark {
    animation: none;
    transition: none;
  }

  .result-card,
  .result-text {
    opacity: 1;
    transform: none;
  }

  .result-ring,
  .result-check,
  .result-cross {
    stroke-dashoffset: 0;
  }
}
