/* ===== GOOGLE FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;0,700;1,400;1,600&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  --bg: #FAF7F2;
  --bg-alt: #F4EEE3;
  --surface: #F0E9DC;
  --surface-2: #E8DFD0;
  --border: #D6C9B4;
  --border-light: #E8DFD0;
  --text-primary: #2C1A0E;
  --text-secondary: #6B5744;
  --text-muted: #9C8470;
  --accent: #C8733A;
  --accent-dark: #A35A25;
  --accent-light: #F2DCC8;
  --green: #5A8A5E;
  --green-light: #D4E8D5;
  --sand: #D6B896;
  --sand-light: #F0E4D4;
  --shadow-sm: 0 2px 8px rgba(44, 26, 14, 0.07);
  --shadow-md: 0 4px 20px rgba(44, 26, 14, 0.10);
  --shadow-lg: 0 8px 40px rgba(44, 26, 14, 0.13);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 68px;
  --max-width: 1100px;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
}

/* ===== BACKGROUND ANIMATION ===== */
#canvas-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10; /* Lower than footer/navbar */
  pointer-events: none;
  opacity: 0.35; /* Faint and subtle */
}

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

  a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
  }

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

  ul {
    list-style: none;
  }

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

  h1 {
    font-size: clamp(2.4rem, 5vw, 3.8rem);
  }

  h2 {
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  }

  h3 {
    font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  }

  h4 {
    font-size: 1.1rem;
  }

  p {
    color: var(--text-secondary);
    font-size: 0.975rem;
  }

  .serif {
    font-family: var(--font-serif);
  }

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

  /* ===== NAVBAR ===== */
  .navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    z-index: 1000;
    background: rgba(250, 247, 242, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
  }

  .navbar.scrolled {
    background: rgba(250, 247, 242, 0.97);
    box-shadow: var(--shadow-sm);
  }

  .nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-logo {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
  }

  .nav-logo span {
    color: inherit;
  }

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

  .nav-links a {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    position: relative;
    padding-bottom: 2px;
  }

  .nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
  }

  .nav-links a:hover,
  .nav-links a.active {
    color: var(--accent);
  }

  .nav-links a:hover::after,
  .nav-links a.active::after {
    width: 100%;
  }

  /* Hamburger */
  .nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
  }

  .nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    margin: 5px 0;
    transition: var(--transition);
  }

  .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);
  }

  /* Mobile nav */
  @media (max-width: 768px) {
    .nav-toggle {
      display: flex;
      flex-direction: column;
    }

    .nav-links {
      display: none;
      position: fixed;
      top: var(--nav-height);
      left: 0;
      right: 0;
      background: var(--bg);
      flex-direction: column;
      padding: 1.5rem 2rem 2rem;
      gap: 1.2rem;
      border-bottom: 1px solid var(--border);
      box-shadow: var(--shadow-md);
    }

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

    .nav-links a {
      font-size: 1rem;
    }
  }

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

  .section {
    padding: 5rem 0;
  }

  .section-alt {
    background: var(--bg-alt);
  }

  .section-title {
    font-family: var(--font-serif);
    font-size: clamp(1.7rem, 3vw, 2.2rem);
    font-weight: 600;
    margin-bottom: 0.4rem;
    position: relative;
    display: inline-block;
  }

  .section-title::after {
    content: '';
    display: block;
    margin-top: 0.4rem;
    width: 48px;
    height: 3px;
    background: var(--accent);
    border-radius: 3px;
  }

  .section-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.6rem;
    margin-bottom: 2.5rem;
  }

  /* Grid helpers */
  .grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
  }

  @media (max-width: 960px) {
    .grid-3 {
      grid-template-columns: repeat(2, 1fr);
    }

    .grid-4 {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (max-width: 640px) {
    .grid-2 {
      grid-template-columns: 1fr;
    }

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

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

  /* ===== CARDS ===== */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.6rem;
    transition: var(--transition);
  }

  .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--sand);
  }

  .card-featured {
    background: linear-gradient(135deg, var(--surface) 0%, var(--sand-light) 100%);
    border: 1.5px solid var(--sand);
    padding: 2rem;
  }

  /* ===== BUTTONS ===== */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    font-family: var(--font-sans);
  }

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

  .btn-primary:hover {
    background: var(--accent-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(200, 115, 58, 0.35);
  }

  .btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
  }

  .btn-outline:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-1px);
  }

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

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

  /* ===== BADGES & TAGS ===== */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.03em;
  }

  .badge-live {
    background: var(--green-light);
    color: var(--green);
  }

  .badge-live::before {
    content: '●';
    font-size: 0.6rem;
  }

  .badge-local {
    background: var(--surface-2);
    color: var(--text-muted);
  }

  .badge-research {
    background: var(--accent-light);
    color: var(--accent-dark);
  }

  .tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
  }

  .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
  }

  /* ===== STAT PILLS ===== */
  .stat-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 90px;
  }

  .stat-pill .stat-num {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
  }

  .stat-pill .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.2rem;
  }

  /* ===== TIMELINE ===== */
  .timeline {
    position: relative;
    padding-left: 2rem;
  }

  .timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.4rem;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--sand), var(--border-light));
    border-radius: 2px;
  }

  .timeline-item {
    position: relative;
    padding-bottom: 2rem;
  }

  .timeline-item::before {
    content: '';
    position: absolute;
    left: -2.4rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border: 2px solid var(--bg);
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--accent-light);
  }

  .timeline-item:last-child {
    padding-bottom: 0;
  }

  .timeline-date {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 0.2rem;
  }

  .timeline-role {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
  }

  .timeline-org {
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
  }

  .timeline-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
  }

  /* ===== BLOCKQUOTE ===== */
  blockquote {
    position: relative;
    padding: 1.5rem 1.5rem 1.5rem 2.5rem;
    background: var(--surface);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.75;
  }

  blockquote::before {
    content: '"';
    position: absolute;
    left: 0.6rem;
    top: -0.2rem;
    font-size: 3.5rem;
    color: var(--sand);
    font-family: var(--font-serif);
    line-height: 1;
  }

  .quote-attr {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: normal;
    font-family: var(--font-sans);
  }

  /* ===== PROJECT DETAIL ===== */
  .project-hero {
    padding: calc(var(--nav-height) + 3rem) 0 3rem;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-alt) 100%);
    border-bottom: 1px solid var(--border);
  }

  .project-hero-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
  }

  .project-breadcrumb {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .project-breadcrumb a {
    color: var(--text-muted);
  }

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

  .tldr-box {
    background: linear-gradient(135deg, var(--surface) 0%, var(--sand-light) 100%);
    border: 1.5px solid var(--sand);
    border-radius: var(--radius-md);
    padding: 1.5rem 2rem;
    margin: 2rem 0;
  }

  .tldr-box h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 0.75rem;
    font-family: var(--font-sans);
    font-weight: 600;
  }

  .tldr-box ul {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .tldr-box li {
    font-size: 0.93rem;
    color: var(--text-secondary);
    padding-left: 1.2rem;
    position: relative;
  }

  .tldr-box li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 600;
  }

  .stat-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
  }

  .deep-dive-section {
    padding: 2.5rem 0;
    border-top: 1px solid var(--border-light);
  }

  .deep-dive-section h3 {
    margin-bottom: 1rem;
  }

  .callout {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1rem 1.2rem;
    margin: 1rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
  }

  /* Challenge/Solution table */
  .cs-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.88rem;
  }

  .cs-table th {
    background: var(--surface-2);
    padding: 0.7rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
  }

  .cs-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: top;
  }

  .cs-table tr:last-child td {
    border-bottom: none;
  }

  /* ===== SKILLS ===== */
  .skill-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
  }

  .skill-card-icon {
    font-size: 1.8rem;
    margin-bottom: 0.75rem;
  }

  .skill-card h4 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
  }

  .skill-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .skill-list li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    padding-left: 1rem;
    position: relative;
  }

  .skill-list li::before {
    content: '·';
    position: absolute;
    left: 0.2rem;
    color: var(--accent);
    font-weight: 700;
  }

  /* ===== ACHIEVEMENT CARDS ===== */
  .achievement-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
  }

  .achievement-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
  }

  .achievement-title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
  }

  .achievement-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
  }

  /* ===== HERO PAGE ===== */
  .hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: calc(var(--nav-height) + 2rem) 0 4rem;
    position: relative;
    overflow: hidden;
  }

  .hero-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 4rem;
    align-items: center;
  }

  .hero-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
  }

  .hero-name {
    margin-bottom: 0.5rem;
  }

  .hero-tagline {
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    color: var(--text-secondary);
    font-weight: 400;
    font-style: italic;
    margin-bottom: 1.5rem;
  }

  .hero-bio {
    margin-bottom: 2rem;
    font-size: 0.97rem;
    line-height: 1.8;
    max-width: 540px;
  }

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

  .hero-photo-wrap {
    position: relative;
    display: flex;
    justify-content: center;
  }

  .hero-photo-frame {
    width: 300px;
    height: 300px;
    border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
    overflow: hidden;
    border: 4px solid var(--sand);
    box-shadow: var(--shadow-lg);
    position: relative;
  }

  .hero-photo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
  }

  .hero-photo-bg {
    position: absolute;
    width: 320px;
    height: 320px;
    top: 10px;
    left: 10px;
    border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--sand-light));
    z-index: -1;
  }

  .monogram-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface), var(--sand-light));
    font-family: var(--font-serif);
    font-size: 5rem;
    font-weight: 700;
    color: var(--accent);
    user-select: none;
  }

  /* What I do strip */
  .whatido-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 3rem;
  }

  .whatido-item {
    background: var(--surface);
    padding: 1.5rem;
    text-align: center;
  }

  .whatido-item .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .whatido-item h4 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
  }

  .whatido-item p {
    font-size: 0.85rem;
  }

  /* ===== MOLECULE BG ===== */
  .molecule-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
  }

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

  /* ===== CONTACT PAGE ===== */
  .contact-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-primary);
  }

  .contact-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--text-primary);
    transform: translateX(4px);
  }

  .contact-icon {
    font-size: 1.4rem;
    width: 40px;
    text-align: center;
  }

  .contact-label {
    font-size: 0.78rem;
    color: var(--text-muted);
  }

  .contact-value {
    font-weight: 500;
    font-size: 0.95rem;
  }

  /* ===== FOOTER ===== */
  .footer {
    background: var(--text-primary);
    color: var(--sand);
    padding: 4rem 0 2rem;
    font-size: 0.9rem;
    position: relative;
    z-index: 100; /* Higher than canvas */
  }

  .footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 3rem;
    margin-bottom: 3rem;
  }

  .footer-brand {
    max-width: 320px;
  }

  .footer .nav-logo {
    color: var(--sand);
    display: block;
    margin-bottom: 0.75rem;
    font-size: 1.4rem;
  }

  .footer-links {
    display: flex;
    gap: 4rem;
  }

  .footer-links h4 {
    color: var(--accent);
    font-family: var(--font-sans);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    margin-bottom: 1.2rem;
  }

  .footer-links ul {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .footer-links a {
    color: var(--sand);
    text-decoration: none;
    font-size: 0.88rem;
    transition: var(--transition);
  }

  .footer-links a:hover {
    color: var(--accent-light);
  }

  .footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid rgba(214, 184, 150, 0.1);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
  }

  @media (max-width: 800px) {
    .footer-grid {
      flex-direction: column;
      gap: 2.5rem;
      text-align: center;
      align-items: center;
    }

    .footer-links {
      gap: 3rem;
      flex-wrap: wrap;
      justify-content: center;
    }
  }

  /* ===== SCROLL REVEAL ===== */
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.65s ease, transform 0.65s ease;
  }

  .reveal.visible {
    opacity: 1;
    transform: none;
  }

  /* ===== WAVE DIVIDER ===== */
  .wave-divider {
    display: block;
    width: 100%;
    overflow: hidden;
    line-height: 0;
  }

  .wave-divider svg {
    display: block;
  }

  /* ===== RESPONSIVE ===== */
  @media (max-width: 900px) {
    .hero-grid {
      grid-template-columns: 1fr;
      text-align: center;
      gap: 2.5rem;
    }

    .hero-photo-wrap {
      order: -1;
    }

    .hero-actions {
      justify-content: center;
    }

    .hero-bio {
      margin: 0 auto 2rem;
    }

    .whatido-strip {
      grid-template-columns: 1fr;
    }
  }

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

    .container {
      padding: 0 1.25rem;
    }

    .stat-row {
      gap: 0.6rem;
    }

    .hero-photo-frame {
      width: 220px;
      height: 220px;
    }

    .hero-photo-bg {
      width: 240px;
      height: 240px;
    }
  }