/* links page: Liquid Glass by default, plus solid Midnight and Paper themes. */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: #7aa2ff;
  --accent-rgb: 122 162 255;
  --glass-alpha: 0.12;
  --glass-blur: 18px;
  --radius: 20px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Glass, dark */
  --bg: #0b0f1a;
  --ink: #f3f5fa;
  --ink-2: rgb(243 245 250 / 0.76);
  --ink-3: rgb(243 245 250 / 0.62);
  --surface: rgb(255 255 255 / var(--glass-alpha));
  --surface-top: rgb(255 255 255 / calc(var(--glass-alpha) + 0.06));
  --surface-solid: #1b2132;
  --sheet: rgb(22 27 42 / 0.82);
  --edge: rgb(255 255 255 / 0.18);
  --edge-strong: rgb(255 255 255 / 0.34);
  --hi: rgb(255 255 255 / 0.22);
  --chip: rgb(255 255 255 / 0.09);
  --shadow: 0 10px 28px -16px rgb(0 0 0 / 0.7);
  --shadow-lift: 0 18px 38px -18px rgb(0 0 0 / 0.75);
  --vignette: radial-gradient(120% 90% at 50% 0%, transparent 40%, rgb(0 0 0 / 0.45) 100%);
  --blob-opacity: 0.45;
  --scrim: rgb(8 11 20 / 0.42);
  --text-shadow: 0 1px 2px rgb(0 0 0 / 0.28);
}

/* Glass, light (explicit, or following the system when mode is auto) */
html[data-theme="glass"][data-mode="light"] {
  --bg: #e9edf5;
  --ink: #121726;
  --ink-2: rgb(18 23 38 / 0.74);
  --ink-3: rgb(18 23 38 / 0.54);
  --surface: rgb(255 255 255 / calc(var(--glass-alpha) + 0.36));
  --surface-top: rgb(255 255 255 / calc(var(--glass-alpha) + 0.5));
  --surface-solid: #ffffff;
  --sheet: rgb(248 250 253 / 0.86);
  --edge: rgb(255 255 255 / 0.75);
  --edge-strong: rgb(255 255 255 / 0.95);
  --hi: rgb(255 255 255 / 0.9);
  --chip: rgb(18 23 38 / 0.06);
  --shadow: 0 10px 26px -16px rgb(30 40 70 / 0.35);
  --shadow-lift: 0 18px 36px -18px rgb(30 40 70 / 0.4);
  --vignette: none;
  --blob-opacity: 0.42;
  --scrim: rgb(255 255 255 / 0.4);
  --text-shadow: none;
}
@media (prefers-color-scheme: light) {
  html[data-theme="glass"][data-mode="auto"] {
    --bg: #e9edf5;
    --ink: #121726;
    --ink-2: rgb(18 23 38 / 0.74);
    --ink-3: rgb(18 23 38 / 0.54);
    --surface: rgb(255 255 255 / calc(var(--glass-alpha) + 0.36));
    --surface-top: rgb(255 255 255 / calc(var(--glass-alpha) + 0.5));
    --surface-solid: #ffffff;
    --sheet: rgb(248 250 253 / 0.86);
    --edge: rgb(255 255 255 / 0.75);
    --edge-strong: rgb(255 255 255 / 0.95);
    --hi: rgb(255 255 255 / 0.9);
    --chip: rgb(18 23 38 / 0.06);
    --shadow: 0 10px 26px -16px rgb(30 40 70 / 0.35);
    --shadow-lift: 0 18px 36px -18px rgb(30 40 70 / 0.4);
    --vignette: none;
    --blob-opacity: 0.42;
    --scrim: rgb(255 255 255 / 0.4);
    --text-shadow: none;
  }
}

/* Midnight: solid charcoal, like Linktree's "Air Black" */
html[data-theme="midnight"] {
  --bg: #2a3236;
  --ink: #ffffff;
  --ink-2: rgb(255 255 255 / 0.78);
  --ink-3: rgb(255 255 255 / 0.56);
  --surface-solid: #222222;
  --sheet: #222222;
  --edge: #222222;
  --edge-strong: rgb(255 255 255 / 0.35);
  --chip: rgb(255 255 255 / 0.07);
  --radius: 10px;
  --shadow: 0 2px 8px rgb(255 255 255 / 0.12);
  --shadow-lift: 0 4px 14px rgb(255 255 255 / 0.18);
}

/* Paper: warm and light */
html[data-theme="paper"] {
  --bg: #f5f2ec;
  --ink: #1f1c17;
  --ink-2: #4d473e;
  --ink-3: #7a7368;
  --surface-solid: #fffdf9;
  --sheet: #fffdf9;
  --edge: #e4ddd0;
  --edge-strong: #cfc6b6;
  --chip: #f3eee5;
  --radius: 16px;
  --shadow: 0 6px 18px -12px rgb(60 45 20 / 0.35);
  --shadow-lift: 0 12px 26px -14px rgb(60 45 20 / 0.4);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; }
button { font: inherit; }
:focus-visible { outline: 2px solid rgb(var(--accent-rgb)); outline-offset: 3px; }

