/* ============================================================
   Caleta — shared stylesheet
   Identity: editorial serif (Fraunces) + Inter, navy + gold
   ============================================================ */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --navy: #0b0f14;
  --navy-soft: #1b2430;
  --gold: #b78628;
  --gold-ink: #8a6512;
  --gold-on-dark: #d4a24c;  /* dorado del logo: legible sobre navy a 16px */          /* gold text on white — WCAG AA */
  --gold-bg: #f5efe2;

  --ink: #16181d;
  --ink-2: #454b54;
  --ink-3: #6b7280;
  --bg: #ffffff;
  --bg-2: #faf8f4;              /* warm paper */
  --surface: #ffffff;           /* card / pill / dropdown surfaces */
  --line: #e8e5df;

  --tag-work-bg: #fef3c7; --tag-work-ink: #92400e;
  --tag-pub-bg: #ecfdf5;  --tag-pub-ink: #065f46;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(11,15,20,.04), 0 6px 16px rgba(11,15,20,.05);
  --shadow-md: 0 12px 34px rgba(11,15,20,.12);
  --maxw: 1180px;

  color-scheme: light;
}

/* Dark palette: system preference (unless the visitor picked Light explicitly) ... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gold: #d4a24c;
    --gold-ink: #d9ae5d;
    --gold-bg: #2a2117;
    --ink: #eef1f4;
    --ink-2: #a7afb8;
    --ink-3: #838d98;
    --bg: #12161b;
    --bg-2: #1b1710;
    --surface: #181d24;
    --line: #262c34;
    --tag-work-bg: #3a2e12; --tag-work-ink: #f5c34d;
    --tag-pub-bg: #0f2e22;  --tag-pub-ink: #4ade95;
    color-scheme: dark;
  }
}
/* ... or the explicit toggle, which always wins over the system setting */
:root[data-theme="dark"] {
  --gold: #d4a24c;
  --gold-ink: #d9ae5d;
  --gold-bg: #2a2117;
  --ink: #eef1f4;
  --ink-2: #a7afb8;
  --ink-3: #838d98;
  --bg: #12161b;
  --bg-2: #1b1710;
  --surface: #181d24;
  --line: #262c34;
  --tag-work-bg: #3a2e12; --tag-work-ink: #f5c34d;
  --tag-pub-bg: #0f2e22;  --tag-pub-ink: #4ade95;
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.62;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-ink); }

::selection { background: var(--gold-bg); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- Typography ---------- */
h1, h2, h3, .paper-title, .theme-title {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.18;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-ink);
  margin-bottom: 1.25rem;
}

.muted { color: var(--ink-3); }

/* ---------- Header / nav ---------- */
header {
  background: var(--bg); /* fallback for browsers without color-mix() */
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo, .logo a { display: block; line-height: 0; }
.logo img { height: 40px; width: auto; }

.nav-right { display: flex; align-items: center; gap: 1.1rem; }

.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-2);
  transition: color 0.2s;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--navy); }
.nav-links a[aria-current="page"] { color: var(--gold-ink); }

.theme-toggle {
  all: unset;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--ink-2);
}
.theme-toggle:hover { background: var(--bg-2); }
.theme-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
.lang-switch button {
  all: unset; cursor: pointer; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  padding: 5px 8px; color: var(--ink-3);
}
.lang-switch button:not(:last-child) { border-right: 1px solid var(--line); }
.lang-switch button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.lang-switch button:hover { color: var(--gold-ink); }
.lang-switch button[aria-pressed="true"]:hover { color: #fff; }
.lang-switch button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

/* ---------- Buttons ---------- */
.btn, .cta-button, .dash-open, .btn-download {
  display: inline-block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  transition: background 0.2s, transform 0.15s;
  cursor: pointer;
}
.btn:hover, .cta-button:hover, .dash-open:hover, .btn-download:hover {
  background: var(--navy-soft);
  color: #fff;
}
.btn--ghost, .dash-open.secondary {
  background: var(--surface);
  color: var(--navy);
  border-color: var(--line);
}
.btn--ghost:hover, .dash-open.secondary:hover {
  background: var(--bg-2);
  color: var(--navy);
  border-color: var(--navy);
}

/* ---------- Layout primitives ---------- */
.wrap, .container, .authority-content, .tech-stack-content, .clients {
  max-width: var(--maxw);
  margin: 0 auto;
}

.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6rem 2rem 5rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(2.4rem, 6.2vw, 4rem);
  font-weight: 600;
  margin-bottom: 1.4rem;
}
.hero .subtitle {
  font-size: clamp(1.05rem, 2.1vw, 1.22rem);
  color: var(--ink-2);
  max-width: 680px;
  margin: 0 auto;
}

