/* ============================================================
   Giovanni Benefico — Portfolio
   Minimal, professional, accessibility-first
   ============================================================ */

/* ---------- Design tokens — fir-green palette ---------- */
:root {
  --bg: #fbfdfb;
  --bg-alt: #eef4f0;
  --surface: #ffffff;
  --surface-2: #e6efe9;
  --text: #122019;
  --text-soft: #3f5247;
  --text-faint: #687c71;
  --border: #d6e3db;
  --accent: #2c6e4f;
  --accent-soft: rgba(44, 110, 79, 0.1);
  --accent-contrast: #ffffff;
  --shadow-sm: 0 1px 2px rgba(18, 45, 31, 0.06);
  --shadow-md: 0 8px 24px rgba(18, 45, 31, 0.09);
  --shadow-lg: 0 18px 48px rgba(18, 45, 31, 0.13);

  --maxw: 1120px;
  --radius: 14px;
  --radius-sm: 9px;
  --space: clamp(1rem, 2vw, 1.5rem);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --header-h: 68px;
}

:root[data-theme="dark"] {
  --bg: #0a120d;
  --bg-alt: #0e1812;
  --surface: #121e17;
  --surface-2: #1a2a20;
  --text: #e9f2ec;
  --text-soft: #b0c4b8;
  --text-faint: #84998c;
  --border: #243a2d;
  --accent: #61bd8c;
  --accent-soft: rgba(97, 189, 140, 0.15);
  --accent-contrast: #07120b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.42);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.58);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: clip; /* guard against accidental horizontal scroll without breaking sticky header */
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

/* ---------- Accessibility helpers ---------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: -100px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.7rem 1.2rem;
  border-radius: 0 0 10px 10px;
  font-weight: 600;
  z-index: 200;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}

.section { padding-block: clamp(4rem, 9vw, 7rem); }
.section--alt { background: var(--bg-alt); }

.section__title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 2rem;
}
.section__num {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
}
.section__intro {
  color: var(--text-soft);
  margin-top: -1.2rem;
  margin-bottom: 2.4rem;
  max-width: 60ch;
}

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}
.nav__brand { font-weight: 700; font-size: 1.1rem; }
.nav__mono { font-family: var(--font-mono); color: var(--accent); }

.nav__menu {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 2vw, 1.6rem);
}
.nav__menu a {
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.4rem 0.2rem;
  position: relative;
  transition: color 0.2s ease;
}
.nav__menu a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.nav__menu a:hover { color: var(--text); }
.nav__menu a:hover::after { width: 100%; }

.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.25s ease, opacity 0.25s ease;
}

.nav__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.theme-toggle:hover { background: var(--surface-2); transform: translateY(-1px); }

.lang-toggle {
  height: 38px;
  min-width: 44px;
  padding: 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.lang-toggle:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.theme-toggle__icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: absolute;
}
.theme-toggle__icon--moon { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ---------- Hero ---------- */
/* Animated LetterGlitch background (rendered on <canvas> by js/main.js) */
:root { --glitch-1: #2c6e4f; --glitch-2: #3f9468; --glitch-3: #5aa57c; --glitch-opacity: 0.40; }
:root[data-theme="dark"] { --glitch-1: #2c6e4f; --glitch-2: #41906a; --glitch-3: #569d77; --glitch-opacity: 0.50; }

.hero { padding-block: clamp(3rem, 8vw, 6rem); position: relative; overflow: hidden; }
.hero__bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.hero__glitch { display: block; width: 100%; height: 100%; opacity: var(--glitch-opacity); }
.hero__bg-veil {
  position: absolute;
  inset: 0;
  /* fade the glitch out at the top (under the header) and bottom (into the next
     section) so it blends seamlessly — no hard edge — plus a readability scrim */
  background:
    linear-gradient(to bottom,
      var(--bg) 0%,
      transparent 20%,
      transparent 60%,
      var(--bg) 100%),
    color-mix(in srgb, var(--bg) 50%, transparent);
}
.hero > .container { position: relative; z-index: 1; }
.hero__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.hero__grid > * { min-width: 0; } /* prevent any child from forcing the grid wider than the viewport */
.hero__eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}
.hero__title {
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1.05;
}
.hero__role {
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  font-weight: 600;
  color: var(--text-soft);
  margin-top: 0.5rem;
}
.hero__lead {
  margin-top: 1.4rem;
  color: var(--text-soft);
  max-width: 52ch;
  font-size: 1.05rem;
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2rem;
}
/* GitHub-style contribution calendar (rendered by js/main.js) */
.hero__contrib {
  grid-column: 1 / -1;
  margin-top: 2.8rem;
  width: 100%;
  min-width: 0; /* allow the column to shrink instead of being blown out by the wide calendar */
  /* cell sizing */
  --cell: 13px;
  --gap: 3px;
  /* GitHub light palette */
  --gh-0: #ebedf0; --gh-1: #9be9a8; --gh-2: #40c463; --gh-3: #30a14e; --gh-4: #216e39;
}
:root[data-theme="dark"] .hero__contrib {
  /* GitHub dark palette */
  --gh-0: #161b22; --gh-1: #0e4429; --gh-2: #006d32; --gh-3: #26a641; --gh-4: #39d353;
}
.contrib__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-bottom: 0.9rem;
}
.contrib__count { font-size: 0.95rem; color: var(--text-soft); font-weight: 500; }
.contrib__link { font-size: 0.85rem; color: var(--text-faint); transition: color 0.2s ease; }
.contrib__link:hover { color: var(--accent); }

.contrib__scroll {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  padding-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch; /* momentum scroll on iOS */
  overscroll-behavior-x: contain;
}
.contrib__cal {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 4px;
  width: max-content;
}
.contrib__months {
  grid-column: 2; grid-row: 1;
  display: grid;
  gap: var(--gap);
  height: 1.1em;
  font-size: 0.72rem;
  color: var(--text-faint);
}
.contrib__month { grid-row: 1; white-space: nowrap; }
.contrib__weekdays {
  grid-column: 1; grid-row: 2;
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: var(--gap);
  align-items: center;
  margin-right: 2px;
  font-size: 0.7rem;
  color: var(--text-faint);
}
.contrib__weekday { white-space: nowrap; line-height: 1; }
.contrib__grid {
  grid-column: 2; grid-row: 2;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--cell);
  grid-template-rows: repeat(7, var(--cell));
  gap: var(--gap);
}
.contrib__cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: 3px;
  background: var(--gh-0);
  outline: 1px solid rgba(27, 31, 35, 0.06);
  outline-offset: -1px;
}
:root[data-theme="dark"] .contrib__cell { outline-color: rgba(255, 255, 255, 0.05); }
.contrib__cell--pad { background: transparent; outline: 0; }
.contrib__legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--text-faint);
}
.contrib__swatch { width: var(--cell); height: var(--cell); }
/* image fallback if the data API is unreachable */
.hero__contrib img { max-width: 100%; height: auto; border-radius: 6px; }

