/* =========================================================
   GLOW PILLS · Linktree — Techno / Cyber-Pharma
   ========================================================= */

:root {
  /* Brand — from the neon pill logo */
  --green:  #3dff2e;   /* pill green */
  --yellow: #eaff00;   /* pill yellow */
  /* Holographic accents — from the avatar */
  --cyan:   #25e6ff;
  --pink:   #ff3ea6;
  --violet: #a06bff;

  --bg:     #050608;
  --bg-2:   #0a0d12;
  --ink:    #eafff0;
  --muted:  #7d9488;
  --line:   rgba(61,255,46,.16);

  --font-name: "Unbounded", system-ui, sans-serif;
  --font-disp: "Chakra Petch", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;

  --radius:  22px;
  --maxw:    480px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-disp);
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--font-mono); }

/* =========================================================
   AMBIENT SCENE
   ========================================================= */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

/* Drifting aurora blobs (green / yellow / holo) */
.aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(38% 44% at 22% 26%, rgba(61,255,46,.30), transparent 60%),
    radial-gradient(34% 40% at 82% 20%, rgba(234,255,0,.20), transparent 60%),
    radial-gradient(46% 50% at 74% 82%, rgba(160,107,255,.24), transparent 62%),
    radial-gradient(40% 46% at 18% 84%, rgba(37,230,255,.18), transparent 62%);
  filter: blur(28px) saturate(120%);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(-3%, -2%, 0) scale(1.05) rotate(0deg); }
  100% { transform: translate3d(3%, 3%, 0)  scale(1.15) rotate(6deg); }
}

/* Warehouse grid floor in perspective */
.grid-floor {
  position: absolute; left: -20%; right: -20%; bottom: -10%; height: 62%;
  background-image:
    linear-gradient(rgba(61,255,46,.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61,255,46,.16) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: perspective(340px) rotateX(74deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, #000 0%, rgba(0,0,0,.5) 40%, transparent 78%);
  animation: floor 14s linear infinite;
  opacity: .55;
}
@keyframes floor { to { background-position: 0 46px, 46px 0; } }

/* CRT scanlines */
.scanlines {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px);
  mix-blend-mode: multiply; opacity: .5;
}

/* Film grain */
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: .05; animation: grain 6s steps(6) infinite;
}
@keyframes grain {
  0%{transform:translate(0,0)} 20%{transform:translate(-4%,3%)} 40%{transform:translate(3%,-2%)}
  60%{transform:translate(-2%,4%)} 80%{transform:translate(4%,2%)} 100%{transform:translate(0,0)}
}

/* =========================================================
   STAGE / CARD
   ========================================================= */
.stage {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; justify-content: center;
  padding: clamp(18px, 5vw, 44px) 16px calc(96px + env(safe-area-inset-bottom));
}

.card {
  width: 100%; max-width: var(--maxw);
  display: flex; flex-direction: column; gap: 18px;
}

/* Top status bar */
.topbar { display: flex; justify-content: space-between; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255,255,255,.02); backdrop-filter: blur(6px);
}
.chip--live { color: var(--green); border-color: rgba(61,255,46,.4); }
.chip .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 10px var(--green); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.35;transform:scale(.7)} }

/* =========================================================
   HERO
   ========================================================= */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }

.avatar-wrap { position: relative; width: 152px; height: 152px; display: grid; place-items: center; }
.avatar {
  width: 128px; height: 128px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.14);
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  position: relative; z-index: 2;
  user-select: none;
}
.avatar-glow {
  position: absolute; inset: 8px; border-radius: 50%; z-index: 0;
  background: conic-gradient(from 0deg, var(--green), var(--yellow), var(--cyan), var(--violet), var(--pink), var(--green));
  filter: blur(16px); opacity: .55; animation: spin 8s linear infinite;
}
.ring {
  position: absolute; border-radius: 50%; z-index: 1;
  border: 2px solid transparent;
}
.ring--1 {
  inset: 0;
  background: conic-gradient(from 90deg, var(--green), var(--yellow), var(--green) 40%, transparent 40%, transparent 55%, var(--cyan) 55%, var(--violet), transparent 80%) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 6s linear infinite;
}
.ring--2 {
  inset: -8px; border: 1px dashed rgba(234,255,0,.4);
  animation: spin 18s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

.avatar-edit {
  position: absolute; z-index: 3; right: 8px; bottom: 8px;
  width: 34px; height: 34px; border-radius: 50%;
  display: none; place-items: center; cursor: pointer;
  color: #04110a; background: var(--green);
  border: 2px solid var(--bg); box-shadow: 0 0 14px rgba(61,255,46,.7);
}
body.editing .avatar-edit { display: grid; }
.avatar-edit:hover { transform: scale(1.08); }

/* Wordmark */
.name {
  font-family: var(--font-name); font-weight: 800;
  font-size: clamp(2.1rem, 10vw, 3.1rem);
  line-height: .96; letter-spacing: -.01em; text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 22px rgba(255,255,255,.18);
}
.name .w { display: inline-block; }
.name .accent-y { color: var(--yellow); text-shadow: 0 0 18px rgba(234,255,0,.75); }
.name .accent-g { color: var(--green);  text-shadow: 0 0 18px rgba(61,255,46,.75); }
.name.glitch { position: relative; }
.name.glitch::before, .name.glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
  clip-path: inset(0 0 55% 0);
}
.name.glitch::before { color: var(--cyan); animation: glitch 4.6s infinite steps(2); }
.name.glitch::after  { color: var(--pink); clip-path: inset(58% 0 0 0); animation: glitch 4.6s .1s infinite steps(2); }
@keyframes glitch {
  0%,92%,100% { transform: translate(0); opacity: 0; }
  93% { transform: translate(-2px,-1px); opacity: .55; }
  95% { transform: translate(2px,1px);  opacity: .5; }
  97% { transform: translate(-1px,1px); opacity: .5; }
}

