/* ==========================================================================
   Salvador Lourenço Antunes · Portfolio
   Flat colours, one accent, no effects. Light by default, dark on request.
   ========================================================================== */

:root {
  --bg: #fbfbf8;
  --text: #151515;
  --muted: #63635d;
  --rule: #dcdcd4;
  --accent: #1c3fe6;
  --photo-bg: #e8e8e0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --text: #ecebe6;
    --muted: #a3a29b;
    --rule: #2e2e2b;
    --accent: #93a8ff;
    --photo-bg: #1c1c1a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111110;
  --text: #ecebe6;
  --muted: #a3a29b;
  --rule: #2e2e2b;
  --accent: #93a8ff;
  --photo-bg: #1c1c1a;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; background: var(--photo-bg); border-radius: 3px; }

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--bg); }

.wrap { max-width: 1160px; margin-inline: auto; padding-inline: 28px; }

.skip { position: absolute; left: -9999px; top: 8px; padding: 6px 12px; background: var(--text); color: var(--bg); z-index: 20; }
.skip:focus { left: 8px; }

/* ---------- Text pieces used everywhere ---------- */

h3 { font-size: 1.3rem; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }

.meta { margin-top: 4px; font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: 0.8rem; color: var(--muted); }
.flag { color: var(--accent); font-weight: 500; }

.list { margin-top: 14px; }
.list li { position: relative; padding-left: 1.3em; }
.list li + li { margin-top: 6px; }
.list li::before { content: "–"; position: absolute; left: 0; color: var(--muted); }

.stack-line { margin-top: 14px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; }
.note { margin-top: 12px; color: var(--muted); font-style: italic; }

.sub { margin: 44px 0 6px; font-size: 1rem; }
.sub span { margin-left: 6px; font-weight: 400; color: var(--muted); font-size: 0.9rem; }

figcaption { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }

/* ---------- Header ---------- */

.site-head { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--rule); }
.head-inner { display: flex; align-items: baseline; gap: 28px; padding-block: 15px; }
.site-name { font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.site-head nav { display: flex; gap: 22px; margin-left: auto; font-size: 0.92rem; }
.site-head nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.site-head nav a:hover { color: var(--text); text-decoration: underline; }
.theme-toggle {
  padding: 3px 10px;
  border: 1px solid var(--rule); border-radius: 3px;
  background: none; color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: 0.75rem;
  white-space: nowrap; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text); }

/* ---------- Intro ---------- */

.intro { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 64px; align-items: end; padding-block: 72px 56px; }
h1 { margin-bottom: 28px; font-size: clamp(2.6rem, 6.2vw, 4.6rem); font-weight: 500; line-height: 1.02; letter-spacing: -0.035em; }
.intro-lead { max-width: 33em; font-size: 1.22rem; line-height: 1.5; }
.intro-links { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 26px; }
.intro-photo { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }

.strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--text); }
.strip div { padding: 16px 20px 22px 0; }
.strip dt, .facts dt, .skills dt, .stats dt { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: 0.78rem; color: var(--muted); }
.strip dd { margin-top: 2px; font-weight: 500; }

/* ---------- Sections: label on the left, content on the right ---------- */

.sec { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 48px; padding-block: 64px; border-top: 1px solid var(--rule); }
.sec-label h2 { position: sticky; top: 84px; font-size: 1.05rem; font-weight: 600; }
.sec-body > p { max-width: 40em; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 56px; }
.about-bio { font-size: 1.06rem; }
.about-bio p + p { margin-top: 1em; }
.facts div { padding-block: 11px; border-top: 1px solid var(--rule); }
.facts div:first-child { padding-top: 4px; border-top: 0; }
.facts dd { margin-top: 2px; }
.skills div { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; padding-block: 10px; border-top: 1px solid var(--rule); }
.skills dt { padding-top: 4px; }

/* Experience photos */
.photos { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin-top: 30px; }
.frame { height: 300px; overflow: hidden; border-radius: 3px; background: var(--photo-bg); }
.frame img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.frame.zoom img { object-position: 42% 62%; transform: scale(1.35); transform-origin: 42% 78%; }