.hero__media { display: grid; place-items: center; }
.hero__avatar-wrap { position: relative; }
.hero__avatar {
  width: clamp(200px, 30vw, 300px);
  height: clamp(200px, 30vw, 300px);
  border-radius: 24px;
  object-fit: cover;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.hero__avatar-wrap::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--accent), transparent 60%);
  opacity: 0.18;
  z-index: -1;
}
.hero__badge {
  position: absolute;
  bottom: -14px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------- About ---------- */
.about__grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.about__text p { color: var(--text-soft); margin-bottom: 1.1rem; }
.about__text strong { color: var(--text); font-weight: 600; }

.about__facts {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}
.about__facts-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 1rem;
}
.about__facts-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.about__facts-list > div:last-child { border-bottom: 0; }
.about__facts-list dt { color: var(--text-faint); font-size: 0.9rem; }
.about__facts-list dd { font-weight: 600; font-size: 0.9rem; text-align: right; }

/* ---------- Projects ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: 1.4rem;
}
.project {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.project:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.project__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.project__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.project__folder { color: var(--accent); }
.project__link {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  box-shadow: var(--shadow-sm);
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.project__link:hover,
.project__link:focus-visible {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.project__title { font-size: 1.2rem; }
.project__desc { color: var(--text-soft); font-size: 0.95rem; flex-grow: 1; }
.project__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.project__tags li {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.project--cta {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--accent-soft);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.project__cta-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--accent);
}
.project__cta-inner p { color: var(--text-soft); }

/* ---------- Skills ---------- */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 1.4rem;
}
.skills__group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
.skills__group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 1rem;
}
.skills__group ul { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.skills__group li {
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface-2);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
}

