/* ============================================================
   TOKENS
   ============================================================ */
[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-surface: #1a1a1a;
  --text: #efefef;
  --muted: #888;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #c96a3a;
  --accent-text: #fff;
  --bg-header: rgba(15, 15, 15, 0.88);
}

[data-theme="light"] {
  --bg: #f5f0e8;
  --bg-surface: #faf7f2;
  --text: #18211d;
  --muted: #5a6b62;
  --border: rgba(24, 33, 29, 0.1);
  --accent: #a04d22;
  --accent-text: #fff;
  --bg-header: rgba(245, 240, 232, 0.92);
}

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

html {
  scroll-behavior: smooth;
}

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

body {
  font-family: "Aptos", "Segoe UI", "Trebuchet MS", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 200ms ease, color 200ms ease;
}

a {
  color: inherit;
}

[id] {
  scroll-margin-top: calc(64px + 1.5rem);
}

/* ============================================================
   HEADER & NAV
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  backdrop-filter: blur(16px);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}

.site-nav {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand {
  text-decoration: none;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.3rem;
}

.nav-links a {
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
  background: var(--bg-surface);
  border-color: var(--border);
  outline: none;
}

.nav-links a.is-active {
  color: var(--accent-text);
  background: var(--accent);
  border-color: transparent;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1;
  margin-left: 0.4rem;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-surface);
  border-color: var(--border);
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page-wrap {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 5rem 0 6rem;
  display: flex;
  flex-direction: column;
  gap: 7rem;
}

/* ============================================================
   HOME SECTION
   ============================================================ */
.section-home {
  display: flex;
  flex-direction: column;
  align-items: center; /* centers the photo */
}

.hero-photo {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 18%;
  border: 2px solid var(--border);
  margin-bottom: 2.5rem;
  display: block;
  /* GPU layer promotion helps with circular crop rendering */
  transform: translateZ(0);
  backface-visibility: hidden;
  /* Safari antialiasing fix for border-radius */
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.section-home h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(1.9rem, 4.2vw, 3rem);
  line-height: 1.15;
  /* Reserve height for two lines so layout never jumps as text cycles */
  min-height: 2.3em;
  margin: 0 0 1.2rem;
  width: 100%;
  text-align: left;
}

.typewriter {
  color: var(--accent);
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 0.75em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: -0.05em;
  animation: blink 0.9s step-end infinite;
}

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

.lead {
  color: var(--muted);
  font-size: clamp(0.95rem, 1.8vw, 1.08rem);
  margin: 0 0 1.8rem;
  width: 100%;
  text-align: left;
  line-height: 1.75;
}

.section-home .actions {
  justify-content: flex-start;
}

/* ============================================================
   ABOUT SECTION
   ============================================================ */
.section-about {
  max-width: 80ch;
  margin: 0 auto;
}

.about-text {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.85;
  margin: 0;
}

/* ============================================================
   METRICS SECTION
   ============================================================ */
.section-metrics {
  max-width: 80ch;
  margin: 0 auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.metric-number {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  color: var(--accent);
  line-height: 1;
}

.metric-label {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ============================================================
   PORTFOLIO SECTION
   ============================================================ */
.section-heading {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(1.2rem, 2.5vw, 1.7rem);
  margin: 0 0 0.75rem;
}

.portfolio-intro {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0 0 1.5rem;
  line-height: 1.7;
}

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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 180ms ease;
}

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

.card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 0;
  flex: 1;
}

/* ============================================================
   CONTACT SECTION
   ============================================================ */
.section-contact {
  max-width: 80ch;
  margin: 0 auto;
  text-align: center;
}

.section-contact h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  margin: 0 0 1rem;
}

.section-contact p {
  color: var(--muted);
  margin: 0 0 1.6rem;
  line-height: 1.75;
}

.section-contact .actions {
  justify-content: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.52rem 1rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  transition: border-color 180ms ease, background 180ms ease;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.button:hover,
.button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.button-primary:hover,
.button-primary:focus-visible {
  opacity: 0.88;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
}

/* ============================================================
   SCROLL REVEAL
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 520ms ease, transform 520ms ease;
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .page-wrap {
    gap: 4.5rem;
    padding-top: 3rem;
    padding-bottom: 4rem;
  }

  .section-home h1 {
    min-height: 3.45em;
  }
}

@media (max-width: 480px) {
  .nav-links a {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
  }

  .brand-sub {
    display: none;
  }

  .brand-name {
    letter-spacing: 0.07em;
  }
}
