/* CheckNews — portada pública.
   Sala de monitoreo global: fondo claro, mapa como protagonista y tarjetas
   fotográficas donde el número de fuentes es el dato con más peso. */

:root {
    --breaking:   #E5342A;
    --developing: #F5921E;
    --updates:    #EDC02A;
    --quiet:      #8B7BD8;

    --ink:        #16181D;
    --ink-2:      #3D434E;
    --ink-3:      #6B7280;
    --line:       #E3E6EB;
    --line-2:     #EFF1F4;
    --canvas:     #F7F8FA;
    --white:      #FFFFFF;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    --shadow-card: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 12px rgba(16, 20, 28, .05);
    --shadow-pop:  0 4px 16px rgba(16, 20, 28, .10), 0 12px 32px rgba(16, 20, 28, .08);

    --maxw: 1480px;
    --pad: 24px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2;
      stroke-linecap: round; stroke-linejoin: round; }

.sr, .skip {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip:focus {
    position: fixed; top: 12px; left: 12px;
    width: auto; height: auto; clip: auto;
    background: var(--white); padding: 10px 16px;
    border-radius: var(--r-sm); box-shadow: var(--shadow-pop); z-index: 999;
}

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* --- Marca ---------------------------------------------------------------- */

.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 9px;
    line-height: 1;
}

/* Los dos tramos van pegados: el wordmark es una sola palabra. */
.wordmark {
    font-size: 1.62rem;
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1;
    white-space: nowrap;
}
.brand-check { color: var(--ink); }
.brand-news  { color: var(--breaking); }

.live {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--breaking);
    align-self: center;
    padding-bottom: 1px;
}

.live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--breaking);
    flex: none;
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.brand-tag {
    color: var(--ink-3);
    font-size: 0.82rem;
    margin-top: 4px;
}

/* --- Cabecera ------------------------------------------------------------- */

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 14px var(--pad);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
}

.mainnav { display: flex; gap: 30px; justify-self: center; }

.mainnav a {
    position: relative;
    padding: 8px 2px;
    font-size: 0.94rem;
    font-weight: 500;
    color: var(--ink-3);
}
.mainnav a:hover { color: var(--ink); }

.mainnav a.is-active { color: var(--ink); font-weight: 600; }
.mainnav a.is-active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: var(--breaking);
    border-radius: 2px;
}

.topbar-tools { display: flex; gap: 10px; justify-content: flex-end; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
}
.icon-btn:hover { border-color: var(--ink-3); }
.icon-btn svg { font-size: 1.05rem; }

.icon-btn-square {
    padding: 9px;
    border-radius: var(--r-sm);
}
.icon-btn-square svg { fill: currentColor; stroke: none; }

/* --- Mapa ----------------------------------------------------------------- */

.hero { padding: 18px var(--pad) 0; }

.hero-inner {
    position: relative;
    max-width: var(--maxw);
    margin: 0 auto;
    height: 340px;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: #E8EEF5;
    border: 1px solid var(--line);
}

.hero.is-hidden { display: none; }

.map {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.leaflet-container {
    background: #DDE6F0;
    font: inherit;
}

.map.is-failed::after {
    content: "No se pudo cargar el mapa.";
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    color: var(--ink-3);
    font-size: 0.86rem;
}

/* Controles de Leaflet con el lenguaje visual del resto de la interfaz. */
.leaflet-control-zoom {
    border: 0 !important;
    border-radius: var(--r-sm) !important;
    overflow: hidden;
    box-shadow: var(--shadow-card) !important;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    color: var(--ink-2) !important;
    background: var(--white) !important;
    border-bottom: 1px solid var(--line) !important;
    font-size: 1.05rem !important;
    font-weight: 500;
}
.leaflet-control-zoom a:last-child { border-bottom: 0 !important; }
.leaflet-control-zoom a:hover { background: #F4F6F9 !important; color: var(--ink) !important; }

.leaflet-control-attribution {
    background: rgba(255, 255, 255, .78) !important;
    color: var(--ink-3);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px 0 0 0;
}
.leaflet-control-attribution a { color: var(--ink-2); }

.leaflet-popup-content-wrapper {
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-pop);
}
.leaflet-popup-content { margin: 11px 14px; font-size: 0.82rem; line-height: 1.45; }
.leaflet-popup-content strong { font-weight: 600; }
.leaflet-popup-content a { color: var(--breaking); font-weight: 500; }

/* Burbujas de país */
.cn-pin-wrap { background: none; border: 0; }

.cn-pin {
    display: grid;
    place-items: center;
    width: 100%; height: 100%;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    border: 2px solid rgba(255, 255, 255, .92);
    box-shadow: 0 2px 8px rgba(16, 20, 28, .22);
    transition: transform .16s ease;
}
.cn-pin-wrap:hover .cn-pin { transform: scale(1.12); }

.cn-pin-breaking   { background: var(--breaking); }
.cn-pin-developing { background: var(--developing); }
.cn-pin-updates    { background: var(--updates); color: #4A3B00; }
.cn-pin-quiet      { background: var(--quiet); }

.livepanel {
    position: absolute;
    top: 18px; left: 18px;
    z-index: 10;
    width: 250px;
    background: var(--white);
    border-radius: var(--r-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-pop);
}

.livepanel-head {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ink-2);
    margin-bottom: 10px;
}

.livepanel-count {
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.livepanel-sub {
    color: var(--ink-3);
    font-size: 0.86rem;
    margin-top: 2px;
    margin-bottom: 14px;
}

.livepanel-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px 10px;
    font-size: 0.76rem;
    color: var(--ink-2);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-2);
}

