/* ==========================================================
   Marcos Cavanagh · estilos
   Tema oscuro por defecto (estética de tablero) + tema claro
   ========================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:      #0d0d0d;
  --surface:   #1a1a19;
  --surface-2: #232321;
  --border:    rgba(255,255,255,.10);
  --ink:       #f0efec;
  --ink-2:     #c3c2b7;
  --muted:     #898781;
  --grid:      #2c2c2a;
  --axis:      #383835;
  --accent:    #3987e5;
  --accent-ink:#ffffff;
  --accent-soft: rgba(57,135,229,.14);
  --good:      #0ca30c;
  --critical:  #e66767;
  /* Series categóricas (paleta validada para superficie oscura) */
  --s1: #3987e5;  /* azul    · sector privado */
  --s2: #d95926;  /* naranja · sector público */
  --s3: #199e70;  /* aqua    · org. internacional */
  --s4: #c98500;  /* amarillo */
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.35);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page:      #f9f9f7;
  --surface:   #fcfcfb;
  --surface-2: #f0efec;
  --border:    rgba(11,11,11,.10);
  --ink:       #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #6f6d68;
  --grid:      #e1e0d9;
  --axis:      #c3c2b7;
  --accent:    #2a78d6;
  --accent-ink:#ffffff;
  --accent-soft: rgba(42,120,214,.10);
  --good:      #006300;
  --critical:  #d03b3b;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.25rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .9rem; font-weight: 600; color: var(--ink-2); }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .85em; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand__mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 700; letter-spacing: .02em;
}
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  text-decoration: none; color: var(--ink-2); font-size: .9rem; font-weight: 500;
  padding: 6px 12px; border-radius: 8px;
}
.nav a:hover, .nav a.is-current { color: var(--ink); background: var(--surface-2); }
.topbar__tools { display: flex; align-items: center; gap: 8px; }
.pill {
  text-decoration: none; font-size: .8rem; font-weight: 600; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--ink-2);
}
.pill:hover { color: var(--ink); border-color: var(--ink-2); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }
:root[data-theme="dark"] .i-moon, :root:not([data-theme]) .i-moon { display: none; }
:root[data-theme="light"] .i-sun { display: none; }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: grid; }
  .nav {
    position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; gap: 0;
    background: var(--page); border-bottom: 1px solid var(--border); padding: 8px 16px 16px;
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px; }
  .topbar__tools { margin-left: auto; }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn--block { width: 100%; justify-content: flex-start; }
