/* =====================================================
   convocatoriasybecas.online — Homepage CSS (front-page.php only)
   Paleta Global "Humanitas" — sin referencias a España.
   ===================================================== */

/* ── Hero ──────────────────────────────────────────── */
.hero {
    position: relative;
    background: var(--navy);
    color: var(--white);
    text-align: center;
    padding: 3rem var(--pad) 4rem;
    overflow: hidden;
    min-height: 380px;
    display: flex;
    align-items: center;
}
.hero__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 1;
}
/* Capa de oscuridad sobre la imagen (controlada desde Personalizar) */
.hero__bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,var(--hero-overlay-opacity, .60));
}
/* Franja global — representa los 5 países sin bandera específica */
.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg,
        #0891B2 0%, #0284C7 20%,
        #F97316 20% 40%,
        #10B981 40% 60%,
        #F97316 60% 80%,
        #0284C7 80% 100%
    );
}
.hero__inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}
.hero h1 {
    color: var(--white);
    margin-bottom: .75rem;
    text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.hero__subtitle {
    font-size: 1rem;
    opacity: .9;
    margin-bottom: 1.75rem;
    line-height: 1.5;
}
.hero__ctas {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    align-items: center;
}
.hero__ctas .btn { width: 100%; max-width: 300px; }

/* Desktop: botones en fila */
@media (min-width: 600px) {
    .hero__ctas {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    .hero__ctas .btn { width: auto; max-width: none; }
}

/* ── Convocatorias Destacadas ──────────────────────── */
.featured-section { padding: var(--section) 0; }

.featured-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.featured-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.featured-card__icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: .25rem;
}
.featured-card__icon--red   { background: #FEE2E2; }
.featured-card__icon--blue  { background: #DBEAFE; }
.featured-card__icon--green { background: #D1FAE5; }
.featured-card__icon--gold  { background: #FEF3C7; }

.featured-card h3 {
    font-size: .95rem;
    margin: 0;
    color: var(--navy);
}
.featured-card .amount {
    font-size: .85rem;
    color: var(--red);
    font-weight: 700;
}
.featured-card .organismo {
    font-size: .8rem;
    color: var(--gray-600);
}
.featured-card__excerpt {
    font-size: .82rem;
    color: var(--gray-600);
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.featured-card .cta-link {
    font-size: .85rem;
    font-weight: 700;
    color: var(--red);
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.featured-card .cta-link::after { content: '→'; }

/* ── Segments: Encuentra Ayudas para Ti ────────────── */
.segments-section { padding: var(--section) 0; background: var(--gray-50); }

.segment-grid {
    display: grid;
    grid-template-columns: repeat(var(--seg-cols, 2), 1fr);
    gap: .75rem;
}

/* Mobile: 1 columna siempre */
@media (max-width: 599px) {
    .segment-grid { grid-template-columns: 1fr; }
    .segment-card { height: auto; min-height: var(--seg-height, 200px); }
}
/* Tablet: máximo 2 columnas */
@media (min-width: 600px) and (max-width: 1023px) {
    .segment-grid { grid-template-columns: repeat(2, 1fr); }
}
.segment-card {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    height: var(--seg-height, 280px);
    display: flex;
    align-items: flex-end;
    text-decoration: none;
}
/* Overlay oscuro sobre la imagen — controlado desde Personalizar */
.segment-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0, var(--seg-overlay, .3));
    z-index: 1;
    pointer-events: none;
    transition: background .3s;
}
.segment-card:hover::before {
    background: rgba(0,0,0, calc(var(--seg-overlay, .3) + .1));
}
.segment-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Placeholder cuando no hay imagen */
.segment-card__placeholder {
    position: absolute;
    inset: 0;
    background: var(--navy);
}
.segment-card__label {
    position: relative;
    z-index: 3;
    width: 100%;
    /* Fallback sólido; el degradado real viene del inline style generado en PHP */
    background: linear-gradient(to right, #1E3A5F, #0891B2);
    color: var(--white);
    padding: .55rem .85rem;
    font-weight: 700;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: filter .2s;
}
.segment-card:hover .segment-card__label { filter: brightness(.9); }
.segment-card__icon { font-size: 1rem; }

/* ── Comunidades Autónomas ─────────────────────────── */
.comunidades-section { padding: var(--section) 0; }

.comunidades-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: center;
}
.comunidad-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem .9rem;
    background: var(--pill-bg, var(--white));
    border: 1px solid var(--pill-border, var(--gray-200));
    border-radius: 99px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--pill-color, var(--navy));
    text-decoration: none;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
.comunidad-pill:hover {
    background: var(--pill-hover, var(--red));
    color: #fff;
    border-color: var(--pill-hover, var(--red));
    text-decoration: none;
}
.comunidad-pill__icon { font-size: 1rem; }

/* ── Últimos Artículos ─────────────────────────────── */
.latest-section { padding: var(--section) 0; background: var(--gray-50); }

/* Grid — usa --latest-cols inyectado desde PHP */
.latest-grid {
    display: grid;
    grid-template-columns: repeat(var(--latest-cols, 3), 1fr);
    gap: 1rem;
}

/* Forzar 1 columna en mobile independientemente del valor de --latest-cols */
@media (max-width: 599px) {
    .latest-grid { grid-template-columns: 1fr; }
}
@media (min-width: 600px) and (max-width: 1023px) {
    .latest-grid { grid-template-columns: repeat(min(var(--latest-cols, 3), 2), 1fr); }
}

/* Layout en lista: tarjetas horizontales */
.latest--list .latest-grid {
    grid-template-columns: 1fr;
}
.latest--list .article-card {
    flex-direction: row;
}
.latest--list .card__img-wrap {
    flex: 0 0 160px;
    width: 160px;
}
.latest--list .card__img {
    height: 100% !important;
    min-height: 120px;
}
.latest--list .card__img--placeholder {
    height: 120px;
}
@media (max-width: 599px) {
    .latest--list .article-card { flex-direction: column; }
    .latest--list .card__img-wrap { flex: none; width: 100%; }
    .latest--list .card__img { height: 170px !important; }
}

/* Tarjeta artículo */
.article-card { text-decoration: none; color: inherit; }
.article-card:hover { text-decoration: none; }
.article-card .card__title { font-size: .95rem; }

/* Imagen wrapper */
.card__img-wrap {
    display: block;
    overflow: hidden;
    flex-shrink: 0;
}
.card__img-wrap .card__img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    transition: transform .3s;
}
.card__img-wrap:hover .card__img { transform: scale(1.04); }

/* Placeholder sin imagen */
.card__img--placeholder {
    width: 100%;
    height: 170px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--gray-400);
}

/* Categoría / tipo */
.card__category {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--red);
    margin-bottom: .35rem;
    text-decoration: none;
}
.card__category:hover { text-decoration: underline; }

/* Footer: fecha y autor */
.card__footer {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .75rem;
    align-items: center;
    padding: .6rem 1rem;
    border-top: 1px solid var(--gray-200);
    font-size: .78rem;
    color: var(--gray-600);
}
.card__date { white-space: nowrap; }
.card__author a { color: var(--gray-600); }
.card__author a:hover { color: var(--red); text-decoration: none; }

/* ── Footer Nav 3 columnas ─────────────────────────── */
/* Ya definido en main.css .footer-grid */

/* ── Countries Grid ────────────────────────────────── */
.countries-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    /* Layout por defecto: 2 columnas */
    grid-template-columns: repeat(2, 1fr);
}

