/* horabarata.com / electricitypricespain.com — main stylesheet
   Built from ux-claude/designs/horabarata.md spec (#2144). */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:        #0EA5A4;
    --brand-hover:  #0D8B8A;
    --brand-deep:   #0B6B6B;
    --brand-light:  #ECFDF7;
    --brand-muted:  #5EEAD4;

    --price-cheap:    #16A34A;
    --price-cheap-bg: #DCFCE7;
    --price-mid:      #F59E0B;
    --price-mid-bg:   #FEF3C7;
    --price-high:     #DC2626;
    --price-high-bg:  #FEE2E2;

    --color-bg:           #FAFAFA;
    --color-surface:      #FFFFFF;
    --color-bg-hover:     #F9FAFB;
    --color-border:       #E5E7EB;
    --color-text:         #111827;
    --color-text-secondary: #374151;
    --color-text-muted:   #6B7280;
    --color-text-dim:     #9CA3AF;

    --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --max-width: 720px;
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); text-decoration: underline; }

img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 2rem 0; }

/* ============================================================
   Header
   ============================================================ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.logo {
    font-weight: 500;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}
.logo:hover { color: var(--color-text); text-decoration: none; }
.logo-icon {
    font-size: 1.25rem;
    color: var(--brand);
}
.logo-text .logo-bold { font-weight: 700; color: var(--brand-deep); }

.lang-toggle {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    transition: border-color 150ms, color 150ms;
}
.lang-toggle:hover {
    border-color: var(--brand);
    color: var(--brand);
    text-decoration: none;
}

/* ============================================================
   Layout
   ============================================================ */

.site-main {
    flex: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

@media (min-width: 960px) {
    .site-main { max-width: 880px; }
}

/* ============================================================
   Hero
   ============================================================ */

.hero {
    position: relative;
    overflow: hidden;
    padding: 3rem 1.5rem 2.5rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #fff;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 70%, #064E4E 100%);
}
.hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.hero-content { position: relative; z-index: 1; }

.hero-label {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.85;
    margin-bottom: 0.5rem;
}
.hero-rate {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    margin: 0;
    font-variant-numeric: tabular-nums;
}
.hero-rate .unit {
    font-size: 1.25rem;
    font-weight: 500;
    opacity: 0.7;
    margin-left: 0.25rem;
}
.hero-change {
    margin-top: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #E0F7F7;
}
.hero-change.up { color: #FCA5A5; }
.hero-change.down { color: #86EFAC; }

.hero-cheapest {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    display: inline-block;
}
.cheapest-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.7;
}
.cheapest-time {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .hero { padding: 2.5rem 1rem 2rem; }
    .hero-rate { font-size: 2.75rem; }
}
@media (max-width: 480px) {
    .hero-bg { display: none; }
}

/* ============================================================
   Section header
   ============================================================ */

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
}
.section-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0 0 1rem;
}

/* ============================================================
   Heatmap
   ============================================================ */

.heatmap-section,
.tomorrow-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    overflow: hidden;
}
.heatmap-cell {
    aspect-ratio: 1 / 2.5;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(0,0,0,0.55);
    cursor: pointer;
    transition: transform 120ms ease, outline 120ms ease;
    font-variant-numeric: tabular-nums;
    border: 0;
}
.heatmap-cell:hover,
.heatmap-cell:focus-visible {
    transform: scale(1.08);
    outline: 2px solid var(--brand);
    outline-offset: 1px;
    z-index: 2;
    position: relative;
}
.heatmap-cell.now {
    outline: 2px solid var(--color-text);
    outline-offset: -1px;
    z-index: 3;
    position: relative;
}

