/* ===== Design Tokens ===== */
:root {
  --bg: #f7f4ee;
  --surface: #fffdf8;
  --surface-strong: #fef8ea;
  --text: #171411;
  --muted: #5f584f;
  --line: #d4cbbf;
  --primary: #d44b24;
  --primary-ink: #ffffff;
  --accent: #0f4d5c;
  --accent-light: rgba(15, 77, 92, 0.10);
  --mono: "IBM Plex Mono", monospace;
  --sans: "Sora", sans-serif;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(18, 16, 12, 0.08);
  --header-bg: rgba(247, 244, 238, 0.85);
  --card-hover-border: var(--primary);
  --gradient-start: #d44b24;
  --gradient-mid: #e8734a;
  --gradient-end: #0f4d5c;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-strong: #252525;
  --text: #e8e4de;
  --muted: #a09a92;
  --line: #333;
  --primary: #e8734a;
  --accent: #5ec4b6;
  --accent-light: rgba(94, 196, 182, 0.12);
  --header-bg: rgba(18, 18, 18, 0.88);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  --gradient-start: #e8734a;
  --gradient-mid: #f09070;
  --gradient-end: #5ec4b6;
}

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

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
}

/* ===== Noise Texture Overlay ===== */
.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

[data-theme="dark"] .noise {
  opacity: 0.06;
}

/* ===== Background Blobs ===== */
.bg-layer {
  position: fixed;
  z-index: -2;
  border-radius: 999px;
  filter: blur(0.5px);
  opacity: 0.45;
  transition: opacity 0.35s ease;
}

[data-theme="dark"] .bg-layer {
  opacity: 0.15;
}

.bg-one {
  width: 42rem;
  height: 42rem;
  background: radial-gradient(circle, #f8c97a 0%, transparent 70%);
  top: -17rem;
  right: -9rem;
}

.bg-two {
  width: 36rem;
  height: 36rem;
  background: radial-gradient(circle, #9ad8d3 0%, transparent 70%);
  left: -13rem;
  bottom: -12rem;
}

/* ===== Header ===== */
.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.3rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--header-bg);
  z-index: 10;
  transition: background 0.35s ease;
}

.brand {
  font-family: var(--mono);
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.brand:hover {
  border-color: var(--primary);
  color: var(--primary);
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  position: relative;
  transition: color 0.2s ease;
}

nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.25s ease;
}

nav a:hover::after,
nav a:focus-visible::after,
nav a.is-active::after {
  width: 100%;
}

nav a:hover,
nav a:focus-visible {
  color: var(--primary);
}

/* ===== Hamburger Menu Toggle ===== */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
  padding: 0.45rem;
  position: absolute;
  right: 3.8rem;
  top: 1.3rem;
  z-index: 11;
  transition: border-color 0.2s ease;
}

.nav-toggle:hover {
  border-color: var(--primary);
}

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

.nav-toggle.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ===== Dark Mode Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===== Main ===== */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}

/* ===== Hero ===== */
.hero {
  min-height: 80vh;
  display: grid;
  align-content: center;
  gap: 1.1rem;
  padding: 2rem 0 1rem;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
  min-height: 1.4em;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
  max-width: 18ch;
  margin: 0;
}

/* ===== Gradient Text ===== */
.gradient-text {
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 6s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.lead {
  max-width: 72ch;
  color: var(--muted);
  margin: 0;
}

.lead strong {
  color: var(--text);
}

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

/* ===== Buttons ===== */
.btn {
  text-decoration: none;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 8px 22px rgba(212, 75, 36, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(212, 75, 36, 0.4);
}

.btn-ghost {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .btn-ghost {
  background: rgba(255, 255, 255, 0.06);
}

.btn-resume {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.resume-success {
  margin: 0.1rem 0 0;
  font-size: 0.9rem;
  color: var(--accent);
  font-family: var(--mono);
}

/* ===== Metric Grid ===== */
.metric-grid {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.metric-grid li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.metric-grid li:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 48px rgba(18, 16, 12, 0.12);
  border-color: var(--primary);
}

.metric-grid strong {
  display: block;
  font-size: 1.6rem;
  color: var(--primary);
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.section-head h2 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  line-height: 1.2;
  margin: 0.4rem 0 1rem;
  max-width: 28ch;
}

.section-copy {
  color: var(--muted);
  max-width: 75ch;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 52px rgba(18, 16, 12, 0.13);
  border-color: var(--card-hover-border);
}

.card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.6rem;
  line-height: 1.25;
  font-size: 1.1rem;
}

.card p {
  margin: 0 0 0.8rem;
  color: var(--muted);
}

/* ===== Project Grid ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.project-grid .project-card:first-child {
  grid-column: 1 / -1;
}

.project-card {
  display: grid;
  gap: 0.8rem;
  align-content: start;
}

.project-points {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.project-points li {
  margin-bottom: 0.3rem;
}

.project-link {
  justify-self: start;
}

/* ===== Tech Chips ===== */
.tech-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tech-chips span {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  white-space: nowrap;
}

.stack {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
}

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  margin-bottom: 0.4rem;
  letter-spacing: 0.04em;
}

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

.timeline::before {
  content: "";
  position: absolute;
  left: 0.55rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 2px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  padding: 0 0 2.5rem;
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -1.55rem;
  top: 0.25rem;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  background: var(--primary);
  border: 2px solid var(--bg);
  z-index: 1;
}

.timeline-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid var(--primary);
  animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2); opacity: 0; }
}

