:root {
    --tersia-navy: #0b1220;
    --tersia-navy-2: #111827;
    --tersia-amber: #f59e0b;
    --tersia-amber-dark: #d97706;
    --tersia-cyan: #22d3ee;
    --tersia-bg-alt: #f4f5f7;
    --tersia-text: #1f2937;
    --tersia-text-light: #6b7280;
}

html {
    scroll-behavior: smooth;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

section[id] {
    scroll-margin-top: 90px;
}

/* Secciones a todo lo ancho del viewport, sin importar el .container de _Layout */
.section-pad,
.hero-section,
.timelapse-section {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* ---------- Layout helpers ---------- */
.section-pad {
    padding: 6rem 1.5rem;
}

.section-eyebrow {
    display: inline-block;
    color: var(--tersia-amber-dark);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .8rem;
    margin-bottom: .75rem;
}

.section-title {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 800;
    color: var(--tersia-text);
    margin-bottom: .75rem;
}

.section-subtitle {
    color: var(--tersia-text-light);
    max-width: 640px;
    margin: 0 auto 3rem;
    font-size: 1.05rem;
}

.bg-alt {
    background-color: var(--tersia-bg-alt);
}

body.dark-mode .bg-alt {
    background-color: #17181c;
}

body.dark-mode .section-title {
    color: #f8f9fa;
}

/* ---------- Hero ---------- */
.hero-section {
    padding: 7rem 1.5rem 5rem;
    text-align: center;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ---------- Timelapse (scroll-driven) ---------- */
.timelapse-section {
    /* Altura = 100vh del pin + la distancia de scroll ("+=140%") del ScrollTrigger
       en tersia-scroll.js. Si cambias uno, actualiza el otro o queda espacio muerto. */
    position: relative;
    height: 240vh;
    background: var(--tersia-navy);
}

.timelapse-pin {
    position: relative;
    height: 100vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timelapse-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 25%, rgba(245, 158, 11, .18), transparent 45%),
        radial-gradient(circle at 80% 75%, rgba(34, 211, 238, .16), transparent 45%),
        linear-gradient(180deg, #0b1220, #0d1524 60%, #0b1220);
}

.timelapse-bg::before {
    content: "";
    position: absolute;
    inset: -2px;
    background-image:
        linear-gradient(rgba(148, 163, 184, .12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .12) 1px, transparent 1px);
    background-size: 42px 42px;
    -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
    mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
    animation: tersia-grid-drift 18s linear infinite;
}

@keyframes tersia-grid-drift {
    0% { background-position: 0 0, 0 0; }
    100% { background-position: 84px 42px, 84px 42px; }
}

.timelapse-bg::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, .55), transparent);
    animation: tersia-scanline 5s ease-in-out infinite;
}

@keyframes tersia-scanline {
    0% { top: 8%; opacity: 0; }
    10% { opacity: .8; }
    50% { top: 88%; opacity: .8; }
    60% { opacity: 0; }
    100% { top: 88%; opacity: 0; }
}

.timelapse-svg {
    position: relative;
    z-index: 2;
    width: min(92vw, 900px);
    height: auto;
    overflow: visible;
}

.kinetic-text {
    fill: #fff;
    font-family: "Consolas", "SFMono-Regular", Menlo, Monaco, monospace;
    font-weight: 800;
    letter-spacing: .06em;
    text-anchor: middle;
    dominant-baseline: middle;
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.kinetic-text.glitch {
    animation: tersia-glitch .4s steps(2, end) 1;
}

@keyframes tersia-glitch {
    0% { text-shadow: 3px 0 var(--tersia-cyan), -3px 0 var(--tersia-amber); transform: translate(0, 0); }
    25% { text-shadow: -4px 0 var(--tersia-cyan), 4px 0 var(--tersia-amber); transform: translate(-3px, 2px); }
    50% { text-shadow: 4px 0 var(--tersia-cyan), -4px 0 var(--tersia-amber); transform: translate(3px, -2px); }
    75% { text-shadow: -2px 0 var(--tersia-cyan), 2px 0 var(--tersia-amber); transform: translate(-1px, 1px); }
    100% { text-shadow: none; transform: translate(0, 0); }
}

.ping {
    fill: none;
    stroke: var(--tersia-amber);
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: tersia-ping 2.2s cubic-bezier(0, 0, .2, 1) infinite;
}

.ping-b {
    stroke: var(--tersia-cyan);
    animation-delay: 1.1s;
}

@keyframes tersia-ping {
    0% { transform: scale(.55); opacity: .85; }
    80%, 100% { transform: scale(1.9); opacity: 0; }
}

.orbit {
    transform-box: fill-box;
    transform-origin: 50% 50%;
}

.orbit-dot {
    fill: var(--tersia-cyan);
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, .8));
}

.timelapse-final image {
    filter: drop-shadow(0 0 14px rgba(245, 158, 11, .55));
}

