/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #0B0B0F;
  --surface: #14141A;
  --text: #EDEAE4;
  --muted: #9A96A0;
  --accent: #E8734A;
  --accent2: #7FB7A3;
  --border: rgba(237, 234, 228, 0.08);
  --max-w: 1100px;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
  scroll-behavior: smooth; /* fallback; overridden to auto when Lenis loads */
  font-size: 16px;
}

body {
  background: radial-gradient(ellipse at 28% 18%, #1c1118 0%, #0B0B0F 55%);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============================================================
   3D CANVAS BACKGROUND
   ============================================================ */
#canvas-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  display: block;
}

#canvas-bg.ready {
  opacity: 1;
}

/* Mobile and reduced-motion: never show the canvas */
@media (max-width: 767px) {
  #canvas-bg { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #canvas-bg { display: none; }
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

a:hover {
  opacity: 0.8;
}

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

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
}

h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); letter-spacing: -0.015em; }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
h4 { font-size: 1.05rem; }

p {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.7;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
}

section {
  padding: 5rem 0;
  position: relative;
  z-index: 1;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100; /* above canvas (z-index 0) and sections (z-index 1) */
  background: rgba(11, 11, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-name {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  letter-spacing: 0.01em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.nav-name:hover {
  opacity: 0.8;
}

.nav-mark {
  flex-shrink: 0;
  border-radius: 4px;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
}

.nav-links .nav-cta {
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.35rem 0.9rem;
  border-radius: 3px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links .nav-cta:hover {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ============================================================
   HERO
   ============================================================ */
#hero {
  padding-top: 120px;
  padding-bottom: 5rem;
  position: relative;
  overflow: hidden;
}

.hero-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%23EDEAE4' stroke-width='0.6'%3E%3Crect x='10' y='10' width='60' height='60'/%3E%3Cpolygon points='40,10 70,40 40,70 10,40'/%3E%3Cline x1='40' y1='10' x2='40' y2='70'/%3E%3Cline x1='10' y1='40' x2='70' y2='40'/%3E%3Ccircle cx='40' cy='40' r='15'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 80px 80px;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

/* Hero two-column layout */
.hero-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.hero-text {
  display: flex;
  flex-direction: column;
}

/* Terminal block */
.terminal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}

.terminal-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.terminal-dot:nth-child(1) { background: #FF5F56; }
.terminal-dot:nth-child(2) { background: #FFBD2E; }
.terminal-dot:nth-child(3) { background: #27C93F; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

.terminal-body {
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--text);
  min-height: 100px;
}

.terminal-prompt {
  color: var(--accent2);
}

.terminal-name {
  color: var(--accent);
  font-weight: 600;
}

.terminal-desc {
  color: var(--muted);
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Hero text */
.hero-headline {
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 1.25rem;
}

.hero-subline {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 2.5rem;
}

.hero-subline strong {
  color: var(--text);
  font-weight: 500;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: #d4663f;
  opacity: 1;
}

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

.btn-secondary:hover {
  border-color: var(--muted);
  opacity: 1;
  color: var(--text);
}

/* ============================================================
   PROOF STRIP
   ============================================================ */
#proof {
  padding: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(20, 20, 26, 0.88);
}

.proof-inner {
  padding: 1.5rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.8;
  letter-spacing: 0.02em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .proof-inner {
    white-space: normal;
    line-height: 2;
    font-size: 0.74rem;
  }
}

.proof-dot {
  color: var(--accent);
  margin: 0 0.3em;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
}

.section-title {
  margin-bottom: 0.75rem;
}

.section-intro {
  color: var(--muted);
  max-width: 560px;
  margin-bottom: 3rem;
}

/* ============================================================
   WHAT I DO (CARDS)
   ============================================================ */
#services {
  background: rgba(11, 11, 15, 0.72);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.card {
  background: rgba(20, 20, 26, 0.82);
  padding: 2.25rem;
  transition: background 0.2s ease;
}

.card:hover {
  background: rgba(26, 26, 34, 0.92);
}

.card-number {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
  display: block;
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.card p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ============================================================
   SELECTED WORK
   ============================================================ */
#work {
  background: rgba(11, 11, 15, 0.72);
}

.work-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.case-study {
  padding: 3rem 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 3rem;
  align-items: start;
}

.case-study:last-child {
  border-bottom: none;
}

.case-meta {
  position: sticky;
  top: 80px;
}

.case-index {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.75rem;
}

.case-title {
  font-size: 1.2rem;
  font-family: var(--font-serif);
  color: var(--text);
  line-height: 1.3;
}

.case-body {
  padding-top: 0.25rem;
}

.case-context {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent2);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.case-description {
  color: var(--text);
  margin-bottom: 1.25rem;
  font-size: 0.98rem;
  line-height: 1.75;
}

.case-outcome {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(20, 20, 26, 0.82);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
}

.case-outcome-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding-top: 0.1rem;
}

.case-outcome-text {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ============================================================
   HOW I THINK (MANIFESTO)
   ============================================================ */
#thinking {
  background: rgba(20, 20, 26, 0.84);
  position: relative;
  overflow: hidden;
}

.thinking-inner {
  max-width: 720px;
}

.thinking-inner p {
  font-size: 1.08rem;
  line-height: 1.8;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.thinking-inner p:last-child {
  margin-bottom: 0;
}

.thinking-inner strong {
  color: var(--text);
  font-weight: 500;
}

/* ============================================================
   WRITING AND TEACHING
   ============================================================ */
#writing {
  background: rgba(11, 11, 15, 0.72);
}

.writing-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.writing-video {
  position: sticky;
  top: 80px;
}

.video-wrap {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0a0a0e;
}

.video-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 900px) {
  .writing-cols {
    grid-template-columns: 1fr;
  }

  .writing-video {
    position: static;
  }
}

.writing-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.writing-item {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

.writing-item:last-child {
  border-bottom: none;
}

.writing-item:hover {
  background: rgba(20, 20, 26, 0.82);
}

.writing-platform {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  padding-top: 0.15rem;
  min-width: 80px;
}

.writing-content {
  flex: 1;
}

.writing-content a {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  display: block;
  margin-bottom: 0.25rem;
  text-decoration: none;
  transition: color 0.15s ease;
}

.writing-content a:hover {
  color: var(--accent);
  opacity: 1;
}

.writing-content p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ============================================================
   ABOUT
   ============================================================ */
#about {
  background: rgba(11, 11, 15, 0.72);
  border-top: 1px solid var(--border);
}

.about-inner {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 4rem;
  align-items: start;
}

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

.about-text a {
  color: var(--accent);
}

.about-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.about-links a {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  transition: color 0.15s ease;
}

.about-links a:hover {
  color: var(--accent);
  opacity: 1;
}

.about-links a::before {
  content: '→';
  color: var(--accent);
  font-size: 0.75rem;
}

/* ============================================================
   CONTACT / FOOTER
   ============================================================ */
#contact {
  background: rgba(20, 20, 26, 0.88);
  padding: 5rem 0 0;
}

.contact-heading {
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  max-width: 640px;
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

.contact-sub {
  color: var(--muted);
  margin-bottom: 2.5rem;
  max-width: 480px;
}

.contact-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 5rem;
}

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-credit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ============================================================
   SCROLL REVEAL
   Progressive enhancement: content visible by default.
   JS adds .reveal-active to <html> to enable the hidden state.
   ============================================================ */
.reveal {
  transition: opacity 500ms ease-out, transform 500ms ease-out;
}

html.reveal-active .reveal {
  opacity: 0;
  transform: translateY(24px);
}

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

@media (prefers-reduced-motion: reduce) {
  html.reveal-active .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .cursor {
    animation: none;
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .cards-grid {
    grid-template-columns: 1fr;
    background: transparent;
    border: none;
    border-radius: 0;
    gap: 1rem;
  }

  .card {
    border: 1px solid var(--border);
    border-radius: 6px;
  }

  .case-study {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .case-meta {
    position: static;
  }

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

@media (max-width: 900px) {
  .hero-cols {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 767px) {
  section {
    padding: 3.5rem 0;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem 1.5rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-links .nav-cta {
    border: none;
    padding: 0.65rem 0;
  }

  .nav-toggle {
    display: flex;
  }

  #nav {
    position: fixed;
  }

  .hero-buttons {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  .terminal {
    max-width: 100%;
  }

  .writing-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .contact-links {
    flex-direction: column;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 375px) {
  .container {
    padding: 0 1.25rem;
  }

  h1 {
    font-size: 2rem;
  }

  .hero-headline {
    font-size: 2rem;
  }
}
