/* ============================================================
   profile — standalone page
   Flat near-black background, one soft glow, one glass card, and an
   intro that turns the word "hello" into a window onto the page.
   No external fonts, images or trackers at load.
   Theme comes from <html data-theme="green|purple">.
   ============================================================ */

/* Registered custom property so the avatar ring highlight can sweep
   smoothly. Browsers without @property simply keep it static. */
@property --ring-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

/* ------------------------------------------------------------
   Palettes
   ------------------------------------------------------------ */
:root {
  --radius-card: 28px;
  --radius-badge: 15px;
  --blur: 22px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="green"] {
  --bg: #02120a;
  --veil: #010b06;

  --text: #ecfdf3;
  --text-dim: rgba(220, 252, 231, 0.62);
  --text-faint: rgba(220, 252, 231, 0.42);

  --accent-soft: #86efac;
  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-deep: #15803d;

  --glow: rgba(34, 197, 94, 0.55);
  --glow-soft: rgba(34, 197, 94, 0.22);

  --card-base: rgba(6, 38, 21, 0.34);
  --card-border: rgba(134, 239, 172, 0.22);
  --card-solid: rgba(4, 22, 13, 0.94);
  --badge-solid: rgba(6, 30, 18, 0.88);
  --tip-bg: rgba(2, 15, 9, 0.94);
  --glow-paint: radial-gradient(circle, rgba(34, 197, 94, 0.42) 0%, rgba(21, 128, 61, 0.20) 42%, transparent 68%);
}

html[data-theme="purple"] {
  --bg: #050310;
  --veil: #04020a;

  --text: #f5f3ff;
  --text-dim: rgba(237, 233, 254, 0.62);
  --text-faint: rgba(237, 233, 254, 0.42);

  --accent-soft: #c4b5fd;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-deep: #7c3aed;

  --glow: rgba(139, 92, 246, 0.55);
  --glow-soft: rgba(139, 92, 246, 0.22);

  --card-base: rgba(24, 8, 40, 0.34);
  --card-border: rgba(196, 181, 253, 0.22);
  --card-solid: rgba(14, 6, 26, 0.94);
  --badge-solid: rgba(26, 10, 44, 0.88);
  --tip-bg: rgba(6, 3, 14, 0.94);
  --glow-paint: radial-gradient(circle, rgba(139, 92, 246, 0.42) 0%, rgba(76, 29, 149, 0.20) 42%, transparent 68%);
}

html[data-theme="magenta"] {
  --bg: #0a0308;
  --veil: #080206;

  --text: #fdf2f8;
  --text-dim: rgba(252, 231, 243, 0.62);
  --text-faint: rgba(252, 231, 243, 0.42);

  --accent-soft: #f9a8d4;
  --accent: #f472b6;
  --accent-strong: #ec4899;
  --accent-deep: #be185d;

  --glow: rgba(236, 72, 153, 0.55);
  --glow-soft: rgba(236, 72, 153, 0.22);

  --card-base: rgba(40, 8, 28, 0.34);
  --card-border: rgba(249, 168, 212, 0.22);
  --card-solid: rgba(26, 5, 18, 0.94);
  --badge-solid: rgba(44, 10, 30, 0.88);
  --tip-bg: rgba(14, 3, 9, 0.94);
  --glow-paint: radial-gradient(circle, rgba(236, 72, 153, 0.42) 0%, rgba(157, 23, 77, 0.20) 42%, transparent 68%);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ------------------------------------------------------------
   Background — flat near-black + one soft glow + grain
   ------------------------------------------------------------ */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg);
}

/* The single soft glow: it gives the glass card something to sit on and is
   what the intro's "hello" window shows through. */
.bg__glow {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--glow-paint);
  filter: blur(30px);
  pointer-events: none;
}

.bg__grain {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  pointer-events: none;
}

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
.page {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 28px 16px calc(28px + env(safe-area-inset-bottom));
  transition: transform 0.95s var(--ease);
}

/* The page behind the veil just eases back into place on dismiss. */
html.intro-open .page {
  transform: scale(1.04);
}

/* Outward wrapper owns the idle float so it never fights the JS pointer
   tilt, which drives transform on .card itself. */
.card-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  animation: breathe 7s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ------------------------------------------------------------
   Card
   ------------------------------------------------------------ */
