/* ============================================================
   Ficha pública del aliado
   ------------------------------------------------------------
   1. Contraste y fondo de la página
   2. Franja de marca + migas
   3. Tarjeta principal
   4. Beneficios
   5. Acciones
   6. Contacto
   7. Relacionados
   8. Barra fija (celular)
   9. Responsive
   ============================================================ */

/* ---------- 1. Contraste y fondo ---------- */

/*
 * Solo en esta página se oscurecen los grises de texto:
 * antes eran ~3:1 sobre blanco (difíciles de leer);
 * ahora superan 4.5:1 (recomendación WCAG AA).
 */
.page-detail {
    --muted: #46546b;
    --muted-soft: #5f6b82;
    background: var(--bg);
}

/* ---------- 2. Franja de marca + migas ---------- */
.detail-band {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(1.25rem, 3vw, 1.75rem) 0 clamp(4.75rem, 8vw, 6.25rem);
    background:
        radial-gradient(120% 140% at 85% 0%, #3d5da3 0%, rgba(61, 93, 163, 0) 60%),
        linear-gradient(150deg, #07101f 0%, #15294d 55%, #2b4a86 100%);
    color: #fff;
}

.detail-band::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 64px 64px;
    pointer-events: none;
}

.detail-band .breadcrumb {
    margin: 0;
    color: rgba(226, 236, 255, .6);
}

.detail-band .breadcrumb a {
    color: rgba(233, 240, 255, .85);
}

.detail-band .breadcrumb a:hover {
    color: #fff;
}

.detail-band .breadcrumb span[aria-current] {
    color: #fff;
}

.detail-band .breadcrumb .icon {
    opacity: .5;
}

/* La tarjeta sube y se monta sobre la franja */
.detail-page {
    position: relative;
    z-index: 1;
    margin-top: calc(-1 * clamp(2.75rem, 5.5vw, 4rem));
    padding-top: 0;
    padding-bottom: clamp(3rem, 6vw, 5rem);
}

/* ---------- 3. Tarjeta principal ---------- */
.detail {
    display: grid;
    grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
    align-items: start;              /* las columnas no se estiran */
    overflow: hidden;                /* respaldo para navegadores antiguos */
    overflow: clip;                  /* recorta esquinas sin romper el sticky */
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: 0 40px 70px -40px rgba(7, 16, 31, .55);
    animation: detail-in .45s var(--ease) both;
}

@keyframes detail-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/*
 * La columna de la imagen toma la altura real del afiche
 * y queda fija mientras se lee la información de la derecha.
 */
.detail__media {
    position: sticky;
    top: 1.25rem;
    background: radial-gradient(120% 120% at 40% 0%, #fbfcff 0%, #e8edf6 100%);
}

/* La imagen se ve completa y ocupa todo el ancho, sin franjas vacías */
.ally-media--detail {
    height: auto;
    min-height: 0;
    aspect-ratio: auto;
}

.ally-media--detail .ally-media__img {
    position: relative;
    inset: auto;
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 2.5rem); /* afiches muy altos caben en pantalla */
    object-fit: contain;
}

/* El fondo difuminado solo se ve si el afiche es muy vertical */
.ally-media--detail .ally-media__bg {
    opacity: .5;
}

.detail__zoom {
    position: absolute;
    left: .8rem;
    bottom: .8rem;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .8rem;
    border-radius: 999px;
    background: rgba(7, 16, 31, .78);
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background-color .2s;
}

.detail__zoom:hover {
    background: rgba(7, 16, 31, .95);
}

.detail__body {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: clamp(1.5rem, 3.5vw, 2.6rem);
    border-left: 1px solid var(--line); /* separador entre imagen y texto */
}

.detail__cat {
    align-self: flex-start;
    padding: .28rem .7rem;
    border-radius: 999px;
    background: var(--brand-100);
    color: var(--brand-600);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    transition: background-color .2s, color .2s;
}

.detail__cat:hover {
    background: var(--brand-600);
    color: #fff;
}

.detail__title {
    margin-top: .7rem;
    color: var(--ink-800);
    font-size: clamp(1.9rem, 3.8vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -.04em;
    line-height: 1.05;
}

.detail__places {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: .8rem;
}

.detail__places > .icon {
    color: var(--brand-500);
}

.detail__places > span {
    margin-right: .15rem;
}

.chip-municipio {
    padding: .24rem .65rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-700);
    font-size: .74rem;
    font-weight: 700;
    transition: background-color .2s, border-color .2s, color .2s;
}

.chip-municipio:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
    color: var(--brand-600);
}

