<template>
  <div class="page">

    <!-- NAV -->
    <nav class="nav" :class="{ 'nav--solid': scrolled }">
      <div class="nav__wrap">
        <img src="/titulosib.png" alt="SIB" class="nav__logo" />
        <div class="nav__actions">
          <button class="btn-install" @click="scrollToInstall">¿Cómo instalar?</button>
          <button class="btn-cta btn-cta--sm" @click="launchApp">Abrir app ↗</button>
        </div>
      </div>
    </nav>

    <!-- HERO -->
    <header class="hero">
      <img src="/landing-bg-bus.png" alt="" class="hero__img" />
      <div class="hero__overlay"></div>

      <div class="hero__content">
        <div class="hero__live">
          <span class="hero__live-dot"></span>
          En tiempo real
        </div>

        <h1 class="hero__title">
          ¿Quieres saber donde<br>está tu bus?
        </h1>

        <p class="hero__desc">
          Seguí las rutas en vivo, encontrá ofertas cerca de tu parada
          y descargá la app sin pasar por la tienda.
        </p>

        <div class="hero__btns">
          <button class="btn-cta btn-cta--lg" @click="launchApp">Abrir aplicación ↗</button>
          <button class="btn-outline" @click="scrollToInstall">¿Cómo instalarla?</button>
        </div>
      </div>
    </header>

    <!-- FEATURES -->
    <section class="features">
      <div class="features__wrap">

        <div class="feature">
          <div class="feature__icon">
            <span class="material-icons">gps_fixed</span>
          </div>
          <div class="feature__text">
            <h3>GPS en tiempo real</h3>
            <p>Ves exactamente dónde está cada bus y cuánto tarda en llegar a tu parada.</p>
          </div>
        </div>

        <div class="feature">
          <div class="feature__icon">
            <span class="material-icons">local_offer</span>
          </div>
          <div class="feature__text">
            <h3>Ofertas locales</h3>
            <p>Descubrí descuentos y promociones de negocios cerca de las paradas.</p>
          </div>
        </div>

        <div class="feature">
          <div class="feature__icon">
            <span class="material-icons">download_done</span>
          </div>
          <div class="feature__text">
            <h3>Sin descargar nada</h3>
            <p>Se instala directo desde el navegador como una app normal, sin Play Store ni App Store.</p>
          </div>
        </div>

      </div>
    </section>

    <!-- INSTALL -->
    <section id="install-guide" class="install">
      <div class="install__wrap">

        <div class="install__header">
          <p class="install__eyebrow">Instalación rápida</p>
          <h2 class="install__title">Listo en 30 segundos</h2>
          <p class="install__sub">
            Seguí estos pasos según tu celular para agregar SIB a tu pantalla de inicio.
          </p>
        </div>

        <div class="install__cards">

          <div class="icard">
            <div class="icard__head">
              <span class="material-icons">apple</span>
              <div>
                <strong>iPhone</strong>
                <span>Safari</span>
              </div>
            </div>
            <ol class="icard__steps">
              <li>Abrí esta página en <strong>Safari</strong></li>
              <li>Tocá el botón <strong>Compartir</strong> (cuadro con flecha ↑)</li>
              <li>Elegí <strong>"Agregar a inicio"</strong></li>
            </ol>
          </div>

          <div class="icard">
            <div class="icard__head">
              <span class="material-icons">android</span>
              <div>
                <strong>Android</strong>
                <span>Chrome</span>
              </div>
            </div>
            <ol class="icard__steps">
              <li>Abrí esta página en <strong>Chrome</strong></li>
              <li>Tocá el menú <strong>⋮</strong> arriba a la derecha</li>
              <li>Elegí <strong>"Instalar aplicación"</strong></li>
            </ol>
          </div>

        </div>

        <div class="install__action">
          <button class="btn-cta btn-cta--lg" @click="launchApp">Abrir aplicación ↗</button>
        </div>

      </div>
    </section>

    <!-- FOOTER -->
    <footer class="footer">
      <img src="/titulosib.png" alt="SIB" class="footer__logo" />
      <p class="footer__copy">© 2025 SIB · Todos los derechos reservados</p>
    </footer>

  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'

const router   = useRouter()
const scrolled = ref(false)

const onScroll = () => { scrolled.value = window.scrollY > 40 }

