/* ==========================================================================
   Rafael Baptista - portfolio site
   Light + dark theme, auto by system setting, manual override saved in
   localStorage (set by assets/js/site.js). No frameworks, no external fonts.
   ========================================================================== */

/* ---------- theme tokens ---------- */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #16191f;
  --muted: #5b6472;
  --line: #dfe3e9;
  --accent: #e2560f;
  --accent-2: #f08c2e;
  --on-accent: #ffffff;
  --overlay: rgba(15, 18, 24, .55);
  --shadow: 0 10px 30px rgba(18, 22, 30, .10);
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1d242e;
  --text: #e8eaee;
  --muted: #98a2b3;
  --line: #2a323d;
  --accent: #ff7a30;
  --accent-2: #ffb066;
  --on-accent: #17120c;
  --overlay: rgba(6, 8, 12, .68);
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1d242e;
    --text: #e8eaee;
    --muted: #98a2b3;
    --line: #2a323d;
    --accent: #ff7a30;
    --accent-2: #ffb066;
    --on-accent: #17120c;
    --overlay: rgba(6, 8, 12, .68);
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  }
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

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

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; }

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.wrap-narrow { width: min(760px, 100% - 2.5rem); margin-inline: auto; }

.subheading {
  display: inline-block;
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: .4rem;
}

.section { padding: 4.5rem 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 46rem; margin-bottom: 2.2rem; }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head p { color: var(--muted); margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

/* ---------- skip link ---------- */
.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--on-accent);
  padding: .6rem 1rem; border-radius: 0 0 8px 0; z-index: 100;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .02em; color: var(--text); order: 0; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; order: 1; }
.nav a {
  color: var(--text); font-size: .95rem; font-weight: 500;
  padding: .5rem .75rem; border-radius: 9px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: .88rem; padding: .45rem .7rem; cursor: pointer; order: 2;
}
.icon-btn:hover { border-color: var(--accent); }
.theme-btn .i-auto, .theme-btn .i-light, .theme-btn .i-dark { display: none; }
html:not([data-theme]) .theme-btn .i-auto,
html[data-theme="light"] .theme-btn .i-light,
html[data-theme="dark"] .theme-btn .i-dark { display: inline-flex; }
.theme-btn svg { width: 18px; height: 18px; fill: currentColor; display: block; }

.menu-btn { display: none; }

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; order: 1; }
  .nav {
    position: absolute; left: 0; right: 0; top: 64px; order: 3;
    flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: .5rem 1rem 1rem; display: none; margin-left: 0;
  }
  .nav.open { display: flex; }
  .nav a { padding: .75rem .5rem; }
  .theme-btn { order: 2; }
}

@media (max-width: 560px) {
  .brand { font-size: .95rem; }
  .brand img { width: 28px; height: 28px; }
  .theme-btn .theme-label { display: none; }
  body { font-size: 16px; }
}