/* ---------- Path / Timeline ---------- */
.path__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.5rem, 5vw, 3.5rem);
}
.path__heading {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent-soft);
}
.timeline { position: relative; padding-left: 1.6rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline__item { position: relative; padding-bottom: 1.8rem; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -1.6rem; top: 6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-alt);
  margin-left: -0.5px;
}
.timeline__date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}
.timeline__item h4 { font-size: 1.02rem; margin-top: 0.25rem; }
.timeline__item p { color: var(--text-soft); font-size: 0.92rem; margin-top: 0.2rem; }
.timeline__item a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.path__note {
  margin-top: 1.8rem;
  color: var(--text-faint);
  font-size: 0.92rem;
  font-style: italic;
  border-left: 3px solid var(--border);
  padding-left: 1rem;
}

/* ---------- Contact ---------- */
.section--contact { text-align: left; }
.contact__lead {
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0;
  font-size: 1.05rem;
}
.contact__list {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 1.4rem 2.6rem;
}
.contact__list a,
.contact__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--text);
  transition: color 0.2s ease, transform 0.2s ease;
}
.contact__list a:hover,
.contact__copy:hover { color: var(--accent); transform: translateY(-2px); }
.contact__copy {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.contact__copy.is-copied { color: var(--accent); }
.contact__icon {
  flex-shrink: 0;
  color: var(--accent);
}
.contact__text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  text-align: left;
}
.contact__label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.contact__value { font-weight: 600; word-break: break-word; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2rem;
  background: var(--bg-alt);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  align-items: center;
  color: var(--text-faint);
  font-size: 0.88rem;
}
.site-footer__top {
  font-weight: 600;
  color: var(--text-soft);
  transition: color 0.2s ease;
}
.site-footer__top:hover { color: var(--accent); }
.site-footer__version {
  display: inline-block;
  margin-left: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-faint);
  border: 1px solid var(--border);
  padding: 0.08rem 0.5rem;
  border-radius: 999px;
  vertical-align: 1px;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  /* mobile: hamburger on the left, brand on the right */
  .nav__toggle { display: flex; order: -1; }
  .nav__menu {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem clamp(1.1rem, 4vw, 2.5rem) 1.6rem;
    box-shadow: var(--shadow-md);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .nav__menu.is-open { transform: none; opacity: 1; pointer-events: auto; }
  .nav__menu a { display: block; width: 100%; padding: 0.6rem 0; font-size: 1.05rem; }
  .nav__menu li:last-child { margin-top: 0.4rem; }

  .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); }

  .hero__grid { grid-template-columns: 1fr; text-align: center; }
  .hero__media { grid-row: 1; }
  .hero__lead { margin-inline: auto; }
  .hero__actions { justify-content: center; }
  .hero__contrib { text-align: left; margin-top: 2.2rem; }

  .about__grid { grid-template-columns: 1fr; }
  .path__grid { grid-template-columns: 1fr; gap: 2.5rem; }

  /* tap targets a bit taller in the mobile menu */
  .nav__menu a { padding: 0.7rem 0; }
}

@media (max-width: 600px) {
  /* stack contacts vertically for easier tapping */
  .contact__list {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.15rem;
  }
  /* slightly smaller contribution cells so less horizontal scrolling */
  .hero__contrib { --cell: 11px; --gap: 2px; }
  /* keep the top/bottom blend on mobile too, slightly stronger scrim */
  .hero__bg-veil {
    background:
      linear-gradient(to bottom, var(--bg) 0%, transparent 16%, transparent 62%, var(--bg) 100%),
      color-mix(in srgb, var(--bg) 56%, transparent);
  }

  /* Projects become a swipeable carousel on mobile */
  .projects {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding-bottom: 1.1rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none; /* Firefox */
  }
  .projects::-webkit-scrollbar { display: none; } /* WebKit */
  .project {
    flex: 0 0 84%;
    scroll-snap-align: start;
  }
}

@media (max-width: 480px) {
  .hero { padding-block: clamp(2rem, 7vw, 3rem); }
  .hero__title { font-size: clamp(2rem, 9vw, 2.5rem); }
  .hero__avatar { width: 180px; height: 180px; }
  .section { padding-block: clamp(3rem, 12vw, 4.5rem); }
  .project, .skills__group, .about__facts { padding: 1.3rem; }
  /* let the two header controls sit comfortably */
  .nav__controls { gap: 0.6rem; }
}

/* ---------- 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; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .theme-toggle, .lang-toggle, .nav__toggle, .hero__actions, .hero__contrib, .project--cta { display: none; }
  body { background: #fff; color: #000; }
  .section { padding-block: 1.5rem; }
}
