/* ---------- Fonts (self-hosted, OFL licensed) ---------- */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-var.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Design tokens ---------- */
:root {
  --bg: #0b0b0d;
  --bg-raised: #131316;
  --border: #232328;
  --text: #e7e7ea;
  --text-dim: #a1a1aa;
  --text-faint: #6b6b74;
  --accent: #d97a3f;
  --graph-line: rgba(160, 160, 175, 0.3);
  --sidebar-w: 340px;
  --content-w: 660px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fbfbfa;
  --bg-raised: #f2f1ee;
  --border: #e2e0da;
  --text: #1a1a1a;
  --text-dim: #55534d;
  --text-faint: #8a877e;
  --accent: #b85f27;
  --graph-line: rgba(90, 90, 100, 0.28);
  color-scheme: light;
}

/* Dark is the default on purpose, regardless of the OS setting. Light is
   opt-in through the toggle only. */

* { box-sizing: border-box; }

html, body { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "cv05" 1, "ss03" 1;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

p { margin: 0 0 1.2em; }
p:last-child { margin-bottom: 0; }

.skip-link {
  position: absolute;
  left: -999px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  z-index: 1000;
}
.skip-link:focus { left: 16px; top: 16px; }

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

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  border-right: 1px solid var(--border);
}

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 52px 40px;
  overflow-y: auto;
}

.identity { text-decoration: none; display: block; margin-bottom: 18px; flex-shrink: 0; }

.identity-name {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.identity-role {
  display: block;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}

.identity-lede {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0 0 24px;
  flex-shrink: 0;
}

/* ---------- Discord presence card ---------- */
.presence {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 28px;
  background: var(--bg-raised);
  position: relative;
  overflow: hidden;
  /* The sidebar is a fixed-height column flex container. Without this the
     card is the first thing flex squashes on a short viewport, clipping the
     status text. */
  flex-shrink: 0;
}

.presence-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #747f8d;
  flex-shrink: 0;
}
.presence-dot[data-status="online"] { background: #23a55a; }
.presence-dot[data-status="idle"]   { background: #f0b232; }
.presence-dot[data-status="dnd"]    { background: #f23f43; }

.presence-body {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.presence[data-mode="idle"] .presence-body { display: none; }

.presence-art img {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: 5px;
  object-fit: cover;
}

.presence-detail {
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 0;
  line-height: 1.4;
}

.presence-song {
  display: block;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-sep { color: var(--text-faint); font-size: 0.78rem; }
.presence-artist { font-size: 0.8rem; }

.presence-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--border);
}
.presence-progress::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  transition: width 1s linear;
}

/* ---------- Sidebar nav ---------- */
.site-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: auto;
}

.site-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 8px 12px;
  margin-left: -12px;
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--text-faint);
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text);
  border-left-color: var(--accent);
}

.nav-index { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint); }

.social-row {
  list-style: none;
  display: flex;
  gap: 18px;
  margin: 32px 0 18px;
  padding: 0;
}
.social-row a { color: var(--text-faint); transition: color 0.15s ease; }
.social-row a:hover { color: var(--accent); }
.social-row svg { width: 19px; height: 19px; display: block; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-faint);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  cursor: pointer;
  width: fit-content;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { width: 14px; height: 14px; }

.icon-sun, .icon-moon { display: none; }
:root:not([data-theme="light"]) .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ---------- Main column ---------- */
main {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 52px 48px 80px;
}

.section {
  max-width: var(--content-w);
  padding-top: 56px;
  border-top: 1px solid var(--border);
}
.section:first-child, #hero { border-top: none; padding-top: 0; }

/* ---------- Hero ---------- */
#hero {
  position: relative;
  /* Break out of the content column so the field spans the whole area. */
  margin: -52px -48px 0;
  padding: 52px 48px 0;
  max-width: none;
  min-height: min(74vh, 620px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  isolation: isolate;
}

.hero-canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  /* Visible if WebGL is unavailable or the shader fails to compile. */
  background:
    radial-gradient(120% 90% at 30% 15%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    var(--bg);
}

#hero-shader {
  display: block;
  width: 100%;
  height: 100%;
  /* Rendered below device resolution on purpose; let the GPU smooth it. */
  image-rendering: auto;
}

.hero-title {
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  line-height: 1.28;
  font-weight: 600;
  letter-spacing: -0.025em;
  max-width: 22ch;
  margin: 0 0 40px;
  position: relative;
}

/* Each line is a mask; the inner span slides up out of it. */
.hero-title .line {
  display: block;
  overflow: hidden;
}

.hero-title .line > span {
  display: block;
}

/* Hidden start state only when scripting is on, so a no-JS page still reads. */
:root.js .hero-title .line > span {
  transform: translateY(105%);
  opacity: 0;
}

:root.is-ready .hero-title .line > span {
  animation: line-rise 0.9s cubic-bezier(0.16, 0.84, 0.28, 1) forwards;
}
.hero-title .line:nth-child(1) > span { animation-delay: 0.05s; }
.hero-title .line:nth-child(2) > span { animation-delay: 0.14s; }
.hero-title .line:nth-child(3) > span { animation-delay: 0.23s; }

@keyframes line-rise {
  to { transform: translateY(0); opacity: 1; }
}