/* Hackathons */
.sec-intro { font-size: 1.15rem; }
.sec-intro strong { font-weight: 600; }
.hack { display: grid; grid-template-columns: 5fr 7fr; gap: 36px; margin-top: 36px; padding-top: 36px; border-top: 1px solid var(--rule); }
.hack-flip { grid-template-columns: 7fr 5fr; }
.hack-flip figure { order: 2; }
.hack figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.hack-body .meta { margin-top: 0; }
.hack-body h3 { margin-top: 6px; }
.hack-body h3 + p { margin-top: 10px; }
.hack-body .stack-line { margin-top: 14px; }

.event { display: flex; align-items: center; gap: 24px; margin-top: 36px; padding-top: 36px; border-top: 1px solid var(--rule); }
.event img { flex: none; width: 150px; height: 190px; object-fit: cover; object-position: 45% 80%; }
.event .meta { margin-top: 0; }
.event h3 { margin-block: 4px 6px; font-size: 1.15rem; }

/* Projects */
.proj { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding-block: 28px; border-top: 1px solid var(--rule); }
.proj:first-child { padding-top: 0; border-top: 0; }
.proj:last-child { padding-bottom: 0; }
.proj h3 { font-size: 1.15rem; }
.proj-photo { width: 340px; aspect-ratio: 4 / 3; object-fit: cover; margin-top: 18px; }

/* Education */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 28px; }
.stats dd { font-size: 2.3rem; font-weight: 500; line-height: 1.1; letter-spacing: -0.02em; }
.stats small { font-size: 0.45em; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.stats dt { margin-top: 6px; }

.grades { display: grid; grid-template-columns: 1fr 1fr; column-gap: 48px; }
.grades li, .certs li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding-block: 9px; border-top: 1px solid var(--rule); }
.grades b { font-weight: 600; font-variant-numeric: tabular-nums; }
.certs li > span:last-child { color: var(--muted); font-size: 0.9rem; text-align: right; }

/* Outside of code */
.out { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; padding-block: 36px; border-top: 1px solid var(--rule); }
.out:first-child { padding-top: 0; border-top: 0; }
.out:last-child { padding-bottom: 0; }
.out figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.out-body h3 + p { margin-top: 10px; }
.out-body .gap { margin-top: 32px; }

/* Contact */
.contact-mail { display: inline-block; margin-top: 18px; font-size: clamp(1.3rem, 3.4vw, 2.2rem); font-weight: 500; letter-spacing: -0.02em; overflow-wrap: anywhere; }
#contact .links { margin-top: 18px; }

/* Footer */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; padding-block: 22px 44px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---------- Smaller screens ---------- */

@media (max-width: 1020px) {
  .head-inner { flex-wrap: wrap; row-gap: 8px; }
  .site-head nav { order: 3; width: 100%; margin-left: 0; gap: 18px; overflow-x: auto; scrollbar-width: none; }
  .site-head nav::-webkit-scrollbar { display: none; }
  .theme-toggle { margin-left: auto; }
  html { scroll-padding-top: 108px; }
  .sec-label h2 { top: 108px; }
}

@media (max-width: 860px) {
  .site-head { position: static; }
  html { scroll-padding-top: 16px; }

  .intro { grid-template-columns: 1fr; gap: 36px; padding-block: 44px 40px; }
  .intro-photo { max-width: 420px; }
  .strip { grid-template-columns: 1fr 1fr; }
  .strip div:nth-child(n+3) { border-top: 1px solid var(--rule); }

  .sec { grid-template-columns: 1fr; gap: 22px; padding-block: 48px; }
  .sec-label h2 { position: static; font-size: 1.6rem; font-weight: 500; letter-spacing: -0.02em; }

  .about { grid-template-columns: 1fr; gap: 32px; }
  .hack, .hack-flip { grid-template-columns: 1fr; gap: 20px; }
  .hack-flip figure { order: 0; }
  .proj { grid-template-columns: 1fr; gap: 10px; }
  .out { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding-inline: 18px; }
  .intro-lead { font-size: 1.1rem; }
  .skills div { grid-template-columns: 1fr; gap: 2px; }
  .skills dt { padding-top: 0; }
  .photos { grid-template-columns: 1fr 1fr; gap: 12px; }
  .frame { height: 210px; }
  .frame.zoom img { transform: scale(1.15); }
  .event { align-items: flex-start; gap: 16px; }
  .event img { width: 104px; height: 132px; }
  .proj-photo { width: 100%; }
  .stats { grid-template-columns: 1fr; gap: 16px; }
  .grades { grid-template-columns: 1fr; }
}
