* {
  box-sizing: border-box;
}

/* Registering the theme colors as real colors lets the browser fade between
   them, so switching theme eases over instead of snapping like a flashbang. */
@property --bg { syntax: "<color>"; inherits: true; initial-value: #141210; }
@property --text { syntax: "<color>"; inherits: true; initial-value: #ece6da; }
@property --muted { syntax: "<color>"; inherits: true; initial-value: #9a9284; }
@property --line { syntax: "<color>"; inherits: true; initial-value: #2b2722; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #c9a86a; }
@property --glow-strong { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --glow-soft { syntax: "<color>"; inherits: true; initial-value: transparent; }

:root {
  --bg: #141210;
  --text: #ece6da;
  --muted: #9a9284;
  --line: #2b2722;
  --accent: #c9a86a;
  --glow-strong: rgba(201, 168, 106, 0.08);
  --glow-soft: rgba(201, 168, 106, 0.04);

  --content-width: 960px;

  --font: "Noto Serif", Georgia, "Times New Roman", serif;
  --font-display: "Noto Serif Display", Georgia, "Times New Roman", serif;

  color-scheme: dark;

  transition:
    --bg 0.8s ease,
    --text 0.8s ease,
    --muted 0.8s ease,
    --line 0.8s ease,
    --accent 0.8s ease,
    --glow-strong 0.8s ease,
    --glow-soft 0.8s ease;
}

:root[data-theme="light"] {
  --bg: #f6f1e7;
  --text: #241f18;
  --muted: #6a6256;
  --line: #ddd4c4;
  --accent: #806224;
  --glow-strong: rgba(128, 98, 36, 0.08);
  --glow-soft: rgba(128, 98, 36, 0.04);

  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  font-family: var(--font);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 50% at 85% 15%, var(--glow-strong), transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 100%, var(--glow-soft), transparent 70%),
    var(--bg);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

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

/* Header */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;

  font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}

.site-title {
  font-weight: 700;
}

.site-title::before {
  content: "~/";
  color: var(--accent);
}

.header-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.site-nav {
  display: flex;
  gap: 0.6em;
}

.site-nav a + a::before {
  content: "/";
  margin-right: 0.6em;
  color: var(--accent);
}

/* Theme toggle: shows the mode you'd switch to. */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: -6px 0; /* Keeps the header height the .hero min-height relies on. */
  padding: 0;

  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s;
}

.theme-toggle:hover {
  color: var(--accent);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

:root[data-theme="light"] .icon-moon {
  display: block;
}

/* Easter egg: switching theme makes the screen twitch like an old TV.
   script.js adds .glitching to <html> and skips it for reduced-motion users. */

.glitching {
  overflow-x: clip; /* Stops the twitch from flashing a horizontal scrollbar. */
}

.glitching .site-header,
.glitching main,
.glitching .site-footer {
  animation: tv-twitch 0.5s steps(1) both;
}

.tv-glitch {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  pointer-events: none;

  /* Black and white static. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.glitching .tv-glitch {
  display: block;
  animation: tv-static 0.5s steps(1) both;
}

/* Scanlines. */
.tv-glitch::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.35) 0 2px, transparent 2px 4px);
}

/* Bright band rolling down the screen. */
.tv-glitch::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 16vh;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: tv-roll 0.5s linear both;
}

@keyframes tv-twitch {
  0% {
    transform: translate(-10px, 2px) skewX(3deg);
    text-shadow: 3px 0 rgba(255, 0, 60, 0.7), -3px 0 rgba(0, 220, 255, 0.7);
  }

  10% {
    transform: translate(8px, -3px) skewX(-2deg);
  }

  20% {
    transform: none;
    text-shadow: none;
  }

  36% {
    transform: translate(-14px, 0) skewX(5deg);
    text-shadow: -4px 0 rgba(255, 0, 60, 0.7), 4px 0 rgba(0, 220, 255, 0.7);
  }

  46% {
    transform: translate(4px, 4px);
  }

  58% {
    transform: translate(-4px, -1px);
    text-shadow: 2px 0 rgba(255, 0, 60, 0.7), -2px 0 rgba(0, 220, 255, 0.7);
  }

  72% {
    transform: translate(9px, 0) skewX(-4deg);
  }

  84%,
  100% {
    transform: none;
    text-shadow: none;
  }
}

@keyframes tv-static {
  0% {
    opacity: 0.6;
    background-position: 0 0;
  }

  10% {
    opacity: 0.3;
    background-position: -80px 40px;
  }

  20% {
    opacity: 0;
  }

  36% {
    opacity: 0.5;
    background-position: 120px -60px;
  }

  46% {
    opacity: 0.3;
    background-position: -30px 110px;
  }

  58% {
    opacity: 0.2;
    background-position: 70px 20px;
  }

  72% {
    opacity: 0.12;
    background-position: -140px -90px;
  }

  84%,
  100% {
    opacity: 0;
  }
}

@keyframes tv-roll {
  from {
    transform: translateY(-16vh);
  }

  to {
    transform: translateY(100vh);
  }
}

/* Hero */

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

main {
  flex: 1;
  position: relative;
}

/* Binary columns */

.binary {
  --h: 70vh;

  position: absolute;
  top: 0;
  right: 24px;
  z-index: 1;
  display: flex;
  gap: 22px;
  height: var(--h);
  overflow: hidden;
  pointer-events: none;

  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 60%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 60%, transparent);
}