.card {
  --mx: 50%;
  --my: 50%;
  position: relative;
  width: min(92vw, 420px);
  max-width: 100%;
  padding: clamp(30px, 6.5vw, 44px) clamp(22px, 5.5vw, 36px) clamp(26px, 5vw, 34px);
  border-radius: var(--radius-card);
  /* Low opacity so the glow behind reads through the blur — that is what
     makes it look like glass rather than a flat panel. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02) 34%),
    var(--card-base);
  border: 1px solid var(--card-border);
  box-shadow:
    0 30px 70px -24px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.25) inset,
    0 1px 0 rgba(255, 255, 255, 0.16) inset,
    0 0 90px -40px var(--glow);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(170%) brightness(1.06);
  backdrop-filter: blur(var(--blur)) saturate(170%) brightness(1.06);
  text-align: center;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.25s var(--ease);
  animation: card-in 0.9s var(--ease) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* top sheen */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 22%),
    radial-gradient(120% 60% at 50% -30%, var(--glow-soft), transparent 60%);
  pointer-events: none;
}

/* pointer-follow glow */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    260px circle at var(--mx, 50%) var(--my, 50%),
    var(--glow-soft),
    transparent 62%
  );
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 0;
}
.card:hover::before { opacity: 1; }

.card > * {
  position: relative;
  z-index: 1;
}

/* periodic light sweep across the glass */
.card__shimmer {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.06) 47%,
    rgba(255, 255, 255, 0.16) 50%,
    rgba(255, 255, 255, 0.06) 53%,
    transparent 62%
  );
  background-repeat: no-repeat;
  background-size: 260% 100%;
  pointer-events: none;
  animation: shimmer-sweep 6.5s ease-in-out infinite;
}

@keyframes shimmer-sweep {
  0%, 100% { background-position: 165% 0; }
  55%      { background-position: -65% 0; }
}

/* gradient rim — the single strongest "real glass" cue */
.card__rim {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.55),
    rgba(255, 255, 255, 0) 34%,
    var(--card-border) 100%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* faint grain so the surface reads as material, not a plane */
.card__grain {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 120px 120px;
  pointer-events: none;
}

/* ------------------------------------------------------------
   Avatar
   ------------------------------------------------------------ */
.avatar {
  position: relative;
  width: clamp(96px, 25vw, 112px);
  height: clamp(96px, 25vw, 112px);
  margin: 0 auto 20px;
  border-radius: 27px;
  padding: 3px;
  background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02) 58%, transparent 72%);
  border: 1px solid var(--card-border);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 28px var(--glow-soft),
    0 0 60px var(--glow-soft);
}

.avatar__ring {
  position: absolute;
  inset: -7px;
  border-radius: 33px;
  padding: 1.5px;
  background: conic-gradient(from var(--ring-angle, 0deg), transparent 0 55%, var(--accent-soft) 75%, transparent 100%);
  animation: ring-spin 8s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

.avatar__img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  object-fit: cover;
  background: transparent;
}

@keyframes ring-spin {
  to { --ring-angle: 360deg; }
}

/* ------------------------------------------------------------
   Text
   ------------------------------------------------------------ */
.name {
  margin: 0 0 6px;
  font-size: clamp(1.9rem, 7.5vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  background: linear-gradient(
    100deg,
    #ffffff 0%,
    var(--accent-soft) 34%,
    var(--accent-strong) 52%,
    var(--accent) 68%,
    #ffffff 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 18px var(--glow-soft));
  animation: name-shift 7s ease-in-out infinite;
}

@keyframes name-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.handle {
  margin: 0 0 26px;
  font-size: clamp(0.85rem, 3.4vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-dim);
  min-height: 1.4em;
}

/* the caret is a small dot sitting on the baseline, like a typed period */
.cursor {
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  margin-left: 5px;
  vertical-align: baseline;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 0 10px var(--glow-soft);
  animation: cursor-pulse 1.15s ease-in-out infinite;
}

@keyframes cursor-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.22; }
}

/* ------------------------------------------------------------
   Badge row
   ------------------------------------------------------------ */
.badges {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-badge);
  background: var(--badge-bg, rgba(255, 255, 255, 0.055));
  border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 10px 24px -14px rgba(0, 0, 0, 0.8);
  transition:
    transform 0.22s var(--ease),
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.badge__icon {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
  transition: transform 0.22s var(--ease), filter 0.22s ease;
}

