:root {
  --bg: #f6f3ef;
  --bg-2: #ece4da;
  --text: #1d1a17;
  --muted: #6f675f;
  --card: #ffffff;
  --border: rgba(29, 26, 23, 0.1);
  --accent: #1d1a17;
  --accent-text: #f6f3ef;
  --overlay: rgba(20, 18, 16, 0.45);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(0, 0, 0, 0.05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --bg-2: #1f1b18;
    --text: #f1ece6;
    --muted: #a39a90;
    --card: #1c1a18;
    --border: rgba(241, 236, 230, 0.1);
    --accent: #f1ece6;
    --accent-text: #121110;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg) radial-gradient(120% 55% at 50% 0%, var(--bg-2), var(--bg) 70%) no-repeat;
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding:
    calc(env(safe-area-inset-top) + 48px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 32px)
    calc(env(safe-area-inset-left) + 16px);
}

.page {
  max-width: 420px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.ready .page { opacity: 1; transform: none; }

/* Profil */
.profile { text-align: center; margin-bottom: 28px; }
.avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--muted);
  font: 400 34px/1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Police système très grasse : SF Pro Heavy sur iPhone, Roboto Black sur Android */
h1 {
  font: 800 32px/1.05 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.02em;
}
.bio { color: var(--muted); font-size: 15px; margin-top: 6px; white-space: pre-line; }

/* Pastille de statut (config.status) */
.status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 5px 14px 5px 10px;
  border-radius: 999px;
  background: #ffffff;
  color: #121110;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@media (prefers-reduced-motion: reduce) { .status-dot { animation: none; } }

/* Photo en grand (quand config.photo est renseigné) */
body.has-photo {
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.82);
  --card: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.2);
  --accent: #ffffff;
  --accent-text: #121110;
  --shadow: none;
  /* Couleur d'accent : config.color (par défaut rose framboise) */
  --brand: #ff4f9a;
  --brand-2: #ff7db4;
  --brand-deep: #3a1029;
  --brand-tint: rgba(255, 79, 154, 0.16);
  --brand-line: rgba(255, 79, 154, 0.45);
  --brand-glow: rgba(255, 79, 154, 0.45);
  background: #121110 linear-gradient(to bottom, #121110 30%, var(--brand-deep) 100%) no-repeat;
}
@supports (color: color-mix(in srgb, red, blue)) {
  body.has-photo {
    --brand-2: color-mix(in srgb, var(--brand) 75%, #ffffff);
    --brand-deep: color-mix(in srgb, var(--brand) 22%, #121110);
    --brand-tint: color-mix(in srgb, var(--brand) 16%, transparent);
    --brand-line: color-mix(in srgb, var(--brand) 45%, transparent);
    --brand-glow: color-mix(in srgb, var(--brand) 45%, transparent);
  }
}
/* La photo est dans le flux : le texte chevauche seulement le bas (sous le buste),
   donc la position est la même quelle que soit la taille de l'écran. */
.has-photo .avatar {
  position: relative;
  width: auto;
  height: auto;
  aspect-ratio: 72 / 100; /* on retire le mur en haut et l'oreiller en bas */
  margin: calc(-1 * (env(safe-area-inset-top) + 48px)) calc(-1 * (env(safe-area-inset-right) + 16px)) 0 calc(-1 * (env(safe-area-inset-left) + 16px));
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
/* La photo se fond dans le fond de page (pas de ligne de séparation) */
.has-photo .avatar img {
  position: absolute;
  inset: 0;
  object-position: center 64%;
  -webkit-mask-image: linear-gradient(to bottom, #000 58%, rgba(0, 0, 0, 0.35) 82%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 58%, rgba(0, 0, 0, 0.35) 82%, transparent 100%);
}
.has-photo .profile { margin-bottom: 20px; }
.has-photo h1 { position: relative; margin-top: -22vw; font-size: 48px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45); }
.has-photo .bio { position: relative; }
.has-photo .notice { position: relative; z-index: 2; }
.has-photo .links .btn:not(.btn--primary) {
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  background: var(--brand-tint);
  border-color: var(--brand-line);
}
.has-photo .btn--primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 8px 26px var(--brand-glow);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.has-photo .status-dot { background: #22c55e; }
/* L'age gate garde un fond opaque */
.has-photo .sheet { --card: #1c1a18; --text: #f1ece6; --muted: #a39a90; --border: rgba(241, 236, 230, 0.12); color: var(--text); }

@media (min-width: 480px) {
  .has-photo .avatar { margin: 0; border-radius: 28px; overflow: hidden; }
  .has-photo h1 { margin-top: -96px; }
}

/* Boutons */
.links { display: flex; flex-direction: column; gap: 12px; }
.btn {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); opacity: 0.9; }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.btn--primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.links .btn--primary { min-height: 62px; font-size: 17px; }
.btn-label { display: block; }
.btn-sub { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; opacity: 0.65; }
.links .btn { min-height: 64px; }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }

/* Bandeau navigateur in-app */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 24px;
  padding: 12px 8px 12px 14px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.notice p { flex: 1; }
.notice-close {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 0 6px;
  min-width: 32px;
  min-height: 32px;
  cursor: pointer;
}

/* Age gate (bottom sheet) */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.backdrop.open { opacity: 1; }
.sheet {
  width: 100%;
  max-width: 480px;
  padding: 12px calc(env(safe-area-inset-right) + 20px) calc(env(safe-area-inset-bottom) + 20px) calc(env(safe-area-inset-left) + 20px);
  border-radius: 24px 24px 0 0;
  background: var(--card);
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.backdrop.open .sheet { transform: none; }
.handle { width: 36px; height: 4px; margin: 0 auto 18px; border-radius: 2px; background: var(--border); }
.sheet h2 { font-size: 19px; font-weight: 600; margin-bottom: 8px; }
.sheet p { color: var(--muted); font-size: 15px; margin-bottom: 20px; }
.sheet .btn { box-shadow: none; }
.sheet .btn + .btn { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Animations des boutons */
.ready .links .btn {
  animation: btn-rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.ready .links .btn:nth-child(2) { animation-delay: 0.08s; }
.ready .links .btn:nth-child(3) { animation-delay: 0.16s; }
.ready .links .btn:nth-child(4) { animation-delay: 0.24s; }
@keyframes btn-rise {
  from { opacity: 0; translate: 0 14px; }
  to { opacity: 1; translate: 0 0; }
}

/* Bouton principal : reflet qui passe + halo qui respire */
.links .btn--primary { position: relative; overflow: hidden; isolation: isolate; }
.links .btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: btn-shine 3.6s ease-in-out 1s infinite;
  pointer-events: none;
}
.links .btn--primary .btn-label,
.links .btn--primary .btn-sub { position: relative; z-index: 1; }
@keyframes btn-shine {
  0% { transform: translateX(-120%); }
  30%, 100% { transform: translateX(120%); }
}
.has-photo.ready .links .btn--primary {
  animation: btn-rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both, btn-glow 2.8s ease-in-out 0.6s infinite;
}
@keyframes btn-glow {
  0%, 100% { box-shadow: 0 8px 26px var(--brand-glow); }
  50% { box-shadow: 0 10px 40px var(--brand-glow), 0 0 0 1px rgba(255, 255, 255, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .ready .links .btn,
  .has-photo.ready .links .btn--primary,
  .links .btn--primary::after { animation: none; }
}
