/* ==========================================================================
   style.css — Comercializadora Kadari
   Mobile-first. Requiere Bootstrap, AOS y (opcional) Swiper.
   ========================================================================== */

/* --------------------- Variables y base --------------------- */
:root{
  --brand:#2563eb;          /* azul moderno */
  --brand-2:#f97316;        /* acento naranja */
  --ink:#0f172a;            /* texto principal */
  --muted:#64748b;          /* texto secundario */
  --line:#e2e8f0;           /* bordes suaves */
  --bg:#ffffff;             /* base clara */
  --bg-soft:#f8fafc;        /* secciones suaves */
  --radius-2xl: 1.25rem;
  --shadow-sm: 0 6px 16px rgba(2,6,23,.06);
  --shadow-md: 0 10px 30px rgba(2,6,23,.10);

  /* Tamaño unificado para logos de marcas (display) */
  --brand-logo-w: 160px;
  --brand-logo-h: 48px; /* sube archivos a 320x96px para Retina (2x) */
}

*,
*::before,
*::after{
  box-sizing: border-box;
}

html{ scroll-behavior: smooth; }

body{
  font-family: Manrope, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a{ color: inherit; }
a:hover{ color: var(--brand); }

img{ max-width: 100%; height: auto; display: block; }

/* Accesible focus */
:focus-visible{
  outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

/* Pesos extra (Bootstrap no trae 800 por default) */
.fw-extrabold{ font-weight: 800 !important; }

/* Reduce motion si el usuario lo pide */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* --------------------- Preloader --------------------- */
.preloader{
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: #fff; z-index: 10000;
  transition: opacity .3s ease, visibility .3s ease;
}
.preloader.hidden{ opacity: 0; visibility: hidden; }
.spinner{
  width: 56px; height: 56px; border-radius: 50%;
  border: 4px solid #e2e8f0; border-top-color: var(--brand);
  animation: spin 1s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* --------------------- Barra de progreso lectura --------------------- */
.reading-progress{
  position: fixed; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transform-origin: 0 50%; transform: scaleX(0);
  z-index: 1200;
}

/* --------------------- FAQ (details) --------------------- */
details{
  border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fff;
}
details + details{ margin-top: 12px; }
details summary{
  cursor: pointer; list-style: none; font-weight: 700;
}
details summary::marker{ content: ""; }
details[open]{ box-shadow: var(--shadow-sm); }

/* --------------------- Header --------------------- */
#header{
  position: sticky; top: 0; z-index: 900;
  background: rgba(255,255,255,.8);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid rgba(2,6,23,.06);
}
#header .nav-link{ font-weight: 600; }
.btn-cta{
  border-radius: 999px; padding: .6rem 1rem; font-weight: 800;
}

/* Activo en desktop: subrayado suave */
#header .nav-link.active,
#header .nav-link:hover{
  color: var(--brand);
}
#header .nav-link.active{
  position: relative;
}
#header .nav-link.active::after{
  content: "";
  position: absolute;
  left: .4rem; right: .4rem; bottom: .2rem;
  height: 2px; background: var(--brand);
  border-radius: 2px;
}

/* Offcanvas: tipografía y separación amigable en móvil */
.offcanvas .list-unstyled a{
  color: var(--ink);
}
.offcanvas .list-unstyled a:hover{
  color: var(--brand);}

/* ===== Hero del blog ===== */
.blog-hero{
  padding: clamp(36px, 5vw, 72px) 0;
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(37,99,235,.15), transparent 60%),
    linear-gradient(180deg, #fff, #f8fbff);
  border-bottom: 1px solid var(--line);
}
.eyebrow{
  display:inline-flex; align-items:center; gap:.5rem;
  font-weight:700; font-size:.9rem; letter-spacing:.02em;
  color: var(--brand); background:#eef2ff; border:1px solid #e2e8f0;
  padding:.35rem .6rem; border-radius:999px;
}
.display-title{
  font-weight:800;
  font-size:clamp(30px, 5vw, 48px);
  line-height:1.05;
  margin:.25rem 0 .5rem;
}
.lead-muted{ color:var(--muted); }

/* ===== Searchbar ===== */
.blog-searchbar{
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--line);
  background:#fff;
}
.search-form .search-input{
  position:relative;
}
.search-form .search-input i{
  position:absolute; left:12px; top:50%; transform:translateY(-50%); color:#94a3b8;
}
.search-form .search-input .form-control{
  padding-left: 40px;
}