.tagline {
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.tagline b { color: var(--green); font-weight: 400; }

/* Equalizer */
.eq { display: flex; align-items: flex-end; gap: 4px; height: 22px; margin-top: 2px; }
.eq span {
  width: 4px; border-radius: 2px;
  background: linear-gradient(to top, var(--green), var(--yellow));
  animation: bounce 1s ease-in-out infinite;
}
.eq span:nth-child(1){animation-delay:-.9s} .eq span:nth-child(2){animation-delay:-.3s}
.eq span:nth-child(3){animation-delay:-.6s} .eq span:nth-child(4){animation-delay:-.1s}
.eq span:nth-child(5){animation-delay:-.7s} .eq span:nth-child(6){animation-delay:-.4s}
.eq span:nth-child(7){animation-delay:-.8s}
@keyframes bounce { 0%,100%{height:5px;opacity:.5} 50%{height:22px;opacity:1} }

/* =========================================================
   LINKS — capsule buttons
   ========================================================= */
.links { list-style: none; display: flex; flex-direction: column; gap: 13px; margin-top: 4px; }

.link { position: relative; display: flex; align-items: stretch; gap: 8px; }

.link-face {
  --brand: var(--green);
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; text-decoration: none; color: var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.09);
  backdrop-filter: blur(10px);
  position: relative; overflow: hidden;
  transition: transform .22s cubic-bezier(.2,.8,.3,1), border-color .22s, box-shadow .22s;
}
/* moving sheen */
.link-face::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.16), transparent);
  transform: skewX(-18deg); transition: left .6s ease;
}
.link-face:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 65%, transparent);
  box-shadow: 0 8px 30px rgba(0,0,0,.45), 0 0 22px color-mix(in srgb, var(--brand) 40%, transparent);
}
.link-face:hover::after { left: 130%; }
.link-face:active { transform: translateY(0) scale(.99); }

.link-ico {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; color: var(--brand);
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--brand) 26%, transparent), color-mix(in srgb, var(--brand) 8%, transparent));
  border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent);
  box-shadow: inset 0 0 12px color-mix(in srgb, var(--brand) 22%, transparent);
}
.link-ico svg { width: 22px; height: 22px; fill: currentColor; }

.link-text { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.link-label { font-weight: 600; font-size: 15.5px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-sub { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.link-arrow { flex: none; margin-left: auto; color: var(--muted); transition: transform .22s, color .22s; }
.link-face:hover .link-arrow { color: var(--brand); transform: translate(3px,-3px); }

/* Tools (edit mode) */
.link-tools { display: none; flex-direction: column; justify-content: center; gap: 4px; }
body.editing .link-tools { display: flex; }
body.editing .link-face { pointer-events: none; }
.link-tools button, .drag {
  width: 34px; height: 22px; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,.03); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; font-size: 13px; line-height: 1; transition: .15s;
}
.link-tools button:hover { color: var(--ink); border-color: var(--green); }
.link-tools [data-act="del"]:hover { color: var(--pink); border-color: var(--pink); }
.drag { cursor: grab; height: 100%; }
.link.dragging { opacity: .4; }
.link.drag-over .link-face { border-color: var(--green); }

/* Add capsule + editbar (only visible while editing) */
.add-capsule, .editbar { display: none; }
body.editing .add-capsule {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-disp); font-weight: 600; font-size: 14.5px; letter-spacing: .04em;
  color: var(--green); background: rgba(61,255,46,.06);
  border: 1.5px dashed rgba(61,255,46,.5); transition: .18s;
}
.add-capsule:hover { background: rgba(61,255,46,.12); box-shadow: 0 0 22px rgba(61,255,46,.25); }

body.editing .editbar {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  padding-top: 4px;
}
.editbar button {
  flex: 1 1 auto; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em;
  color: var(--muted); background: rgba(255,255,255,.03); border: 1px solid var(--line);
  transition: .15s;
}
.editbar button:hover { color: var(--ink); border-color: var(--green); }

/* =========================================================
   FOOTER
   ========================================================= */
.foot {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 10px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.06);
  font-size: 11px; color: var(--muted);
}
.foot-logo { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; opacity: .85; }
.foot .mono { letter-spacing: .06em; }
.share {
  margin-left: auto; padding: 7px 13px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-disp); font-weight: 600; font-size: 12px; letter-spacing: .05em;
  color: var(--bg); background: linear-gradient(90deg, var(--green), var(--yellow));
  border: none; box-shadow: 0 0 16px rgba(61,255,46,.35); transition: .18s;
}
.share:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* =========================================================
   FAB
   ========================================================= */