.detail__description {
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: .95rem;
    font-weight: 500;
    line-height: 1.75;
}

/* ---------- 4. Beneficios ---------- */
.detail__section {
    margin-top: 1.75rem;
}

.detail__heading {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .8rem;
    color: var(--navy-700);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.detail__heading .icon {
    color: var(--brand-500);
}

.benefit-list {
    display: grid;
    gap: .45rem;
}

/* Sin línea azul a la izquierda y tarjeta compacta */
.benefit {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .75rem;
    border: 1px solid var(--brand-100);
    border-radius: var(--radius-sm);
    background: var(--brand-50);
}

.benefit__pct,
.benefit__check {
    flex: none;
    background: var(--brand-600);
    color: #fff;
}

.benefit__pct {
    min-width: 3.6rem;
    padding: .28rem .45rem;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 800;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.benefit__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
}

.benefit__text {
    color: var(--navy-700);
    font-size: .87rem;
    font-weight: 600;
    line-height: 1.45;
}

/* ---------- 5. Acciones ---------- */
.detail__actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: .6rem;
    margin-top: 1.6rem;
}

/* El botón principal ocupa toda la fila: jerarquía clara */
.detail__actions .btn--primary {
    grid-column: 1 / -1;
}

.btn--lg {
    padding: .95rem 1.3rem;
    font-size: .95rem;
}

.btn--whatsapp {
    background: #157f43;
    color: #fff;
}

.btn--whatsapp:hover {
    background: #0f6a37;
}

/* ---------- 6. Contacto ---------- */
.detail__contact {
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

/*
 * Flex en lugar de grid: los recuadros comparten fila y se
 * reparten el espacio. Si hay uno solo, ocupa todo el ancho.
 */
.contact-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.contact-item {
    flex: 1 1 11rem;
    min-width: 0;
    padding: .65rem .85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
}

/* La dirección tiene más texto: recibe el doble de espacio */
.contact-item--address {
    flex: 2 1 16rem;
}

/* Varias direcciones: el recuadro ocupa toda la fila */
.contact-item--wide {
    flex-basis: 100%;
}

.contact-item dt {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .2rem;
    color: var(--muted-soft);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.contact-item dt .icon {
    color: var(--brand-500);
}

.contact-item dd {
    color: var(--ink-800);
    font-size: .9rem;
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.contact-item dd a {
    transition: color .2s;
}

.contact-item dd a:hover {
    color: var(--brand-600);
}

.address-list {
    display: grid;
    gap: .5rem;
}

.address-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .3rem .7rem;
}

.contact-item__map {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--brand-600) !important;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background-color .2s, border-color .2s;
}

.contact-item__map:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
}

/* ---------- 7. Relacionados ---------- */
.related {
    margin-top: clamp(2.5rem, 5vw, 4rem);
}

/* Columnas automáticas: nunca se estira una sola tarjeta */
.related .ally-grid {
    grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr));
}

/* ---------- 8. Barra fija (celular) ---------- */
.sticky-cta {
    display: none;
}

/* ---------- 9. Responsive ---------- */
@media (max-width: 980px) {
    .detail {
        grid-template-columns: minmax(0, 1fr);
    }

    /* En una columna la imagen ya no necesita quedarse fija */
    .detail__media {
        position: relative;
        top: auto;
        border-bottom: 1px solid var(--line);
    }

    .detail__body {
        border-left: 0;
    }

    .ally-media--detail .ally-media__img {
        max-height: 75vh;
    }
}

@media (max-width: 760px) {
    /* Al ser hijo directo de <main>, "sticky" lo deja al pie de la
       pantalla mientras se lee y lo suelta sobre el footer al final */
    .sticky-cta {
        position: sticky;
        bottom: 0;
        z-index: 50;
        display: block;
        padding: .7rem var(--gutter) calc(.7rem + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--line-strong);
        background: rgba(255, 255, 255, .95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    /* Con la barra fija, el botón principal de la tarjeta sobra */
    .detail__actions .btn--primary {
        display: none;
    }
}

@media (max-width: 560px) {
    .benefit {
        align-items: flex-start;
    }

    .ally-media--detail .ally-media__img {
        max-height: 65vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .detail {
        animation: none;
    }
}
