/* ============================================================
   Sección Sismos — tablero de datos abiertos (USGS)
   ============================================================ */

.sm-page {
    --sm-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --sm-serif: Georgia, "Iowan Old Style", "Times New Roman", "Liberation Serif", Times, serif;
    --sm-m0: #64748b;
    --sm-m3: #d97706;
    --sm-m4: #ea580c;
    --sm-m5: #dc2626;
    --sm-shallow: #dc2626;
    --sm-mid: #f59e0b;
    --sm-deep: #3b82f6;
    padding: 22px 0 6px;
    font-family: var(--sm-sans);
}

.sm-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--fx-muted);
    font-size: .78rem;
}

.sm-breadcrumb a {
    color: inherit;
    text-decoration: none;
}

.sm-breadcrumb a:hover {
    color: var(--fx-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Cabecera */
.sm-head {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--fx-border);
}

.sm-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    color: var(--fx-accent);
    font-size: .71rem;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.sm-kicker__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sm-m5);
    animation: sm-pulse 2.4s ease-out infinite;
}

@keyframes sm-pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); }
    70% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.sm-head h1 {
    margin: 0;
    font-family: var(--sm-serif);
    font-size: clamp(2.1rem, 5vw, 3.2rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.03em;
    color: var(--fx-text);
}

.sm-dek {
    max-width: 72ch;
    margin: 12px 0 0;
    color: var(--fx-muted);
    font-size: 1rem;
    line-height: 1.6;
}

.sm-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 14px;
    color: var(--fx-muted);
    font-size: .8rem;
}

.sm-status strong {
    color: var(--fx-text);
    font-weight: 700;
}

.sm-status__live {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16a34a;
    animation: sm-pulse-green 2.4s ease-out infinite;
}

@keyframes sm-pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
    70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.sm-status__hint {
    letter-spacing: .02em;
}

.sm-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    margin-left: auto;
    padding: 0 12px;
    border: 1px solid var(--fx-border);
    border-radius: 999px;
    background: var(--fx-surface);
    color: var(--fx-text);
    font-family: inherit;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}

.sm-refresh:hover {
    border-color: var(--fx-accent);
    color: var(--fx-accent);
}

.sm-refresh.is-loading svg {
    animation: sm-spin 1s linear infinite;
}

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

/* Filtros */
.sm-filters {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 18px 26px;
    padding: 16px 0 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--fx-border);
}

.sm-filters__group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.sm-filters__group legend,
.sm-filters__group > label {
    padding: 0;
    color: var(--fx-muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

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

.sm-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--fx-border);
    border-radius: 999px;
    background: var(--fx-surface);
    color: var(--fx-muted);
    font-size: .82rem;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.sm-chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.sm-chip:hover {
    border-color: var(--fx-accent);
    color: var(--fx-accent);
}

.sm-chip:has(input:checked) {
    background: var(--fx-accent);
    border-color: var(--fx-accent);
    color: #fff;
}

.sm-chip:focus-within {
    outline: 2px solid var(--fx-accent);
    outline-offset: 2px;
}

.sm-filters__group--select select {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--fx-border);
    border-radius: 999px;
    background: var(--fx-surface);
    color: var(--fx-text);
    font-family: inherit;
    font-size: .82rem;
    font-weight: 650;
    cursor: pointer;
}

.sm-filters__apply {
    height: 34px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--fx-text);
    color: var(--fx-bg);
    font-family: inherit;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    cursor: pointer;
}

/* Con JS, los filtros se aplican solos. */
.sm-js .sm-filters__apply {
    display: none;
}

/* Mapa */
.sm-map-section {
    margin-bottom: 26px;
}

.sm-map-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 10px;
}

.sm-map-head h2 {
    margin: 0;
    font-family: var(--sm-serif);
    font-size: 1.3rem;
    letter-spacing: -.02em;
}

.sm-map-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--fx-muted);
    font-size: .72rem;
}

.sm-map-legend li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.sm-dot-mini {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
}

.sm-map {
    position: relative;
    height: 420px;
    border: 1px solid var(--fx-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--fx-surface-2);
}

.sm-map .leaflet-container {
    font-family: var(--sm-sans);
    font-size: .82rem;
}

.sm-map__fallback {
    margin: 0;
    padding: 20px;
    color: var(--fx-muted);
    font-size: .9rem;
}

.sm-map-popup strong {
    display: block;
    font-size: .95rem;
}

.sm-map-popup span {
    display: block;
    color: #4b5563;
    font-size: .8rem;
}

.sm-map-popup a {
    display: inline-block;
    margin-top: 6px;
    color: #203473;
    font-weight: 700;
}

/* Colores compartidos */
.is-m0 { --sm-color: var(--sm-m0); }
.is-m3 { --sm-color: var(--sm-m3); }
.is-m4 { --sm-color: var(--sm-m4); }
.is-m5 { --sm-color: var(--sm-m5); }
.is-shallow { --sm-color: var(--sm-shallow); }
.is-mid { --sm-color: var(--sm-mid); }
.is-deep { --sm-color: var(--sm-deep); }

.sm-dot,
.sm-dot-mini,
.sm-event__mag,
.sm-bars__fill,
.sm-legend__item::before {
    background: var(--sm-color, var(--sm-m0));
}

/* KPIs */
.sm-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 24px;
    border: 1px solid var(--fx-border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--fx-border);
}

.sm-kpi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 16px 18px;
    background: var(--fx-surface);
    min-width: 0;
}