/* Layouts via data-layout en el <section> */
.countries-section[data-layout="2-3"] .countries-grid {
    grid-template-columns: repeat(6, 1fr);
}
.countries-section[data-layout="2-3"] .country-card:nth-child(-n+2) {
    grid-column: span 3;
}
.countries-section[data-layout="2-3"] .country-card:nth-child(n+3) {
    grid-column: span 2;
}

.countries-section[data-layout="2-2"] .countries-grid {
    grid-template-columns: repeat(2, 1fr);
}

.countries-section[data-layout="3-3"] .countries-grid {
    grid-template-columns: repeat(3, 1fr);
}

.countries-section[data-layout="1-2"] .countries-grid {
    grid-template-columns: repeat(3, 1fr);
}
.countries-section[data-layout="1-2"] .country-card:first-child {
    grid-column: span 3;
}

/* Tarjeta — imagen de fondo completa con overlay y texto encima */
.country-card {
    position: relative;
    display: flex;
    align-items: flex-end;
    border-radius: var(--radius);
    overflow: hidden;
    min-height: var(--ctry-height, 280px);
    background-color: var(--ctry-bg, var(--navy));
    background-size: cover;
    background-position: center;
    text-decoration: none;
    color: var(--ctry-text, #fff);
    box-shadow: var(--shadow-sm);
    transition: transform .25s, box-shadow .25s;
}
.country-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: var(--ctry-text, #fff);
}

/* Capa oscura sobre la imagen */
.country-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--ctry-overlay, .4));
    transition: background .25s;
    z-index: 1;
}
.country-card:hover .country-card__overlay {
    background: rgba(0, 0, 0, calc(var(--ctry-overlay, .4) + .08));
}

/* Texto superpuesto sobre la imagen */
.country-card__body {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 1rem 1.1rem 1rem;
    /* Degradado oscuro solo en la zona de texto */
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 100%);
}
.country-card__code {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    opacity: .8;
    margin-bottom: .2rem;
    color: var(--ctry-text, #fff);
}
.country-card__title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 .35rem;
    line-height: 1.2;
    color: var(--ctry-text, #fff);
    text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.country-card__excerpt {
    font-size: .8rem;
    line-height: 1.45;
    margin: 0 0 .5rem;
    opacity: .9;
    color: var(--ctry-text, #fff);
}
.country-card__cta {
    display: inline-block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--ctry-link, #67E8F9);
    text-decoration: none;
}
.country-card:hover .country-card__cta {
    text-decoration: underline;
}

/* Responsive: en móvil siempre 1 columna */
@media (max-width: 599px) {
    .countries-grid,
    .countries-section[data-layout] .countries-grid {
        grid-template-columns: 1fr !important;
    }
    .countries-section[data-layout] .country-card {
        grid-column: span 1 !important;
    }
}
/* Tablet: máximo 2 columnas */
@media (min-width: 600px) and (max-width: 1023px) {
    .countries-section[data-layout="2-3"] .countries-grid,
    .countries-section[data-layout="3-3"] .countries-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .countries-section[data-layout="2-3"] .country-card,
    .countries-section[data-layout="3-3"] .country-card {
        grid-column: span 1 !important;
    }
}

/* "Ver todas" button below the grid */
.countries-section__footer {
    text-align: center;
    margin-top: 2rem;
}
.countries-section__btn {
    display: inline-block;
    padding: .7rem 2rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: .95rem;
    text-decoration: none;
    transition: opacity .15s;
}
.countries-section__btn:hover {
    opacity: .85;
    text-decoration: none;
    color: var(--white);
}