/* Background */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; background: var(--bg); }
.backdrop::after { content: ""; position: absolute; inset: 0; background: var(--vignette); }
.blob {
  position: absolute;
  border-radius: 50%;
  background: rgb(var(--accent-rgb));
  opacity: var(--blob-opacity);
  will-change: transform;
}
.b1 { width: 62vmax; height: 62vmax; left: -22vmax; top: -26vmax; filter: blur(80px); animation: drift-a 38s var(--ease) infinite alternate; }
.b2 { width: 52vmax; height: 52vmax; right: -20vmax; bottom: -24vmax; filter: blur(90px) hue-rotate(75deg); opacity: calc(var(--blob-opacity) * 0.75); animation: drift-b 46s var(--ease) infinite alternate; }
.b3 { width: 36vmax; height: 36vmax; right: 6vmax; top: -16vmax; filter: blur(80px) hue-rotate(-70deg); opacity: calc(var(--blob-opacity) * 0.6); animation: drift-c 54s var(--ease) infinite alternate; }
@keyframes drift-a { to { transform: translate(14vmax, 10vmax) scale(1.08); } }
@keyframes drift-b { to { transform: translate(-12vmax, -8vmax) scale(1.12); } }
@keyframes drift-c { to { transform: translate(-16vmax, 14vmax) scale(0.92); } }
html[data-theme="midnight"] .backdrop:not(.has-image), html[data-theme="paper"] .backdrop:not(.has-image) { display: none; }
.bg-image, .bg-dim { position: absolute; inset: 0; }
.bg-image { background-position: center; background-size: cover; background-repeat: no-repeat; }
.bg-dim { background: var(--bg); }

/* Layout */
.page {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 580px);
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 0 max(32px, env(safe-area-inset-bottom));
}

/* Surfaces */
.glass {
  background: linear-gradient(180deg, var(--surface-top), var(--surface));
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 var(--hi), var(--shadow);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(170%);
  backdrop-filter: blur(var(--glass-blur)) saturate(170%);
}
html[data-theme="midnight"] .glass,
html[data-theme="paper"] .glass {
  background: var(--surface-solid);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: var(--shadow);
}
html[data-theme="paper"] .glass { box-shadow: inset 0 1px 0 #fff, var(--shadow); }

/* Profile */
.profile { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; }
.share-btn {
  position: absolute;
  top: -6px;
  right: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s;
}
.share-btn svg { width: 19px; height: 19px; }
.avatar-ring {
  padding: 3px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, rgb(var(--accent-rgb)), rgb(255 255 255 / 0.7), rgb(var(--accent-rgb) / 0.35), rgb(var(--accent-rgb)));
  box-shadow: 0 18px 50px -20px rgb(var(--accent-rgb) / 0.8);
}
html[data-theme="paper"] .avatar-ring { background: var(--edge-strong); box-shadow: var(--shadow); }
.avatar { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); background: var(--chip); }
.name { margin: 18px 0 0; font: 700 clamp(1.6rem, 5vw, 1.95rem) / 1.15 var(--font-display); letter-spacing: -0.015em; }
.handle { margin: 4px 0 0; color: var(--ink-3); font-size: 0.95rem; }
.bio { margin: 12px auto 0; max-width: 42ch; color: var(--ink-2); text-wrap: balance; }
.socials { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.social {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
}
.social svg { width: 20px; height: 20px; }
@media (max-width: 400px) {
  .socials { gap: 7px; }
  .social { width: 40px; height: 40px; }
  .social svg { width: 19px; height: 19px; }
}

/* Links */
.links { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }
.section-title {
  margin: 16px 0 0;
  color: var(--ink-3);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.links > .section-title:first-child { margin-top: 0; }
.link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.18s var(--ease), border-color 0.18s, box-shadow 0.18s;
}
.link-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: calc(var(--radius) - 7px);
  display: grid;
  place-items: center;
  background: var(--chip);
}
.link-icon svg { width: 22px; height: 22px; }
.link-thumb { width: 44px; height: 44px; border-radius: inherit; object-fit: cover; }
.link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
html[data-theme="glass"] .link-text, html[data-theme="glass"] .profile { text-shadow: var(--text-shadow); }
.link-label { font-weight: 620; font-size: 1.02rem; line-height: 1.25; overflow-wrap: anywhere; }
.link-desc { margin-top: 2px; color: var(--ink-2); font-size: 0.86rem; line-height: 1.3; }
.link-go { flex: none; width: 44px; display: grid; place-items: center; color: var(--ink-3); transition: transform 0.2s var(--ease), color 0.2s; }
.link-go svg { width: 18px; height: 18px; }
.link:active, .social:active, .share-btn:active { transform: scale(0.97); }
@media (hover: hover) {
  .link:hover, .social:hover, .share-btn:hover { transform: translateY(-2px); border-color: var(--edge-strong); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); }
  .link:hover .link-go { color: var(--ink); transform: translate(2px, -2px); }
  .has-embed .link:hover .link-go { transform: translateY(2px); }
  html[data-theme="midnight"] .link:hover, html[data-theme="midnight"] .social:hover { box-shadow: var(--shadow-lift); }
}