.livepanel-legend li {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.livepanel-legend span[data-count] { font-weight: 600; color: var(--ink); }

.livepanel-countries {
    font-size: 0.8rem;
    color: var(--ink-3);
    padding: 11px 0;
    border-bottom: 1px solid var(--line-2);
}

.livepanel-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 11px;
    font-size: 0.86rem;
    font-weight: 500;
}
.livepanel-link svg { font-size: 0.95rem; color: var(--ink-3); }
.livepanel-link:hover svg { color: var(--ink); }

.maplegend {
    position: absolute;
    right: 18px; bottom: 18px;
    z-index: 10;
    background: var(--white);
    border-radius: var(--r-sm);
    padding: 10px 13px;
    box-shadow: var(--shadow-card);
    font-size: 0.76rem;
    color: var(--ink-2);
}
.maplegend li { display: flex; align-items: center; gap: 7px; padding: 2px 0; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-breaking   { background: var(--breaking); }
.dot-developing { background: var(--developing); }
.dot-updates    { background: var(--updates); }
.dot-quiet      { background: var(--quiet); }

/* Burbujas del mapa */
.cn-pin {
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    border: 2px solid rgba(255, 255, 255, .9);
    box-shadow: 0 2px 8px rgba(16, 20, 28, .25);
    transition: transform .15s ease;
}
.cn-pin:hover { transform: scale(1.12); }

.cn-pin-breaking   { background: var(--breaking); }
.cn-pin-developing { background: var(--developing); }
.cn-pin-updates    { background: var(--updates); color: #4A3B00; }
.cn-pin-quiet      { background: var(--quiet); }

/* --- Filtros -------------------------------------------------------------- */

.filters { padding: 18px var(--pad) 0; }

.filters-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip svg { font-size: 0.95rem; fill: currentColor; stroke: none; }

.chip.is-on {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--white);
}

.chip-flag { font-size: 1rem; }
.chip-count {
    font-size: 0.76rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}
.chip.is-on .chip-count { color: rgba(255,255,255,.7); }

.filters-right { display: flex; align-items: center; gap: 10px; flex: none; }

.sortbox select {
    appearance: none;
    padding: 9px 34px 9px 15px;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--ink);
}

/* --- Rejilla de tarjetas -------------------------------------------------- */

.feed { padding: 18px var(--pad) 48px; }
.feed-inner { max-width: var(--maxw); margin: 0 auto; }

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.grid.is-list { grid-template-columns: 1fr; }

.card {
    position: relative;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--ink);
    min-height: 230px;
    box-shadow: var(--shadow-card);
    isolation: isolate;
}

.card-tall { min-height: 296px; }

.card-link {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: inherit;
    padding: 12px;
    position: relative;
    z-index: 2;
}

.card-image {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: transform .4s ease;
}
.card:hover .card-image { transform: scale(1.04); }

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to bottom,
        rgba(10, 12, 16, .45) 0%,
        rgba(10, 12, 16, .10) 32%,
        rgba(10, 12, 16, .62) 68%,
        rgba(10, 12, 16, .88) 100%
    );
}

