/* Personal site of Rubén Dorta.
   Theme: "Mediterráneo", Scandinavian cut. Deep azulejo blue is the default for every
   visitor; the cream view is the optional light theme (toggle in the header).
   Fonts: DM Serif Display (headings, 400) and Nunito Sans (body), OFL, served from fonts/. */

@font-face { font-family: "DM Serif Display"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/dm-serif-display/dm-serif-display-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/nunito-sans/nunito-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/nunito-sans/nunito-sans-700.woff2") format("woff2"); }

:root {
  --bg: #0c3553; --surface: #103f62; --surface-2: #164c74; --ink: #f6f1e7; --muted: #bcd0e2;
  --line: rgba(255, 255, 255, 0.14); --line-strong: rgba(255, 255, 255, 0.34);
  --brand: #ffcb6b; --brand-hover: #ffd88a; --on-brand: #0c2b44;
  --accent: #ffd27f; --accent-hover: #ffe2a8; --secondary: #ffbfa8;
  --ok: #a6e6b6; --ok-bg: rgba(166, 230, 182, 0.14); --warn: #ffcb6b; --warn-bg: rgba(255, 203, 107, 0.14);
  --focus: #ffcb6b;
  --serif: "DM Serif Display", Georgia, serif;
  --sans: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Liberation Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #faf6ee; --surface: #ffffff; --surface-2: #f2ece0; --ink: #16222f; --muted: #46525f;
  --line: #d8d0bf; --line-strong: #8f8674;
  --brand: #1a5f93; --brand-hover: #134d79; --on-brand: #ffffff;
  --accent: #7d5900; --accent-hover: #664900; --secondary: #a63f2a;
  --ok: #1a6b35; --ok-bg: #dcefd9; --warn: #6e4f00; --warn-bg: #fbecd2;
  --focus: #936900;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans); transition: background-color .3s ease, color .3s ease; }
::selection { background: #f2bd58; color: #10202e; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: var(--on-brand); padding: 8px 14px; border-radius: var(--radius); z-index: 10; }
.skip:focus { left: 8px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 32px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(36px, 5.2vw, 58px); letter-spacing: -0.01em; }
h2 { font-size: clamp(26px, 3.2vw, 32px); }
h3 { font-size: 20px; }
p, li { text-wrap: pretty; }
:lang(es), :lang(pt) { hyphens: auto; }
.lead { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0; }
.note { font-size: 14px; color: var(--muted); margin: 0; }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Header: logo, four links, then language and theme tools */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px 28px; padding: 14px 0; flex-wrap: wrap; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .2s ease, background-color .3s ease; }
header.top.stuck { border-bottom-color: var(--line); }
/* Full-width background without widening the page */
header.top { box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax); }
[id] { scroll-margin-top: 96px; }
.logo { display: flex; align-items: center; gap: 10px; font: 400 22px var(--serif); color: var(--ink); text-decoration: none; }
.logo:hover { color: var(--ink); }
.main-nav { margin-left: auto; display: flex; gap: 4px 24px; flex-wrap: wrap; font-weight: 700; font-size: 15px; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 10px 0; border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--ink); }
.main-nav a[aria-current] { color: var(--ink); border-bottom-color: var(--brand); }
.tools { display: flex; align-items: center; gap: 8px; }
.langs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.langs a { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; min-width: 32px; padding: 0 6px; border-radius: 999px; font: 700 11px var(--sans); text-decoration: none; color: var(--muted); }
.langs a:hover { color: var(--ink); }
.langs a[aria-current="true"] { background: var(--ink); color: var(--bg); }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; }
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 20px; border-radius: var(--radius); background: var(--brand); color: var(--on-brand); font-weight: 700; text-decoration: none; border: 1px solid var(--brand); transition: background-color .2s ease, border-color .2s ease; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
.btn.alt { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.alt:hover { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.sm { min-height: 40px; padding: 8px 16px; font-size: 14px; }

/* Hero: no box, the page itself is the color */
.hero { display: grid; grid-template-columns: 1fr; gap: 28px 48px; padding: 64px 0 56px; }
.hero.small { padding: 48px 0 40px; }
.hero-text { display: flex; flex-direction: column; gap: 18px; max-width: 760px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.hero:has(.avatar) { grid-template-columns: 1fr auto; }
.hero:has(.avatar) .stats { grid-column: 1 / -1; }
.avatar { width: 160px; height: 160px; border-radius: 999px; object-fit: cover; border: 3px solid var(--line-strong); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 8px 0 0; padding-top: 24px; border-top: 1px solid var(--line); }
.stats div { display: flex; flex-direction: column; gap: 4px; }
.stats dt { font: 400 clamp(32px, 4vw, 44px)/1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.stats dd { margin: 0; color: var(--muted); font-size: 15px; }

/* Sections: title column on the left (sticky), content on the right */
.sec { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px 56px; padding: 56px 0; border-top: 1px solid var(--line); }
.sec-head { position: sticky; top: 96px; align-self: start; display: flex; flex-direction: column; gap: 10px; }
.sec-body { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.thread { margin: 0; font: 400 19px/1.35 var(--serif); color: var(--secondary); }
.sec.cta { grid-template-columns: 1fr; }

/* Projects as rows separated by hairlines */
.proj { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 32px; padding: 0 0 26px; border-bottom: 1px solid var(--line); }
.proj + .proj { padding-top: 4px; }
.proj:last-child { border-bottom: 0; padding-bottom: 0; }
.proj-main { display: flex; flex-direction: column; gap: 8px; }
.proj h3 { font-size: 24px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.proj h3 a { color: var(--ink); text-decoration: none; }
.proj h3 a:hover { color: var(--accent); }
.proj p { margin: 0; color: var(--muted); }
.proj p.origin { color: var(--ink); font-style: italic; }
.proj p.stack { font: 13px var(--mono); color: var(--muted); }
.proj-links { display: flex; gap: 8px; align-items: flex-start; }
.status { font: 700 11px var(--sans); letter-spacing: .05em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); }
.status.building { background: var(--warn-bg); color: var(--warn); }

/* Lists of capabilities: two columns, hairline on top */
.items { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; }
.items.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.items li { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.items h3 { font: 700 16px/1.35 var(--sans); }
.items p { margin: 0; color: var(--muted); font-size: 15px; }

/* Interactive diagrams: a step line with selectable nodes and a detail panel */
.diagram { display: flex; flex-direction: column; gap: 14px; }
.flow { --steps: 5; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--steps), minmax(0, 1fr)); position: relative; }
.flow li { position: relative; }
.flow button { position: relative; width: 100%; min-height: 44px; text-align: left; background: transparent; border: 0; border-top: 2px solid var(--line-strong); padding: 16px 10px 4px 0; color: var(--muted); font: 700 15px/1.3 var(--sans); cursor: pointer; transition: color .2s ease, border-color .3s ease; }
.flow button::before { content: ""; position: absolute; top: -8px; left: 0; width: 14px; height: 14px; border-radius: 999px; background: var(--bg); border: 2px solid var(--line-strong); transition: background-color .3s ease, border-color .3s ease, transform .3s ease; }
.flow button .n { display: block; font: 12px var(--mono); margin-bottom: 2px; }
.flow button:hover { color: var(--ink); }
.flow button.done { border-top-color: var(--brand); }
.flow button.done::before { border-color: var(--brand); }
.flow button[aria-selected="true"] { color: var(--ink); border-top-color: var(--brand); }
.flow button[aria-selected="true"]::before { background: var(--brand); border-color: var(--brand); transform: scale(1.25); }
.panel { padding: 20px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel p { margin: 0; color: var(--ink); }
.js .panel { animation: fade .35s ease; }
.panel .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; }
.panel h3 { font: 700 12px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.panel .ai h3 { color: var(--secondary); }
.layer-toggle { align-self: flex-start; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px dashed var(--secondary); background: transparent; color: var(--secondary); font: 700 13px var(--sans); cursor: pointer; }
.layer-toggle[aria-pressed="true"] { background: var(--secondary); color: var(--bg); border-style: solid; }
/* AI layer: a lane aligned with the stages, hidden until toggled (only with JS) */
.diagram-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.legend { margin: 0; font-size: 14px; color: var(--muted); }
.ai-lane { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px dashed var(--secondary); }
.lane-item { min-width: 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--secondary); color: var(--secondary); font: 700 13px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color .25s ease, color .25s ease; }
.lane-item.soon { border-style: dashed; text-align: center; opacity: .8; }
.lane-item.active { background: var(--secondary); color: var(--bg); opacity: 1; }
.js [data-layered]:not(.layer-on) .ai-lane, .js [data-layered]:not(.layer-on) .legend, .js [data-layered]:not(.layer-on) .panel .ai { display: none; }
.layer-on .ai-lane, .layer-on .legend, .layer-on .panel .ai { animation: fade .4s ease; }
.js [data-layered]:not(.layer-on) .panel .cols { grid-template-columns: 1fr; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Experience timeline: the line fills with the scroll (site.js sets --progress) */
.timeline-sec { padding: 24px 0 40px; border-top: 1px solid var(--line); }
.timeline { position: relative; list-style: none; margin: 0; padding: 8px 0 8px 26px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 36px; max-width: 820px; }
.timeline::before { content: ""; position: absolute; left: -2px; top: 0; width: 2px; height: calc(var(--progress, 1) * 100%); background: var(--brand); }
.timeline .entry { position: relative; display: flex; flex-direction: column; gap: 6px; }
.timeline .entry::before { content: ""; position: absolute; left: -34px; top: 8px; width: 12px; height: 12px; border-radius: 999px; background: var(--brand); box-shadow: 0 0 0 4px var(--bg); transition: transform .3s ease; }
.timeline ul { margin: 4px 0 0; padding-left: 20px; color: var(--muted); }
.timeline ul li + li { margin-top: 4px; }
.entry .role { font: 400 22px var(--serif); }
.entry .meta { color: var(--brand); font: 700 13px var(--mono); }
.entry .context { margin: 0; color: var(--muted); }

/* Reveal on scroll (only with JS; without it everything is visible) */
.js .reveal, .js .timeline .entry { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in, .js .timeline .entry.in { opacity: 1; transform: none; }
.js .timeline .entry:not(.in)::before { transform: scale(.5); }

footer { border-top: 1px solid var(--line); padding: 24px 0 40px; display: flex; gap: 12px 24px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
footer a { color: var(--muted); }
footer a:hover { color: var(--ink); }
footer .grow { margin-left: auto; }

@media (max-width: 860px) {
  .sec { grid-template-columns: 1fr; padding: 44px 0; }
  .sec-head { position: static; }
  .items.cols3 { grid-template-columns: 1fr; }
  .proj { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .ai-lane { display: none !important; }
  .flow button { border-top: 0; border-left: 2px solid var(--line-strong); padding: 10px 0 10px 22px; }
  .flow button::before { top: 16px; left: -8px; }
  .flow button.done, .flow button[aria-selected="true"] { border-left-color: var(--brand); }
  .main-nav { margin-left: 0; order: 3; width: 100%; }
  .tools { margin-left: auto; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .items, .panel .cols, .stats { grid-template-columns: 1fr; }
  .hero { padding: 40px 0; }
  .hero:has(.avatar) { grid-template-columns: 1fr; }
  .hero .avatar { order: -1; width: 96px; height: 96px; }
  .lead { font-size: 17px; }
  .main-nav { gap: 4px 14px; font-size: 14px; }
  footer .grow { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal, .js .timeline .entry { opacity: 1; transform: none; }
}

/* Subheadings inside a section (diagram titles) */
.sec-body h3.sub { font-size: 22px; margin-top: 8px; }
.sec-body h3.sub + .note { margin-top: -14px; }
/* Learning: year on the left, course on the right */
.years { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.years li { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 24px; padding: 12px 0; border-top: 1px solid var(--line); }
.years li:last-child { border-bottom: 1px solid var(--line); }
.years .year { font: 700 13px/1.9 var(--mono); color: var(--brand); }
.years p { margin: 0; color: var(--ink); }
@media (max-width: 600px) { .years li { grid-template-columns: 1fr; } }