onMounted(() => {
  window.addEventListener('scroll', onScroll)
  const isStandalone =
    window.matchMedia('(display-mode: standalone)').matches ||
    (window.navigator as any).standalone === true
  if (isStandalone) router.replace('/splash')
})
onUnmounted(() => window.removeEventListener('scroll', onScroll))

const launchApp      = () => router.push('/splash')
const scrollToInstall = () =>
  document.getElementById('install-guide')?.scrollIntoView({ behavior: 'smooth' })
</script>

<style scoped>
/* ─── BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.page {
  --y:      #FEE715;
  --ydark:  #B8940A;
  --ylight: #FFF8CC;
  --ink:    #0A0A0A;
  --white:  #FFFFFF;
  --gray:   #888;
  --muted:  #BBBBBBB;
  --bg:     #F6F6F6;
  --border: rgba(0,0,0,0.08);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--white);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ─── NAV ──────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 64px; display: flex; align-items: center; padding: 0 24px;
  transition: background .2s, border-color .2s;
}
.nav--solid {
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__wrap {
  max-width: 1100px; margin: 0 auto; width: 100%;
  display: flex; justify-content: space-between; align-items: center;
}
.nav__logo { 
  height: 52px; 
  width: auto; 
  object-fit: contain; 
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
  transition: all .3s ease;
}
.nav__logo:hover { transform: scale(1.05); }

.nav__actions { display: flex; align-items: center; gap: 14px; }

/* ─── NEW INSTALL BUTTON (NAV) ───────────────────── */
.btn-install {
  background: rgba(255,255,255, 0.15);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255,255,255, 0.3);
  color: #fff;
  font-family: inherit; font-size: .88rem; font-weight: 700;
  padding: 10px 22px; border-radius: 12px; cursor: pointer;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  white-space: nowrap;
}
.btn-install:hover {
  background: rgba(255,255,255, 0.25);
  border-color: rgba(255,255,255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.nav--solid .btn-install {
  background: rgba(0,0,0, 0.04);
  border: 1.5px solid rgba(0,0,0, 0.1);
  color: var(--ink);
}
.nav--solid .btn-install:hover {
  background: rgba(0,0,0, 0.08);
  border-color: var(--ink);
}

/* ─── BUTTONS ──────────────────────────────────────── */
.btn-cta {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; font-family: inherit; font-weight: 700;
  background: var(--y); color: var(--ink);
  border: none; border-radius: 10px; cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  white-space: nowrap;
}
.btn-cta--sm { font-size: .88rem; padding: 9px 18px; }
.btn-cta--lg { font-size: 1rem;   padding: 15px 34px; }
.btn-cta:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(254,231,21,.4); }
.btn-cta:active { transform: translateY(0);    box-shadow: none; }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit; font-weight: 700; font-size: 1rem;
  background: rgba(255,255,255, 0.1);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(255,255,255, 0.2);
  color: #ffffff;
  padding: 15px 34px; border-radius: 10px; cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.btn-outline:hover { 
  background: rgba(255,255,255, 0.2); 
  border-color: rgba(255,255,255, 0.5);
  transform: translateY(-2px);
}

/* ─── HERO ─────────────────────────────────────────── */
.hero {
  position: relative; min-height: 100svh;
  display: flex; align-items: flex-end;
  padding: 88px 24px 72px;
  overflow: hidden;
}

.hero__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 35%;
}
.hero__overlay {
  position: absolute; inset: 0;
  background: linear-gradient(
    to top,
    rgba(10,10,10,.96) 0%,
    rgba(10,10,10,.72) 45%,
    rgba(10,10,10,.28) 100%
  );
}

.hero__content {
  position: relative; z-index: 1;
  max-width: 640px; color: #fff;
}

.hero__live {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .73rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--y); margin-bottom: 20px;
}
.hero__live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--y);
  animation: dot 2s ease-in-out infinite;
}
@keyframes dot { 0%,100%{opacity:1} 50%{opacity:.25} }

.hero__title {
  font-size: clamp(2.4rem, 6.5vw, 4.6rem);
  font-weight: 800; line-height: 1.06; letter-spacing: -.03em;
  margin-bottom: 18px;
}

.hero__desc {
  font-size: clamp(.92rem, 2vw, 1.05rem);
  color: rgba(255,255,255,.58); line-height: 1.75;
  margin-bottom: 36px;
}