.tier-1 { background: #BBF7D0; }
.tier-2 { background: #FEF3C7; }
.tier-3 { background: #FED7AA; }
.tier-4 { background: #FCA5A5; }
.tier-5 { background: #F87171; color: #fff; }

/* Show only every 6th hour label to reduce clutter */
.heatmap-cell:not([data-hour="00"]):not([data-hour="06"]):not([data-hour="12"]):not([data-hour="18"]) .hour-label {
    visibility: hidden;
}

.heatmap-legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.heatmap-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.summary-item {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border-left: 3px solid;
}
.summary-item.cheapest {
    background: var(--price-cheap-bg);
    border-color: var(--price-cheap);
}
.summary-item.priciest {
    background: var(--price-high-bg);
    border-color: var(--price-high);
}
.summary-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}
.summary-value {
    display: block;
    font-weight: 600;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
    .heatmap-cell { aspect-ratio: 1 / 3; font-size: 0.55rem; }
    .heatmap-summary { grid-template-columns: 1fr; }
}

/* ============================================================
   Empty / waiting state
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-muted);
}
.empty-icon { font-size: 2rem; margin: 0 0 0.5rem; }
.empty-hint { font-size: 0.85rem; margin-top: 0.25rem; }

/* ============================================================
   Details / table
   ============================================================ */

.details-table {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.details-table summary {
    padding: 1rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.details-table summary::-webkit-details-marker { display: none; }
.details-table summary::after {
    content: '▾';
    color: var(--color-text-muted);
    transition: transform 200ms ease;
}
.details-table[open] summary::after { transform: rotate(180deg); }

.hours-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.hours-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}
.hours-table td {
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.hours-table .hour, .hours-table .price {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.hours-table .diff.up { color: var(--price-high); font-weight: 600; }
.hours-table .diff.down { color: var(--price-cheap); font-weight: 600; }
.tier-row.tier-1 .price { color: var(--price-cheap); font-weight: 700; }
.tier-row.tier-5 .price { color: var(--price-high); font-weight: 700; }
.tier-row.now { background: rgba(14, 165, 164, 0.06); }

/* ============================================================
   ICS / push CTA
   ============================================================ */

.ics-cta {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}
.ics-icon { font-size: 1.75rem; flex-shrink: 0; }
.ics-text { flex: 1; }
.ics-text h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.15rem; }
.ics-text p { font-size: 0.825rem; color: var(--color-text-muted); margin: 0; line-height: 1.4; }
.btn-disabled {
    background: var(--color-bg-hover);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .ics-cta { flex-direction: column; text-align: center; }
}

/* ============================================================
   FAQ
   ============================================================ */

.faq-section { margin-bottom: 2rem; }
.faq-section h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.faq-item { border-bottom: 1px solid var(--color-border); }
.faq-item summary {
    padding: 1rem 0;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--color-text-muted);
    transition: transform 200ms;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p {
    padding: 0 0 1rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}
.faq-item code {
    background: var(--color-bg-hover);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-size: 0.95em;
}

/* ============================================================
   Articles teaser (homepage)
   ============================================================ */

.articles-teaser {
    background: var(--brand-light);
    border: 1px solid rgba(14, 165, 164, 0.18);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.articles-teaser h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.4rem; }
.articles-teaser h2 a { color: var(--brand-deep); text-decoration: none; }
.articles-teaser h2 a:hover { text-decoration: underline; }
.articles-teaser p { font-size: 0.9rem; color: var(--color-text-secondary); margin: 0; }

/* ============================================================
   Featured articles (homepage)
   ============================================================ */

.featured-articles {
    margin-bottom: 1.5rem;
}
.featured-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
@media (min-width: 560px) {
    .featured-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
.featured-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
}
.featured-card h3 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 0.4rem;
}
.featured-card h3 a { color: var(--color-text); text-decoration: none; }
.featured-card h3 a:hover { color: var(--brand); text-decoration: underline; }
.featured-card .card-desc {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0 0 0.75rem;
    flex: 1;
}
.featured-card .card-cta {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand);
    align-self: flex-start;
}
.featured-card .card-cta:hover { color: var(--brand-deep); text-decoration: underline; }
.featured-all {
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
}
.featured-all a { font-weight: 600; }

/* ============================================================
   Listing page
   ============================================================ */

.listing-page h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}
.listing-intro {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}
.article-cards {
    display: grid;
    gap: 1rem;
}
.article-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
}
.article-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.4rem;
    line-height: 1.35;
}
.article-card h2 a { color: var(--color-text); text-decoration: none; }
.article-card h2 a:hover { color: var(--brand); text-decoration: underline; }
.card-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin: 0 0 0.5rem;
}
.card-desc {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin: 0;
}

/* ============================================================
   Article + prose pages
   ============================================================ */

.breadcrumb {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--brand); }

.article-page,
.prose-page {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.75rem 1.5rem;
}
@media (min-width: 720px) {
    .article-page,
    .prose-page { padding: 2.25rem 2.25rem; }
}