/* Soft entrance on load: eyebrow, then headline, then subtitle. Once, under 1s. */
.hero .eyebrow, .hero h1, .hero .subtitle {
  opacity: 0;
  transform: translateY(10px);
  animation: hero-rise 0.6s cubic-bezier(.2,.7,.3,1) forwards;
}
.hero .eyebrow { animation-delay: 0.05s; }
.hero h1 { animation-delay: 0.15s; }
.hero .subtitle { animation-delay: 0.32s; }

@keyframes hero-rise {
  to { opacity: 1; transform: translateY(0); }
}

/* sub-page hero */
.research-hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3.5rem 2rem 1.5rem;
}
.research-hero h1 { font-size: clamp(2rem, 5vw, 2.9rem); margin-bottom: 0.9rem; }
.research-hero p { font-size: 1.15rem; color: var(--ink-2); max-width: 760px; }
.back-link {
  display: inline-block;
  color: var(--gold-ink);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--navy); }

.container { padding: 2rem; }

/* ---------- Sections ---------- */
.services { max-width: var(--maxw); margin: 0 auto; padding: 6rem 2rem; }
.services h2, .authority h2, .tech-stack h2, .clients h2, .contact h2 {
  text-align: center;
  font-size: clamp(1.7rem, 3.6vw, 2.2rem);
}
.services h2 { margin-bottom: 0.6rem; }
.tech-stack h2 { margin-bottom: 2.5rem; }
.section-subtitle {
  text-align: center;
  color: var(--ink-3);
  font-size: 1.05rem;
  margin-bottom: 3rem;
}
.section-subtitle a, .research-hero p a {
  color: var(--gold-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.authority, .tech-stack {
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 5rem 2rem;
}
.authority h2 { margin-bottom: 0.75rem; }
.authority .section-subtitle { margin-bottom: 3rem; }

/* ---------- Cards ---------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.75rem;
}
.authority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.service-card, .authority-card, .dash-card, .paper-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
}
.service-card { padding: 1.9rem; }
.authority-card { padding: 1.9rem; text-align: center; }
.service-card:hover, .dash-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.service-card h3, .authority-card h3, .dash-card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}
.authority-card h3 { font-size: 1.15rem; }
.authority-card h3 a { color: var(--gold-ink); }
.authority-card h3 a:hover { color: var(--navy); text-decoration: underline; }
.service-card h3 a, .dash-card h3 a { color: inherit; }
.service-card h3 a:hover, .dash-card h3 a:hover { color: var(--gold-ink); }

.service-card ul { list-style: none; margin: 0 0 1rem; }
.service-card ul li {
  padding: 0.4rem 0 0.4rem 1.5rem;
  color: var(--ink-2);
  position: relative;
  font-size: 0.97rem;
}
.service-card ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.95rem;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
}
.service-card .tools, .authority-card p, .dash-card p {
  color: var(--ink-3);
  font-size: 0.92rem;
}
.service-card .tools {
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  margin-top: 1rem;
}
.card-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--gold-ink);
  font-weight: 600;
  font-size: 0.92rem;
}
.card-link:hover { color: var(--navy); text-decoration: underline; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}
.tab-button {
  font-family: var(--font-sans);
  padding: 0.7rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-2);
  transition: all 0.2s;
}
.tab-button:hover { border-color: var(--gold); color: var(--gold-ink); }
.tab-button.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Tech strip ---------- */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 0.85rem;
}
.tech-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.92rem;
}
.tech-item img { width: 26px; height: 26px; opacity: 0.85; flex: none; }

