/* Tomás Rivero portfolio: Everforest palette, Schibsted Grotesk text, JetBrains Mono for tool names.
   Instrument Serif and Bricolage Grotesque appear only in the headline. */
:root {
  --bg: #fdf6e3;
  --surface: #f4f0d9;
  --line: #e6e2cc;
  --line-strong: #bdc3af;
  --text: #4f5b58;
  --muted: #616f69;
  --accent: #5f7100;
  --accent-fill: #8da101;
  --accent-soft: #eef0cf;
  --on-accent: #fdf6e3;
  --stage: #efebd4; /* Everforest bg_dim, the side bars on wide screens */

  /* Type scale: 17px base, 1.25 ratio. */
  --step--1: 0.85rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --radius: 6px;

  --sans: "Schibsted Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  font-size: 106.25%;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #2d353b;
  --surface: #343f44;
  --line: #414c52;
  --line-strong: #56635f;
  --text: #d3c6aa;
  --muted: #a5b0a6;
  --accent: #a7c080;
  --accent-fill: #a7c080;
  --accent-soft: #3c4841;
  --on-accent: #2d353b;
  --stage: #232a2e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 400 var(--step-0)/1.6 var(--sans);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Slim scrollbar in the text colour, like hermes-agent.nousresearch.com: a 4px thumb that
   widens and turns green under the pointer. Firefox only takes the standard properties. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; }
::-webkit-scrollbar-thumb {
  min-height: 40px; border: 3px solid transparent; border-radius: 10px; background-clip: padding-box;
  background-color: color-mix(in srgb, var(--muted) 55%, transparent);
}
::-webkit-scrollbar-thumb:hover { border-width: 2px; background-color: var(--accent); }
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent; }
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
button { font: inherit; color: inherit; }
svg { width: 1.1em; height: 1.1em; flex: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
section[id], footer[id] { scroll-margin-top: 24px; }
/* Lenis drives the scrolling once it loads; native smooth scroll would fight it. */
html.lenis, html.lenis body { height: auto; }
html.lenis.lenis-smooth { scroll-behavior: auto; }

.shell { width: 100%; max-width: calc(1120px + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); --gutter: clamp(20px, 5vw, 48px); }
/* Wide screens: the page becomes a 1440px sheet with darker bars either side, as on hermes-agent.nousresearch.com. */
@media (min-width: 1601px) {
  html, body { background: var(--stage); }
  .shell { max-width: 1440px; min-height: 100vh; background: var(--bg); --gutter: 160px; }
}

/* Masthead */
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 28px 0; }
.masthead-name { text-decoration: none; line-height: 1.3; }
.masthead-name b { display: block; font-weight: 600; }
.masthead-name span { color: var(--muted); font-size: var(--step--1); }
.masthead-actions { display: flex; align-items: center; gap: 24px; font-size: var(--step--1); }
.masthead-actions a { text-decoration: none; }
.masthead-actions a:hover { text-decoration: underline; }
.masthead-cv { display: inline-flex; align-items: center; gap: 6px; }
.theme-toggle {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* Hero */
.hero { padding: clamp(56px, 9vw, 112px) 0 clamp(72px, 10vw, 128px); }
.hero h1 {
  font-size: clamp(2.4rem, 5.6vw, 4.5rem); font-weight: 500; line-height: 1.04; letter-spacing: -.028em;
}
.hero-intro { margin-top: clamp(32px, 5vw, 56px); }
.hero-intro p { font-size: var(--step-1); line-height: 1.5; }
.hero-intro p + p:not(.hero-location) { margin-top: 1em; }
/* People, product and code each get their own voice: a warm italic serif, a sturdy
   variable grotesque squeezed narrow, and the editor's monospace. Sizes are nudged so
   the three read at the same visual height as the headline face. */
.word-people { font: italic 400 1.14em/1 "Instrument Serif", Georgia, serif; letter-spacing: -.01em; }
.word-product { font-family: "Bricolage Grotesque", var(--sans); font-weight: 650; font-stretch: 86%; letter-spacing: -.025em; font-variation-settings: "opsz" 96; }
.word-code { font: 500 .84em/1 var(--mono); letter-spacing: -.03em; }
.hero-intro .hero-location { margin-top: 20px; color: var(--muted); font-size: var(--step--1); }


/* Sections */
.row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px;
  padding: clamp(56px, 7vw, 88px) 0; border-top: 1px solid var(--line);
}
.row-title { position: sticky; top: 28px; align-self: start; font-size: var(--step-0); font-weight: 600; }
.row-body { min-width: 0; }