.article-title {
    font-size: clamp(1.5rem, 4.5vw, 2rem);
    line-height: 1.25;
    margin: 0 0 0.75rem;
}
.article-meta {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.article-meta a { color: var(--color-text-secondary); }
.article-language-toggle {
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

.article-body,
.prose-page {
    color: var(--color-text-secondary);
    font-size: 1rem;
    line-height: 1.7;
}
.article-body h2,
.prose-page h2 {
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 700;
    margin: 1.75rem 0 0.75rem;
}
.article-body h3,
.prose-page h3 {
    color: var(--color-text);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}
.article-body p,
.prose-page p { margin: 0 0 1rem; }
.article-body ul,
.article-body ol,
.prose-page ul,
.prose-page ol { margin: 0 0 1rem 1.25rem; }
.article-body li,
.prose-page li { margin-bottom: 0.35rem; }
.article-body strong,
.prose-page strong { color: var(--color-text); }
.article-body code,
.prose-page code {
    background: var(--color-bg-hover);
    padding: 0.1em 0.35em;
    border-radius: 4px;
    font-size: 0.95em;
}
.article-body table,
.prose-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.92rem;
}
.article-body th,
.article-body td,
.prose-page th,
.prose-page td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}
.article-body th,
.prose-page th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.article-divider { margin: 2rem 0 1rem; }
.article-back {
    margin-top: 1rem;
    font-size: 0.9rem;
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    background: var(--color-surface);
}
.footer-cross {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.footer-eco { font-weight: 600; margin: 0 0 0.25rem; color: var(--color-text-secondary); }
.footer-cross a { color: var(--brand); font-weight: 600; }
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}
.footer-links a { color: var(--color-text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--brand); }
.footer-copy a { color: var(--color-text-muted); }

/* ============================================================
   Daily-URL pages (/today, /hoy, /tomorrow, /manana, /YYYY-MM-DD)
   ============================================================ */

.daily-page .article-meta .badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: 1px;
}
.daily-page .badge-now {
    background: var(--brand);
    color: #fff;
}
.daily-page .badge-soon {
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
}
.daily-page .badge-past {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.daily-headline {
    margin: 1.25rem 0 1.5rem;
}
.headline-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
@media (min-width: 640px) {
    .headline-grid { grid-template-columns: repeat(3, 1fr); }
}
.headline-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.headline-item.cheap { border-color: #16A34A; }
.headline-item.pricy { border-color: #DC2626; }
.headline-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.headline-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}
.headline-sub {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.daily-hours-table .now-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    background: var(--brand);
    color: #fff;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.daily-hours-table .tier-row.now {
    box-shadow: inset 3px 0 0 var(--brand);
}

.daily-page .article-body .table-preamble {
    margin-bottom: 0.5rem;
}

.hero-daily-links {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    font-size: 0.95rem;
}
.hero-daily-links a {
    color: #fff;
    opacity: 0.85;
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 500;
}
.hero-daily-links a:hover { opacity: 1; }

/* ============================================================
   Dark mode
   ============================================================ */

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0F1814;
        --color-surface: #16221E;
        --color-bg-hover: #1E2A26;
        --color-border: #243029;
        --color-text: #E8E8ED;
        --color-text-secondary: #B0B5B0;
        --color-text-muted: #808880;
        --brand-light: #0F2929;
    }
    .site-header,
    .site-footer { background: #0F1814; border-color: #243029; }
    .hero {
        background: linear-gradient(160deg, #0B6B6B 0%, #064E4E 50%, #022B2B 100%);
    }
    .tier-1 { background: #166534; color: #DCFCE7; }
    .tier-2 { background: #65420B; color: #FEF3C7; }
    .tier-3 { background: #7C2D12; color: #FED7AA; }
    .tier-4 { background: #991B1B; color: #FCA5A5; }
    .tier-5 { background: #7F1D1D; color: #FECACA; }

    .summary-item.cheapest { background: #06241A; border-color: #16A34A; }
    .summary-item.priciest { background: #2A0E0E; border-color: #DC2626; }

    .articles-teaser {
        background: #0F2929;
        border-color: rgba(14,165,164,0.3);
    }
    .articles-teaser h2 a { color: var(--brand-muted); }
}

/* ============================================================
   Reduced motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .heatmap-cell,
    .details-table summary::after,
    .faq-item summary::after { transition: none !important; }
    html { scroll-behavior: auto; }
}
