/* Tupla — propuesta de rebranding. Colores de los cuatro rumbos: rojo cochinilla, amarillo maíz, azul cielo, negro y blanco. */
:root {
  --night: #FFFFFF;
  --deep: #F5F3EF;
  --navy: #5C0F1E;
  --blue-mid: #8C1A2E;
  --blue: #C8102E;          /* rojo cochinilla */
  --blue-light: #8F6200;    /* amarillo maíz (oscurecido para leerse en blanco) */
  --sky: #2F8FCB;           /* azul cielo */
  --paper: #111111;
  --mute: #4A4540;
  --hair: rgba(17, 17, 17, .12);
  --display: "Montserrat", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --pad: clamp(1.25rem, 5vw, 5rem);
  /* Superficies y tintas que cambian por tema */
  --glass: rgba(255, 255, 255, .88);
  --glass-soft: rgba(255, 255, 255, .55);
  --glass-log: rgba(255, 255, 255, .78);
  --panel: rgba(255, 255, 255, .98);
  --lead: #3A3530;
  --bot-bg: rgba(47, 143, 203, .10);
  --bot-ink: #1A1A1A;
  --err: #A3101F;
  --grain-blend: multiply;
  --grain-opacity: .07;
}

/* Modo oscuro: fondo casi negro, tinta clara. El amarillo puede ir como texto (pasa AA); el rojo sigue en detalles. */
[data-theme="dark"] {
  --night: #0E0F12;
  --deep: #181A1F;
  --navy: #7A1424;
  --blue-mid: #A3203A;
  --blue: #FF4D63;
  --blue-light: #F2B705;
  --sky: #5AAEE0;
  --paper: #F2F0EC;
  --mute: #B4AFA8;
  --hair: rgba(255, 255, 255, .14);
  --glass: rgba(14, 15, 18, .86);
  --glass-soft: rgba(14, 15, 18, .6);
  --glass-log: rgba(24, 26, 31, .82);
  --panel: rgba(22, 24, 29, .98);
  --lead: #CFCAC2;
  --bot-bg: rgba(90, 174, 224, .14);
  --bot-ink: #ECE9E4;
  --err: #FF6B7D;
  --grain-blend: screen;
  --grain-opacity: .04;
}

* { box-sizing: border-box; }
html { background: var(--night); color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; font: 400 1.0625rem/1.55 var(--body); color: var(--mute); background: var(--night); }
h1, h2, h3 { font-family: var(--display); color: var(--paper); margin: 0; line-height: 1.04; letter-spacing: -.02em; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 4px; }

/* Grano: textura de impresión sobre todo el sitio */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 60; background: var(--paper); color: var(--night); padding: .5rem 1rem; }

.bar { position: fixed; inset: 0 0 auto; z-index: 40; display: flex; justify-content: space-between; align-items: center;
       padding: 1.25rem var(--pad); }
.bar { transition: background .3s; }
.bar.solid { background: var(--glass); backdrop-filter: blur(8px); border-bottom: 1px solid var(--hair); }
.bar img { display: block; height: 34px; width: auto; }
.bar nav { display: flex; align-items: center; gap: 2rem; font-size: .95rem; }
.bar nav a { text-decoration: none; color: var(--paper); opacity: .8; padding: .6rem 0; }
.bar nav a:hover { opacity: 1; }
.bar nav .bar-cta { border: 1px solid var(--hair); padding: .7rem 1.4rem; white-space: nowrap; border-radius: 999px; opacity: 1 !important; }
.bar-cta:hover { border-color: var(--blue-light); }

.btn { display: inline-block; margin-top: 2rem; padding: .95rem 1.5rem; border-radius: 999px; background: var(--paper);
       color: var(--night); font: 600 1rem/1 var(--body); text-decoration: none; transition: background .2s; }
