:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --border: #e4e4ea;
  --text: #15161b;
  --text-2: #5b5c66;
  --accent: #0e7490;
  --on-accent: #ffffff;
  --chip: #eeeef4;
  --hover: rgb(0 0 0 / 0.04);
  --shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  --radius: 16px;
  --bg-opacity: 0.12;
  color-scheme: light;
}

/* Dark follows the system unless the toggle saved a choice (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d11;
    --surface: #14151b;
    --border: #24252e;
    --text: #f3f3f5;
    --text-2: #a0a0ab;
    --accent: #22d3ee;
    --on-accent: #0c0d11;
    --chip: #1d1e26;
    --hover: rgb(255 255 255 / 0.06);
    --shadow: 0 8px 24px rgb(0 0 0 / 0.5);
    --bg-opacity: 0.16;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0d11;
  --surface: #14151b;
  --border: #24252e;
  --text: #f3f3f5;
  --text-2: #a0a0ab;
  --accent: #22d3ee;
  --on-accent: #0c0d11;
  --chip: #1d1e26;
  --hover: rgb(255 255 255 / 0.06);
  --shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  --bg-opacity: 0.16;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Always reserve the scrollbar's space, so short pages (like the landing page)
   don't shift the layout sideways compared with pages that scroll. */
html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Rotating black-and-white photos behind everything, kept faint so text stays readable. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.bg-layer {
  position: absolute;
  inset: 0;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 2s ease;
}
.bg-layer.on { opacity: var(--bg-opacity); }
@media (prefers-reduced-motion: reduce) {
  .bg-layer { transition: none; }
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}

.hero { padding: 56px 0 40px; }

/* Sticky bar with the Projects / CV switcher, visible while scrolling. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.brand img { border-radius: 50%; }
.pages { display: flex; gap: 6px; }
.pages a {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.pages a:hover { border-color: var(--accent); }
.pages a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.topbar-inner .pages { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* Theme toggle and language menu, matching the bot dashboard (bot.miguelcorreia.dev). */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.pill:hover { background: var(--hover); }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The sun shows in light mode, the moon in dark, and they swap with a spin. */
.theme-toggle { width: 38px; justify-content: center; padding: 0; }
.theme-icons { position: relative; width: 18px; height: 18px; transition: transform 0.1s; }
.theme-icons .icon { position: absolute; inset: 0; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s; }
.theme-icons .icon:first-child { color: #e8a317; }
.theme-icons .icon:last-child { color: var(--accent); opacity: 0; transform: rotate(-90deg) scale(0.4); }
:root[data-theme="dark"] .theme-icons .icon:first-child { opacity: 0; transform: rotate(90deg) scale(0.4); }
:root[data-theme="dark"] .theme-icons .icon:last-child { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icons .icon:first-child { opacity: 0; transform: rotate(90deg) scale(0.4); }
  :root:not([data-theme="light"]) .theme-icons .icon:last-child { opacity: 1; transform: none; }
}
.theme-toggle:active .theme-icons { transform: scale(0.85); }
/* Colours fade only while switching themes, not on every hover. */
.theme-switching, .theme-switching *:not(.icon), .theme-switching *::before, .theme-switching *::after {
  transition: background-color 0.3s, border-color 0.3s, color 0.3s !important;
}

.flag { width: 22px; height: 16px; border-radius: 3px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12); }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > .pill > .icon:last-child { width: 16px; height: 16px; color: var(--text-2); transition: transform 0.15s; }
.menu[open] > .pill { border-color: var(--accent); }
.menu[open] > .pill > .icon:last-child { transform: rotate(180deg); }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 170px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: menu-in 0.12s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.menu-list button:hover { background: var(--hover); }
.menu-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-list button > span { flex: 1; }
.menu-list button > .icon { color: var(--accent); visibility: hidden; }
.menu-list button[aria-current="true"] { font-weight: 700; }
.menu-list button[aria-current="true"] > .icon { visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .menu-list { animation: none; }
  .pill, .menu > .pill > .icon:last-child, .theme-icons, .theme-icons .icon { transition: none; }
}

/* Portuguese is swapped in by /i18n.js; hide the English for that moment so it doesn't flash. */
.translating body { visibility: hidden; }