.fab {
  position: fixed; z-index: 30; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-disp); font-weight: 600; font-size: 13.5px; letter-spacing: .05em;
  color: var(--ink); background: rgba(10,13,18,.75); backdrop-filter: blur(12px);
  border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.5);
  transition: .2s;
}
.fab:hover { border-color: var(--green); box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 22px rgba(61,255,46,.3); }
/* Édition réservée à l'admin : le bouton n'existe que si le device est déverrouillé */
body:not(.admin) .fab { display: none; }
.fab .fab-ico { color: var(--green); }
.fab .fab-ico--done { display: none; }
body.editing .fab { background: linear-gradient(90deg, var(--green), var(--yellow)); color: var(--bg); border-color: transparent; }
body.editing .fab .fab-ico { color: var(--bg); }
body.editing .fab .fab-ico--edit { display: none; }
body.editing .fab .fab-ico--done { display: block; }
body.editing .fab .fab-label::after { content: "Terminer"; }
.fab .fab-label::after { content: "Éditer"; }
.fab .fab-label { font-size: 0; }
.fab .fab-label::after { font-size: 13.5px; }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: 84px; transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 999px; pointer-events: none;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
  color: var(--bg); background: linear-gradient(90deg, var(--green), var(--yellow));
  box-shadow: 0 8px 30px rgba(0,0,0,.5); opacity: 0; transition: .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   MODAL
   ========================================================= */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: end center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,3,5,.7); backdrop-filter: blur(6px); animation: fade .2s ease; }
.modal-panel {
  position: relative; width: 100%; max-width: var(--maxw);
  margin: 0 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--bg-2), #070a0e);
  border: 1px solid var(--line); border-radius: 24px 24px 22px 22px;
  box-shadow: 0 -10px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(61,255,46,.06);
  padding: 22px 20px 24px; animation: rise .3s cubic-bezier(.2,.8,.3,1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 560px) { .modal { place-items: center; } .modal-panel { margin-bottom: 12px; border-radius: 22px; } @keyframes rise { from { transform: translateY(16px); opacity: 0; } } }

.modal-x {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; font-size: 14px; transition: .15s;
}
.modal-x:hover { color: var(--ink); border-color: var(--pink); }
.modal-title {
  font-family: var(--font-name); font-weight: 700; font-size: 20px; text-transform: uppercase;
  letter-spacing: .01em; margin-bottom: 16px; color: #fff;
}
.modal-title b { color: var(--green); }
.login-hint { font-size: 12px; color: var(--muted); letter-spacing: .04em; margin: -6px 0 16px; }

/* Form */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.field input, .field select {
  width: 100%; padding: 12px 13px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12);
  color: var(--ink); font-family: var(--font-disp); font-size: 15px; outline: none;
  transition: .15s;
}
.field input:focus, .field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(61,255,46,.14); }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237d9488' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field select option { background: var(--bg-2); }

.net-preview {
  display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 16px;
  border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--line);
}
.net-preview .link-ico { width: 40px; height: 40px; }
.net-preview .np-meta { display: flex; flex-direction: column; }
.np-meta .np-name { font-weight: 600; font-size: 14px; }
.np-meta .np-url { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn {
  flex: 1; padding: 13px; border-radius: 13px; cursor: pointer; border: none;
  font-family: var(--font-disp); font-weight: 600; font-size: 14.5px; letter-spacing: .03em;
  transition: .16s;
}
.btn-primary { color: var(--bg); background: linear-gradient(90deg, var(--green), var(--yellow)); box-shadow: 0 6px 22px rgba(61,255,46,.3); }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { color: var(--muted); background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { flex: none; width: 50px; color: var(--pink); background: rgba(255,62,166,.08); border: 1px solid rgba(255,62,166,.35); }
.btn-danger:hover { background: rgba(255,62,166,.16); }

.avatar-preview { display: flex; justify-content: center; margin-bottom: 16px; }
.avatar-preview img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2px solid var(--green); box-shadow: 0 0 20px rgba(61,255,46,.4); }
.file-row { display: flex; gap: 10px; }
.file-row .btn { flex: 1; }

/* =========================================================
   ENTRANCE ANIMATIONS
   ========================================================= */
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.topbar, .hero, .links > *, .add-capsule, .foot { animation: reveal .6s both; }
.topbar { animation-delay: .05s; }
.avatar-wrap { animation: reveal .7s both .1s; }
.name { animation: reveal .7s both .2s; }
.tagline { animation: reveal .7s both .3s; }
.eq { animation: reveal .7s both .38s; }
.foot { animation-delay: .5s; }

/* =========================================================
   ACCESSIBILITY
   ========================================================= */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .aurora, .grid-floor, .grain, .eq span, .avatar-glow, .ring { animation: none !important; }
}