.btn:hover { background: var(--blue-light); }
.btn-line { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1px var(--hair); }
.btn-line:hover { background: transparent; box-shadow: inset 0 0 0 1px var(--blue-light); }

/* ---- Historia con escena fija ---- */
.story { position: relative; }
.stage { position: sticky; top: 0; height: 100svh; overflow: hidden;
         background: radial-gradient(120% 90% at 70% 45%, var(--deep) 0%, var(--night) 62%); }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
#graph:active { cursor: grabbing; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.label { position: absolute; left: 0; top: 0; font: 500 .78rem/1 var(--body); color: var(--paper); white-space: nowrap;
         padding: .3rem .55rem; border-radius: 4px; background: var(--glass-soft); border: 1px solid var(--hair);
         transition: color .3s, border-color .3s; will-change: transform, opacity; }
.label.on { color: #111; background: #F2B705; border-color: #F2B705; }
.hint { position: absolute; right: var(--pad); bottom: 2rem; font-size: .8rem; color: var(--mute); opacity: .8;
        transition: opacity .6s; }
.hint.gone { opacity: 0; }
.rail { position: absolute; left: calc(var(--pad) - 1.5rem); top: 30%; bottom: 30%; width: 1px; background: var(--hair); }
.rail i { position: absolute; inset: 0 0 auto; height: 0; background: var(--blue-light); }
.log { position: absolute; right: var(--pad); top: 6.5rem; margin: 0; padding: 0; list-style: none; width: min(22rem, 40vw);
       font: 400 .8rem/1.4 var(--body); color: var(--mute); opacity: 0; transition: opacity .5s;
       background: var(--glass-log); backdrop-filter: blur(6px); padding: .75rem 1rem; border: 1px solid var(--hair); border-radius: 6px; z-index: 3; }
.log.on { opacity: 1; }
.log li { padding: .45rem 0; border-bottom: 1px solid var(--hair); display: flex; gap: .6rem; animation: logIn .5s both; }
.log li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: .45rem; border-radius: 50%; background: var(--blue-light); }
.log li.ask::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--blue-light); }
.log .tag { margin-left: auto; color: var(--blue-light); }
.log-title { color: var(--paper); font-weight: 600; border-bottom-color: var(--blue-mid) !important; }
.log-title::before { display: none; }
@keyframes logIn { from { opacity: 0; transform: translateY(-6px); } }

.story { height: 420svh; }
.steps { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.step { position: absolute; inset: 0 auto 0 0; display: flex; flex-direction: column; justify-content: center;
        padding: 0 var(--pad); max-width: calc(36rem + var(--pad)); transform: translateY(24px);
        transition: opacity .6s, transform .8s cubic-bezier(.2,.7,.2,1); }
.step > * { pointer-events: auto; }
.step h1 { font-size: clamp(2.4rem, 4.6vw, 4.4rem); font-weight: 800; max-width: 13ch; }
.step .btn { align-self: flex-start; }
.step h2 { font-size: clamp(2rem, 4.2vw, 3.6rem); font-weight: 800; max-width: 13ch; }
.step p { font-size: 1.15rem; max-width: 34ch; margin: 1.5rem 0 0; color: var(--lead); }
.step-n { font: 500 .85rem/1 var(--body); color: var(--blue-light); margin-bottom: 1.25rem; }
.step { opacity: 0; visibility: hidden; }
.step.active { opacity: 1; visibility: visible; transform: none; }

/* ---- Secciones ---- */
.section { position: relative; z-index: 3; background: var(--night); padding: 9rem var(--pad); border-top: 1px solid var(--hair); }
.section-head { max-width: 46rem; margin-bottom: 4rem; }
.section-head h2, .contact h2 { font-size: clamp(2rem, 4.4vw, 3.8rem); font-weight: 800; }
.section-head p { font-size: 1.15rem; margin: 1.25rem 0 0; max-width: 46ch; }

.roles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
         border-top: 1px solid var(--hair); }
