/* ============================================================
   Leonardo Costa · personal site
   Modern minimal theme. All design tokens live in :root below.
   ============================================================ */

:root {
  color-scheme: light;

  /* Colors */
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --text: #16181d;
  --text-muted: #5b616e;
  --border: #e6e8ec;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-dark: #3f37c9;
  --header-bg: rgba(255, 255, 255, 0.82);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --fs-900: clamp(2.6rem, 6vw, 4.2rem);
  --fs-700: clamp(1.6rem, 3.5vw, 2.2rem);
  --fs-500: 1.25rem;
  --fs-400: 1rem;
  --fs-300: 0.9rem;

  /* Spacing */
  --space-section: clamp(3.5rem, 8vw, 6.5rem);
  --container: 1080px;

  /* Misc */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 4px 8px rgba(16, 24, 40, 0.06), 0 16px 40px rgba(16, 24, 40, 0.1);
  --header-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Dark theme ----------
   Applied when the user picks "dark", or via the inline head script when the
   user picks "system" and the OS prefers dark. Only the tokens change. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1115;
  --bg-alt: #161922;
  --text: #e7e9ee;
  --text-muted: #a0a6b4;
  --border: #272b36;
  --accent: #8b8cf7;
  --accent-soft: #1d2030;
  --accent-dark: #7071f2;
  --header-bg: rgba(15, 17, 21, 0.82);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.6);
}

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

html { scroll-behavior: smooth; }

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

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; transition: color 0.2s var(--ease); }
img { max-width: 100%; display: block; }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.2rem, 4vw, 2rem);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-cluster { display: flex; align-items: center; gap: 0.7rem; }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0;
}
.brand-name { font-size: 1rem; letter-spacing: -0.01em; }

.nav-list { display: flex; align-items: center; gap: 0.4rem; }
.nav-list a {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  font-size: var(--fs-300);
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
}
.nav-list a:hover { color: var(--text); background: var(--bg-alt); }
.nav-list a.active { color: var(--accent); }
.nav-cta {
  color: #fff !important;
  background: var(--accent);
}
.nav-cta:hover { background: var(--accent-dark) !important; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.nav-toggle-bar {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s var(--ease), opacity 0.2s var(--ease);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Theme switch (system / light / dark) ---------- */
.theme-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.theme-btn:hover { color: var(--text); }
.theme-btn[aria-pressed="true"] {
  background: var(--bg);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.theme-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- Hero ---------- */
.hero {
  padding: clamp(4rem, 12vw, 8rem) 0 clamp(3rem, 8vw, 5rem);
  background:
    radial-gradient(60% 50% at 50% 0%, var(--accent-soft) 0%, transparent 70%);
}
.hero-inner {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
}
.hero-text { max-width: 720px; }

/* Cute circular profile photo with soft accent ring */
.hero-photo {
  margin: 0;
  justify-self: center;
  position: relative;
  width: clamp(200px, 26vw, 300px);
  aspect-ratio: 1;
}
.hero-photo::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: conic-gradient(from 140deg, var(--accent), #7c8cff, var(--accent-soft), var(--accent));
  filter: blur(2px);
  opacity: 0.55;
  z-index: 0;
}
.hero-photo img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;         /* show the whole photo, zoomed out, same circle */
  object-position: center bottom;
  background: #c7dcef;          /* matches the photo's own background */
  border-radius: 50%;
  border: 5px solid var(--bg);
  box-shadow: var(--shadow-hover);
  transition: transform 0.4s var(--ease);
}
.hero-photo:hover img { transform: translateY(-4px) scale(1.02); }
.hero-eyebrow {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--fs-300);
  margin-bottom: 0.6rem;
}
.hero-name { font-size: var(--fs-900); font-weight: 800; }
.hero-title {
  font-size: var(--fs-700);
  color: var(--text-muted);
  font-weight: 600;
  margin: 0.4rem 0 1rem;
}
.hero-tagline { font-size: var(--fs-500); color: var(--text-muted); max-width: 60ch; }
.hero-location { color: var(--text-muted); font-size: var(--fs-300); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 1.8rem 0 1.6rem; }

.hero-social { display: flex; gap: 0.6rem; }
.hero-social a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  transition: all 0.2s var(--ease);
}
.hero-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.hero-social svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--fs-300);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-ghost { border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-lg { padding: 0.9rem 1.8rem; font-size: 1rem; }

/* ---------- Sections ---------- */
.section { padding-block: var(--space-section); scroll-margin-top: calc(var(--header-h) + 12px); }
.section-alt { background: var(--bg-alt); }
.section-title {
  font-size: var(--fs-700);
  font-weight: 700;
  margin-bottom: 2.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}
.section-num {
  font-size: var(--fs-300);
  color: var(--accent);
  font-weight: 700;
  font-feature-settings: "tnum";
}
.subsection-title { font-size: var(--fs-500); margin: 2.6rem 0 1.2rem; }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.about-text p { color: var(--text-muted); font-size: 1.05rem; }
.about-facts {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
}
.section-alt .about-facts { background: var(--bg); }
.about-facts dl { display: grid; gap: 0.9rem; }
.about-facts div { display: grid; grid-template-columns: 76px 1fr; gap: 0.5rem; }
.about-facts dt { color: var(--text-muted); font-size: var(--fs-300); }
.about-facts dd { margin: 0; font-weight: 500; font-size: var(--fs-300); }
.about-facts a { color: var(--accent); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 1.8rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 2.2rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute;
  left: -1.8rem;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}
.timeline-head h3 { font-size: 1.15rem; font-weight: 700; }
.timeline-date { color: var(--text-muted); font-size: var(--fs-300); white-space: nowrap; }
.timeline-org { color: var(--accent); font-weight: 500; font-size: var(--fs-300); margin: 0.2rem 0 0.7rem; }
.timeline-org a:hover { text-decoration: underline; }
.timeline-grade { font-weight: 600; font-size: var(--fs-300); margin: 0 0 0.6rem; }
.timeline-grade span { color: var(--text-muted); font-weight: 500; }
.timeline-desc { color: var(--text-muted); font-size: var(--fs-300); margin: 0 0 0.8rem; }
.timeline-content .tags-sm { margin-bottom: 0.2rem; }
.timeline-link { display: inline-block; margin-top: 0.7rem; color: var(--accent); font-weight: 600; font-size: var(--fs-300); }
.timeline-link:hover { text-decoration: underline; }
.timeline-bullets { display: grid; gap: 0.4rem; }
.timeline-bullets li {
  position: relative;
  padding-left: 1.1rem;
  color: var(--text-muted);
}
.timeline-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4rem;
}
.skill-group h3 { font-size: 1rem; margin-bottom: 0.9rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tags li {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: var(--fs-300);
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}
/* Tech chips on project cards: bordered, with a small accent dot. */
.tags-sm { gap: 0.45rem; }
.tags-sm li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.28rem 0.65rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.tags-sm li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.section-alt .tags-sm li { background: var(--bg-alt); }
.card:hover .tags-sm li { border-color: var(--accent); }

.soft-skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.soft-skills li {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  display: grid;
  gap: 0.2rem;
}
.soft-skills strong { font-size: 1rem; }
.soft-skills span { color: var(--text-muted); font-size: var(--fs-300); }

/* ---------- Cards (projects + volunteering) ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.4rem;
}
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: #d7dae0; }
.card-title { font-size: 1.2rem; font-weight: 700; }
.card-meta { color: var(--accent); font-weight: 500; font-size: var(--fs-300); margin: 0; }
.card-desc { color: var(--text-muted); margin: 0; flex: 1; }
.card-link { color: var(--accent); font-weight: 600; font-size: var(--fs-300); margin-top: auto; }
.card-link:hover { color: var(--accent-dark); }

/* ---------- Passions ---------- */
.passions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}
.passions li {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  font-weight: 500;
}
.passion-icon { font-size: 1.2rem; }