/* ===== Destacado ===== */
.featured-wrap{ padding:28px 0; }
.featured-post{
  display:grid; grid-template-columns: 1.1fr 1fr;
  gap: 22px;
  background:#fff; border:1px solid var(--line);
  border-radius: 18px; overflow:hidden; box-shadow: var(--shadow-sm);
}
.featured-post .cover{ display:block; position:relative; overflow:hidden; }
.featured-post .cover img{
  width:100%; height:100%; object-fit:cover; display:block;
  transform: scale(1.02);
  transition: transform .5s ease;
}
.featured-post:hover .cover img{ transform: scale(1.06); }
.featured-post .content{ padding:18px; display:flex; flex-direction:column; gap:.5rem; }
.featured-post .title{ font-weight:800; margin:.25rem 0; }
.featured-post .title a{ color:inherit; text-decoration:none; }
.featured-post .title a:hover{ color:var(--brand); }
.featured-post .meta{ display:flex; gap:14px; color:var(--muted); font-size:.95rem; }
.badge-cat{
  display:inline-block; font-weight:700; font-size:.75rem; letter-spacing:.02em;
  background:#eef2ff; color:#334155; border:1px solid #e2e8f0;
  border-radius:999px; padding:.25rem .6rem;
}
.excerpt{ color:#334155; }

/* Responsive del destacado */
@media (max-width: 991.98px){
  .featured-post{ grid-template-columns: 1fr; }
  .featured-post .cover{ max-height: 340px; }
}

/* ===== Cards del grid ===== */
.posts-grid{ padding: 24px 0 40px; }
.post-card{
  background:#fff; border:1px solid var(--line);
  border-radius:18px; overflow:hidden; box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.post-card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #dbe4f2;
}
.post-card .thumb{
  display:block; position:relative; overflow:hidden;
  aspect-ratio: 16 / 9;
  background:#f1f5f9;
}
.post-card .thumb img{
  width:100%; height:100%; object-fit:cover; display:block;
  transition: transform .5s ease;
}
.post-card:hover .thumb img{ transform: scale(1.05); }
.post-card .title-link{
  color:inherit; text-decoration:none;
}
.post-card .title-link:hover{ color:var(--brand); }
.post-meta i{ opacity:.8; }

/* ===== Paginación ===== */
.blog-pagination .pagination .page-link{
  color:#334155; border-color: var(--line);
}
.blog-pagination .pagination .page-item.active .page-link{
  background: var(--brand); border-color: var(--brand); color:#fff;
}

/* Utilidades */
.btn-cta{
  border-radius: 999px; padding:.55rem 1rem; font-weight:800;
}

/* --------------------- Contacto --------------------- */
.contact-card{
  border: 1px solid var(--line); border-radius: 24px; padding: 24px;
  box-shadow: var(--shadow-sm); background: #fff;
}

/* --------------------- Toast flotante --------------------- */
.toast-floating{
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 1300; background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow-md); border-radius: 14px;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
.toast-floating.show{ opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-floating.success .icon{ color: #16a34a; }
.toast-floating.danger .icon{ color: #dc2626; }
.toast-floating .close{
  background: transparent; border: 0; font-size: 18px; line-height: 1; opacity: .6; cursor: pointer;
}

/* Variante (opcional) esquina superior derecha
.toast-floating{ left: auto; right: 16px; bottom: 16px; transform: translateY(12px); }
.toast-floating.show{ transform: translateY(0); }
*/

/* --------------------- Footer --------------------- */
#footer{
  border-top: 1px solid var(--line); background: var(--bg-soft);
}

/* --------------------- Dock vertical (acciones) --------------------- */
.actions-dock .btn{
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* --------------------- Helpers responsivos --------------------- */
@media (max-width: 575.98px){
  #header .btn-cta{ padding: .5rem .9rem; }
  .brand-grid{ gap: 16px; }
  .service-card{ padding: 18px; }
  .contact-card{ padding: 18px; }
  .toast-floating{ bottom: 16px; }
}

/* --- Article typography shared (si no la tienes ya) --- */
.article-body{ font-size:1.05rem; }
.article-body a{ color:#2563eb; text-decoration:underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.article-body a:hover{ color:#1e3a8a; }

  /* Hero del post con overlay (apoya legibilidad) */
  .post-hero{
    min-height: clamp(380px, 55vh, 640px);
    position: relative; display:flex; align-items:flex-end;
    background: url('<?php echo htmlspecialchars($img); ?>') no-repeat center/cover;
    color:#fff;
  }
  .post-hero::after{
    content:""; position:absolute; inset:0;
    background: radial-gradient(1200px 600px at 110% -10%, rgba(15,23,42,.20), transparent 60%),
                linear-gradient(180deg, rgba(2,6,23,0) 30%, rgba(2,6,23,.55) 100%);
  }
  .post-hero .inner{
    position:relative; z-index:1; padding: clamp(18px, 4vw, 36px) 0;
  }
  .breadcrumbs{
    margin-bottom: .5rem; font-size:.95rem;
  }
  .breadcrumbs a{ color: #e2e8f0; text-decoration:none; }
  .breadcrumbs a:hover{ color:#fff; text-decoration:underline; }
  .post-title{ font-weight:800; line-height:1.05; font-size: clamp(28px, 4.8vw, 48px); margin: .25rem 0 .5rem; }
  .post-meta{ color:#e2e8f0; display:flex; gap:12px; flex-wrap:wrap; }
  .post-meta i{ opacity:.9; }

  /* Layout contenido */
  .article-wrap{ padding: 28px 0 40px; }
  .article-grid{ display:grid; grid-template-columns: minmax(0,1fr) 300px; gap: 26px; }
  @media (max-width: 991.98px){ .article-grid{ grid-template-columns: 1fr; } }

  /* TOC */
  .toc-card{
    position:sticky; top:90px;
    background:#fff; border:1px solid #e2e8f0; border-radius:18px; padding:16px;
  }
  .toc-card h6{ font-weight:800; margin:0 0 .5rem; }
  .toc-list{ list-style:none; padding-left:0; margin:0; }
  .toc-list li{ margin:.25rem 0; }
  .toc-list a{ text-decoration:none; color:#334155; }
  .toc-list a:hover{ color:#2563eb; }

  /* Share */
  .share-bar{ display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
  .share-bar a{ border:1px solid #e2e8f0; border-radius:999px; padding:6px 10px; text-decoration:none; color:#334155; }
  .share-bar a:hover{ border-color:#cbd5e1; }

  /* Cuerpo del artículo (tipografía) */
  .article-body{ background:#fff; border:1px solid #e2e8f0; border-radius:18px; padding:20px; }
  .article-body h2{ font-weight:800; margin-top:1.2em; margin-bottom:.5em; }
  .article-body h3{ font-weight:700; margin-top:1.1em; margin-bottom:.5em; }
  .article-body p{ color:#334155; line-height:1.7; }
  .article-body img{ border-radius:12px; border:1px solid #e2e8f0; margin:14px 0; max-width:100%; height:auto; display:block; }
  .article-body ul, .article-body ol{ padding-left:1.1rem; }
  .article-body blockquote{
    border-left:4px solid #2563eb33; padding:.5rem .9rem; background:#f8fbff; border-radius:8px; color:#334155;
  }

  /* Prev/Next + Relacionados */
  .post-nav{ display:flex; gap:12px; flex-wrap:wrap; margin-top:20px; }
  .post-nav a{ border:1px solid #e2e8f0; border-radius:14px; padding:10px 12px; text-decoration:none; color:#334155; }
  .post-nav a:hover{ border-color:#cbd5e1; }
  .related{ padding: 8px 0 24px; }
  .related .card{
    border:1px solid #e2e8f0; border-radius:18px; overflow:hidden;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  }
  .related .card:hover{ transform:translateY(-2px); box-shadow:0 14px 36px rgba(2,6,23,.12); border-color:#dbe4f2; }
  .badge-cat{
    display:inline-block; font-weight:700; font-size:.75rem; letter-spacing:.02em;
    background:#eef2ff; color:#334155; border:1px solid #e2e8f0;
    border-radius:999px; padding:.25rem .6rem;
  }

  /* Toast (reutilizado) */
  .toast-floating{
    position:fixed; left:50%; bottom:22px; transform:translateX(-50%) translateY(10px);
    opacity:0; pointer-events:none; transition:opacity .25s, transform .25s; z-index:2200;
    background:#fff; border:1px solid #e2e8f0; box-shadow:0 10px 30px rgba(2,6,23,.1);
    border-radius:14px; padding:12px 14px; display:flex; align-items:center; gap:10px; color:#0f172a;
  }
  .toast-floating.show{ opacity:1; transform:translateX(-50%) translateY(0); pointer-events:auto; }
  .toast-floating .icon{ color:#16a34a; }
  .toast-floating .close{ background:transparent; border:0; font-size:18px; opacity:.6; cursor:pointer; }

  /* --------------------- FAQ (details) --------------------- */
details{
  border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: #fff;
}
details + details{ margin-top: 12px; }
details summary{
  cursor: pointer; list-style: none; font-weight: 700;
}
details summary::marker{ content: ""; }
details[open]{ box-shadow: var(--shadow-sm); }

/* ===== Miniraíl lateral (esquina inferior derecha) ===== */
.side-rail{
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  display: flex;
  flex-direction: column;   /* apila hacia arriba */
  gap: 8px;
  z-index: 1100;
  pointer-events: auto;
}

.rail-btn{
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
  touch-action: manipulation; /* mejor respuesta en móvil */
}
.rail-btn i{ font-size: 18px; }
.rail-btn:hover{ transform: translateY(-1px); box-shadow: var(--shadow-md); }

.rail-btn.brand{ background: var(--brand); color: #fff; border-color: transparent; }
.rail-btn.whatsapp{ background: #22c55e; color: #fff; border-color: transparent; }

/* Ocultarlo en desktop (tu HTML ya tiene d-lg-none, esto es redundante por si acaso) */
@media (min-width: 992px){
  .side-rail{ display: none !important; }
}

/* Ajustes ultra-compactos en pantallas muy chicas */
@media (max-width: 360px){
  .side-rail{ right: 8px; bottom: 8px; gap: 6px; }
  .rail-btn{ width: 40px; height: 40px; }
}