.roles li { padding: 2rem 2rem 2.5rem 0; border-bottom: 1px solid var(--hair); display: flex; flex-direction: column; gap: .9rem; }
.roles li + li { padding-left: 2rem; border-left: 1px solid var(--hair); }
.roles h3 { font-size: 1.5rem; font-weight: 700; }
.roles p { margin: 0; }
.roles span { margin-top: auto; padding-top: 1rem; font-size: .9rem; color: var(--blue-light); }

.months { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
          counter-reset: m; }
.months li { padding: 2rem 2rem 0 0; border-top: 2px solid var(--blue-mid); position: relative; }
.months li::before { content: ""; position: absolute; top: -7px; left: 0; width: 12px; height: 12px; border-radius: 50%;
                     background: var(--night); box-shadow: inset 0 0 0 2px var(--blue-light); }
.months b { font: 500 .85rem/1 var(--body); color: var(--blue-light); }
.months h3 { font-size: 1.6rem; font-weight: 700; margin: .9rem 0 .7rem; }
.months p { margin: 0; max-width: 28ch; }

.contact { text-align: left; padding-bottom: 11rem; }
.contact h2 { max-width: 14ch; }
.contact p { font-size: 1.15rem; max-width: 40ch; margin: 1.5rem 0 0; }
.contact-row { display: flex; flex-wrap: wrap; gap: 1rem; }

.foot { position: relative; z-index: 3; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
        padding: 2rem var(--pad); border-top: 1px solid var(--hair); font-size: .85rem; background: var(--night); }

