/* ==========================================================================
   Nicolás Cardiel — personal homepage
   Self-contained stylesheet: system fonts only, no external resources.
   ========================================================================== */

/* ---------- Design tokens ---------------------------------------------- */
:root {
  --bg: #f5f4ef;
  --bg-elev: #ffffff;
  --text: #1a2233;
  --muted: #5a6476;
  --border: #dedcd3;
  --accent: #a8650f;
  --link: #1d4f9c;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 6px 20px rgba(20, 30, 50, .06);
  --stars: none;
  --radius: 14px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --wrap: 1080px;
  color-scheme: light;
}

/* Dark "night sky" palette: follows the OS unless the visitor forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1325;
    --bg-elev: #111d36;
    --text: #e4e8f1;
    --muted: #9ba6bc;
    --border: #22325a;
    --accent: #f2b84b;
    --link: #8cb8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
    --stars: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1325;
  --bg-elev: #111d36;
  --text: #e4e8f1;
  --muted: #9ba6bc;
  --border: #22325a;
  --accent: #f2b84b;
  --link: #8cb8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  --stars: block;
  color-scheme: dark;
}

/* ---------- Base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--font-sans);
  overflow-x: hidden;
}

/* Subtle starfield (dark theme only), pure CSS gradients */
body::before {
  content: "";
  display: var(--stars, none);
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .55;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 38% 62%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 48%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 82%, #cfe0ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 32%, #ffe9c2 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 86%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 5% 50%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 48% 92%, #fff 50%, transparent 51%),
    radial-gradient(ellipse 80% 60% at 70% -10%, rgba(80, 110, 200, .18), transparent 70%);
  background-size: 420px 420px, 420px 420px, 420px 420px, 420px 420px, 420px 420px,
                   420px 420px, 420px 420px, 420px 420px, 420px 420px, 100% 100%;
}

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

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.01em;
}
h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); margin: 0 0 .4rem; }
h2 { font-size: 1.6rem; margin: 3rem 0 1.2rem; }
h3 { font-size: 1.2rem; margin: 2rem 0 .8rem; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #000; padding: .5rem 1rem; z-index: 100;
}
.skip:focus { left: 1rem; top: 1rem; }

.icon { width: 1em; height: 1em; flex: none; vertical-align: -.125em; }

/* ---------- Header / navigation ---------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 1rem;
  min-height: 64px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  color: var(--text); text-decoration: none;
  font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600;
  margin-right: auto;
}
.brand:hover { color: var(--text); }
.brand .icon { width: 26px; height: 26px; color: var(--accent); }
.brand small { font-family: var(--font-sans); font-weight: 400; color: var(--muted); font-size: .8rem; }

.nav { order: 1; }
.icon-btn { order: 2; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .15rem; }
.nav a {
  display: block; padding: .4rem .7rem; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: .95rem;
}
.nav a:hover { color: var(--text); background: var(--bg-elev); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); cursor: pointer; font: inherit;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn .icon { width: 20px; height: 20px; }
.menu-btn { display: none; }

/* Theme toggle shows the icon of the theme you would switch TO */
.theme-btn .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
}
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }

/* Mobile: collapse nav behind the menu button (only when JS is available) */
@media (max-width: 860px) {
  .js .menu-btn { display: inline-flex; }
  .js .nav { display: none; width: 100%; padding-bottom: .8rem; }
  .js .nav.open { display: block; }
  .js .nav ul { flex-direction: column; }
  .js .nav a { padding: .6rem .7rem; }
  .nav { width: 100%; order: 3; }
  .site-header .wrap { gap: .5rem; }
}
@media (max-width: 440px) {
  .brand small { display: none; }
}

/* ---------- Main ------------------------------------------------------- */
main { flex: 1; padding: 3rem 0 4rem; }

.page-head { margin-bottom: 2rem; max-width: 46rem; }
.eyebrow {
  display: inline-block; margin-bottom: .6rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.lead { font-size: 1.15rem; color: var(--muted); margin: 0; }
.prose { max-width: 46rem; }

.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }

/* ---------- Hero (home) ------------------------------------------------ */
.hero {
  display: grid; gap: 2.5rem; align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 860px) { .hero { grid-template-columns: 1.15fr 1fr; } }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.4rem); }
.hero .role { font-size: 1.2rem; color: var(--muted); margin: .4rem 0 1.4rem; }
.hero .role strong { color: var(--text); font-weight: 600; }

.photo {
  margin: 0; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow); background: var(--bg-elev);
}
.photo img {
  display: block; width: 100%; aspect-ratio: 513 / 166;
  object-fit: cover; object-position: center bottom;
}
.photo figcaption {
  display: flex; align-items: center; gap: .4rem;
  padding: .6rem .9rem; font-size: .85rem; color: var(--muted);
}