.timeline-date {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.82rem;
}

.duration-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.timeline-meta h3 {
  margin: 0.4rem 0 0.1rem;
  font-size: 1.12rem;
}

.timeline-company {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.timeline-item ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.timeline-item li {
  margin-bottom: 0.3rem;
}

/* ===== Skills Grid ===== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.skill-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.skill-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 16px 48px rgba(18, 16, 12, 0.12);
}

.skill-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

/* ===== Education ===== */
.education-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.education-card {
  display: grid;
  gap: 0.3rem;
  align-content: start;
}

.edu-institution {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

.edu-date {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0;
}

/* ===== Contact ===== */
.contact {
  text-align: center;
  padding-bottom: 2rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.contact-links a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.52rem 0.9rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.5);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

[data-theme="dark"] .contact-links a {
  background: rgba(255, 255, 255, 0.06);
}

.contact-links a:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.contact-resume-btn {
  margin-top: 1rem;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 20, 17, 0.52);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 30;
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  width: min(640px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(18, 16, 12, 0.25);
  padding: 1.2rem 1.2rem 1.35rem;
  position: relative;
}

.modal-card h2 {
  margin: 0.35rem 0 1rem;
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  line-height: 1.24;
}

.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.38rem;
}

.form-grid label {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.35rem;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.62rem 0.72rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.form-grid input:focus-visible,
.form-grid textarea:focus-visible {
  outline: 2px solid rgba(212, 75, 36, 0.45);
  border-color: var(--primary);
}

.form-grid .field-missed {
  border-color: #b42424;
  background: #fff6f6;
}

.form-banner {
  margin: 0.3rem 0 0.7rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #7f1e1e;
  background: #ffecec;
  border: 1px solid #efb2b2;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}

.modal-submit {
  margin-top: 0.95rem;
}

.honeypot {
  display: none;
}

[hidden] {
  display: none !important;
}

/* ===== Hero Entrance ===== */
.hero {
  opacity: 0;
  animation: hero-entrance 0.8s ease 0.2s forwards;
}

@keyframes hero-entrance {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  z-index: 20;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, border-color 0.2s ease, color 0.2s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.2rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ===== Reveal Animations ===== */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children */
[data-reveal-stagger] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

[data-reveal-stagger].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Typed Cursor ===== */
.typed-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .metric-grid,
  .card-grid,
  .skills-grid,
  .project-grid,
  .education-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-grid .project-card:first-child {
    grid-column: auto;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .site-header {
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding-right: 5.5rem;
  }

  .nav-toggle {
    display: flex;
  }

  .theme-toggle {
    position: absolute;
    top: 1.3rem;
    right: 1.25rem;
  }

  nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0.15rem;
    padding: 0.75rem 0 0.25rem;
  }

  nav.is-open {
    display: flex;
  }

  nav a {
    padding: 0.5rem 0;
    font-size: 1rem;
  }

  nav a::after {
    bottom: 2px;
  }

  h1 {
    max-width: 100%;
  }

  .metric-grid,
  .card-grid,
  .skills-grid,
  .project-grid,
  .education-grid {
    grid-template-columns: 1fr;
  }

  .section {
    padding-top: 3.8rem;
  }

  .modal-card {
    padding: 1rem 0.95rem 1.1rem;
  }

  .back-to-top {
    bottom: 1.2rem;
    right: 1.2rem;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  [data-reveal],
  [data-reveal-stagger] {
    opacity: 1;
    transform: none;
  }

  .hero {
    opacity: 1;
    animation: none;
  }

  .gradient-text {
    animation: none;
  }

  .timeline-pulse {
    display: none;
  }
}

/* ===== Print ===== */
@media print {
  .noise,
  .bg-layer,
  .site-header,
  .theme-toggle,
  .nav-toggle,
  .back-to-top,
  .hero-actions,
  .modal-backdrop,
  .btn-resume,
  .contact-resume-btn,
  .typed-cursor {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  main {
    max-width: 100%;
    padding: 0;
  }

  .hero {
    min-height: auto;
    opacity: 1;
    animation: none;
  }

  .section {
    padding-top: 1.5rem;
    page-break-inside: avoid;
  }

  [data-reveal],
  [data-reveal-stagger] {
    opacity: 1 !important;
    transform: none !important;
  }

  .card,
  .skill-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .gradient-text {
    -webkit-text-fill-color: currentColor;
    background: none;
  }

  .card-grid,
  .skills-grid,
  .project-grid,
  .education-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .contact-links a {
    color: #000;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  footer {
    border-top: 1px solid #ccc;
  }
}