/* ---------- Clients / sectors ---------- */
.clients { padding: 5rem 2rem; text-align: center; }
.clients h2 { margin-bottom: 0.6rem; }
.sector-strip {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.7rem;
}
.sector-strip span {
  border: 1px solid var(--line);
  border-radius: 9999px;
  padding: 0.55rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
}
.trusted-label {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-3); margin: 3.5rem 0 1.5rem;
}
.logo-strip {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2.75rem;
}
.client-logo { display: flex; align-items: center; gap: 0.6rem; filter: grayscale(1); opacity: 0.7; }
.client-logo svg { width: 34px; height: 34px; flex: none; }
.client-logo span { font-weight: 700; color: var(--ink); }

/* ---------- Contact ---------- */
.contact {
  max-width: 760px;
  margin: 0 auto;
  padding: 6rem 2rem;
  text-align: center;
}
.contact h2 { margin-bottom: 0.8rem; }
.contact p { color: var(--ink-3); margin-bottom: 2rem; font-size: 1.08rem; }
.contact-links {
  display: flex; justify-content: center; gap: 1.75rem; flex-wrap: wrap;
}
.contact-links a { color: var(--gold-ink); font-weight: 600; }
.contact-links a:hover { color: var(--navy); }

/* ---------- Dashboards / research / tools grids ---------- */
/* Each theme section is a collapsible accordion: the whole title bar is the
   trigger. Behavior in assets/accordion.js. Count badge fills itself in from
   the number of .dash-card elements — no need to update it by hand. */
.theme { margin-bottom: 14px; }

.theme-trigger {
  all: unset;
  display: flex; align-items: center; gap: 12px; width: 100%;
  cursor: pointer; box-sizing: border-box;
  background: var(--bg-2); color: var(--ink);
  padding: 16px 18px; border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.theme-trigger:hover { background: #f2ecdd; }
.theme-trigger:hover .theme-title { color: var(--gold-ink); }
.theme-trigger:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; }

.theme-trigger .chev {
  flex: none; width: 20px; height: 20px; color: var(--ink-3);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), color 0.15s;
}
.theme-trigger:hover .chev { color: var(--gold-ink); }
.theme-trigger[aria-expanded="true"] .chev { transform: rotate(90deg); }

.theme-title { font-size: 1.28rem; color: var(--ink); margin: 0; transition: color 0.15s; }

.theme-trigger .count {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  color: var(--ink-3); background: var(--surface); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 9999px;
}
.theme-trigger .state-label {
  margin-left: auto; font-size: 0.82rem; font-weight: 600; color: var(--gold-ink);
}

.theme-panel {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows 0.28s cubic-bezier(.4,0,.2,1), opacity 0.22s ease;
}
.theme-panel.open { grid-template-rows: 1fr; opacity: 1; }
.theme-panel > div { overflow: hidden; }
.theme-inner { padding: 14px 4px 28px; }

.dash-card.placeholder {
  background: transparent; border: 1px dashed var(--line); box-shadow: none;
  align-items: center; justify-content: center; text-align: center; color: var(--ink-3);
  font-size: 0.85rem; min-height: 150px; gap: 6px;
}
.dash-card.placeholder b { color: var(--ink-2); font-weight: 600; font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  .theme-trigger .chev, .theme-panel { transition: none; }
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}
.dash-card { padding: 1.75rem; display: flex; flex-direction: column; }
.dash-card p { color: var(--ink-2); font-size: 0.95rem; margin-bottom: 1rem; }
.dash-tag {
  display: inline-block; align-self: flex-start;
  background: var(--gold-bg); color: var(--gold-ink);
  padding: 0.25rem 0.8rem; border-radius: 9999px;
  font-size: 0.78rem; font-weight: 600; margin-bottom: 0.9rem;
}
.dash-tag.working, .paper-tag.working { background: var(--tag-work-bg); color: var(--tag-work-ink); }
.dash-tag.published, .paper-tag.published { background: var(--tag-pub-bg); color: var(--tag-pub-ink); }
.dash-meta {
  font-size: 0.85rem; color: var(--ink-3);
  border-top: 1px solid var(--line); padding-top: 0.9rem; margin-top: auto;
}
.dash-links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.dash-open { padding: 0.6rem 1.15rem; margin-top: 0.6rem; }
.soon { color: var(--ink-3); font-style: italic; font-size: 0.95rem; }