/* ---------- hero ---------- */
.hero { padding: clamp(3rem, 8vw, 6rem) 0 clamp(2.5rem, 6vw, 4.5rem); }
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 2.5rem; align-items: center; }
.hero h1 span { color: var(--accent); }
.hero .tagline { font-size: 1.15rem; color: var(--muted); margin: 0 0 1.75rem; max-width: 34rem; }
/* hero portrait */
.hero-media { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); background: var(--surface-2); }
.hero-media img { width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 22%; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .7rem; }
@media (max-width: 900px) {
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-media { order: -1; max-width: 380px; }
  .hero-media img { aspect-ratio: 1 / 1; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.25rem; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; font-size: .95rem; border: 1px solid transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- about ---------- */
.about-grid { display: grid; grid-template-columns: .85fr 1.15fr; gap: 2.5rem; align-items: start; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; } }
.portrait { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); position: sticky; top: 90px; }
@media (max-width: 900px) { .portrait { position: static; } }
/* about: three of my own workshop photos instead of one portrait */
.collage {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 6px;
  aspect-ratio: 4 / 4.4; background: var(--line);
}
.collage figure { margin: 0; overflow: hidden; }
.collage figure:first-child { grid-row: span 2; }
.collage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stat-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.stat {
  background: var(--accent); color: var(--on-accent);
  border-radius: 12px; padding: .9rem 1.3rem; font-weight: 600;
}
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.35rem;
}
.section-alt .card { background: var(--bg); }
.card h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- home lab ---------- */
.lab-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) { .lab-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .lab-grid { grid-template-columns: 1fr; } }
.lab-grid li {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; position: relative; overflow: hidden;
}
.lab-grid li::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.lab-grid span { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.lab-grid h3 { font-size: 1.05rem; margin: .3rem 0 .35rem; }
.lab-grid h3 a { color: var(--text); }
.lab-grid h3 a:hover { color: var(--accent); }
.lab-grid p { margin: 0; color: var(--muted); font-size: .93rem; }

/* ---------- skills ---------- */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.4rem 2.5rem; }
.skill h3 { font-size: 1rem; margin-bottom: .4rem; display: flex; justify-content: space-between; gap: 1rem; }
.skill h3 span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- project grid / cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.entry {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  transition: transform .18s ease, border-color .18s ease;
}
.entry:hover { transform: translateY(-3px); border-color: var(--accent); }
.entry .thumb { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.entry .thumb img { width: 100%; height: 100%; object-fit: cover; }
.entry .body { padding: 1.15rem 1.25rem 1.35rem; }
.entry h3 { margin: 0 0 .4rem; font-size: 1.15rem; }
.entry h3 a { color: var(--text); }
.entry p { margin: 0; color: var(--muted); font-size: .95rem; }
.meta { display: flex; flex-wrap: wrap; gap: .75rem; color: var(--muted); font-size: .82rem; margin-bottom: .6rem; }
.tag {
  display: inline-block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  padding: .2rem .55rem; border-radius: 99px;
}
.tag.draft { color: var(--accent); border-color: var(--accent); }

/* featured tiles on the home page */
.tiles { display: grid; grid-template-columns: 2fr 1fr; grid-auto-rows: 1fr; gap: 1.5rem; }
/* first favourite is the big one on the left, the other two stack next to it */
.tiles .tile:first-child { grid-row: span 2; }
@media (max-width: 800px) { .tiles { grid-template-columns: 1fr; } .tiles .tile:first-child { grid-row: auto; } }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 240px; border: 1px solid var(--line); display: flex; align-items: flex-end; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, var(--overlay)); }
.tile .cap { position: relative; padding: 1.2rem 1.3rem; color: #fff; }
.tile .cap h3 { margin: 0; font-size: 1.2rem; }
.tile .cap h3 { color: #fff; }
.tile .cap span { font-size: .85rem; opacity: .85; }
.tile a { position: absolute; inset: 0; }
.tile:hover { border-color: var(--accent); }

/* ---------- CV banner ---------- */
.cta-band { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; }
.cta-band .wrap { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; justify-content: space-between; padding: 2.5rem 0; }
.cta-band h2 { margin: 0; color: #fff; }
.cta-band p { margin: .3rem 0 0; opacity: .9; }
.cta-band .btn { background: #fff; color: #12161c; }

/* ---------- article (project detail) ---------- */
.page-head { padding: 3rem 0 2rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.page-head h1 { margin-bottom: .5rem; }
.crumbs { font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

article.post { padding: 2.5rem 0 3rem; }
article.post p, article.post ul, article.post ol { max-width: 46rem; }
article.post h2 { margin-top: 2.4rem; }
article.post h2:first-of-type { margin-top: 0; }
article.post img, article.post video { border-radius: 12px; border: 1px solid var(--line); margin: 1.4rem 0; background: var(--surface); }
article.post ul, article.post ol { padding-left: 1.3rem; }
article.post li { margin: .35rem 0; }
article.post code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: .1rem .35rem;
}
article.post li code { white-space: nowrap; }
/* multi-line commands in the home-lab guides */
article.post pre {
  max-width: 46rem; overflow-x: auto; margin: 1rem 0 1.4rem; padding: .9rem 1.1rem;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
  font-size: .88rem; line-height: 1.55;
}
article.post pre code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre; }
article.post .todo { background: var(--accent); color: var(--on-accent); padding: 0 .3rem; border-radius: 4px; font-weight: 600; }
blockquote {
  margin: 1.4rem 0; padding: .2rem 1.2rem; border-left: 3px solid var(--accent);
  color: var(--muted); font-style: italic;
}
figure { margin: 1.4rem 0; }
figcaption { color: var(--muted); font-size: .85rem; }
.post-nav { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 1.5rem; margin-top: 2rem; }

/* ---------- experience timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.timeline li {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem 1.35rem;
}
.section-alt .timeline li { background: var(--bg); }
.timeline .when { display: inline-block; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); font-weight: 700; }
.timeline h3 { margin: .35rem 0 0; font-size: 1.15rem; }
.timeline .where { color: var(--muted); font-size: .95rem; margin: 0; }
.timeline p.desc { margin: .5rem 0 0; color: var(--muted); font-size: .95rem; max-width: 46rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.chips li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px;
  padding: .35rem .9rem; font-size: .9rem;
}
.chips li b { color: var(--accent); }

/* ---------- certificates ---------- */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cert-highlights { margin-bottom: 2.75rem; }
.cert-highlights h2 { font-size: 1.5rem; margin: 0 0 .25rem; }
.cert-highlights > p { margin: 0 0 1rem; }
.cert-highlights ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.cert-feature {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 12px; padding: 1rem 1.1rem; display: flex; flex-direction: column;
}
.cert-feature h3 { font-size: 1rem; margin: 0 0 .3rem; line-height: 1.35; }
.cert-feature .cert-links { margin-top: auto; padding-top: .6rem; }
.cert-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.cert-search { flex: 1 1 280px; }
.cert-search input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .95rem;
}
.cert-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.cert-years { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.cert-years a {
  display: inline-block; padding: .35rem .75rem; border: 1px solid var(--line); border-radius: 99px;
  color: var(--muted); font-size: .88rem; background: var(--surface);
}
.cert-years a b { color: var(--text); margin-right: .2rem; }
.cert-years a:hover { border-color: var(--accent); text-decoration: none; }
.cert-year { margin-top: 2.25rem; scroll-margin-top: 90px; }
.cert-year:first-of-type { margin-top: 0; }
.cert-year h2 { font-size: 1.5rem; display: flex; align-items: baseline; gap: .75rem; padding-bottom: .6rem; border-bottom: 2px solid var(--accent); margin: 0 0 .25rem; }
.cert-year h2 span { font-size: .9rem; font-weight: 500; color: var(--muted); }
.cert-list { list-style: none; margin: 0; padding: 0; }
.cert-row {
  display: grid; grid-template-columns: 7.5rem 1fr auto; gap: .35rem 1.25rem; align-items: center;
  padding: .85rem .25rem; border-bottom: 1px solid var(--line);
}
.cert-row time { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.cert-row h3 { font-size: 1rem; margin: 0; line-height: 1.35; }
.cert-row h3 a { color: var(--text); }
.cert-row h3 a:hover { color: var(--accent); }
.cert-meta { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.cert-links { display: flex; gap: 1rem; margin: 0; font-size: .88rem; white-space: nowrap; }
.cert-links a { display: inline-flex; align-items: center; gap: .3rem; }
.cert-links svg { width: 15px; height: 15px; fill: currentColor; flex: none; }
@media (max-width: 680px) {
  .cert-row { grid-template-columns: 1fr; padding: .9rem 0; }
  .cert-row time { order: -1; }
}

/* ---------- contact / footer ---------- */
.contact-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 0 0 1.5rem; padding: 0; list-style: none; }
.contact-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.15rem; }
.contact-list span { display: block; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.contact-list a, .contact-list b { font-weight: 600; }

footer.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 3rem 0 2rem; font-size: .92rem; }
footer.site-footer .cols { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr; gap: 2rem; }
@media (max-width: 900px) { footer.site-footer .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { footer.site-footer .cols { grid-template-columns: 1fr; } }
footer.site-footer h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .8rem; }
footer.site-footer ul { list-style: none; margin: 0; padding: 0; }
footer.site-footer li { margin: .35rem 0; }
footer.site-footer a { color: var(--text); }
footer.site-footer a:hover { color: var(--accent); }
footer.site-footer a svg { width: 15px; height: 15px; fill: currentColor; vertical-align: -3px; }
.social { display: flex; gap: .5rem; margin-top: 1rem; }
.social a {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
.social a:hover { border-color: var(--accent); color: var(--accent); }
.social svg { width: 18px; height: 18px; fill: currentColor; }
.colophon { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- scroll reveal (only when JavaScript is on) ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s ease, transform .5s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
}