@media (max-width: 860px) {
  .bar nav a:not(.bar-cta) { display: none; }
  .log { display: none; }
  .rail { display: none; }
  .step { justify-content: flex-end; padding-bottom: 14svh; }
  .hint { display: none; }
  .step { right: 0; padding-bottom: 8svh; background: linear-gradient(to top, var(--night) 45%, transparent 75%); max-width: none; }
  .label { font-size: .75rem; }
  .months { grid-template-columns: 1fr; gap: 2.5rem; }
  .roles li + li { padding-left: 0; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Asistente ---- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chat-open { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 45; display: flex; align-items: center; gap: .6rem;
  background: var(--paper); color: var(--night); border: 0; border-radius: 999px; padding: .85rem 1.25rem .85rem 1rem;
  font: 600 .95rem var(--body); cursor: pointer; }
.chat-open i { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px rgba(200,16,46,.3); }
.chat-open[aria-expanded="true"] { display: none; }
.chat { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 46; width: min(25rem, calc(100vw - 2rem)); height: min(36rem, calc(100svh - 3rem));
  display: flex; flex-direction: column; background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--hair); border-radius: 14px; overflow: hidden; }
.chat[hidden] { display: none; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 1rem 1.1rem; border-bottom: 1px solid var(--hair); }
.chat-head strong { display: block; color: var(--paper); font: 700 1rem var(--display); }
.chat-head span { font-size: .78rem; }
.chat-head button { background: none; border: 0; color: var(--mute); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .7rem; }
.chat-log li { max-width: 88%; padding: .6rem .85rem; border-radius: 12px; font-size: .93rem; line-height: 1.45; white-space: pre-wrap; }
.chat-log .bot { background: var(--bot-bg); color: var(--bot-ink); border-top-left-radius: 4px; }
.chat-log .me { align-self: flex-end; background: var(--paper); color: var(--night); border-top-right-radius: 4px; }
.chat-log .err { color: var(--err); font-size: .85rem; background: none; padding: 0; }
.chat-log .typing::after { content: "…"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem .7rem; }
.chat-suggest button { background: none; border: 1px solid var(--hair); color: var(--paper); border-radius: 999px; padding: .35rem .75rem; font: 400 .82rem var(--body); cursor: pointer; }
.chat-suggest button:hover { border-color: var(--blue-light); }
.chat-form { display: flex; gap: .5rem; padding: .8rem; border-top: 1px solid var(--hair); }
.chat-form textarea { flex: 1; resize: none; background: var(--night); border: 1px solid var(--hair); color: var(--paper); border-radius: 10px;
  padding: .6rem .7rem; font: 400 .93rem var(--body); max-height: 7rem; }
.chat-form button { background: var(--paper); color: var(--night); border: 0; border-radius: 10px; padding: 0 1rem; font: 600 .9rem var(--body); cursor: pointer; }
.chat-form button:disabled { opacity: .5; cursor: wait; }
.chat-intake { display: grid; gap: .35rem; padding: .9rem 1.1rem 1rem; border-top: 1px solid var(--hair); font-size: .9rem; }
.chat-intake p { margin: 0 0 .4rem; }
.chat-intake label { font-weight: 600; color: var(--paper); margin-top: .35rem; }
.chat-intake input, .chat-intake select { background: var(--night); border: 1px solid var(--hair); color: var(--paper); border-radius: 10px;
  padding: .6rem .7rem; font: 400 .93rem var(--body); }
.chat-intake [aria-invalid="true"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.chat-intake .intake-err { color: var(--err); min-height: 1.2em; margin: .2rem 0 0; }
.chat-intake button { background: var(--paper); color: var(--night); border: 0; border-radius: 10px; padding: .75rem; font: 600 .95rem var(--body); cursor: pointer; }
.chat-intake button:disabled { opacity: .5; cursor: wait; }
.chat-intake small { color: var(--mute); } .chat-intake small a { color: inherit; }
[hidden] { display: none !important; }

/* ---- Móvil: encabezado con solo el isotipo, botones a escala de pulgar ---- */
.bar .logo-mark { display: none; }
@media (max-width: 640px) {
  .logo-full { display: none !important; }
  .bar .logo-mark { display: block; height: 30px; width: auto; }
  .bar { padding: 1rem 1.25rem; }
  .bar nav .bar-cta { font-size: .85rem; padding: .65rem 1.25rem; white-space: nowrap; }
  .btn { padding: .8rem 1.25rem; font-size: .95rem; margin-top: 1.5rem; }
  .step p { font-size: 1.02rem; }
  .chat-open { right: 1rem; bottom: 1rem; width: 56px; height: 56px; padding: 0; justify-content: center; }
  .chat-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .chat-open i { width: 14px; height: 14px; }
  .step { padding-bottom: calc(8svh + 64px); }
  .chat { right: .5rem; left: .5rem; bottom: .5rem; width: auto; height: calc(100svh - 1rem); }
}

/* Secciones oscuras: alternan con las blancas para dar ritmo. Mismos componentes, variables invertidas. */
.section.dark {
  --night: #111111; --deep: #1B1B1B; --paper: #FFFFFF; --mute: #C9C4BC;
  --hair: rgba(255, 255, 255, .16); --blue-light: #F2B705; --blue: #FF4D63;
  background: var(--night); color: var(--mute);
}
.section.dark .btn:hover { color: #111; }

/* En modo oscuro las secciones .dark se aclaran un paso para conservar el ritmo */
[data-theme="dark"] .section.dark { --night: #181A1F; --deep: #202329; }

/* ---- Switch de tema ---- */
.only-dark { display: none !important; }
[data-theme="dark"] .only-dark { display: block !important; }
[data-theme="dark"] .only-light { display: none !important; }
@media (max-width: 640px) { [data-theme="dark"] .logo-full.only-dark { display: none !important; } }
@media (min-width: 641px) { [data-theme="dark"] .logo-mark.only-dark { display: none !important; } }
.theme-toggle { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: none; border: 1px solid var(--hair); color: var(--paper); cursor: pointer; transition: border-color .2s; }
.theme-toggle:hover { border-color: var(--blue-light); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.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: 640px) { .bar nav { gap: .75rem; } }