/* CTF highlight card */
.ctf-card {
  margin-top: 1.8rem;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
}
.ctf-title { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.ctf-desc { color: var(--text-muted); margin: 0.6rem 0 1.1rem; max-width: 65ch; }
.ctf-links { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.ctf-card .btn-ghost { background: var(--bg); }

/* ---------- Contact ---------- */
.contact-inner { max-width: 640px; text-align: center; margin-inline: auto; }
.contact-inner .section-title { justify-content: center; }
.contact-lead { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 1.6rem; }
.contact-social { display: flex; justify-content: center; gap: 1.4rem; margin-top: 1.6rem; }
.contact-social a { color: var(--text-muted); font-weight: 500; font-size: var(--fs-300); }
.contact-social a:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding-block: 1.6rem; }
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: var(--fs-300);
}
.back-to-top:hover { color: var(--accent); }

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */

/* Stop long, unbroken strings (emails, URLs) from forcing horizontal scroll. */
body { overflow-x: hidden; }
.about-facts dd,
.about-facts a,
.contact-inner .btn-lg,
.timeline-org,
.card-desc { overflow-wrap: anywhere; }

/* Tablet & phone: collapse nav to hamburger (8 items need the room sooner). */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    transition: transform 0.35s var(--ease);
    box-shadow: var(--shadow);
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
  }
  .nav.open { transform: translateY(0); }
  .nav-list { flex-direction: column; align-items: stretch; gap: 0; padding: 0.6rem; }
  .nav-list a { padding: 0.9rem 1rem; font-size: 1rem; }
  .nav-cta { text-align: center; margin-top: 0.4rem; }

  .about-grid { grid-template-columns: 1fr; }

  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-text { margin-inline: auto; }
  .hero-photo { grid-row: 1; order: -1; width: clamp(170px, 48vw, 230px); }
  .hero-actions, .hero-social { justify-content: center; }
}

/* Phones: comfier tap targets, full-width buttons, tighter spacing. */
@media (max-width: 520px) {
  :root { --space-section: 3rem; }

  .brand-name { display: none; }              /* keep header clean on tiny screens */

  .hero { padding-top: 3rem; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { width: 100%; }

  .about-facts div { grid-template-columns: 1fr; gap: 0.1rem; }
  .about-facts dt { font-weight: 600; }

  .timeline-head { flex-direction: column; }
  .timeline-date { white-space: normal; }

  .ctf-card { padding: 1.3rem 1.2rem; }
  .ctf-links { flex-direction: column; }
  .ctf-links .btn { width: 100%; }

  .contact-inner .btn-lg { width: 100%; padding-inline: 1rem; font-size: 0.95rem; }
  .contact-social { flex-wrap: wrap; gap: 0.9rem 1.2rem; }

  .footer-inner { justify-content: center; text-align: center; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* No-JS fallback: ensure content is always visible */
.no-js .reveal { opacity: 1; transform: none; }