.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); text-decoration: none; font-size: .95rem; font-weight: 500;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.primary:hover { filter: brightness(1.08); color: #111; }

/* ---------- Cards ------------------------------------------------------ */
.cards {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  padding: 0; margin: 0; list-style: none;
}
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  position: relative;
  display: flex; flex-direction: column; gap: .35rem;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h3 { margin: 0; font-size: 1.15rem; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.card .meta {
  display: inline-flex; align-items: center; gap: .35rem; margin-top: auto; padding-top: .5rem;
  font-size: .8rem; color: var(--muted);
}
.card .tag {
  align-self: flex-start;
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
}

/* Big image cards (outreach index) */
.feature { padding: 0; overflow: hidden; }
.feature .cover {
  display: block; width: 100%; aspect-ratio: 4 / 3;
  object-fit: cover; object-position: top; border-bottom: 1px solid var(--border);
}
.feature .body { padding: 1rem 1.2rem 1.2rem; display: flex; flex-direction: column; gap: .35rem; }

/* ---------- Timeline --------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: .6rem; bottom: .6rem;
  width: 2px; background: var(--border);
}
.timeline > li { position: relative; padding: 0 0 1.6rem 2.2rem; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: .45rem;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.timeline > li:last-child { padding-bottom: 0; }
.when {
  display: inline-block; margin-bottom: .15rem;
  font-size: .82rem; font-weight: 700; letter-spacing: .04em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.timeline .title { display: block; font-weight: 600; font-size: 1.05rem; }
.timeline .title i, .timeline .title em { font-style: italic; }
.timeline p { margin: .1rem 0 0; color: var(--muted); }
.timeline p.plain { color: var(--text); }

/* Course list chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; padding: 0; list-style: none; }
.chips li {
  padding: .25rem .65rem; border-radius: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  font-size: .88rem; line-height: 1.4;
}
.chips li small { color: var(--muted); }

/* ---------- Galleries -------------------------------------------------- */
.gallery { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .7rem; }
.thumb {
  position: relative; display: block; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-elev); box-shadow: var(--shadow);
  line-height: 0;
}
.thumb img {
  height: 170px; width: auto; max-width: 100%; object-fit: cover;
  transition: transform .25s ease;
}
.gallery.single .thumb img { height: auto; width: 100%; max-width: 420px; }
.gallery.four .thumb img { height: 130px; }
.thumb:hover img { transform: scale(1.03); }
.thumb .badge {
  position: absolute; left: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .55rem; border-radius: 6px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: .8rem; line-height: 1;
}
@media (max-width: 520px) {
  .thumb img { height: 140px; }
  .gallery.four .thumb img { height: 110px; }
}

/* ---------- Lightbox (built by main.js) -------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 3.5rem 1rem 1rem;
  background: rgba(5, 9, 18, .92);
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #fff;
}
.lightbox button {
  position: absolute; top: .8rem;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08);
  color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.lightbox button:hover { background: rgba(255, 255, 255, .2); }
.lightbox .lb-close { right: .8rem; }
.lightbox .lb-prev { left: .8rem; }
.lightbox .lb-next { left: 4rem; }
.lightbox .lb-count { position: absolute; top: 1.4rem; left: 50%; transform: translateX(-50%); color: #ccd; font-size: .9rem; }
.no-scroll { overflow: hidden; }

/* ---------- Disclosure groups ----------------------------------------- */
details.group {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: .8rem; box-shadow: var(--shadow);
}
details.group > summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: .6rem;
  padding: .9rem 1.2rem; font-weight: 600;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before {
  content: ""; width: .5rem; height: .5rem; flex: none;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg); transition: transform .15s ease;
}
details.group[open] > summary::before { transform: rotate(45deg); }
details.group > summary .count {
  margin-left: auto; font-weight: 500; font-size: .8rem; color: var(--muted);
  padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--border);
}
details.group > .inner { padding: .4rem 1.2rem 1.4rem; }

/* ---------- Misc ------------------------------------------------------ */
.panel {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem 1.5rem; box-shadow: var(--shadow);
}
.two-col { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } }

.email-img {
  display: inline-block; background: #fff; border-radius: 8px; padding: .35rem .6rem;
  border: 1px solid var(--border); line-height: 0;
}
.email-img img { width: 190px; }

address { font-style: normal; line-height: 1.7; }

.book { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.book .gallery { margin-top: 0; }
.book .gallery .thumb img { height: 230px; }
.book .info { flex: 1 1 260px; }

/* ---------- Footer ---------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0; font-size: .9rem; color: var(--muted);
}
.site-footer .wrap {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .lightbox, body::before { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .panel, details.group { box-shadow: none; }
}
