/* ==========================================================================
   Historia CONFITECA — scroll storytelling (estilo narrativo, sin frameworks)
   ========================================================================== */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.06);
  --accent: #dd1d16;
  --accent-soft: rgba(221, 29, 22, 0.08);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --space-section: clamp(5rem, 14vw, 9rem);
  --max-text: 38rem;
  --max-wide: min(1120px, 92%);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 4%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  text-decoration: none;
}

.brand__badge {
  background: #dd1d16;
  color: #fff;
  padding: 0.28rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
}

.brand__text {
  color: #a90f0a;
  font-size: 0.85rem;
}

.main-nav {
  display: none;
  gap: 1rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.main-nav a {
  color: var(--muted);
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--text);
}

.menu-toggle {
  border: 0;
  background: #fff;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  display: grid;
  place-content: center;
  gap: 4px;
}

.menu-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 99px;
}

.mobile-menu {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 4%;
  display: none;
  gap: 0.5rem;
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 95;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.08);
  max-height: calc(100vh - 58px);
  overflow-y: auto;
}

.mobile-menu.is-open {
  display: grid;
}

.mobile-menu a {
  color: var(--text);
  text-decoration: none;
  padding: 0.55rem;
  border-radius: 8px;
}

.mobile-menu a:hover {
  background: #f5f5f5;
}

/* —— Cabecera mínima (coherente con landing) —— */
.story-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 250, 250, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.story-header__inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0.85rem 4%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.story-brand {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.story-brand span {
  color: var(--accent);
}

.story-nav {
  display: none;
  gap: 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.story-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease-out);
}

.story-nav a:hover,
.story-nav a[aria-current="page"] {
  color: var(--text);
}

.story-menu-btn {
  border: none;
  background: transparent;
  width: 44px;
  height: 44px;
  display: grid;
  place-content: center;
  gap: 5px;
  cursor: pointer;
  border-radius: 8px;
}

.story-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.story-drawer {
  display: none;
  flex-direction: column;
  padding: 0.5rem 4% 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: fixed;
  top: 62px;
  left: 0;
  right: 0;
  z-index: 45;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.08);
  max-height: calc(100vh - 62px);
  overflow-y: auto;
}

.story-drawer.is-open {
  display: flex;
}

.story-drawer a {
  padding: 0.65rem 0;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.story-drawer a:last-child {
  border-bottom: none;
}

@media (min-width: 768px) {
  .story-nav {
    display: flex;
  }

  .story-menu-btn {
    display: none;
  }

  .story-drawer {
    display: none !important;
  }
}

/* —— Intro hero —— */
.story-hero {
  padding: var(--space-section) 4% calc(var(--space-section) * 1.1);
  max-width: var(--max-wide);
  margin: 0 auto;
  text-align: center;
}

.story-hero__eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}

.story-hero__title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0 auto 1.25rem;
  max-width: 12ch;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s var(--ease-out) 0.08s, transform 1s var(--ease-out) 0.08s;
}

.story-hero__lead {
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  color: var(--muted);
  max-width: 36rem;
  margin: 0 auto;
  font-weight: 500;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.95s var(--ease-out) 0.18s, transform 0.95s var(--ease-out) 0.18s;
}

.story-hero.is-visible .story-hero__eyebrow,
.story-hero.is-visible .story-hero__title,
.story-hero.is-visible .story-hero__lead {
  opacity: 1;
  transform: translateY(0);
}

/* —— Capítulos (cada hito = slide en el scroll) —— */
.story-chapter {
  padding: clamp(4rem, 12vw, 8rem) 4%;
  border-top: 1px solid var(--line);
  opacity: 0;
  transform: translateY(48px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
  will-change: opacity, transform;
}

.story-chapter.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.story-chapter__inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: grid;
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: center;
}

@media (min-width: 900px) {
  .story-chapter__inner {
    grid-template-columns: 1fr 1fr;
    gap: clamp(3rem, 6vw, 5rem);
  }

  .story-chapter--flip .story-chapter__inner {
    direction: rtl;
  }

  .story-chapter--flip .story-chapter__inner > * {
    direction: ltr;
  }
}

.story-chapter__year {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.story-chapter__title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin: 0 0 1rem;
}

.story-chapter__text {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
  max-width: var(--max-text);
  font-weight: 500;
}

/* Visual: bloque premium tipo Apple (sin imágenes externas) */
.story-visual {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 1.25rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.06);
  transform: scale(0.97);
  transition: transform 1.1s var(--ease-out), box-shadow 1.1s var(--ease-out);
}

.story-chapter.is-visible .story-visual {
  transform: scale(1);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.08);
}

.story-visual__layer {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #f5f5f7 0%, #e8e8ed 45%, #fafafa 100%);
}

.story-visual__accent {
  position: absolute;
  width: 120%;
  height: 120%;
  left: -10%;
  top: -10%;
  background: radial-gradient(
    ellipse at 30% 40%,
    var(--accent-soft) 0%,
    transparent 55%
  );
  opacity: 0.9;
  transition: transform 1.2s var(--ease-out);
}

.story-chapter.is-visible .story-visual__accent {
  transform: translate(2%, -2%);
}

.story-visual__glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: rgba(0, 0, 0, 0.04);
  user-select: none;
}

/* Parallax suave aplicado por JS (--parallax en px) */
.story-visual__parallax {
  transform: translate3d(0, var(--parallax, 0px), 0);
  will-change: transform;
}

/* —— Cierre —— */
.story-finale {
  padding: var(--space-section) 4%;
  text-align: center;
  border-top: 1px solid var(--line);
  max-width: 44rem;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}

.story-finale.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.story-finale__quote {
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin: 0 0 1rem;
}

.story-finale__sub {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

.story-finale__cta {
  margin-top: 2rem;
}

.story-finale__cta a {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.story-finale__cta a:hover {
  border-bottom-color: var(--accent);
}

.footer {
  background: #121212;
  color: #ededed;
  padding-bottom: 2rem;
}

.footer__grid {
  width: min(1120px, 92%);
  margin-inline: auto;
  display: grid;
  gap: 1.2rem;
}

.footer h3 {
  margin: 0 0 0.7rem;
}

.footer p,
.footer a {
  margin: 0 0 0.45rem;
  color: #d3d3d3;
  text-decoration: none;
}

.footer__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.footer__social a {
  border: 1px solid #3a3a3a;
  padding: 0.32rem 0.55rem;
  border-radius: 0.45rem;
}

.footer__legal {
  width: min(1120px, 92%);
  margin: 1.1rem auto 0;
  border-top: 1px solid #2d2d2d;
  padding-top: 1rem;
  font-size: 0.88rem;
}

@media (min-width: 920px) {
  .main-nav {
    display: flex;
  }

  .menu-toggle,
  .mobile-menu {
    display: none !important;
  }

  .footer__grid {
    grid-template-columns: 1.2fr 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-hero__eyebrow,
  .story-hero__title,
  .story-hero__lead,
  .story-chapter,
  .story-visual,
  .story-finale,
  .story-visual__accent {
    transition: none;
    transform: none !important;
    opacity: 1 !important;
  }

  .story-chapter:not(.is-visible) {
    opacity: 1;
    transform: none;
  }

  .story-visual__parallax {
    transform: none !important;
  }
}
