/*
 * ECYD News Feed — Estilos encapsulados
 * Todos los selectores tienen prefijo .ecyd-news o .ecyd-card
 * No hay selectores globales que afecten otras áreas del sitio
 *
 * Para personalizar colores desde el tema (Elementor Global Colors):
 *   .ecyd-news { --ecyd-accent: #tucolor; --ecyd-accent-dark: #tucolordarker; }
 */

/* ============================================================
   Custom properties (sobrescribibles desde el tema)
   ============================================================ */
.ecyd-news,
.ecyd-news__more {
    --ecyd-accent:       #a6192e;
    --ecyd-accent-dark:  #9e0d21;
    --ecyd-radius:       20px;
    --ecyd-gap:          20px;
    --ecyd-card-bg:      #ffffff;
    --ecyd-text:         #1a1a1a;
    --ecyd-text-muted:   #6b7280;
    --ecyd-img-height:   150px;
    --ecyd-shadow:       0 2px 12px rgba(0, 0, 0, 0.15);
    --ecyd-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.15);
    font-family: inherit;
    box-sizing: border-box;
}

.ecyd-news *,
.ecyd-news *::before,
.ecyd-news *::after,
.ecyd-news__more *,
.ecyd-news__more *::before,
.ecyd-news__more *::after {
    box-sizing: inherit;
}

/* ============================================================
   Card — compartida entre grid y row
   ============================================================ */
.ecyd-card {
    background: var(--ecyd-card-bg);
    border-radius: var(--ecyd-radius);
    overflow: hidden;
    box-shadow: var(--ecyd-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.ecyd-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ecyd-shadow-hover);
}

/* Imagen */
.ecyd-card__img-wrap {
    position: relative;
    display: block;
    height: var(--ecyd-img-height);
    min-height: var(--ecyd-img-height);
    max-height: var(--ecyd-img-height);
    overflow: hidden;
    flex-shrink: 0;
    text-decoration: none;
}

/* position: absolute garantiza que el img llena el wrapper
   aunque Astra/Elementor apliquen img { height: auto } globalmente */
.ecyd-card__img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.ecyd-card:hover .ecyd-card__img {
    transform: scale(1.05);
}

/* Placeholder cuando no hay imagen */
.ecyd-card__img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Badge de territorio */
.ecyd-card__source {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--ecyd-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 100px;
    line-height: 1.2;
    pointer-events: none;
    white-space: nowrap;
}

/* Cuerpo */
.ecyd-card__body {
    padding: 12px 18px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}

/* Especificidad aumentada para sobrescribir h3 { margin } del tema */
.ecyd-card .ecyd-card__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--ecyd-text);
    margin: 0 !important;
    padding: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ecyd-card__date {
    font-size: 12px;
    color: var(--ecyd-text-muted);
    display: block;
}

.ecyd-card__excerpt {
    font-size: 13px;
    color: var(--ecyd-text-muted);
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ecyd-card__btn {
    display: inline-block;
    margin-top: auto;
    padding: 7px 14px;
    background: var(--ecyd-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 15px;
    align-self: flex-start;
    line-height: 1.2;
    transition: background 0.2s ease;
}

.ecyd-card__btn:hover,
.ecyd-card__btn:focus-visible,
.ecyd-card__btn:focus {
    background: var(--ecyd-accent-dark);
    color: #fff !important;
    text-decoration: none;
}

/* ============================================================
   Modo Grid (home)
   ============================================================ */
.ecyd-news--grid .ecyd-news__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--ecyd-gap);
}

.ecyd-news--grid .ecyd-news__grid > .ecyd-news__loading,
.ecyd-news--grid .ecyd-news__grid > .ecyd-news__error {
    grid-column: 1 / -1;
}

@media (max-width: 1024px) {
    .ecyd-news--grid .ecyd-news__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 580px) {
    .ecyd-news--grid .ecyd-news__grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Modo Row / Carrusel (interior)
   ============================================================ */
.ecyd-news--row .ecyd-news__row-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ecyd-news--row .ecyd-news__track-wrap {
    overflow: hidden;
    flex: 1;
    min-width: 0;
}

.ecyd-news--row .ecyd-news__track {
    display: flex;
    gap: var(--ecyd-gap);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.ecyd-news--row .ecyd-news__track > .ecyd-news__loading,
.ecyd-news--row .ecyd-news__track > .ecyd-news__error {
    flex: 0 0 100%;
    min-width: 100%;
}

/* Ancho de card en row — calculado por JS según items visibles.
   El valor inicial evita flash de layout antes del primer render. */
.ecyd-news--row .ecyd-card {
    flex-shrink: 0;
}

/* Flechas de navegación */
.ecyd-news__arrow {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--ecyd-accent);
    background: transparent;
    color: var(--ecyd-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 0;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.ecyd-news__arrow:hover {
    background: var(--ecyd-accent);
    color: #fff;
    transform: scale(1.08);
    border-color: var(--ecyd-accent) !important;
}

.ecyd-news__arrow:focus-visible {
    outline: 2px solid var(--ecyd-accent);
    outline-offset: 2px;
}

.ecyd-news__arrow:disabled {
    opacity: 0.3;
    cursor: default;
    transform: none;
    pointer-events: none;
}

@media (max-width: 480px) {
    .ecyd-news__arrow {
        width: 36px;
        height: 36px;
    }

    .ecyd-news--row .ecyd-news__row-wrap {
        gap: 8px;
    }
}

/* ============================================================
   Botón "Ver más" (row mode)
   ============================================================ */
.ecyd-news__more {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.ecyd-news__more-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 22px;
    border: 2px solid var(--ecyd-accent);
    color: var(--ecyd-accent);
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: 50px;
    transition: background 0.2s ease, color 0.2s ease;
    line-height: 1.2;
}

.ecyd-news__more-btn:hover,
.ecyd-news__more-btn:focus-visible {
    background: var(--ecyd-accent-dark);
    color: #fff;
    text-decoration: none !important;
}

/* ============================================================
   Estados: loading y error
   ============================================================ */
.ecyd-news__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 56px 20px;
    color: var(--ecyd-text-muted);
    font-size: 14px;
    width: 100%;
}

.ecyd-news__spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid #e0e0e0;
    border-top-color: var(--ecyd-accent);
    border-radius: 50%;
    animation: ecyd-spin 0.75s linear infinite;
}

@keyframes ecyd-spin {
    to { transform: rotate(360deg); }
}

.ecyd-news__error {
    text-align: center;
    padding: 40px 20px;
    color: var(--ecyd-text-muted);
    font-size: 14px;
    margin: 0;
}