.sm-kpi__label {
    color: var(--fx-muted);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sm-kpi__value {
    font-family: var(--sm-serif);
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    color: var(--fx-text);
}

.sm-kpi--mag .sm-kpi__value {
    color: var(--sm-m4);
}

.sm-kpi__meta {
    color: var(--fx-muted);
    font-size: .76rem;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Gráficos */
.sm-charts {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 26px;
    padding-bottom: 26px;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--fx-border);
}

.sm-chart {
    margin: 0;
    min-width: 0;
}

.sm-chart figcaption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 14px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--fx-text);
}

.sm-chart figcaption small {
    color: var(--fx-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
}

/* Dispersión */
.sm-scatter {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: auto 20px;
    gap: 0 6px;
}

.sm-scatter__y {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    height: 220px;
    color: var(--fx-muted);
    font-size: .64rem;
    font-weight: 700;
}

.sm-scatter__y span {
    position: absolute;
    right: 0;
    transform: translateY(50%);
}

.sm-scatter__plot {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    height: 220px;
    border-left: 1px solid var(--fx-border);
    border-bottom: 1px solid var(--fx-border);
    background:
        linear-gradient(to right, rgba(0, 0, 0, .02), rgba(0, 0, 0, 0));
}

.sm-scatter__empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 18px;
    color: var(--fx-muted);
    font-size: .78rem;
    text-align: center;
}

.sm-scatter__grid {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 1px dashed var(--fx-border);
    opacity: .7;
}

.sm-scatter__x {
    position: relative;
    grid-column: 2;
    grid-row: 2;
    height: 20px;
    color: var(--fx-muted);
    font-size: .62rem;
    font-weight: 700;
}

.sm-scatter__x span {
    position: absolute;
    top: 5px;
    transform: translateX(-50%);
    white-space: nowrap;
}

.sm-scatter__x span.is-hidden {
    display: none;
}

.sm-dot {
    position: absolute;
    transform: translate(-50%, 50%);
    border-radius: 50%;
    border: 2px solid var(--fx-surface);
    opacity: .9;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .22);
    transition: opacity .15s ease, transform .15s ease;
}

.sm-dot:hover {
    opacity: 1;
    transform: translate(-50%, 50%) scale(1.25);
    z-index: 3;
}

.sm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 12px;
    color: var(--fx-muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.sm-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sm-legend__item::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Barras */
.sm-bars {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sm-bars li {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
}

.sm-bars__label {
    color: var(--fx-muted);
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.2;
}

.sm-bars__track {
    display: block;
    height: 9px;
    border-radius: 999px;
    background: var(--fx-surface-2);
    overflow: hidden;
}

.sm-bars__fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    transition: width .4s cubic-bezier(.22, 1, .36, 1);
}

.sm-bars__value {
    color: var(--fx-text);
    font-size: .78rem;
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Listado */
.sm-panel.is-loading {
    opacity: .55;
    transition: opacity .2s ease;
}

.sm-list__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 6px;
}

.sm-list__head h2 {
    margin: 0;
    font-family: var(--sm-serif);
    font-size: 1.45rem;
    letter-spacing: -.02em;
}

.sm-list__head span {
    color: var(--fx-muted);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.sm-events {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sm-event {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--fx-border);
}

.sm-event__mag {
    display: grid;
    place-items: center;
    width: 46px;
    height: 34px;
    border-radius: 4px;
    color: #fff;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: -.01em;
}

.sm-event__body {
    min-width: 0;
}

.sm-event__body h3 {
    margin: 0 0 3px;
    font-size: .94rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--fx-text);
}

.sm-event__body p {
    margin: 0;
    color: var(--fx-muted);
    font-size: .76rem;
}

.sm-event__body .sm-ago {
    color: var(--fx-accent);
    font-weight: 700;
}

.sm-event__link {
    color: var(--fx-accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-decoration: none;
    white-space: nowrap;
}

.sm-event__link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sm-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(220, 38, 38, .1);
    color: var(--sm-m5);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.sm-sep {
    margin: 0 5px;
    opacity: .6;
}

.sm-empty {
    margin: 18px 0;
    padding: 24px;
    border: 1px dashed var(--fx-border);
    border-radius: 6px;
    color: var(--fx-muted);
    font-size: .9rem;
    text-align: center;
}

.sm-source {
    margin: 18px 0 0;
    color: var(--fx-muted);
    font-size: .72rem;
    line-height: 1.5;
}

.sm-source a {
    color: var(--fx-accent);
    font-weight: 700;
}

/* Responsive */
@media (max-width: 1100px) {
    .sm-charts {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
    }

    .sm-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .sm-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sm-kpi:last-child {
        grid-column: 1 / -1;
    }

    .sm-map {
        height: 320px;
    }

    .sm-filters {
        gap: 14px 18px;
    }

    .sm-refresh {
        margin-left: 0;
    }

    .sm-scatter__plot,
    .sm-scatter__y {
        height: 180px;
    }

    .sm-bars li {
        grid-template-columns: 92px minmax(0, 1fr) 30px;
        gap: 8px;
    }

    .sm-event {
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 10px;
    }

    .sm-event__mag {
        width: 42px;
        height: 32px;
    }

    .sm-event__link {
        grid-column: 2;
        justify-self: start;
    }
}

@media (max-width: 460px) {
    .sm-kpi__value {
        font-size: 1.5rem;
    }

    .sm-dek {
        font-size: .94rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sm-kicker__dot,
    .sm-status__live,
    .sm-refresh.is-loading svg,
    .sm-bars__fill,
    .sm-dot {
        animation: none;
        transition: none;
    }
}