.badge__icon--steam { filter: drop-shadow(0 0 6px var(--glow-soft)); }

/* idle breathing glow — pre-rendered shadow faded in/out (cheap) */
.badge::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  box-shadow: 0 0 16px 2px var(--glow-soft);
  opacity: 0;
  animation: badge-pulse 4.5s ease-in-out infinite;
  pointer-events: none;
}

.badge:nth-child(2)::before { animation-delay: 1.5s; }
.badge:nth-child(3)::before { animation-delay: 3s; }
.badge:nth-child(4)::before { animation-delay: 4.5s; }

@keyframes badge-pulse {
  0%, 100% { opacity: 0; }
  50%      { opacity: 0.9; }
}

.badge:hover,
.badge:focus-visible {
  transform: translateY(-5px);
  background: var(--glow-soft);
  border-color: var(--accent-soft);
  box-shadow:
    0 0 0 1px var(--card-border),
    0 14px 34px -12px var(--glow),
    0 0 26px -6px var(--glow);
  outline: none;
}

.badge:hover .badge__icon,
.badge:focus-visible .badge__icon {
  transform: scale(1.12);
}

.badge:active { transform: translateY(-2px) scale(0.98); }

.badge:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 3px;
}

/* tooltip */
.badge__tip {
  position: absolute;
  z-index: 2;
  bottom: calc(100% + 11px);
  left: 50%;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--tip-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.badge__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--tip-bg);
}

.badge:hover .badge__tip,
.badge:focus-visible .badge__tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ------------------------------------------------------------
   Hello intro — the word is a window onto the page
   ------------------------------------------------------------ */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  transition: opacity 0.55s ease 0.3s;
  /* No background of its own: the veil paints the black, and the mask
     punches the "hello" out of it so the live page shows through. */
}

/* opening: the veil fades while the window blooms */
.intro.is-opening {
  opacity: 0;
  pointer-events: none;
}

/* One full-screen SVG: a black rect with the "hello" masked out of it. */
.intro__veil {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.intro__curtain {
  fill: var(--veil);
}

/* The stroke *is* the window: black inside a luminance mask means "cut this
   out", so the shape you see through it is the live page behind the veil. */
.intro__stroke {
  fill: none;
  stroke: #000;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* hidden until the draw starts */
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-width 0.7s var(--ease);
}

/* opening: the window blooms outwards as the veil fades away */
.intro.is-opening .intro__stroke {
  stroke-width: 90;
}

/* pathLength="1" normalises the path; JS overrides with the measured length
   for engines that ignore pathLength in dash arithmetic. */
.intro.is-drawing .intro__stroke {
  animation: intro-draw 2.6s cubic-bezier(0.5, 0.05, 0.2, 1) forwards;
}

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

.intro__hint {
  position: absolute;
  bottom: max(2.5rem, calc(1.5rem + env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.66);
  font: inherit;
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: opacity 0.8s ease 0.2s, color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.intro.is-ready .intro__hint {
  opacity: 1;
}

.intro__hint:hover,
.intro__hint:focus-visible {
  color: #fff;
  background: var(--glow-soft);
  border-color: var(--accent-soft);
}

.intro__hint:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   Small screens
   ------------------------------------------------------------ */
@media (max-width: 380px) {
  :root { --radius-card: 22px; --radius-badge: 13px; }
  .card { padding: 28px 18px 24px; }
  .badges { gap: 13px; }
  .badge { width: 46px; height: 46px; }
  .badge__icon { width: 24px; height: 24px; }
}

/* ------------------------------------------------------------
   Fallback when backdrop-filter is unsupported
   ------------------------------------------------------------ */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--card-solid); }
  .badge { background: var(--badge-solid); }
  .intro__hint { background: var(--card-solid); }
  .badge__tip { background: var(--tip-bg); }
}

/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  /* This is a personal profile whose whole point is its motion, so the ambient
     animations (avatar-ring sweep, cursor, shimmer, name gradient, badge pulse)
     are kept. Only the pointer tilt and the page settle are dropped. */
  .card { transform: none !important; }
  .page { transition: none; }
  html.intro-open .page { transform: none; }
}