/* Sin foto: la tipografía y el color de la categoría sostienen la tarjeta. */
.card-flat { background: #232833; }
.card-flat::after {
    background:
        radial-gradient(120% 90% at 15% 0%, rgba(255,255,255,.10), transparent 60%),
        linear-gradient(160deg, var(--cat, #2C3340) 0%, #171B23 100%);
}

.cat-politica   { --cat: #34405C; }
.cat-negocios   { --cat: #1F4A42; }
.cat-tecnologia { --cat: #2E3A63; }
.cat-clima      { --cat: #1D4B57; }
.cat-deportes   { --cat: #35502C; }
.cat-ciencia    { --cat: #3F3663; }
.cat-cultura    { --cat: #5A3348; }
.cat-general    { --cat: #2C3340; }

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.badge {
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #fff;
    white-space: nowrap;
}
.badge-breaking   { background: var(--breaking); }
.badge-developing { background: var(--developing); }
.badge-updates    { background: var(--updates); color: #4A3B00; }
.badge-quiet      { background: var(--quiet); }

.card-ago {
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .82);
    padding: 3px 7px;
    background: rgba(10, 12, 16, .35);
    border-radius: 5px;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.card-body { margin-top: auto; }

.card-place {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .88);
    margin-bottom: 5px;
}
.card-flag { font-size: 0.95rem; }

.card-title {
    color: #fff;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.28;
    letter-spacing: -0.015em;
    text-shadow: 0 1px 12px rgba(0, 0, 0, .35);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tall .card-title { font-size: 1.1rem; }

.card-foot {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 11px;
}

.stack { display: flex; }

.avatar {
    width: 21px; height: 21px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: #fff;
    background: hsl(var(--hue, 210) 42% 42%);
    border: 1.5px solid rgba(255, 255, 255, .85);
    margin-left: -6px;
    flex: none;
}
.stack .avatar:first-child { margin-left: 0; }

.avatar-more {
    background: rgba(255, 255, 255, .22);
    backdrop-filter: blur(4px);
    font-size: 0.58rem;
}

.card-sources {
    font-size: 0.76rem;
    font-weight: 500;
    color: rgba(255, 255, 255, .88);
}

.bookmark {
    position: absolute;
    right: 10px; bottom: 10px;
    z-index: 3;
    width: 28px; height: 28px;
    display: grid;
    place-items: center;
    background: none;
    border: 0;
    padding: 0;
    color: rgba(255, 255, 255, .78);
    border-radius: 6px;
}
.bookmark svg { width: 17px; height: 17px; stroke-width: 1.7; }
.bookmark:hover { color: #fff; background: rgba(255,255,255,.14); }
.bookmark.is-saved svg { fill: #fff; color: #fff; }

/* Vista de lista */
.grid.is-list .card {
    min-height: 0;
    background: var(--white);
    box-shadow: none;
    border: 1px solid var(--line);
}
.grid.is-list .card-image { display: none; }
.grid.is-list .card::after { display: none; }
.grid.is-list .card-link { flex-direction: row; align-items: center; gap: 16px; padding: 14px 16px; }
.grid.is-list .card-top { flex: none; width: 150px; flex-direction: column; align-items: flex-start; gap: 5px; }
.grid.is-list .card-body { margin-top: 0; flex: 1; }
.grid.is-list .card-title { color: var(--ink); text-shadow: none; -webkit-line-clamp: 2; font-size: 0.98rem; }
.grid.is-list .card-place { color: var(--ink-3); }
.grid.is-list .card-sources { color: var(--ink-3); }
.grid.is-list .card-ago { background: none; color: var(--ink-3); padding: 0; }
.grid.is-list .bookmark { color: var(--ink-3); position: static; }

/* --- Cargar más ----------------------------------------------------------- */

.loadmore-wrap { display: flex; justify-content: center; margin-top: 26px; }

.loadmore {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    font-size: 0.89rem;
    font-weight: 500;
    box-shadow: var(--shadow-card);
}
.loadmore:hover { border-color: var(--ink-3); }
.loadmore[disabled] { opacity: .55; cursor: default; }
.loadmore svg { font-size: 1rem; }

/* --- Vacío y países ------------------------------------------------------- */

.empty-state {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 44px 32px;
    text-align: center;
}
.empty-state h2 { font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { color: var(--ink-3); max-width: 44ch; margin: 0 auto 18px; }

.btn-plain {
    display: inline-block;
    padding: 9px 18px;
    background: var(--ink);
    color: #fff;
    border-radius: var(--r-pill);
    font-size: 0.88rem;
    font-weight: 500;
}

.countries { padding: 0 var(--pad) 48px; }
.countries-inner { max-width: var(--maxw); margin: 0 auto; }

.section-title {
    font-size: 1.02rem;
    margin-bottom: 14px;
}

/* --- Pie ------------------------------------------------------------------ */

.foot {
    background: var(--white);
    border-top: 1px solid var(--line);
    padding: 28px var(--pad);
}
.foot-inner { max-width: var(--maxw); margin: 0 auto; }
.foot-brand .wordmark { font-size: 1.15rem; }
.foot-note {
    color: var(--ink-3);
    font-size: 0.83rem;
    margin-top: 6px;
    max-width: 62ch;
}

/* --- Adaptación ----------------------------------------------------------- */

@media (max-width: 1280px) {
    .grid { grid-template-columns: repeat(4, 1fr); }
}

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

    .topbar-inner { grid-template-columns: 1fr auto; row-gap: 12px; }
    .mainnav { grid-column: 1 / -1; justify-self: start; gap: 22px; overflow-x: auto; }
    .brand-tag { display: none; }
}

@media (max-width: 720px) {
    :root { --pad: 14px; }

    .grid { grid-template-columns: repeat(2, 1fr); }
    .card, .card-tall { min-height: 210px; }
    .card-title { font-size: 0.92rem; -webkit-line-clamp: 3; }
    .card-tall .card-title { font-size: 0.95rem; }


    .livepanel {
        position: static;
        width: auto;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid var(--line);
    }
    .hero-inner { display: flex; flex-direction: column; height: auto; }
    .map { position: relative; inset: auto; height: 250px; }
    .maplegend { display: none; }

    .filters-inner { flex-direction: column; align-items: stretch; }
    .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .filters-right { justify-content: space-between; }

    .grid.is-list .card-link { flex-direction: column; align-items: flex-start; }
    .grid.is-list .card-top { width: auto; flex-direction: row; }
}

@media (max-width: 420px) {
    .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; scroll-behavior: auto; }
}