/* Featured link */
.link.featured {
  border: 1.5px solid transparent;
  background:
    linear-gradient(180deg, rgb(var(--accent-rgb) / 0.22), rgb(var(--accent-rgb) / 0.1)) padding-box,
    linear-gradient(var(--scrim), var(--scrim)) padding-box,
    linear-gradient(135deg, rgb(var(--accent-rgb)), rgb(255 255 255 / 0.6), rgb(var(--accent-rgb) / 0.45)) border-box;
}
html[data-theme="midnight"] .link.featured { background: linear-gradient(#222, #222) padding-box, linear-gradient(135deg, rgb(var(--accent-rgb)), rgb(var(--accent-rgb) / 0.35)) border-box; }
html[data-theme="paper"] .link.featured { background: linear-gradient(#fffdf9, #fffdf9) padding-box, linear-gradient(135deg, rgb(var(--accent-rgb)), rgb(var(--accent-rgb) / 0.4)) border-box; }
.link.featured { box-shadow: inset 0 1px 0 var(--hi), 0 14px 34px -20px rgb(var(--accent-rgb) / 0.9); }
.link.featured .link-icon { background: rgb(var(--accent-rgb) / 0.22); }
.link.featured::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgb(255 255 255 / 0.22) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 7s var(--ease) 1.2s infinite;
  pointer-events: none;
}
@keyframes sheen { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

/* Inline players */
.has-embed .link[aria-expanded="true"] .link-go { transform: rotate(180deg); }
.embed-panel { margin-top: 8px; border-radius: var(--radius); overflow: hidden; padding: 6px; }
.embed-panel iframe { display: block; width: 100%; border: 0; border-radius: calc(var(--radius) - 6px); background: rgb(0 0 0 / 0.2); }
.embed-panel .embed-spotify { height: 152px; }
.embed-panel .embed-spotify.tall { height: 352px; }
.embed-panel .embed-youtube { aspect-ratio: 16 / 9; height: auto; }
.embed-out { display: inline-flex; align-items: center; gap: 6px; margin: 8px 6px 2px; color: var(--ink-2); font-size: 0.84rem; text-decoration: none; }
.embed-out:hover { color: var(--ink); text-decoration: underline; }
.embed-out svg { width: 14px; height: 14px; }

/* Footer */
.foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; margin-top: 40px; color: var(--ink-3); font-size: 0.82rem; }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.ver { font-variant-numeric: tabular-nums; opacity: 0.75; }

/* Share sheet */
.share-sheet { width: min(100% - 32px, 380px); max-width: none; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
.share-sheet::backdrop { background: rgb(5 8 15 / 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.share-sheet[open] .sheet-inner { animation: sheet-in 0.26s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.sheet-inner { border-radius: 28px; padding: 18px 18px 20px; background: var(--sheet); }
html[data-theme="midnight"] .sheet-inner, html[data-theme="paper"] .sheet-inner { background: var(--sheet); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0 0 0 4px; font: 650 1.1rem/1.2 var(--font-display); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--chip); color: var(--ink); cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }
.qr-tile { width: min(100%, 248px); margin: 14px auto 0; padding: 10px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px -16px rgb(0 0 0 / 0.5); }
.qr-tile svg { width: 100%; height: auto; }
.share-url { margin: 12px 0 0; text-align: center; font-weight: 620; overflow-wrap: anywhere; }
.share-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 620;
  text-decoration: none;
  cursor: pointer;
}
.pill svg { width: 17px; height: 17px; }

/* Entrance */
@media (prefers-reduced-motion: no-preference) {
  html[data-motion="on"] .profile, html[data-motion="on"] .links > * { animation: rise 0.55s var(--ease) both; }
  html[data-motion="on"] .links > * { animation-delay: calc(var(--n, 0) * 40ms + 120ms); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* Editor preview marks for links visitors can't see */
[data-preview] [data-draft-hidden] { opacity: 0.45; position: relative; }
[data-preview] [data-draft-hidden]::before {
  content: "Hidden";
  position: absolute;
  z-index: 2;
  top: -7px;
  left: 14px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[data-preview] [data-draft-hidden="scheduled"]::before { content: "Scheduled"; }

/* Fallbacks: no blur support, reduced transparency, high contrast, reduced motion */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface-solid); }
  .sheet-inner { background: var(--surface-solid); }
}
html.no-glass .glass, html.no-glass .sheet-inner { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-reduced-transparency: reduce) {
  .glass, .sheet-inner { background: var(--surface-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .backdrop .blob { display: none; }
}
@media (forced-colors: active) {
  .glass, .sheet-inner, .link.featured { background: Canvas; border: 1px solid CanvasText; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; forced-color-adjust: auto; }
  .link.featured { border: 2px solid Highlight; }
  .link.featured::after, .backdrop { display: none; }
}
html[data-motion="off"] .blob, html[data-motion="off"] .link.featured::after { animation: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