.hero__btns { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ─── FEATURES ─────────────────────────────────────── */
.features { padding: 72px 24px; border-bottom: 1px solid var(--border); }
.features__wrap {
  max-width: 1100px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3,1fr);
}

.feature {
  display: flex; flex-direction: column; gap: 14px;
  padding: 0 40px 0 0;
  margin-right: 40px;
  border-right: 1px solid var(--border);
}
.feature:last-child { border-right: none; padding-right: 0; margin-right: 0; }

.feature__icon {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--ylight);
  display: flex; align-items: center; justify-content: center;
}
.feature__icon .material-icons { font-size: 22px; color: var(--ydark); }

.feature__text h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; }
.feature__text p  { font-size: .9rem; color: var(--gray); line-height: 1.65; }

/* ─── INSTALL ──────────────────────────────────────── */
.install { background: var(--bg); padding: 88px 24px; }
.install__wrap { max-width: 840px; margin: 0 auto; }

.install__header { text-align: center; margin-bottom: 52px; }
.install__eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gray); margin-bottom: 10px;
}
.install__title {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800; letter-spacing: -.03em; margin-bottom: 12px;
}
.install__sub { font-size: .93rem; color: var(--gray); line-height: 1.65; max-width: 400px; margin: 0 auto; }

.install__cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 44px;
}

.icard {
  background: var(--white); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 28px;
  transition: box-shadow .2s;
}
.icard:hover { box-shadow: 0 6px 28px rgba(0,0,0,.07); }

.icard__head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 20px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.icard__head .material-icons { font-size: 26px; }
.icard__head div { display: flex; flex-direction: column; gap: 1px; }
.icard__head strong { font-size: .97rem; font-weight: 700; }
.icard__head span   { font-size: .8rem; color: var(--gray); }

.icard__steps { list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.icard__steps li {
  counter-increment: s;
  display: flex; align-items: flex-start; gap: 12px;
  font-size: .9rem; color: #444; line-height: 1.5;
}
.icard__steps li::before {
  content: counter(s);
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--ink); font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.icard__steps li strong { color: var(--ink); }

.install__action { text-align: center; }

/* ─── FOOTER ───────────────────────────────────────── */
.footer {
  background: var(--white); border-top: 1px solid var(--border);
  padding: 32px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.footer__logo { height: 22px; opacity: .4; }
.footer__copy { font-size: .8rem; color: #ccc; }

/* ─── RESPONSIVE ───────────────────────────────────── */

/* Tablet + */
@media (min-width: 768px) {
  .nav { padding: 0 40px; }
  .hero { padding: 100px 48px 88px; }
  .nav__link { display: block; }
}

/* Mobile */
@media (max-width: 767px) {
  /* Nav */
  .nav  { padding: 0 18px; height: 58px; }
  .nav--solid { border-bottom: 1px solid var(--border); }
  .nav__logo  { height: 38px; }
  .btn-install { display: none; }
  .btn-cta--sm { font-size: .82rem; padding: 8px 14px; border-radius: 8px; }

  /* Hero */
  .hero { padding: 72px 20px 56px; }
  .hero__title { font-size: clamp(2.1rem, 10.5vw, 3rem); }
  .hero__desc  { font-size: .9rem; margin-bottom: 28px; }
  .hero__btns  { flex-direction: column; }
  .btn-cta--lg,
  .btn-outline { width: 100%; font-size: .97rem; }
  .btn-outline { border-color: rgba(255,255,255,.2); }

  /* Features */
  .features { padding: 52px 20px; }
  .features__wrap { grid-template-columns: 1fr; gap: 0; }
  .feature {
    flex-direction: row; align-items: flex-start; gap: 16px;
    padding: 24px 0; margin-right: 0;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .feature:last-child { border-bottom: none; }
  .feature__icon { margin-top: 2px; flex-shrink: 0; }

  /* Install */
  .install { padding: 56px 20px; }
  .install__title { font-size: 1.75rem; }
  .install__cards { grid-template-columns: 1fr; gap: 12px; }
  .icard { padding: 24px 20px; border-radius: 12px; }
  .install__action .btn-cta--lg { width: 100%; }

  /* Footer */
  .footer { flex-direction: column; align-items: center; text-align: center; padding: 28px 20px; }
}
</style>