/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
}

ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Typography */
body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: var(--font-weight-regular);
  font-size: var(--fs-base);
  line-height: var(--line-height-base);
}

h1,
h2,
h3 {
  line-height: var(--line-height-tight);
  font-weight: var(--font-weight-bold);
}

h1 {
  font-size: var(--fs-3xl);
}

h2 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-5);
}

h3 {
  font-size: var(--fs-lg);
}

p {
  max-width: 65ch;
}

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

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: var(--font-weight-bold);
  transition: top var(--duration-fast) var(--ease-standard);
}

.skip-link:focus {
  top: var(--space-4);
}

/* Layout primitives */
.container {
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main section {
  padding-block: var(--space-9);
}

/* Header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-surface);
}

.nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: var(--header-height);
}

.nav__logo {
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  color: var(--color-text);
}

.nav__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  background: none;
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
}

.nav__menu {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
}

/* Each link lights up in its own editor syntax colour on hover/active, in menu order */
.nav__menu li:nth-child(1) { --link-color: var(--color-accent); }
.nav__menu li:nth-child(2) { --link-color: var(--color-syntax-green); }
.nav__menu li:nth-child(3) { --link-color: var(--color-syntax-pink); }
.nav__menu li:nth-child(4) { --link-color: var(--color-syntax-amber); }
.nav__menu li:nth-child(5) { --link-color: var(--color-syntax-purple); }
.nav__menu li:nth-child(6) { --link-color: var(--color-syntax-cyan); }
.nav__menu li:nth-child(7) { --link-color: var(--color-syntax-orange); }

.nav__menu a {
  display: inline-block;
  padding-block: var(--space-3);
  color: var(--color-text);
  font-family: var(--font-code);
  font-size: var(--fs-sm);
  text-decoration: underline 2px transparent;
  text-underline-offset: 6px;
  transition: color var(--duration-fast) var(--ease-standard),
    text-decoration-color var(--duration-fast) var(--ease-standard);
}

.nav__menu a:hover,
.nav__menu a.is-active {
  color: var(--link-color);
  text-decoration-color: currentColor;
}

@media (max-width: 900px) {
  html.js .nav__toggle {
    display: inline-flex;
  }

  html.js .nav__menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4) var(--gutter);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-surface);
  }

  html.js .nav__menu.is-open {
    display: flex;
  }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-surface);
  padding: var(--space-6) var(--gutter);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

.site-footer p {
  margin-inline: auto;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: var(--font-weight-bold);
  transition: background var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.button--primary {
  background: var(--color-button);
  color: var(--color-on-button);
}

.button--primary:hover {
  background: var(--color-button-hover);
}

.button--secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-text-muted);
}

.button--secondary:hover {
  border-color: var(--color-text);
}

/* Terminal window chrome — reused across hero + work cards */
.terminal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.terminal__bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.terminal__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.terminal__dot:nth-child(1) {
  background: var(--color-dot-red);
}

.terminal__dot:nth-child(2) {
  background: var(--color-dot-amber);
}

.terminal__dot:nth-child(3) {
  background: var(--color-dot-green);
}

/* Easter egg (js/egg.js): clicked dots hop, a bubble pops up then dissolves */
.terminal__dot.is-hopping {
  animation: dot-hop var(--duration-egg) var(--ease-standard);
}

@keyframes dot-hop {
  30% { transform: translateY(-9px) scale(1.15); }
  55% { transform: translateY(0) scale(1.2, 0.8); }
  75% { transform: translateY(-3px); }
}

/* Pixel-dissolve overlays (js/egg.js); bubbles sit above the sticky header */
.pixel-overlay {
  position: absolute;
  z-index: 40;
  pointer-events: none;
}

.egg {
  z-index: 60;
  transform-origin: var(--egg-origin, 50% 100%);
  animation: egg-pop var(--duration-egg) var(--ease-pop);
}

@keyframes egg-pop {
  from { transform: translateY(8px) scale(0.4); opacity: 0; }
}

.terminal__title {
  margin-left: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal__body {
  padding: var(--space-6) var(--space-5);
}

/* Prompt-style eyebrow label, precedes section headings */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

.eyebrow::first-letter {
  color: var(--color-syntax-green);
}

.eyebrow--typed {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--color-accent);
  width: 0;
  animation: typing 0.6s steps(var(--type-steps, 10)) 0.15s both,
    caret-blink 0.8s step-end infinite;
}

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: var(--type-width, 10ch);
  }
}

@keyframes caret-blink {
  50% {
    border-color: transparent;
  }
}

/* Scroll reveal — progressive enhancement only, gated on html.js */
html.js .reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--duration-slow) var(--ease-standard),
    transform var(--duration-slow) var(--ease-standard);
}

html.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}