/* ---------- Compact list rows (many entries, one line each — e.g. Replication studies) ---------- */
.replist { display: flex; flex-direction: column; }
.rep-row {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
}
.rep-row:last-child { border-bottom: 0; }
.rep-main { flex: 1; min-width: 0; }
.rep-main h3 { font-size: 1.05rem; margin: 0 0 3px; }
.rep-main h3 a { color: var(--ink); text-decoration: none; }
.rep-main h3 a:hover { color: var(--gold-ink); }
.rep-main p { margin: 0; font-size: 0.88rem; color: var(--ink-2); }
.rep-main .dash-meta { border: 0; padding: 0; margin: 3px 0 0; font-size: 0.78rem; }
.rep-cta {
  flex: none; font-size: 0.85rem; font-weight: 600; color: var(--gold-ink);
  text-decoration: none; white-space: nowrap;
}
.rep-cta:hover { text-decoration: underline; }

.rep-row.locked .rep-main h3 a { color: var(--ink-3); pointer-events: none; }
.rep-row.locked .rep-main p { color: var(--ink-3); }
.rep-row.locked .rep-cta {
  color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px;
}

.rep-row.soon .rep-main h3 { color: var(--ink-3); }
.rep-row.soon .rep-main p { color: var(--ink-3); }
.rep-row.soon .rep-cta { color: var(--ink-3); font-style: italic; }

/* ---------- Publications paper cards ---------- */
.paper-card { padding: 2.75rem; margin-bottom: 2.5rem; }
.paper-tag {
  display: inline-block; background: var(--gold-bg); color: var(--gold-ink);
  padding: 0.25rem 0.8rem; border-radius: 9999px;
  font-size: 0.82rem; font-weight: 600; margin-bottom: 1rem;
}
.paper-title { font-size: 1.65rem; margin-bottom: 0.4rem; }
.paper-meta { font-size: 0.92rem; color: var(--ink-3); margin-bottom: 1.75rem; }
.paper-section { margin-bottom: 1.5rem; }
.paper-section h3 {
  font-family: var(--font-sans);
  font-size: 1.05rem; font-weight: 700;
  border-left: 3px solid var(--gold); padding-left: 0.7rem; margin-bottom: 0.5rem;
}
.paper-section p { color: var(--ink-2); }
.paper-visuals {
  display: grid; gap: 1.25rem; margin-top: 1.75rem; padding-top: 1.75rem;
  border-top: 1px solid var(--line);
}

/* ---------- Footer ---------- */
footer {
  background: var(--navy);
  color: #cfd3d9;
  text-align: center;
  padding: 3rem 2rem;
  margin-top: 4rem;
}
.footer-links {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 1.5rem;
  margin-bottom: 1.25rem;
}
.footer-links a { color: #e9ebee; font-size: 0.9rem; font-weight: 500; }
.footer-links a:hover { color: #fff; }
footer p { font-size: 0.88rem; color: #9aa2ac; margin-top: 0.35rem; }
footer p a { color: #e9ebee; text-decoration: underline; text-underline-offset: 2px; }
footer p a:hover { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  header { padding: 0.75rem 1.25rem; }
  .hero { padding: 4rem 1.5rem 3.5rem; }
  .services, .authority, .tech-stack, .clients, .contact { padding-left: 1.5rem; padding-right: 1.5rem; }
  .container { padding: 1.5rem; }

  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 0.85rem 1.5rem; }

  .tabs { flex-direction: column; }
  .tab-button { width: 100%; }
  .paper-card { padding: 1.5rem; }
}
