/* =========================================================
   Design tokens
   Palette contrast-checked (relative luminance) against
   WCAG AA: body text ~15:1, muted text ~7.4-8:1,
   accent on bg ~7.1:1, borders ~3.6-3.9:1.
   ========================================================= */
:root {
  --bg: #14110f;
  --surface: #1e1a17;
  --surface-raised: #262019;
  --border: #34302b;
  --border-control: #7a7166;
  --text: #ece6df;
  --muted: #b3a89c;
  --accent: #d98f4e;
  --accent-strong: #e8a868;
  --success: #7fae5b;
  --success-text: #c9e2ac;
  --error: #e2665a;
  --error-text: #ffcac1;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --max-content: 46rem;
  --max-wide: 64rem;
  --radius: 10px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html { color-scheme: dark; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 1.5rem + 2vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 1.3rem + 1vw, 2.1rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }

a { color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 0.15em; }
a:hover { color: var(--accent-strong); }

/* Visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--bg);
  padding: 0.75em 1.25em;
  z-index: 100;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus {
  left: 0;
}

.container {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.prose { max-width: var(--max-content); }

/* =========================================================
   Header / nav
   ========================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(20, 17, 15, 0.92);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.header-nav {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
.header-brand:hover { color: var(--accent-strong); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.45em 0.9em;
  cursor: pointer;
}

.header-links {
  display: flex;
  gap: 1.75rem;
}

.header-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.98rem;
  padding: 0.25em 0;
  border-bottom: 2px solid transparent;
}
.header-links a:hover { color: var(--text); }
.header-links a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-block; }
  .header-links {
    display: none;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1.5rem 1rem;
  }
  .header-links.is-open { display: flex; }
  .header-links a { padding: 0.6em 0; border-bottom: 1px solid var(--border); }
  .header-links a[aria-current="page"] { border-bottom-color: var(--border); }
}

/* =========================================================
   Hero
   ========================================================= */
.hero {
  padding: 4rem 0 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
  gap: 3rem;
  align-items: center;
}

.hero h1 { margin-bottom: 0.6em; }
.hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 34rem; }

.cta-row { display: flex; gap: 1rem; margin-top: 1.75rem; flex-wrap: wrap; }

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  padding: 0.75em 1.4em;
  border-radius: 8px;
  text-decoration: none;
}
.button:hover { background: var(--accent-strong); color: var(--bg); }

.button-secondary {
  display: inline-block;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-control);
  padding: 0.7em 1.35em;
  border-radius: 8px;
  text-decoration: none;
}
.button-secondary:hover { border-color: var(--accent-strong); color: var(--accent-strong); }

.stat-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.stat-panel .stat + .stat { border-top: 1px solid var(--border); padding-top: 1.4rem; }
.stat .stat-number { font-family: var(--font-display); font-size: 1.9rem; color: var(--accent-strong); display: block; line-height: 1; }
.stat .stat-label { color: var(--muted); font-size: 0.92rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 2.5rem; }
}

/* =========================================================
   Featured project cards (home)
   ========================================================= */
.featured-projects { padding: 1rem 0 4rem; }
.featured-projects > .container > h2 { margin-bottom: 1.5rem; }

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem;
}

.project-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.5rem;
}
.project-card h3 { margin-bottom: 0.4em; }
.project-card p { color: var(--muted); font-size: 0.97rem; }

.tech-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1rem; }
.tag {
  font-size: 0.8rem;
  background: rgba(217, 143, 78, 0.16);
  color: var(--text);
  border: 1px solid rgba(217, 143, 78, 0.4);
  padding: 0.2em 0.65em;
  border-radius: 999px;
}

.view-link { color: var(--accent); font-weight: 600; text-decoration: none; font-size: 0.95rem; }
.view-link:hover { color: var(--accent-strong); }

/* =========================================================
   Projects timeline (projects.html)
   ========================================================= */
.timeline-intro { padding: 3rem 0 1rem; }

.timeline { list-style: none; margin: 0; padding: 0 0 4rem; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 1.15rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--border);
}

.timeline-item { position: relative; padding: 0 0 2.5rem 3.25rem; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-marker {
  position: absolute;
  left: 0.3rem;
  top: 0.15rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.5rem 1.75rem;
}

.timeline-skill {
  display: inline-block;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 0.5rem;
}

.timeline-card p { color: var(--muted); }

.timeline-links { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-top: 1rem; }

.timeline-closing {
  border: 1px dashed var(--border-control);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* =========================================================
   About page
   ========================================================= */
.about-section { padding: 3rem 0; }
.about-section + .about-section { border-top: 1px solid var(--border); }

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}
.skill-group h3 { font-size: 1.05rem; color: var(--accent-strong); margin-bottom: 0.5em; }
.skill-group ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.skill-group li { margin-bottom: 0.3em; }

/* =========================================================
   Contact form
   ========================================================= */
.contact-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.contact-group legend {
  font-family: var(--font-display);
  font-weight: 600;
  padding: 0 0.4em;
  color: var(--text);
}

.form-field { margin-bottom: 1.25rem; }
.form-field:last-child { margin-bottom: 0; }

.form-field label { display: block; margin-bottom: 0.4em; font-weight: 600; font-size: 0.95rem; }
.form-field .hint { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.4em; }

.form-field input[type="text"],
.form-field input[type="email"],
.form-field textarea {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border-control);
  color: var(--text);
  border-radius: 6px;
  padding: 0.65em 0.8em;
  font-family: var(--font-body);
  font-size: 1rem;
}
.form-field textarea { resize: vertical; min-height: 7rem; }

.form-field input[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] {
  border-color: var(--error);
}

.radio-option { display: flex; align-items: center; gap: 0.6em; margin-bottom: 0.6em; }
.radio-option:last-child { margin-bottom: 0; }
.radio-option input { accent-color: var(--accent); width: 1.1em; height: 1.1em; }

.field-error {
  color: var(--error-text);
  font-size: 0.88rem;
  margin-top: 0.4em;
  min-height: 1.2em;
}

.required-note { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }

.error-summary {
  background: rgba(226, 102, 90, 0.12);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.5rem;
}
.error-summary h3 { color: var(--error-text); font-size: 1.05rem; margin-bottom: 0.5em; }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary a { color: var(--error-text); }
.error-summary[hidden] { display: none; }

.success-message {
  background: rgba(127, 174, 91, 0.14);
  border: 1px solid var(--success);
  color: var(--success-text);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin-bottom: 1.5rem;
}
.success-message[hidden] { display: none; }

.submit-button {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 0.8em 1.6em;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font-body);
}
.submit-button:hover { background: var(--accent-strong); }

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-strong); }
