/* ---------- Tokens ---------- */
:root {
  --bg: #ECEFF3;
  --surface: #F6F7F9;
  --ink: #1B2433;
  --muted: #566074;
  --rule: #C8CFDA;
  --accent: #1F4FD8;
  --accent-ink: #FFFFFF;

  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --text-body: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --text-lede: clamp(1.25rem, 1.05rem + 1vw, 1.625rem);
  --text-h2: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
  --text-small: 0.9375rem;

  --gutter: clamp(1.25rem, 5vw, 3rem);
  --max: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171F;
    --surface: #1A212C;
    --ink: #E6EAF0;
    --muted: #9AA5B8;
    --rule: #2B3545;
    --accent: #8AA4FF;
    --accent-ink: #10151D;
  }
}

:root[data-theme="dark"] {
  --bg: #12171F;
  --surface: #1A212C;
  --ink: #E6EAF0;
  --muted: #9AA5B8;
  --rule: #2B3545;
  --accent: #8AA4FF;
  --accent-ink: #10151D;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--text-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }

a { color: inherit; }

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

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--sans);
  font-size: var(--text-small);
  z-index: 10;
}
.skip-link:focus { top: 0.75rem; }

/* ---------- Header ---------- */
.site-header {
  padding-block: 1.25rem;
}

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

.wordmark {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 1.75rem;
  font-family: var(--sans);
  font-size: var(--text-small);
  font-weight: 500;
  margin-left: auto;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--ink); }

.nav a[aria-current="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  font-family: var(--sans);
  font-size: var(--text-small);
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}

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

@media (max-width: 36rem) {
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 1.5rem;
  }
}

/* ---------- Hero ---------- */
.hero {
  padding-block: clamp(2.5rem, 8vw, 6rem) clamp(3rem, 8vw, 6rem);
}

.hero-name {
  font-family: var(--sans);
  font-weight: 800;
  font-stretch: 112%;
  font-size: clamp(3.75rem, 14vw, 10.5rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
}

.hero-name .line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.06em;
}

.hero-name .line > span {
  display: block;
  animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hero-name .line:nth-child(2) > span { animation-delay: 0.12s; }

@keyframes rise {
  from { transform: translateY(105%); }
  to { transform: translateY(0); }
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
  align-items: start;
}

.lede {
  font-size: var(--text-lede);
  line-height: 1.5;
  max-width: 34rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
}

.now {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  display: grid;
  gap: 1.1rem;
}

.now dt {
  font-family: var(--sans);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--muted);
}

.now dd {
  font-size: 1.0625rem;
  line-height: 1.4;
  margin-top: 0.1rem;
}

@media (max-width: 52rem) {
  .hero-grid { grid-template-columns: 1fr; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
  padding: 0.95rem 1.4rem;
  border-radius: 4px;
  border: 1.5px solid transparent;
  cursor: pointer;
}

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

.btn-primary:hover { filter: brightness(1.1); }

.btn-text {
  padding-inline: 0;
  border-radius: 0;
  border-bottom: 1.5px solid var(--ink);
  padding-block: 0.4rem;
}

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

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
  padding: 0.7rem 1.1rem;
  font-size: var(--text-small);
}

.btn-outline:hover { border-color: var(--ink); }

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(3rem, 7vw, 5.5rem);
  border-top: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}

.section h2 {
  font-family: var(--sans);
  font-weight: 700;
  font-stretch: 105%;
  font-size: var(--text-h2);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* ---------- Projects ---------- */
.projects { margin-top: clamp(1.75rem, 4vw, 3rem); }

.project {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 14rem;
  gap: 1rem 2rem;
  padding-block: 1.75rem;
  border-top: 1px solid var(--rule);
}

.project:last-child { border-bottom: 1px solid var(--rule); }

.project-year,
.project-stack {
  font-family: var(--sans);
  font-size: var(--text-small);
  color: var(--muted);
  line-height: 1.5;
  padding-top: 0.3rem;
}

.project h3 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.375rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.project h3 a {
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 2px no-repeat;
  padding-bottom: 2px;
  transition: background-size 0.25s ease;
}

.project h3 a:hover { background-size: 100% 2px; }

.project-body p {
  margin-top: 0.4rem;
  max-width: 36rem;
  color: var(--muted);
}

@media (max-width: 48rem) {
  .project {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .project-year,
  .project-stack { padding-top: 0; }
  .project-year { order: -1; }
}

/* ---------- About & Contact ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 1rem 2rem;
}

.about-grid h2 { grid-column: 1 / -1; }

.about-body,
.contact-body { grid-column: 1 / -1; }

@media (min-width: 48rem) {
  .about-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: 2rem 4rem; }
  .about-grid h2 { grid-column: 1; }
  .about-body,
  .contact-body { grid-column: 2; }
}

.about-body > p,
.contact-body > p:first-child { max-width: 38rem; }

.skills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2rem;
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

.skills dt {
  font-family: var(--sans);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--muted);
}

.skills dd { margin-top: 0.15rem; line-height: 1.45; }

@media (max-width: 36rem) {
  .skills { grid-template-columns: 1fr; }
}

.email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.5rem;
}

.email {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.25rem);
  letter-spacing: -0.02em;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--rule);
  word-break: break-word;
}

.email:hover { text-decoration-color: var(--accent); }

.copy-status {
  font-family: var(--sans);
  font-size: var(--text-small);
  color: var(--accent);
  min-width: 4rem;
}

.links {
  display: flex;
  gap: 1.75rem;
  margin-top: 1.75rem;
  font-family: var(--sans);
  font-weight: 600;
}

.links a {
  text-decoration: none;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 0.15rem;
}

.links a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: var(--text-small);
  color: var(--muted);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-name .line > span { animation: none; }
  .project h3 a { transition: none; }
}
