/* ================================
   Design Tokens
================================ */
:root {
  --brand: #0891b2;
  --brand-light: #06b6d4;
  --brand-dark: #0e7490;

  --ink: #0f172a;
  --ink-light: #1e293b;
  --ink-lighter: #475569;
  --paper: #ffffff;
  --surface: #f8fafc;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .08), 0 2px 4px -1px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .1), 0 4px 6px -2px rgba(15, 23, 42, .05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, .12), 0 10px 10px -5px rgba(15, 23, 42, .04);

  --grid-color: rgba(8, 145, 178, .08);
}

/* ================================
   Base
================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--surface);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: 'Sora', sans-serif;
  letter-spacing: -0.02em;
  font-weight: 700;
  line-height: 1.2;
}

h1 { font-size: clamp(2.75rem, 5vw, 4rem) !important; }
h2 { font-size: clamp(2rem, 4vw, 2.75rem) !important; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem) !important; }

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.01em;
}

/* Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ================================
   Scroll Progress Bar
================================ */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  z-index: 200;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ================================
   Accessibility
================================ */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: white;
  color: var(--ink);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  z-index: 200;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ================================
   Header
================================ */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
}

header nav a {
  position: relative;
  color: var(--ink-lighter);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: color 0.3s ease;
}

header nav a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--brand);
  transition: width 0.3s ease;
}

header nav a:hover {
  color: var(--brand);
}

header nav a:hover::after {
  width: 100%;
}

header nav a[aria-current="page"] {
  color: var(--brand-dark);
  font-weight: 600;
}

/* ================================
   Mobile Navigation
================================ */
.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.hamburger-btn:hover {
  background: rgba(15, 23, 42, 0.05);
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
}

.hamburger-btn.is-open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.is-open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.hamburger-btn.is-open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

#mobile-nav {
  display: none;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

#mobile-nav.is-open {
  display: block;
  animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-nav-link {
  display: block;
  color: var(--ink-lighter);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  transition: color 0.2s ease, padding-left 0.2s ease;
}

.mobile-nav-link:last-child {
  border-bottom: none;
}

.mobile-nav-link:hover {
  color: var(--brand);
  padding-left: 0.5rem;
}

@media (max-width: 767px) {
  .hamburger-btn {
    display: flex;
  }
}

/* ================================
   Components
================================ */
.card {
  position: relative;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(8, 145, 178, 0.2);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.875rem;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-lighter);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.badge:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
  color: var(--brand);
}

.badge-fall {
  position: absolute;
  top: -100px;
  left: 0;
  opacity: 1;
  cursor: default;
  pointer-events: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--brand-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: white;
  color: var(--ink);
  border: 1px solid rgba(15, 23, 42, 0.15);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: var(--shadow-md);
}

/* Icon containers */
.icon-box {
  position: relative;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: var(--brand);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.card:hover .icon-box {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

/* ================================
   Sections
================================ */
section {
  position: relative;
  padding: 5rem 0;
}

section:nth-child(even) {
  background: white;
}

section:nth-child(odd) {
  background: var(--surface);
}

/* ================================
   Animations
================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.show {
  opacity: 1;
  transform: translateY(0);
}

.float {
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* ================================
   Hero
================================ */
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(8, 145, 178, .12), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(8, 145, 178, .15), transparent 35%),
    linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .6));
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
  mask-image: radial-gradient(circle at 50% 30%, black 30%, transparent 70%);
}

.geo {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-geo {
  opacity: 0.08;
}

.grid-pattern {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(8, 145, 178, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(8, 145, 178, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, black 30%, transparent 70%);
}

.logo-image {
  max-height: 1000px;
}

.logo-caption {
  position: absolute;
  bottom: -20px;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-md);
  text-align: center;
}

/* ================================
   Projects
================================ */
.project {
  position: relative;
}

.project::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.project:hover::after {
  opacity: 0.02;
}

/* ================================
   Search
================================ */
#search {
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.9375rem;
  transition: all 0.3s ease;
  outline: none;
  width: 100%;
  max-width: 20rem;
}

#search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

/* ================================
   Footer
================================ */
footer {
  background: var(--ink);
  color: #e2e8f0;
  position: relative;
  overflow: hidden;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand);
  opacity: 0.6;
}

/* ================================
   Physics / Word Cloud
================================ */
.flex-badges {
  position: relative;
  height: 140px;
  overflow: hidden;
}

#physics-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

#wordcloud {
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.75rem;
}

/* ================================
   Loading Shimmer
================================ */
.loading-shimmer {
  background: linear-gradient(90deg,
    rgba(248, 250, 252, 0) 0%,
    rgba(248, 250, 252, 0.8) 50%,
    rgba(248, 250, 252, 0) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ================================
   Utility
================================ */
.brand-text {
  color: var(--brand);
  font-weight: 700;
}

/* ================================
   Responsive
================================ */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  section {
    padding: 3rem 0;
  }

  h1 { font-size: 2.5rem !important; }
  h2 { font-size: 1.875rem !important; }

  #search {
    max-width: 100%;
  }
}

/* ================================
   Scrollbar
================================ */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-dark); }

/* ================================
   Focus States
================================ */
*:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
