/* ---------- Font (self-hosted variable font, weights 300-700) ---------- */
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: block; /* preloaded 22 KB: brief FOIT beats layout shift from swap */
}

/* ---------- Design tokens: change these to restyle the whole page ---------- */
:root {
  color-scheme: light dark; /* follows the visitor's system setting by default */

  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --card-width: 40rem; /* card size: try 48rem for an even wider card */
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --gap: 0.75rem;
  --speed: 160ms; /* shared transition timing; disabled under reduced motion */

  /* light-dark(light value, dark value) */
  --bg: light-dark(#f4f4f5, #09090b);
  --surface: light-dark(#fff, #141417);
  --surface-glass: light-dark(rgb(255 255 255 / 0.85), rgb(20 20 23 / 0.8));
  --fg: light-dark(#18181b, #f4f4f5);
  --muted: light-dark(#52525b, #a1a1aa);
  --line: light-dark(#e4e4e7, #26262b);
  --border: light-dark(#18181b, #f4f4f5);
  --shadow:
    0 1px 2px light-dark(rgb(24 24 27 / 0.08), rgb(255 255 255 / 0.05)),
    0 8px 24px light-dark(rgb(24 24 27 / 0.16), rgb(255 255 255 / 0.09)),
    0 28px 64px light-dark(rgb(24 24 27 / 0.14), rgb(255 255 255 / 0.07)),
    0 0 0 1px light-dark(rgb(24 24 27 / 0.04), rgb(255 255 255 / 0.12));

  /* Background */
  --bg-top: light-dark(#eef4fb, #050506);
  --bg-bottom: light-dark(#faf3ec, #131316);
  --accent: #4f8ef7; /* calm blue; overridden from links.js */
  --accent-2: #ff9d63; /* warm peach; overridden from links.js */
  --grid: light-dark(rgb(24 24 27 / 0.16), rgb(255 255 255 / 0.14));
}
/* Manual override set by the theme toggle */
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}

@media (min-width: 64rem) {
  :root {
    --card-width: 44rem;
  }
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
  display: grid;
  place-items: center; /* centers the card on large screens */
  padding: clamp(1rem, 4vw, 3rem);
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem / 1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Card ---------- */
/* Reveal the card only once JS has filled it: everything appears at once in
   its final position, so hydration never causes a layout shift (CLS). */
html.js main {
  opacity: 0;
  transition: opacity 180ms ease;
}
html.js main.ready {
  opacity: 1;
}

main {
  width: min(100%, var(--card-width));
  padding: clamp(1.5rem, 4.5vw, 2.75rem);
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid light-dark(rgb(24 24 27 / 0.15), rgb(255 255 255 / 0.16));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* ---------- Profile ---------- */
.profile {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  overflow: hidden;
  background: var(--bg);
  border-radius: calc(var(--radius) + 0.25rem);
  outline: 2px solid var(--accent);
  outline-offset: 3px; /* accent ring: the small detail */
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.who {
  min-width: 0;
  flex: 1;
}
h1 {
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.role {
  color: var(--muted);
  font-weight: 500;
}
.bio {
  margin-top: 1.25rem;
  max-width: 60ch;
  color: var(--muted);
}

/* Reserve the toggle's spot before JS upgrades it (avoids a header shift) */
theme-toggle {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
}

/* ---------- Tiles (icon squares shared by buttons, socials and the toggle) ---------- */
.tile {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 0.25rem);
  cursor: pointer;
  transition:
    background var(--speed) ease,
    transform var(--speed) ease;
}
.tile:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

/* ---------- Link buttons ---------- */
#links {
  display: grid;
  gap: var(--gap);
  margin-top: 1.75rem;
}
.link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  background: var(--brand, var(--surface));
  color: var(--text, var(--fg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.125rem;
  font-weight: 600;
  transition:
    background var(--speed) ease,
    border-color var(--speed) ease,
    transform var(--speed) ease,
    box-shadow var(--speed) ease;
}
/* A quiet lift instead of a hard shadow: pressable but calm */
.link:hover,
.socials a:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 6px 16px light-dark(rgb(24 24 27 / 0.1), rgb(0 0 0 / 0.4));
}
.link:active,
.socials a:active {
  transform: translateY(0);
  box-shadow: none;
}
/* Colored buttons keep their own border from the brand color */
.link[style*="--brand"]:hover {
  border-color: transparent;
  filter: brightness(1.08);
}

/* ---------- Socials ---------- */
hr {
  margin: 2rem 0 1.5rem;
  border: 0;
  border-top: 1px solid var(--line);
}
.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.socials a {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
}

/* ---------- Reduced motion: transitions off, states still visible ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Footer (outside the card) ---------- */
footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Background: perspective grid ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}
.bg svg {
  display: block;
  width: 100%;
  height: 100%;
}
.bg path {
  fill: none;
  stroke: var(--grid);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* Fade the lines near the horizon so they don't pile up (--h is the horizon height, set by bg.js) */
.bg[data-grid="floor"] svg {
  -webkit-mask-image: linear-gradient(to bottom, transparent var(--h), #000 calc(var(--h) + 35%));
  mask-image: linear-gradient(to bottom, transparent var(--h), #000 calc(var(--h) + 35%));
}
.bg[data-grid="both"] svg {
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent var(--h), #000 calc(var(--h) + 35%));
  mask-image: linear-gradient(to bottom, #000 0%, transparent var(--h), #000 calc(var(--h) + 35%));
}

/* Dots: a fine dot grid that fades out toward the edges */
.bg[data-style="dots"]::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--grid) 1px, transparent 1.5px);
  background-size: 24px 24px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 25%, transparent 80%);
  mask-image: radial-gradient(ellipse at 50% 45%, #000 25%, transparent 80%);
}

/* Glow: two soft lights (cool blue top right, warm peach bottom left) over the gradient.
   Colors come from links.js (--accent / --accent-2). */
.bg[data-style="glow"] {
  --tint-1: light-dark(
    color-mix(in srgb, var(--accent) 14%, transparent),
    color-mix(in srgb, var(--accent) 22%, transparent)
  );
  --tint-2: light-dark(
    color-mix(in srgb, var(--accent-2) 20%, transparent),
    color-mix(in srgb, var(--accent-2) 10%, transparent)
  );
  background:
    radial-gradient(ellipse 80% 50% at 85% 0%, var(--tint-1), transparent 70%),
    radial-gradient(ellipse 70% 45% at 10% 100%, var(--tint-2), transparent 70%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}