/* The graph fades in just behind the headline, a beat later. */
.graph-wrap {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s ease 0.45s, transform 0.7s ease 0.45s;
}
.graph-wrap.is-shown {
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 0 0 24px;
}
.section-index { font-family: var(--font-mono); color: var(--accent); }

.section p { color: var(--text-dim); max-width: 62ch; }

.section-note {
  font-size: 0.88rem;
  color: var(--text-faint);
  margin-top: -12px;
}

.minor-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 12px;
}

/* ---------- Repo graph ---------- */
.graph-wrap {
  margin: 0 0 8px;
  max-width: var(--content-w);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 12px;
  /* Sits over the shader field, so it is glass rather than a solid panel. */
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  overflow: hidden;
}

#repo-graph {
  display: block;
  width: 100%;
  height: 400px;
  touch-action: none;
}

.graph-wrap figcaption {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-faint);
  line-height: 1.5;
}

/* ---------- GitHub stats ---------- */
.stats-wrap { margin-bottom: 36px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stat {
  background: var(--bg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}
.stat-value-text { font-size: 1rem; padding-top: 6px; }

.stat-label {
  font-size: 0.74rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Language bar ---------- */
.lang-block { margin-bottom: 40px; }

.lang-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.lang-seg { display: block; height: 100%; }

.lang-legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.lang-legend li { display: flex; align-items: center; gap: 6px; }
.lang-legend .dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.lang-legend .muted { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.76rem; }

/* ---------- Activity heatmap ---------- */
.activity-block { margin-bottom: 40px; }

.activity-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.activity-grid .cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
}
.cell-empty { background: transparent; border-color: transparent; }
.cell[data-level="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--bg-raised)); border-color: transparent; }
.cell[data-level="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--bg-raised)); border-color: transparent; }
.cell[data-level="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--bg-raised)); border-color: transparent; }
.cell[data-level="4"] { background: var(--accent); border-color: transparent; }

.activity-summary {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}

/* ---------- Skills ---------- */
.skills-list { margin: 0; display: grid; gap: 0; }

.skills-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.skills-row:last-child { border-bottom: none; }
.skills-row dt { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-faint); }
.skills-row dd { margin: 0; min-width: 0; color: var(--text-dim); font-size: 0.93rem; }

/* ---------- Projects ---------- */
.projects-list { display: grid; gap: 44px; }

.project-heading h3 { margin: 0; font-size: 1.08rem; font-weight: 600; }
.project-heading h3 a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.project-heading h3 a:hover { color: var(--accent); border-color: var(--accent); }

.project-stack {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-faint);
  margin: 4px 0 0;
}

.project-live {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent);
  margin: 4px 0 10px;
}

.project p { color: var(--text-dim); max-width: 62ch; }

.project ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 0.88rem;
  display: grid;
  gap: 6px;
}

/* ---------- Other repositories ---------- */
.other-repos-wrap { margin-top: 48px; }

.other-repos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.repo-card a {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  text-decoration: none;
  background: var(--bg-raised);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.repo-card a:hover { border-color: var(--accent); transform: translateY(-2px); }

.repo-name {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
}

.repo-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: auto;
  padding-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
}
.repo-lang { display: flex; align-items: center; gap: 5px; }
.repo-lang .dot { width: 7px; height: 7px; border-radius: 50%; }

.more-projects { margin-top: 36px; font-size: 0.9rem; color: var(--text-faint); }
.more-projects a, #contact a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.more-projects a:hover, #contact a:hover { border-color: var(--accent); }

/* ---------- Music ---------- */
.artists {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px 20px;
}

.artist { display: flex; align-items: center; gap: 11px; min-width: 0; }

.artist img, .artist-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-raised);
}

.artist-meta { min-width: 0; display: flex; flex-direction: column; }
.artist-meta strong {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist-meta small { font-size: 0.75rem; color: var(--text-faint); }

.tracks {
  list-style: none;
  margin: 30px 0 0;
  padding: 0;
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}

.track {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
}

.track-rank {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

.track-meta { min-width: 0; display: flex; flex-direction: column; }
.track-meta strong {
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-meta small { font-size: 0.74rem; color: var(--text-faint); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.8rem;
  max-width: var(--content-w);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.site-footer p { margin: 0; }
.footer-note { font-family: var(--font-mono); font-size: 0.74rem; }

/* ---------- Mobile nav toggle ---------- */
.nav-toggle {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.nav-toggle svg { width: 18px; height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-inner { padding: 22px 22px 18px; overflow: visible; }
  .identity-lede { margin-bottom: 18px; }
  .presence { margin-bottom: 18px; }

  .site-nav {
    position: fixed;
    inset: 0 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 72px 22px 18px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 150;
  }
  .site-nav.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .site-nav a { padding: 12px; margin-left: 0; }

  .social-row { margin: 14px 0; }
  .nav-toggle { display: flex; }

  main { padding: 30px 22px 60px; }
  #repo-graph { height: 280px; }
  .site-footer { margin-top: 56px; }

  /* Keep the hero's full-bleed break-out in step with main's padding. */
  #hero {
    margin: -30px -22px 0;
    padding: 30px 22px 0;
    min-height: auto;
  }
  .hero-title { max-width: none; margin-bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
  .presence-progress::after { transition: none; }
  /* The entrance animation is the only thing hiding this text, so it has to
     be visible unconditionally when animation is off. */
  .hero-title .line > span { transform: none; opacity: 1; }
  .graph-wrap { opacity: 1; transform: none; }
}
