/* =============================================
   CSS Custom Properties
   ============================================= */
:root {
  --bg: #0d0d0d;
  --bg-soft: #141414;
  --text: #f0ede8;
  --text-muted: #888880;
  --border: rgba(240, 237, 232, 0.08);
  --accent: #f0ede8;
  --link-hover: rgba(240, 237, 232, 0.5);
  --font-sans: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

body.light {
  --bg: #f5f2ed;
  --bg-soft: #ede9e3;
  --text: #0d0d0d;
  --text-muted: #0d0d0d;
  --border: rgba(13, 13, 13, 0.1);
  --accent: #0d0d0d;
  --link-hover: rgba(13, 13, 13, 0.4);
}

/* =============================================
   Reset & Base
   ============================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition:
    background-color 0.4s var(--ease-out),
    color 0.4s var(--ease-out);
}

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

ul {
  list-style: none;
}

/* =============================================
   Skip Navigation Link
   ============================================= */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.75rem 1.25rem;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  z-index: 9999;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 0;
}

/* =============================================
   Background Canvas
   ============================================= */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* Focus mode  cell grid (focus.js) */
#focus-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}

/* =============================================
   Header
   ============================================= */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 3rem;
}

.logo {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text);
  opacity: 0.9;
  transition: opacity 0.2s;
}

.logo:hover {
  opacity: 1;
}

.theme-toggle,
.focus-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
  transition:
    color 0.2s,
    border-color 0.2s;
}

.theme-toggle:hover,
.focus-toggle:hover {
  color: var(--text);
  border-color: var(--text);
}

.focus-toggle.active {
  color: var(--text);
  border-color: var(--text);
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* =============================================
   Inner page nav
   ============================================= */
.page-nav {
  position: fixed;
  top: 50%;
  right: 3rem;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: flex-end;
}

.page-nav .nav-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  transition: color 0.2s;
  writing-mode: horizontal-tb;
}

.page-nav .nav-link:hover,
.page-nav .nav-link.active {
  color: var(--text);
}

.page-nav .nav-link.active {
  position: relative;
}

.page-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: var(--text);
  border-radius: 50%;
}

/* =============================================
   Home Page
   ============================================= */
.home-main {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 3rem;
}

.hero {
  max-width: 640px;
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 0.2s forwards;
}

.hero__name {
  font-size: clamp(2.8rem, 6vw, 5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 1.5rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 0.35s forwards;
}

.hero__desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 3rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 0.5s forwards;
}

.hero__nav {
  display: flex;
  gap: 2.5rem;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease-out) 0.65s forwards;
}

.hero__nav .nav-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  position: relative;
  transition: color 0.2s;
}

.hero__nav .nav-link::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.3s var(--ease-out);
}

.hero__nav .nav-link:hover {
  color: var(--text);
}

.hero__nav .nav-link:hover::after {
  width: 100%;
}

/* =============================================
   Inner pages
   ============================================= */
.inner-main {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  padding: 6rem 3rem 6rem;
}

.page-content {
  max-width: 800px;
  width: 100%;
}

.page-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 3rem;
}

/* Reveal animation for inner pages */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp 0.7s var(--ease-out) 0.1s forwards;
}

/* =============================================
   About Page
   ============================================= */
.about-intro {
  margin-bottom: 3rem;
}

.about-lead {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 300;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--text);
}

.about-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.about-col p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.skills-heading {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.skills-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  transition:
    color 0.2s,
    padding-left 0.2s;
}

.skills-list li:hover {
  color: var(--text);
  padding-left: 0.5rem;
}

/* =============================================
   Work Page
   ============================================= */
.work-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.work-item {
  background: var(--bg);
  padding: 2rem;
  transition: background 0.2s;
}

.work-item:hover {
  background: var(--bg-soft);
}

.work-item__meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.work-item__year,
.work-item__type {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.work-item__type::before {
  content: "-";
}

.work-item__title {
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.work-item__desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.work-item__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.work-item__tags span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
}

.work-item__link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  transition: color 0.2s;
}

.work-item__link:hover {
  color: var(--text);
}

/* =============================================
   Contact Page
   ============================================= */
.contact-email {
  display: block;
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 3rem;
  position: relative;
  display: inline-block;
}

.contact-email::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text);
  transition: width 0.4s var(--ease-out);
}

.contact-email:hover::after {
  width: 100%;
}

.contact-links {
  display: flex;
  gap: 2rem;
}

.contact-social {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  transition: color 0.2s;
}

.contact-social:hover {
  color: var(--text);
}

/* =============================================
   Footer
   ============================================= */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem 3rem;
  pointer-events: none;
}

.site-footer > * {
  pointer-events: auto;
}

.footer__copy {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.footer__links {
  display: flex;
  gap: 1.5rem;
}

.footer__links a {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  transition: color 0.2s;
}

.footer__links a:hover {
  color: var(--text);
}

/* =============================================
   Animations
   ============================================= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 900px) {
  .site-header {
    padding: 1.5rem 1.5rem;
  }

  .home-main,
  .inner-main {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .page-nav {
    position: static;
    transform: none;
    flex-direction: row;
    justify-content: flex-start;
    padding: 6rem 1.5rem 0;
    gap: 2rem;
  }

  .page-nav .nav-link.active::before {
    display: none;
  }

  .inner-main {
    padding-top: 2rem;
  }

  .about-body {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .work-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    padding: 1.25rem 1.5rem;
  }
}

@media (max-width: 600px) {
  .hero__name {
    font-size: 2.4rem;
  }

  .hero__nav {
    gap: 1.75rem;
  }

  .br-md {
    display: none;
  }

  .contact-email {
    font-size: 1.1rem;
  }
}

/* =============================================
   Focus visible (keyboard navigation)
   ============================================= */
:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 1px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* =============================================
   Reduced motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
