/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #331E38;
  --color-text: #F4E8C1;
  --color-text-muted: #A0C1B9;
  --color-accent: #706993;
  --color-accent-soft: #70A0AF;

  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-body: 'Bebas Neue', 'Arial Narrow', sans-serif;

  /* Reserved width down the right edge, wide enough to clear the fixed nav's
     rendered footprint (~145px) plus its own header padding and a safety
     margin. Fixed nav is a constant pixel size, so this holds at any
     viewport aspect ratio above the mobile breakpoint. */
  --nav-exclusion-width: 260px;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 1.5rem 2rem;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  color: var(--color-text);
  transition: color 0.3s ease;
}

.logo:hover {
  color: var(--color-text);
}

.main-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  color: var(--color-text);
  transition: transform 0.25s ease, opacity 0.25s ease, text-shadow 0.25s ease;
}

.nav-btn-label {
  font-size: 3rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.01em;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--color-accent);
}

.nav-btn-ext {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: rgba(244, 232, 193, 0.75);
}

.nav-btn:hover {
  transform: translateX(-4px) scale(1.04);
  text-shadow: 0 0 18px rgba(112, 105, 147, 0.6);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 200;
  padding: 0.5rem;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--color-text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Tether — a cable running from a fixed top-center anchor down to the
   spaceman, redrawn every frame by js/main.js so it follows him as he
   glides and bobs, with a gentle sway to sell the zero-g spacewalk feel. */
.tether-anchor {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, 0);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-text);
  box-shadow: 0 0 8px rgba(244, 232, 193, 0.7);
  z-index: -1;
}

.tether-line {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  pointer-events: none;
  overflow: visible;
}

.tether-line path {
  fill: none;
  stroke: var(--color-text);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.55;
}

/* Spaceman — floats to a new spot per section; js/main.js sets left/top.
   Sized generously larger than the image itself (which is only ~100px)
   and centered via flexbox, so the click/drag area — which lives on this
   outer element — comfortably covers the full range of the idle float
   animation's translateY/rotate instead of just his resting position. */
.spaceman {
  position: fixed;
  left: 50%;
  top: 45%;
  z-index: -2;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: left 2.5s cubic-bezier(0.65, 0, 0.35, 1), top 2.5s cubic-bezier(0.65, 0, 0.35, 1);
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Only draggable while the home section is in view (js/main.js toggles
   this); pointer-events stay off everywhere else. He normally sits behind
   all page content (z-index -2), which also means the page content in
   front of him would otherwise swallow every click before it reaches him —
   so pull him back above it while this class is active. */
.spaceman.draggable {
  z-index: 60;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.spaceman.draggable .spaceman-box {
  -webkit-user-drag: none;
  user-select: none;
}

.spaceman.dragging {
  cursor: grabbing;
  transition: none;
}

.spaceman.dragging .spaceman-box {
  animation-play-state: paused;
}

/* Set on pointerdown, removed once the post-release coast-to-a-stop
   finishes (see js/main.js). Disables the transition below so the per-frame
   rotate() updates during the drag/coast aren't fighting a 2.5s transition
   meant for the discrete section-to-section and return-home spins. */
.spaceman.spinning .spaceman-orient {
  transition: none;
}

.spaceman-orient {
  transition: transform 2.5s cubic-bezier(0.65, 0, 0.35, 1);
  /* The idle float animation only bobs upward (translateY goes to -16px,
     never positive), so centering this dead-center in .spaceman would put
     the hitbox's "extra" room mostly where he never visually is. This
     margin biases the flex-centering to give more headroom above (where
     the bob actually happens) and less below. */
  margin-top: 70px;
}

.spaceman-box {
  display: block;
  width: 100px;
  height: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
  animation: spaceman-float 4s ease-in-out infinite;
}

@keyframes spaceman-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-16px) rotate(4deg); }
}

/* Hero */
.hero {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  overflow: hidden;
  padding: 0 3rem 3.5rem;
  gap: 2.5rem;
  scroll-margin-top: 1rem;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 600px;
  text-align: left;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.15s, transform 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.15s;
}