.timelapse-final text {
    fill: #cbd5e1;
    font-family: "Consolas", "SFMono-Regular", Menlo, Monaco, monospace;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 500;
}

.timelapse-caption {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: #fff;
    text-align: center;
    font-family: "Consolas", "SFMono-Regular", Menlo, Monaco, monospace;
    font-size: .85rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    opacity: .7;
}

.timelapse-caption::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tersia-cyan);
    margin-right: .5rem;
    box-shadow: 0 0 8px var(--tersia-cyan);
    animation: tersia-blink 1.6s ease-in-out infinite;
}

@keyframes tersia-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

.timelapse-hint {
    position: absolute;
    bottom: 2.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: #fff;
    opacity: .85;
    font-size: .85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    animation: tersia-bounce 1.8s infinite;
}

@keyframes tersia-bounce {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 8px); }
}

/* ---------- Qué resolvemos ---------- */
.pain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.pain-item {
    text-align: center;
}

.pain-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(245, 158, 11, .12);
    color: var(--tersia-amber-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 1rem;
}

.pain-item h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: .35rem;
}

.pain-item p {
    color: var(--tersia-text-light);
    font-size: .92rem;
}

/* ---------- Servicios ---------- */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.75rem;
    max-width: 1200px;
    margin: 0 auto;
}

.service-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem 1.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    border: 1px solid rgba(0, 0, 0, .05);
    transition: transform .3s ease, box-shadow .3s ease;
}

.service-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(17, 24, 39, .12);
}

body.dark-mode .service-card {
    background: #1f2126;
    border-color: rgba(255, 255, 255, .06);
}

.service-icon {
    width: 52px;
    height: 52px;
    border-radius: .75rem;
    background: var(--tersia-navy);
    color: var(--tersia-amber);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1.1rem;
}

.service-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.service-card p {
    color: var(--tersia-text-light);
    font-size: .95rem;
    margin-bottom: 0;
}

/* ---------- Tecnologías ---------- */
.tech-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
}

.tech-pill {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem 1.1rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    font-weight: 600;
    font-size: .92rem;
    color: var(--tersia-text);
}

body.dark-mode .tech-pill {
    background: #1f2126;
    border-color: rgba(255, 255, 255, .08);
    color: #f8f9fa;
}

.tech-pill i {
    color: var(--tersia-amber-dark);
    font-size: 1.05rem;
}

/* ---------- Casos / proyectos ---------- */
.case-card {
    background: #fff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    border: 1px solid rgba(0, 0, 0, .05);
    transition: transform .35s ease, box-shadow .35s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.case-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 24px 48px rgba(17, 24, 39, .14);
}

body.dark-mode .case-card {
    background: #1f2126;
    border-color: rgba(255, 255, 255, .06);
}

.case-card img {
    width: 100%;
    height: 190px;
    object-fit: cover;
}

.case-card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.case-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.case-card p {
    color: var(--tersia-text-light);
    font-size: .95rem;
    flex: 1;
}

.case-card .badge {
    align-self: flex-start;
    margin-bottom: .75rem;
}

.case-stat {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    font-weight: 700;
    color: var(--tersia-amber-dark);
    margin-bottom: .6rem;
}

.case-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin: .75rem 0 0;
}

.case-tag {
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: var(--tersia-bg-alt);
    color: var(--tersia-text-light);
    border: 1px solid rgba(0, 0, 0, .06);
}

body.dark-mode .case-tag {
    background: #26282e;
    border-color: rgba(255, 255, 255, .08);
    color: #cbd5e1;
}

/* ---------- Forma de trabajo ---------- */
.timeline-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2.5rem;
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}

.timeline-step {
    text-align: center;
    position: relative;
}

.timeline-step .step-number {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--tersia-amber);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin: 0 auto 1rem;
    position: relative;
    z-index: 1;
}

.timeline-step h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: .4rem;
}

.timeline-step p {
    color: var(--tersia-text-light);
    font-size: .9rem;
}

@media (min-width: 768px) {
    .timeline-row::before {
        content: "";
        position: absolute;
        top: 24px;
        left: 8%;
        right: 8%;
        height: 2px;
        background: repeating-linear-gradient(90deg, var(--tersia-amber) 0 8px, transparent 8px 16px);
        z-index: 0;
    }
}

/* ---------- Contacto ---------- */
.contact-section {
    background: var(--tersia-navy);
    color: #fff;
    text-align: center;
}

.contact-section .section-subtitle {
    color: #cbd5e1;
}

.contact-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn-outline-light-amber {
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff;
    background: transparent;
    border-radius: .5rem;
    padding: .6rem 1.3rem;
    font-weight: 500;
    transition: border-color .2s ease, background .2s ease;
}

.btn-outline-light-amber:hover {
    border-color: var(--tersia-amber);
    background: rgba(245, 158, 11, .1);
    color: #fff;
}