.btn--block .mono { margin-left: auto; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- Hero ---------- */
.hero { padding: clamp(48px, 8vw, 96px) 0 32px; position: relative; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000 10%, transparent 75%);
  opacity: .55;
}
.hero__grid { display: grid; grid-template-columns: 1fr 300px; gap: 48px; align-items: center; }
.eyebrow, .kicker {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .78rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
}
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.75rem); font-weight: 700; letter-spacing: -.025em; margin: 14px 0 18px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lead { font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--ink-2); max-width: 62ch; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.profile { padding: 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.profile__photo {
  width: 160px; height: 160px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--surface); outline: 2px solid var(--accent);
}
.profile__photo img { width: 100%; height: 100%; object-fit: cover; }
.profile__photo--empty {
  display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); font-size: 3rem; font-weight: 700; letter-spacing: .02em;
}
.profile__id { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.profile__id strong { font-size: 1.1rem; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.profile__id .muted { font-size: .85rem; }

.kpis { list-style: none; margin: 48px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi__value { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi__label { font-size: .85rem; color: var(--ink-2); line-height: 1.35; }

@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; gap: 32px; }
  .profile { flex-direction: row; text-align: left; }
  .profile__photo { width: 88px; height: 88px; }
  .profile__photo--empty { font-size: 1.8rem; }
  .profile__id { align-items: flex-start; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* ---------- Secciones ---------- */
.section { padding: clamp(56px, 9vw, 104px) 0 0; }
.section__head { margin-bottom: 32px; max-width: 720px; display: grid; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

.chart-card { margin: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chart-card figcaption { display: grid; gap: 4px; }
.chart-box { position: relative; height: 300px; }
.chart-box--sm { height: 240px; }
.note { font-size: .85rem; color: var(--ink-2); border-top: 1px solid var(--border); padding-top: 12px; }

.tiles { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile { padding: 18px 20px; display: grid; gap: 4px; }
.tile__value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.tile__label { font-size: .9rem; line-height: 1.4; }
.tile__ctx { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }

/* ---------- Gantt de trayectoria ---------- */
.gantt { padding: 20px; }
.gantt__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch--private { background: var(--s1); }
.swatch--public  { background: var(--s2); }
.swatch--ngo     { background: var(--s3); }

.gantt__body { --label-w: 250px; position: relative; }
.gantt__axis {
  position: relative; height: 20px; margin-left: var(--label-w);
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .72rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.gantt__axis span { position: absolute; transform: translateX(-50%); }
.gantt__rows { list-style: none; margin: 0; padding: 0; position: relative; }
.gantt__rows::before {
  /* líneas verticales cada 2 años, alineadas con el eje */
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px calc(100% / var(--years, 7.4)));
}
.gantt__row { display: grid; grid-template-columns: var(--label-w) 1fr; align-items: center; min-height: 44px; border-top: 1px solid var(--grid); }
.gantt__row:last-child { border-bottom: 1px solid var(--axis); }
.gantt__label {
  all: unset; cursor: pointer; font-size: .88rem; color: var(--ink-2); padding-right: 12px;
  line-height: 1.25; padding-block: 4px;
}
.gantt__label:hover, .gantt__label.is-active { color: var(--ink); font-weight: 600; }
.gantt__label:focus-visible { outline: 2px solid var(--accent); }
.gantt__track { position: relative; height: 44px; }
.gantt__bar {
  position: absolute; top: 50%; height: 20px; transform: translateY(-50%);
  border: 0; padding: 0; border-radius: 4px; cursor: pointer;
  transition: filter .15s, box-shadow .15s, opacity .15s;
}
.gantt__bar--private { background: var(--s1); }
.gantt__bar--public  { background: var(--s2); }
.gantt__bar--ngo     { background: var(--s3); }
.gantt__rows.has-active .gantt__bar:not(.is-active) { opacity: .55; }
.gantt__bar.is-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.gantt__bar:hover { filter: brightness(1.12); opacity: 1 !important; }
.gantt__tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 8px; font-size: .78rem; line-height: 1.35; white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 5; text-align: left;
}
.gantt__tip strong { display: block; }
.gantt__bar:hover .gantt__tip, .gantt__bar:focus-visible .gantt__tip { opacity: 1; }
.gantt__row:last-child .gantt__tip { bottom: auto; top: calc(100% + 10px); }
@media (max-width: 640px) {
  .gantt__body { --label-w: 110px; }
  .gantt__label { font-size: .78rem; white-space: normal; line-height: 1.2; }
  .gantt__axis .minor { display: none; }
  .gantt__tip { white-space: normal; width: 180px; }
}

.roles { margin-top: 16px; }
.role { padding: 24px; }
.role[hidden] { display: none; }
.role.is-active { animation: fadeUp .35s ease; }
.role__head { display: grid; gap: 8px; margin-bottom: 18px; }
.role__head h3 { font-size: 1.35rem; }
.role__org { color: var(--ink-2); font-size: .95rem; }
.role__body { display: grid; grid-template-columns: 1fr 240px; gap: 32px; }
.role__body p { color: var(--ink-2); }
.bullets { margin: 14px 0 0; padding-left: 18px; display: grid; gap: 8px; }
.bullets li::marker { color: var(--accent); }
.role__kpis { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; align-content: start; }
.role__kpis li { background: var(--surface-2); border-radius: 10px; padding: 14px 16px; display: grid; gap: 2px; }
.role__kpis .kpi__value { font-size: 1.45rem; }
@media (max-width: 760px) {
  .role__body { grid-template-columns: 1fr; gap: 20px; }
  .role__kpis { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

.badge {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.badge--private::before { background: var(--s1); }
.badge--public::before  { background: var(--s2); }
.badge--ngo::before     { background: var(--s3); }
.badge--demo::before    { background: var(--s4); border-radius: 50%; }

.edu-grid { margin-top: 16px; }
.edu { padding: 20px 24px; }
.edu h3 { margin-bottom: 10px; }
.edu ul { list-style: none; margin: 0; padding: 0; }
.edu li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--grid); font-size: .92rem; }
.edu li:first-child { border-top: 0; }

/* ---------- Casos ---------- */
.cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 960px) { .cases { grid-template-columns: minmax(0, 1fr); } }
.case { padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.case__meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.case__sector { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.case h3 { font-size: 1.25rem; }
.case__story { margin: 0; display: grid; gap: 10px; }
.case__story div { display: grid; grid-template-columns: 92px 1fr; gap: 12px; font-size: .9rem; }
.case__story dt { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.case__story dd { margin: 0; color: var(--ink-2); }
@media (max-width: 480px) { .case__story div { grid-template-columns: 1fr; gap: 2px; } }
.case__chart { margin-top: auto; border-top: 1px solid var(--border); padding-top: 16px; display: grid; gap: 12px; }
.chart-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg button {
  font: inherit; font-size: .8rem; font-weight: 500; border: 0; background: transparent; color: var(--ink-2);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; min-height: 32px;
}
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.2); }

.table-view summary { cursor: pointer; font-size: .82rem; color: var(--ink-2); }
.table-view summary:hover { color: var(--ink); }
.table-scroll { overflow-x: auto; margin-top: 10px; }
.table-view table { border-collapse: collapse; width: 100%; font-size: .8rem; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
.table-view th:first-child { text-align: left; }
.table-view thead th { color: var(--muted); font-weight: 600; }

/* ---------- Proyectos ---------- */
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 960px) { .projects { grid-template-columns: minmax(0, 1fr); } }
.project { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.project__head { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; }
.project__logo { width: 56px; height: 56px; border-radius: 12px; }
.project__head h3 { font-size: 1.25rem; }
.project__logo--mono {
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 1.15rem; letter-spacing: .02em;
}
.project__stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.project__stats li { background: var(--surface-2); border-radius: 10px; padding: 12px 16px; display: grid; gap: 2px; }
.project__stats .kpi__value { font-size: 1.45rem; }
.project__tagline { color: var(--ink-2); font-size: .92rem; }
.project .bullets { margin: 0; }
.project__link { margin-top: auto; align-self: flex-start; }
.badge--status::before { background: var(--s4); border-radius: 50%; }
@media (max-width: 480px) {
  .project__head { grid-template-columns: 48px 1fr; }
  .project__logo { width: 48px; height: 48px; }
  .project__head .badge { grid-column: 1 / -1; }
}

/* ---------- Habilidades ---------- */
.skills { padding: 20px 24px; }
.skills h3 { margin-bottom: 14px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font-size: .82rem; padding: 5px 11px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.langs { margin-top: 20px; color: var(--ink-2); }

/* ---------- Contacto ---------- */
.contact__intro { max-width: 640px; }
.contact__intro { display: grid; gap: 14px; }
.contact__links { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }

/* ---------- Footer ---------- */
.footer { margin-top: clamp(56px, 9vw, 104px); border-top: 1px solid var(--border); padding: 24px 0; font-size: .85rem; color: var(--muted); }
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.footer a { color: var(--ink-2); }

/* ---------- Animaciones ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .role.is-active { animation: none; }
}

@media print {
  .topbar, .seg, .hero::before { display: none; }
  .js .reveal { opacity: 1; transform: none; }
  .role[hidden] { display: block; }
}