.binary-col {
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  color: var(--accent);
  opacity: 0.6;
}

.binary-track {
  white-space: pre;
  animation: binary-fall var(--dur, 30s) linear var(--delay, 0s) 1 both;
}

@keyframes binary-fall {
  from {
    transform: translateY(-100%);
  }

  to {
    transform: translateY(var(--h));
  }
}

@media (prefers-reduced-motion: reduce) {
  .binary-track {
    animation: none;
  }
}

@media (max-width: 800px) {
  .binary {
    display: none;
  }
}

.hero {
  min-height: calc(100vh - 62px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* Footer */

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;

  font-size: 0.95rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

@media (max-width: 800px) {
  .site-footer {
    padding: 16px;
  }
}

/* Sections */

.section {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 96px 24px;
  border-top: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 16px;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.2;
}

.section h2::before {
  content: "> ";
  color: var(--accent);
}

.section p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.section p + p {
  margin-top: 16px;
}

.section .lead {
  color: var(--text);
  font-size: 1.2rem;
}

/* Skills */

.section .skills-title {
  margin-bottom: 16px;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: start;
}

.skill-groups {
  display: grid;
  gap: 12px;
  margin: 0;
}

.skill-group {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: baseline;
}

.skill-group dt {
  font-size: 0.9rem;
  color: var(--muted);
}

.skill-group dd {
  margin: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 2px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}

@media (max-width: 800px) {
  .about-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .skill-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* Projects */

.projects {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.project + .project {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.project h3 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 400;
}

.project h3 a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.section .project p {
  margin: 8px 0 16px;
}

/* Contact */

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.link-btn {
  display: inline-block;
  padding: 6px 14px;

  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.link-btn::before {
  content: "~/";
  color: var(--accent);
}

.link-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.875rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  opacity: 0.85;
}

.hero h1 {
  margin: 0;
  font-size: 4.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.tagline {
  margin: 16px 0 0;
  font-size: 1.05rem;
}

.tagline::before {
  content: "> ";
  color: var(--accent);
}

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  margin-left: 4px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.quote {
  margin: 48px 0 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* The hero lines rise in one after another when the page loads. The animation
   only runs once, so switching theme doesn't replay it. */
.hero > * {
  animation: hero-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero > :nth-child(1) { animation-delay: 0.1s; }
.hero > :nth-child(2) { animation-delay: 0.25s; }
.hero > :nth-child(3) { animation-delay: 0.45s; }
.hero > :nth-child(4) { animation-delay: 0.7s; }

/* No "to" keyframe, so each line ends at its own opacity (the eyebrow is 0.85). */
@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor,
  .hero > * {
    animation: none;
  }
}

@media (max-width: 800px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
  }

  .hero {
    padding: 48px 16px 64px;
  }

  .hero h1 {
    font-size: 3rem;
  }
}
