/* ==========================================================================
   Josué Ortega Caro — shared design system (every page)
   Tokens · reset · type · layout · navigation · buttons · footer · utilities
   Page styles live in site.css (root pages) and paper.css (project pages).
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #fbfaf7;
  --bg-subtle: #f3f1ec;
  --surface: #ffffff;
  --border: rgba(27, 27, 36, 0.1);
  --border-strong: rgba(27, 27, 36, 0.2);

  /* Text (all ≥ 4.5:1 on --bg and --bg-subtle) */
  --text: #1b1b24;
  --text-2: #4b4b5a;
  --text-3: #6a6a7b;

  /* Accent — project pages override these four */
  --accent: #b3433a;
  --accent-hover: #933429;
  --accent-soft: rgba(179, 67, 58, 0.08);
  --accent-ring: rgba(179, 67, 58, 0.35);
  --ink: #1b1b24;
  --blue: #33588f;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --nav-h: 64px;
  --toc-h: 0px;
  --maxw: 1120px;
  --gutter: 28px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05);
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 10px 28px rgba(20, 20, 30, 0.07);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---- Reset ---------------------------------------------------------------- */

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

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

body {
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select { font: inherit; color: inherit; }
ul[class], ol[class] { list-style: none; padding: 0; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent-ring); color: var(--text); }

/* ---- Type ----------------------------------------------------------------- */

h1, h2, h3, h4 { color: var(--text); line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; }
h1 { font-size: clamp(2.25rem, 1.55rem + 2.6vw, 3.4rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.55rem, 1.25rem + 1.1vw, 2.05rem); }
h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
p { text-wrap: pretty; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.86em; }
:not(pre) > code {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.06em 0.36em;
  white-space: nowrap;
}

.eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.lede { font-size: 1.075rem; line-height: 1.7; color: var(--text-2); }
.muted { color: var(--text-3); }

/* ---- Layout --------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(56px, 7vw, 96px); }
.section--subtle { background: var(--bg-subtle); border-block: 1px solid var(--border); }
.section--tight { padding-block: clamp(40px, 5vw, 64px); }

.section-head { max-width: 720px; margin-bottom: clamp(28px, 4vw, 44px); }
.section-head h2 { margin-bottom: 12px; }
.section-head--row {
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 32px;
}
.section-head--row > div { max-width: 720px; }

[id] { scroll-margin-top: calc(var(--nav-h) + var(--toc-h) + 20px); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 2000;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; color: #fff; text-decoration: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- Navigation ----------------------------------------------------------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  z-index: 1000;
  background: rgba(251, 250, 247, 0.9);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Home page: transparent over the hero until the page scrolls */
.nav[data-overlay]:not(.is-scrolled):not(.is-open) {
  background: transparent;
  border-bottom-color: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.nav__inner {
  height: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav__brand {
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.nav__brand:hover { color: var(--text); text-decoration: none; }

.nav__menu { display: flex; align-items: center; gap: 2px; }

.nav__link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav__link:hover { color: var(--text); background: rgba(27, 27, 36, 0.05); text-decoration: none; }
.nav__link.is-active {
  color: var(--text);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: calc(100% - 24px) 2px;
  background-position: center bottom 4px;
}

.nav__toggle { display: none; }

@media (max-width: 800px) {
  .nav__toggle {
    position: relative;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
  }
  .nav__toggle-bar {
    grid-area: 1 / 1;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 0.25s var(--ease);
  }
  .nav__toggle-bar:first-child { transform: translateY(-4px); }
  .nav__toggle-bar:last-child { transform: translateY(4px); }
  .nav.is-open .nav__toggle-bar:first-child { transform: rotate(45deg); }
  .nav.is-open .nav__toggle-bar:last-child { transform: rotate(-45deg); }

  .nav.is-open { background: var(--surface); }

  .nav__menu {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 4px var(--gutter) 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 18px 36px rgba(20, 20, 30, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s var(--ease), visibility 0s linear 0.2s;
  }
  .nav.is-open .nav__menu {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, transform 0.2s var(--ease);
  }
  .nav__link {
    height: 52px;
    padding: 0 2px;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
    font-size: 1.05rem;
  }
  .nav__link:last-child { border-bottom: 0; }
  .nav__link:hover { background: transparent; }
  .nav__link.is-active { background-image: none; color: var(--accent); }
}

/* ---- Buttons & controls --------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover { background: #34343f; color: #fff; }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover { border-color: var(--text); color: var(--text); }
.btn--sm { height: 34px; padding: 0 13px; font-size: 0.82rem; gap: 6px; }
.btn--sm svg { width: 14px; height: 14px; }
.btn.is-disabled,
.btn[aria-disabled='true'] {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text-3);
  cursor: default;
}

/* Segmented control (publications filter, schematic controls) */
.segmented {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.segmented button {
  height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

/* Small pill labels: venue badges etc. */
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tag--neutral { background: rgba(27, 27, 36, 0.06); color: var(--text-2); }
.tag--blue { background: rgba(51, 88, 143, 0.09); color: var(--blue); }

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-2);
}
.icon-link svg { width: 16px; height: 16px; flex: none; }
.icon-link:hover { color: var(--accent); text-decoration: none; }

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
}
.arrow-link svg { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }
.arrow-link:hover { text-decoration: none; }
.arrow-link:hover svg { transform: translateX(3px); }

/* ---- Reveal on scroll (only when JS runs; off for reduced motion) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---- Footer --------------------------------------------------------------- */

.footer {
  padding: 48px 0 32px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-2);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px 48px;
}
.footer__name { font-weight: 650; color: var(--text); margin-bottom: 2px; }
.footer__links {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px 22px;
  max-width: 520px;
}
.footer__links a { color: var(--text-2); }
.footer__links a:hover { color: var(--text); }
.footer__meta {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-3);
}

/* ---- Small screens -------------------------------------------------------- */

@media (max-width: 600px) {
  :root { --gutter: 18px; --nav-h: 58px; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .nav, .toc, .footer, .skip-link, .viz__bar { display: none !important; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
  body { background: #fff; font-size: 11pt; }
  .section { padding-block: 16px; }
}
