:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --ink: #f0f0ec;
  --ink-2: #b4b5ae;
  --ink-3: #83847e;
  --ink-4: #55565a;
  --accent: #8db4e2;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* --- background layers --- */
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(100deg, rgba(12, 13, 16, 0.9) 0%, rgba(12, 13, 16, 0.62) 42%, rgba(12, 13, 16, 0.12) 72%),
    radial-gradient(120% 90% at 50% 50%, rgba(12, 13, 16, 0) 55%, rgba(12, 13, 16, 0.7) 100%);
}

/* --- content --- */
.page {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 6vh, 84px) clamp(24px, 6vw, 96px);
  max-width: 1600px;
}

.intro {
  margin-top: clamp(8px, 8vh, 120px);
}

h1 {
  text-wrap: balance;
  font-family: var(--sans);
  font-size: clamp(2.3rem, 5.2vw, 4.6rem);
  font-weight: 620;
  letter-spacing: -0.025em;
  line-height: 1.02;
  max-width: 12ch;
}

.tagline {
  margin-top: 1.1em;
  font-size: clamp(0.92rem, 1.35vw, 1.08rem);
  line-height: 1.55;
  color: var(--ink-2);
}

/* --- projects --- */
.projects {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  font-size: clamp(0.82rem, 1.1vw, 0.95rem);
}

.projects li {
  display: flex;
  align-items: baseline;
  gap: 1.2em;
  white-space: nowrap;
}

.projects a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 240, 236, 0.25);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.projects a::after {
  content: " ↗";
  color: var(--ink-4);
  transition: color 0.15s;
}

.projects a:hover,
.projects a:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.projects a:hover::after,
.projects a:focus-visible::after {
  color: var(--accent);
}

.projects span {
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- contacts --- */
.contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 2.2em;
  font-size: clamp(0.78rem, 1vw, 0.88rem);
}

.contacts a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.contacts a:hover,
.contacts a:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- hovered node address --- */
#bg-label {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  pointer-events: none; /* must never eat a click or hover itself */
  will-change: transform;
  transform: translate3d(-9999px, -9999px, 0);
  padding: 5px 8px;
  background: rgba(12, 13, 16, 0.86);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(240, 240, 236, 0.14);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s linear;
}

#bg-label[data-on="1"] {
  opacity: 1;
}

/* the label cannot have a hover state, so the address states its own
   clickability: accent colour plus the same arrow the page's links use */
#bg-label .a {
  color: var(--accent);
}

#bg-label .v {
  display: block;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

html.bg-linkable .page,
html.bg-linkable body {
  cursor: pointer;
}

#bg-label .v:empty {
  display: none;
}

@media (max-width: 720px) {
  #bg-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #bg-label {
    transition: none;
  }
}

.plain-link {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 240, 236, 0.25);
  padding-bottom: 1px;
}

.plain-link:hover,
.plain-link:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- bottom-right HUD: status line + settings panel --- */
.hud {
  position: fixed;
  right: clamp(16px, 2.5vw, 36px);
  bottom: clamp(14px, 2.5vh, 28px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hud-line {
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--ink-4);
}

#bg-settings {
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

#bg-settings:hover,
#bg-settings:focus-visible,
#bg-settings[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

#bg-panel {
  width: 248px;
  max-height: min(72vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px;
  background: rgba(12, 13, 16, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(240, 240, 236, 0.09);
  border-radius: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

#bg-panel .group {
  margin: 4px 0 8px;
  color: var(--ink-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.6rem;
}

#bg-panel .group:not(:first-child) {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(240, 240, 236, 0.08);
}

#bg-panel .row {
  display: grid;
  grid-template-columns: 84px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

#bg-panel label {
  color: var(--ink-3);
}

#bg-panel output {
  color: var(--ink-4);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#bg-panel input[type="range"] {
  width: 100%;
  height: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

#bg-panel .panel-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

#bg-panel .panel-foot button {
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-4);
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

#bg-panel .panel-foot button:hover,
#bg-panel .panel-foot button:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

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

::selection {
  background: rgba(141, 180, 226, 0.25);
}

/* --- small screens: keep it one calm column --- */
@media (max-width: 720px) {
  body {
    overflow: auto;
  }
  .page {
    height: auto;
    min-height: 100dvh;
    gap: 2.4em;
  }
  .intro {
    margin-top: 6vh;
  }
  .projects li {
    flex-direction: column;
    gap: 0.15em;
    white-space: normal;
  }
  .projects {
    gap: 1.1em;
  }
  .hud {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .projects a,
  .contacts a {
    transition: none;
  }
}