/* Narrow screens: drop the name, then the photo and the "EN" label, so the bar stays on one line. */
@media (max-width: 640px) {
  .brand { font-size: 0; gap: 0; }
}
@media (max-width: 440px) {
  .topbar-inner { gap: 8px; }
  .brand { display: none; }
  .topbar-inner .pages { margin-left: 0; }
  .pages { gap: 4px; }
  .pages a { padding: 7px 12px; font-size: 0.9rem; }
  .lang-label { display: none; }
  .menu > .pill { padding: 0 8px; gap: 6px; }
}

/* Landing page: the two places to go next. */
.choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (min-width: 700px) {
  .choices { grid-template-columns: 1fr 1fr; }
}
.choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.choice:hover { border-color: var(--accent); transform: translateY(-2px); }
.choice-title { font-size: 1.5rem; font-weight: 700; }
.choice-title span { color: var(--accent); }
.choice-text { color: var(--text-2); }
@media (prefers-reduced-motion: reduce) {
  .choice { transition: none; }
  .choice:hover { transform: none; }
}

/* Projects and CV pages: a title instead of the full intro. */
.page-head { padding-top: 48px; padding-bottom: 32px; }
.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.page-head .lede { margin-bottom: 0; }
.hero-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px;
}
.avatar {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
/* No room beside the text on phones: show it small above the name. */
@media (max-width: 640px) {
  .hero-inner { grid-template-columns: 1fr; gap: 20px; }
  .avatar { order: -1; width: 96px; height: 96px; }
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.location {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 0.95rem;
}
.lede {
  margin: 12px 0 20px;
  max-width: 36rem;
  color: var(--text-2);
  font-size: 1.15rem;
}
.wip {
  display: flex;
  gap: 10px;
  max-width: 36rem;
  margin: 0 0 20px;
  color: var(--text-2);
  font-size: 0.95rem;
}
.wip::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 0.55em;
  border-radius: 50%;
  background: var(--accent);
}
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.links a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.links a:hover { text-decoration: underline; }

.section-title {
  margin: 0 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.project {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (min-width: 760px) {
  .project { grid-template-columns: 1.3fr 1fr; padding: 32px; gap: 32px; }
}

/* Experience and education: one card per section, entries separated by a rule. */
.panel {
  margin-bottom: 32px;
  padding: 8px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (min-width: 760px) {
  .panel { padding: 8px 32px; }
}
.entry { padding: 20px 0; }
.entry + .entry { border-top: 1px solid var(--border); }
.entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 6px;
}
.entry-head h3 { margin: 0; font-size: 1.1rem; }
.when { color: var(--text-2); font-size: 0.9rem; white-space: nowrap; }
.entry .features { margin-top: 10px; }
.entry .tags { margin-bottom: 4px; }
.entry .kind + .tags { margin-top: 12px; }
.tags:not(:has(li)) { display: none; }
/* Many skills read better as labelled rows than as one block of tags. */
.skill-groups { display: grid; gap: 12px; margin-top: 14px; }
.skill-group h4 {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.skill-group .tags { margin: 0; }
@media (min-width: 760px) {
  .skill-group { display: grid; grid-template-columns: 190px 1fr; gap: 16px; align-items: baseline; }
  .skill-group h4 { margin: 0; }
}

.project-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.project-head h3 { margin: 0; font-size: 1.35rem; }
.kind { margin: 0; color: var(--text-2); font-size: 0.9rem; }
.project-icon { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.project-icon.round { border-radius: 50%; }

.project-body > p { margin: 0 0 12px; }

.features { margin: 0 0 16px; padding-left: 1.2rem; color: var(--text-2); }
.features li { margin-bottom: 4px; }
code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.9em;
  background: var(--chip);
  padding: 1px 5px;
  border-radius: 4px;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.note { margin: -8px 0 16px; color: var(--text-2); font-size: 0.9rem; }
.tags li {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 0.8rem;
  color: var(--text-2);
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.btn:hover { border-color: var(--text-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }

.project-media {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: 12px;
  overflow: hidden;
}
.project-media img { display: block; max-width: 100%; height: auto; }
.project-media:not(.art) { background: #0f0f0f; padding: 16px; }
.project-media:not(.art) img { max-height: 420px; width: auto; border-radius: 8px; }

.art.ytmp { background: radial-gradient(circle at 30% 20%, #2a2b4a, #0c0d11 70%); }
.art.ytmp img { width: 140px; height: 140px; }
.art.bot { background: radial-gradient(circle at 30% 20%, #3b43a8, #1e1f2b 70%); }
.art.bot img { width: 140px; height: 140px; border-radius: 50%; }

.footer { padding: 32px 16px 48px; color: var(--text-2); font-size: 0.9rem; }
.footer p { margin: 0; }
