:root {
  --marina: #5f4b8b;
  --marina-dark: #4a3a6e;
  --marina-soft: #efebf7;
  --accent: #5f4b8b;        /* texto e iconos de acento (en oscuro, más claro para que se lea) */
  --surface: #ffffff;       /* tarjetas, botones claros, modal */
  --header-bg: rgba(255, 255, 255, .9);
  --ink: #1f1b2b;
  --text: #4a4658;
  --muted: #7a7589;
  --bg: #ffffff;
  --bg-alt: #f7f5fb;
  --line: #e6e2ee;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(47, 34, 84, 0.25);
  --max: 1160px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Tema oscuro: lo activa js (data-theme en <html>), según la preferencia guardada o la del sistema */
:root[data-theme="dark"] {
  --marina: #6e59a3;
  --marina-dark: #7f6ab6;
  --marina-soft: #2a2440;
  --accent: #b9a9e8;
  --ink: #f2eff9;
  --text: #c8c3d6;
  --muted: #9b95ad;
  --bg: #14111c;
  --bg-alt: #1b1726;
  --surface: #211c2e;
  --line: #312b44;
  --header-bg: rgba(20, 17, 28, .85);
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 800; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.section { padding: 96px 0; }
.section--alt { background: var(--bg-alt); }
.section__head { max-width: 640px; margin-bottom: 48px; }
.section__head--center { margin-inline: auto; text-align: center; }
.eyebrow {
  display: inline-block;
  font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.lead { font-size: 1.15rem; color: var(--text); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 26px; border-radius: 999px; border: 2px solid transparent;
  font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--marina); color: #fff; }
.btn--primary:hover { background: var(--marina-dark); }
.btn--ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--light { background: #fff; color: #5f4b8b; }

/* Cabecera */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.header.is-scrolled { border-bottom-color: var(--line); }
.header__inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--accent); }
.brand__logo { height: 38px; width: auto; }
.brand__logo--blanco, [data-theme="dark"] .brand__logo--color { display: none; }
[data-theme="dark"] .brand__logo--blanco { display: block; }
.nav { display: flex; align-items: center; gap: 32px; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); }
.nav .btn { color: #fff; padding: 10px 20px; }
.nav-toggle {
  display: none; background: none; border: 0; padding: 8px; cursor: pointer; color: var(--ink);
}
.nav-toggle svg { width: 26px; height: 26px; }
.header__inner { gap: 16px; }
.nav { margin-left: auto; }

/* Selector de tema */
.theme-toggle {
  width: 40px; height: 40px; flex: none; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .2s, color .2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .i-sun, [data-theme="dark"] .theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .theme-toggle { margin-left: auto; }
  .nav {
    position: absolute; top: 72px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 8px 24px 24px;
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .nav .btn { margin-top: 16px; justify-content: center; border: 0; }
}

/* Hero */
.hero { padding: 88px 0 96px; overflow: hidden; }
.hero h1 { max-width: 820px; }
.hero h1 span { color: var(--accent); }
.hero .lead { max-width: 540px; margin-bottom: 32px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__platforms { display: flex; gap: 24px; margin-top: 40px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.hero__platforms span::before { content: "✓ "; color: var(--accent); }

@media (max-width: 860px) {
  .hero { padding: 48px 0 64px; }
  .hero__platforms { flex-wrap: wrap; gap: 8px 20px; }
}

/* Servicios */
.services { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.service { padding: 28px; }
.service {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; transition: box-shadow .2s, transform .2s;
}
.service:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.service__icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--marina-soft); color: var(--accent); margin-bottom: 20px;
}
.service__icon svg { width: 26px; height: 26px; }
.service p { margin: 0; font-size: .98rem; }
@media (max-width: 1080px) { .services { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .services { grid-template-columns: 1fr; } }

/* Nosotros */
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 28px; border: 1px solid var(--line); }
.stat strong { display: block; font-size: 2.4rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat span { font-size: .92rem; color: var(--muted); }
@media (max-width: 860px) { .about { grid-template-columns: 1fr; gap: 40px; } }

/* Portfolio */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 36px; }
.filter {
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.filter:hover { border-color: var(--accent); color: var(--accent); }
.filter.is-active { background: var(--marina); border-color: var(--marina); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
@media (max-width: 960px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }

.card {
  display: block; text-align: left; width: 100%;
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: none;
}
.card__media {
  aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  background: var(--marina-soft); margin-bottom: 16px;
  transition: box-shadow .25s;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.card:hover .card__media { box-shadow: var(--shadow); }
.card:hover .card__media img { transform: scale(1.04); }
.card__cat { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.card h3 { margin: 4px 0 2px; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }

/* Placeholder: se usa cuando una imagen todavía no existe */
.ph {
  width: 100%; height: 100%;
  display: grid; place-items: center; text-align: center; padding: 16px;
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(95, 75, 139, .06) 14px 28px),
    var(--marina-soft);
  color: var(--accent); font-weight: 700; font-size: .95rem;
}
.ph small { display: block; font-weight: 500; font-size: .78rem; color: var(--muted); margin-top: 4px; }

.center { text-align: center; margin-top: 48px; }


/* Contacto */
#contacto { padding-top: 96px; }
@media (max-width: 860px) { #contacto { padding-top: 64px; } }
.contact {
  background: var(--marina); color: #e9e4f5; border-radius: 24px;
  padding: 64px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center;
}
.contact h2 { color: #fff; }
.contact .eyebrow { color: #cfc3ec; }
.contact__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.contact__list a, .contact__list div {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .1); border-radius: 12px; padding: 16px 20px;
  color: #fff; text-decoration: none; font-weight: 600;
}
.contact__list a:hover { background: rgba(255, 255, 255, .18); }
.contact__list svg { width: 22px; height: 22px; flex: none; }
.contact__list small { display: block; font-weight: 500; color: #cfc3ec; font-size: .82rem; }
@media (max-width: 860px) { .contact { grid-template-columns: 1fr; padding: 40px 24px; } }
.contact__map {
  grid-column: 1 / -1; height: 340px; border-radius: 16px; overflow: hidden;
  background: rgba(255, 255, 255, .1); z-index: 0;
}
.contact__map .leaflet-popup-content { font: 500 .9rem/1.4 var(--font); color: #1f1b2b; }
.contact__map .leaflet-popup-content a { color: #5f4b8b; font-weight: 700; }
[data-theme="dark"] .contact__map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }
.map-pin { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); }
@media (max-width: 860px) { .contact__map { height: 260px; } }

/* Pie */
.footer { padding: 40px 0; border-top: 1px solid var(--line); margin-top: 96px; font-size: .9rem; color: var(--muted); }
.footer__inner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }

/* Cabecera de página interior */
.page-head { padding: 72px 0 24px; }

/* Modal de proyecto */
.modal {
  border: 0; padding: 0; margin: auto;
  width: min(1040px, calc(100% - 32px)); max-height: calc(100% - 48px);
  border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(20, 10, 50, .5);
  color: var(--text); background: var(--surface);
}
.modal::backdrop { background: rgba(26, 18, 46, .6); backdrop-filter: blur(4px); }
.modal__close {
  position: sticky; top: 16px; float: right; margin: 16px 16px 0 0; z-index: 2;
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(0, 0, 0, .12); font-size: 22px; line-height: 1; color: var(--ink);
}
.modal__body { padding: 48px; }
.modal__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 24px; }
.tag { font-size: .8rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; background: var(--marina-soft); color: var(--accent); }
.modal__links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.gallery { display: grid; gap: 16px; margin-top: 36px; }
.gallery--movil { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.gallery--movil .shot { aspect-ratio: 9 / 19.5; border-radius: 22px; }
/* Con imagen, la captura manda su proporción (App Store 9:16, móviles modernos 9:19.5) */
.gallery--movil { align-items: start; }
.gallery--movil .shot:has(img) { aspect-ratio: auto; }
.gallery--movil .shot img { display: block; height: auto; }
.gallery--web { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.gallery--web .shot { aspect-ratio: 16 / 10; border-radius: 10px; }
.shot { overflow: hidden; background: var(--marina-soft); border: 1px solid var(--line); }
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
@media (max-width: 600px) {
  .modal__body { padding: 28px 20px; }
  .gallery--movil { grid-template-columns: repeat(2, 1fr); }
  .gallery--web { grid-template-columns: 1fr; }
}

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