/* ============================================================
   marcoromagnolo.it — single stylesheet, no dependencies
   Dark by default (identity of the previous site), light via
   prefers-color-scheme. Print styles at the bottom.
   ============================================================ */

/* ---------- Tokens: dark (default) ---------- */
:root {
  --bg:            #222222;
  --bg-alt:        #1b1b1b;
  --surface:       #2b2b2b;
  --surface-2:     #333333;
  --border:        #3d3d3d;
  --text:          #e5e5e5;
  --heading:       #ffffff;
  --muted:         #9a9a9a;
  --accent:        #00f925;
  --accent-ink:    #0b1a0d;   /* text ON the accent */
  --accent-quiet:  #00c41d;   /* accent for small text / borders */

  --wrap:      64rem;
  --radius:    10px;
  --gap:       1.25rem;
  --header-h:  56px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

/* ---------- Tokens: light ---------- */
@media (prefers-color-scheme: light) {
  :root {
    --bg:           #ffffff;
    --bg-alt:       #f4f5f4;
    --surface:      #ffffff;
    --surface-2:    #f0f1f0;
    --border:       #d9dcd9;
    --text:         #24292b;
    --heading:      #111417;
    --muted:        #5c6360;
    --accent:       #00801a;   /* darkened: AA on white */
    --accent-ink:   #ffffff;
    --accent-quiet: #026b17;

    color-scheme: light;
  }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  color: var(--heading);
  line-height: 1.2;
  margin: 0 0 .5em;
  font-weight: 650;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.9rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 1.85rem); letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
h4 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 650;
  margin: 1.1em 0 .3em;
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-quiet); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent); }

img { max-width: 100%; height: auto; display: block; }

ul, ol { margin: 0; padding: 0; list-style: none; }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .6rem 1rem;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* Inline SVG icons: stroked line style unless fill is set in markup */
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   Header / navigation
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  color: var(--heading);
  text-decoration: none;
  letter-spacing: -.01em;
  margin-right: auto;
}
.brand:hover { color: var(--accent); }

.site-nav ul {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}
.site-nav a {
  display: block;
  padding: .4rem .6rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 550;
}
.site-nav a:hover { color: var(--heading); background: var(--surface-2); }
.site-nav a[aria-current="true"] { color: var(--accent); background: var(--surface-2); }

.nav-toggle {
  display: none;
  align-items: center;
  gap: .5rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .7rem;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before,
.nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after  { top: 5px; }

@media (max-width: 47.99em) {
  .nav-toggle { display: inline-flex; }
  .site-nav { display: none; width: 100%; }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; padding-bottom: .75rem; }
  .site-nav a { padding: .6rem .5rem; font-size: 1rem; }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 3rem);
  align-items: center;
}

@media (max-width: 47.99em) {
  .hero-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}

.avatar {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
}

.hero-text h1 { margin-bottom: .15em; }

.tagline {
  color: var(--accent);
  font-size: clamp(1rem, .9rem + .5vw, 1.2rem);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 2rem;
  margin: 0 0 1.5rem;
}
@media (max-width: 47.99em) { .facts { justify-content: center; } }

.facts > div { min-width: 0; }
.facts dt {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  font-weight: 650;
}
.facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 47.99em) { .actions { justify-content: center; } }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--heading); }

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

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}
@media (max-width: 47.99em) { .social { justify-content: center; } }

.social a {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 550;
}
.social a:hover { color: var(--accent); }

/* ============================================================
   Sections
   ============================================================ */
.section {
  padding-block: clamp(2.5rem, 6vw, 4rem);
  scroll-margin-top: calc(var(--header-h) + 8px);
}
.section-alt { background: var(--bg-alt); }

.section > .wrap > h2 {
  position: relative;
  padding-bottom: .5rem;
  margin-bottom: 1.5rem;
}
.section > .wrap > h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.5rem;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.lede {
  font-size: 1.15rem;
  color: var(--heading);
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ---------- Service cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--gap);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card h3 { margin-bottom: .5rem; }
.card p { color: var(--muted); font-size: .95rem; }

.card-icon {
  width: 2rem;
  height: 2rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: .9rem;
}

/* ---------- Timeline (experience / education / certifications) ---------- */
.timeline {
  display: grid;
  gap: var(--gap);
  position: relative;
  padding-left: 1.5rem;
  border-left: 2px solid var(--border);
}

.entry {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
}

.entry::before {
  content: "";
  position: absolute;
  left: calc(-1.5rem - 6px);
  top: 1.9rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}
.section-alt .entry::before { box-shadow: 0 0 0 3px var(--bg-alt); }

.entry-meta {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .35rem;
  font-variant-numeric: tabular-nums;
}
.entry-meta .sep { opacity: .5; margin-inline: .25rem; }

.entry-meta .year {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: .05rem .45rem;
  border-radius: 4px;
  font-size: .8rem;
}

.entry h3 { margin-bottom: .2rem; }

.entry-org {
  color: var(--accent-quiet);
  font-weight: 600;
  margin-bottom: .5rem;
}

.entry p { font-size: .95rem; }

.tech {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.7;
}

/* ---------- Skills ---------- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: var(--gap);
}

.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}
.skill-group h3 {
  font-size: 1rem;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.tags li {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .7rem;
  font-size: .84rem;
  color: var(--text);
}

/* ---------- Contact ---------- */
.contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: .75rem var(--gap);
  margin-top: 1.25rem;
}
.contact-list li {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-width: 0;
}
.contact-list .icon { color: var(--accent); }
.contact-list a, .contact-list span { overflow-wrap: anywhere; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding-block: 1.5rem;
  font-size: .88rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
  align-items: center;
}
.site-footer p { margin: 0; }

/* ============================================================
   Print — the page should read as a clean CV on paper
   ============================================================ */
@media print {
  :root {
    --bg: #fff; --bg-alt: #fff; --surface: #fff; --surface-2: #fff;
    --border: #bbb; --text: #000; --heading: #000; --muted: #333;
    --accent: #000; --accent-quiet: #000; --accent-ink: #fff;
  }

  .site-header,
  .site-footer,
  .skip-link,
  .actions,
  .card-icon { display: none !important; }

  body { font-size: 10.5pt; line-height: 1.45; }

  .section { padding-block: .6rem; }
  .hero { padding-block: 0 .8rem; border-bottom: 1px solid #bbb; }

  .avatar { max-width: 110px; border-width: 1px; border-color: #999; }

  .entry, .card, .skill-group {
    border: 1px solid #ccc;
    padding: .6rem .8rem;
    break-inside: avoid;
  }
  .timeline { border-left: 1px solid #ccc; padding-left: 1rem; gap: .5rem; }
  .entry::before { background: #000; box-shadow: none; width: 7px; height: 7px; left: calc(-1rem - 4px); }

  .entry-meta .year { background: none; color: #000; border: 1px solid #666; }
  .tags li { border: 1px solid #ccc; }

  h2 { break-after: avoid; }
  h3, h4 { break-after: avoid; }

  a { color: #000; text-decoration: underline; }
}