body.loaded .hero-content {
  opacity: 1;
  transform: none;
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--color-text);
  margin-bottom: 1.25rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--color-text);
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.hero-blurb {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--color-text-muted);
  max-width: 560px;
  margin: 0;
}

.hero-cta {
  align-self: stretch;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.9rem 2.1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 2px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-fill {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-bg);
}

.btn-fill:hover {
  background-color: transparent;
  color: var(--color-text);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(112, 105, 147, 0.25);
}

.btn-line {
  background-color: transparent;
  border-color: rgba(244, 232, 193, 0.5);
  color: var(--color-text);
}

.btn-line:hover {
  border-color: var(--color-accent-soft);
  color: var(--color-text);
  transform: translateY(-3px);
}

/* Scroll cue */
.scroll-cue {
  position: absolute;
  bottom: 2.5rem;
  right: 3rem;
  width: 1px;
  height: 48px;
  background: rgba(244, 232, 193, 0.25);
  z-index: 2;
  overflow: hidden;
}

.scroll-cue span {
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-accent);
  animation: scroll-cue-drop 2.2s ease-in-out infinite;
}

@keyframes scroll-cue-drop {
  0% { top: -100%; }
  60% { top: 100%; }
  100% { top: 100%; }
}

/* Page sections (About / Projects / Contact) */
.page-section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 3rem;
  scroll-margin-top: 1rem;
}

.section-inner {
  max-width: min(640px, calc(100vw - 2 * var(--nav-exclusion-width)));
  text-align: center;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.15s, transform 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.15s;
}

.section-inner.in-view {
  opacity: 1;
  transform: none;
}

.section-inner--wide {
  max-width: min(1040px, calc(100vw - 2 * var(--nav-exclusion-width)));
}

.section-eyebrow {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 6vw, 4rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-bottom: 1.5rem;
}

.section-body {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 3rem;
  align-items: center;
  text-align: left;
}

.about-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 2px solid var(--color-text);
  border-radius: 6px;
}

.about-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-text .section-body {
  margin: 0 0 1rem;
}

.about-text .section-body:last-child {
  margin-bottom: 0;
}

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
  text-align: left;
}

.project-card {
  background: rgba(51, 30, 56, 0.55);
  border: 1px solid rgba(244, 232, 193, 0.15);
  border-radius: 4px;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.project-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-4px);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.project-name {
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--color-text);
}

.project-links {
  display: flex;
  gap: 0.75rem;
}

.project-links a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  transition: color 0.3s ease;
}

.project-links a:hover {
  color: var(--color-text);
}

.project-desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  font-family: ui-monospace, 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.7rem;
  color: var(--color-text);
  background: rgba(112, 105, 147, 0.08);
  border: 1px solid rgba(112, 105, 147, 0.3);
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
}

/* Contact */
.contact-links {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.contact-link {
  display: inline-block;
  line-height: 1.2;
  font-size: 1rem;
  color: var(--color-text);
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
  transition: color 0.3s ease, border-color 0.3s ease, transform 0.25s ease;
}

.contact-link:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.contact-plaintext {
  margin-top: 1.5rem;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 760px) {
  :root {
    --nav-exclusion-width: 0px;
  }

  .main-nav {
    position: fixed;
    inset: 0;
    background: rgba(51, 30, 56, 0.98);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    transform: translateX(100%);
    transition: transform 0.4s ease;
  }

  .main-nav.open {
    transform: translateX(0);
  }

  .nav-btn {
    align-items: center;
  }

  .nav-btn-label {
    font-size: 4rem;
  }

  .nav-toggle {
    display: flex;
  }

  .about-grid {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .about-photo {
    max-width: 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-cue span,
  .spaceman-box {
    animation: none;
  }

  .spaceman,
  .spaceman-orient {
    transition: none;
  }

  .hero-content,
  .section-inner {
    transition: none;
    opacity: 1;
    transform: none;
  }
}