/* Experience */
.role-head { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; }
.role h3 { font-size: var(--step-2); font-weight: 500; line-height: 1.25; letter-spacing: -.01em; }
.role-period { flex: none; color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.role-org { margin-top: 4px; color: var(--muted); }
.role-summary { max-width: 38em; margin-top: 24px; }

/* Chips, shared by capabilities and projects */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chips li { padding: 4px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: var(--step--1); }

/* What I do */
.lens-tabs { display: flex; gap: 32px; border-bottom: 1px solid var(--line); }
.lens-tabs button {
  margin-bottom: -1px; padding: 0 0 14px; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted); font-size: var(--step-1); cursor: pointer;
}
.lens-tabs button:hover { color: var(--text); }
.lens-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.lens-tabs button:focus-visible { outline-offset: 4px; }
.lens-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; min-height: 260px; padding-top: 40px; }
.lens-panel:focus-visible { outline-offset: 8px; }
.lens-summary h3 { font-size: var(--step-3); font-weight: 500; line-height: 1.15; letter-spacing: -.02em; }
.lens-summary p { margin-top: 20px; color: var(--muted); }
.lens-evidence { padding-top: 6px; }
.lens-label { margin-bottom: 8px; font-size: var(--step--1); font-weight: 600; }

/* Selected work */
.project + .project { border-top: 1px solid var(--line); }
.project summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 40px; align-items: baseline; column-gap: 24px;
  padding: 28px 0; cursor: pointer; list-style: none;
}
.row-body > .projects > .project:first-child summary { padding-top: 0; }
.project summary::-webkit-details-marker { display: none; }
.project h3 { grid-column: 1; font-size: var(--step-2); font-weight: 500; line-height: 1.25; letter-spacing: -.01em; }
.project-type { grid-column: 2; color: var(--muted); font-size: var(--step--1); white-space: nowrap; }
.project-text { grid-column: 1 / 3; max-width: 38em; margin-top: 8px; color: var(--muted); }
.project-toggle {
  grid-column: 3; grid-row: 1 / 3; align-self: center; position: relative; width: 40px; height: 40px;
  border: 1px solid var(--line-strong); border-radius: 50%; transition: transform .25s ease, border-color .15s;
}
.project-toggle::before, .project-toggle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 1.5px; background: currentColor; translate: -50% -50%;
}
.project-toggle::after { rotate: 90deg; }
.project summary:hover h3 { color: var(--accent); }
.project summary:hover .project-toggle { border-color: var(--accent); color: var(--accent); }
.project[open]:not(.is-closing) .project-toggle { transform: rotate(45deg); }
.project-detail { max-width: 38em; margin: -8px 0 32px; padding-left: 20px; border-left: 2px solid var(--accent); }
.project-detail h4 { font-size: var(--step--1); font-weight: 600; }
.project-detail p { margin-top: 6px; }
.project-detail .chips { margin-top: 16px; }

/* Background */
.details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 48px; }
.details h3 { margin-bottom: 12px; font-size: var(--step-0); font-weight: 600; }
.details p { color: var(--muted); }
.toolkit { display: flex; flex-wrap: wrap; gap: 8px; }
.toolkit li { padding: 4px 10px; border-radius: 4px; background: var(--surface); font: 400 var(--step--1)/1.6 var(--mono); }

/* Contact */
.contact { padding: clamp(72px, 10vw, 120px) 0 40px; border-top: 1px solid var(--line); }
.contact h2 { max-width: 17em; font-size: clamp(2rem, 4.2vw, 3.2rem); font-weight: 500; line-height: 1.1; letter-spacing: -.025em; }
.contact-lede { margin-top: 20px; color: var(--muted); font-size: var(--step-1); }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 36px; }
.button {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: transparent;
  font-size: var(--step-0); text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); color: var(--accent); }
.button-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.button-primary:hover { color: var(--on-accent); filter: brightness(1.08); }
.copy-status { color: var(--muted); font-size: var(--step--1); }
.footer-meta { display: flex; justify-content: space-between; gap: 16px; margin-top: clamp(72px, 10vw, 120px); color: var(--muted); font-size: var(--step--1); }

@media (max-width: 860px) {
  .hero-intro p { font-size: var(--step-0); }
  .row { grid-template-columns: 1fr; gap: 28px; }
  .row-title { position: static; }
  .lens-panel { grid-template-columns: 1fr; gap: 28px; min-height: 0; padding-top: 32px; }
  .details { grid-template-columns: 1fr; gap: 36px; }
}
@media (max-width: 560px) {
  .masthead-name span, .masthead-actions a[href="#contact"] { display: none; }
  .masthead-actions { gap: 16px; }
  .role-head { flex-direction: column; gap: 2px; }
  .lens-tabs { gap: 22px; }
  .lens-tabs button { font-size: var(--step-0); }
  .lens-summary h3 { font-size: var(--step-2); }
  .project summary { grid-template-columns: minmax(0, 1fr) 40px; }
  .project-type { grid-column: 1; grid-row: 2; margin-top: 2px; }
  .project-text { grid-column: 1 / -1; grid-row: 3; }
  .project-toggle { grid-column: 2; grid-row: 1 / 3; }
  .footer-meta { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .theme-toggle, .copy-email, .project-toggle { display: none; }
}
