/* ============================================
   Algarve Daily — Broadsheet Newspaper Styles
   ============================================ */

/* --- 1. CSS Variables --- */
:root {
    --bg: #f5f0e6;
    --page: #fdfaf5;
    --panel: #f8f5ee;
    --text: #1a1a1a;
    --muted: #666;
    --light: #888;
    --rule: #ccc;
    --rule-light: #e0dace;
    --accent: #b33;
    --accent-deep: #8c2f1c;
    --sea: #2a7a5a;
    --shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* --- 2. Reset and Body --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: inherit;
}

/* --- 3. Page Shell --- */
.page {
    max-width: 960px;
    margin: 0 auto;
    background: var(--page);
    min-height: 100vh;
    box-shadow: var(--shadow);
}

/* --- 4. Masthead --- */
.masthead {
    text-align: center;
    padding: 28px 32px 0;
    border-bottom: 3px double #222;
}

.masthead-date {
    font-size: 11px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--light);
}

.masthead-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 52px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 2px;
}

.masthead-subtitle {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #777;
}

.masthead-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-size: 11px;
    color: var(--light);
    padding: 12px 0;
}

.masthead-meta a {
    color: var(--accent);
    font-weight: bold;
    text-decoration: none;
}

/* --- 5. Tab Navigation --- */
.tabs {
    display: flex;
    justify-content: center;
    border-top: 1px solid var(--rule);
    background: var(--page);
    position: sticky;
    top: 0;
    z-index: 100;
}

.tab {
    padding: 10px 28px;
    font-size: 11px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-family: 'Libre Baskerville', Georgia, serif;
    transition: color 0.2s, border-bottom-color 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab:hover {
    color: #444;
}

.tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.content {
    padding: 0 32px 40px;
}

/* --- 6. Today Spotlight --- */
.today-label {
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 8px;
    margin-top: 28px;
}

.today-date {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ddd;
}

.today-grid {
    display: grid;
    grid-template-columns: 1.4fr 1px 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.col-divider {
    background: var(--rule);
}

.headline-event h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 22px;
    font-weight: bold;
    line-height: 1.25;
    margin-bottom: 6px;
}

.headline-event .meta {
    font-size: 12px;
    color: var(--light);
    margin-bottom: 8px;
}

.headline-event .desc {
    font-size: 13.5px;
    color: #444;
    line-height: 1.7;
}

.today-sidebar-event {
    padding: 10px 0;
    border-bottom: 1px solid var(--rule-light);
}

.today-sidebar-event:last-child {
    border-bottom: none;
}

.today-sidebar-event h4 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 3px;
    line-height: 1.3;
}

.today-sidebar-event .meta {
    font-size: 11px;
    color: var(--light);
}

.sidebar-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
    margin: 4px 0 2px;
    display: none;
}

.today-sidebar-event.expanded .sidebar-desc {
    display: block;
}

.today-sidebar-event.expanded .event-link {
    display: inline-block;
}

.today-sidebar-event {
    cursor: pointer;
}

.today-sidebar-event h4 {
    transition: color 0.15s;
}

.today-sidebar-event:hover h4 {
    color: var(--accent);
}

.event-link {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.5px;
    display: none;
    margin-top: 4px;
}

.event-link:hover {
    text-decoration: underline;
}

/* --- 7. Event Badges --- */
.event-type {
    display: inline-block;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 4px;
}

.badge-free {
    display: inline-block;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: bold;
    color: var(--sea);
    background: rgba(42,122,90,0.08);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
}

.badge-translated {
    display: inline-block;
    font-size: 8px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--light);
    margin-left: 6px;
}

/* --- 7b. Type Filter Pills --- */
.type-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.type-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--light);
    border: 1px solid var(--rule);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Libre Baskerville', Georgia, serif;
    user-select: none;
}

.type-pill:hover {
    color: var(--text);
    border-color: var(--text);
}

.type-pill.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.type-count {
    font-size: 9px;
    opacity: 0.7;
}

/* --- 7c. Filtered Layout (flat list when type pill is active) --- */
.today-grid-filtered {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
}

.today-grid-filtered .headline-event {
    border-bottom: 1px solid var(--rule-light);
    padding-bottom: 12px;
    margin-bottom: 0;
}

.today-grid-filtered .today-sidebar-event {
    padding: 10px 0;
}

/* --- 7d. Show More / Hidden Events --- */
.today-hidden {
    display: none;
}

.show-more-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
    background: none;
    border: 1px solid var(--rule);
    cursor: pointer;
    transition: all 0.2s;
}

.show-more-btn:hover {
    background: rgba(179, 51, 51, 0.05);
    border-color: var(--accent);
}

/* --- 8. Weather Panel --- */
.weather-panel {
    background: var(--panel);
    border: 1px solid var(--rule-light);
    padding: 20px 24px;
    margin: 28px 0;
}

.weather-panel-title {
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: bold;
    color: var(--light);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.weather-grid {
    display: grid;
    grid-template-columns: 2fr 1px 1.2fr 1px 0.8fr;
    gap: 20px;
}

.forecast-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    text-align: center;
}

.forecast-day .day-name {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    color: var(--light);
    margin-bottom: 4px;
}

.forecast-day .day-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.forecast-day .day-temp {
    font-size: 13px;
    font-weight: bold;
}

.forecast-day .day-rain {
    font-size: 10px;
    color: #5588bb;
}

.forecast-day .day-sea {
    font-size: 9px;
    color: var(--sea);
    margin-top: 2px;
}

.forecast-day.today-forecast {
    background: rgba(180,50,50,0.06);
    border-radius: 4px;
    padding: 6px 0;
}

.tide-section-label {
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--light);
    margin-bottom: 10px;
}

.tide-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.tide-row:last-child {
    border-bottom: none;
}

.tide-label {
    color: var(--light);
    font-size: 11px;
}

.tide-time {
    font-weight: bold;
}

.tide-height {
    color: var(--muted);
    font-size: 11px;
}

.sea-temp {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 12px;
}

.sea-temp strong {
    font-size: 16px;
}

.moon-display {
    text-align: center;
}

.moon-icon {
    font-size: 42px;
    margin-bottom: 4px;
}

.moon-label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
}

.moon-detail {
    font-size: 11px;
    color: var(--light);
}

.sun-times {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: var(--muted);
    text-align: center;
}

/* --- 9. Day-by-Day Agenda --- */
.section-rule {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 32px 0 0;
}

.week-section-label {
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--light);
    font-weight: bold;
    margin-bottom: 4px;
    margin-top: 28px;
}

.day-header {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    font-weight: bold;
    padding: 10px 0 8px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.day-count {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: 11px;
    color: var(--light);
    font-weight: 400;
}

.day-events {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.compact-event {
    padding: 8px 0;
}

.compact-event h4 {
    font-size: 13.5px;
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1.3;
}

.compact-event .meta {
    font-size: 11px;
    color: var(--light);
}

/* --- 10. News Tab --- */
.news-lead h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 22px;
    font-weight: bold;
    line-height: 1.25;
    margin-bottom: 6px;
}

.news-lead .meta {
    font-size: 12px;
    color: var(--light);
    margin-bottom: 8px;
}

.news-lead .desc {
    font-size: 13.5px;
    color: #444;
    line-height: 1.7;
    margin-bottom: 20px;
}

.news-list-compact {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 16px;
}

.news-item-compact {
    padding: 10px 0;
    border-bottom: 1px solid var(--rule-light);
}

.news-item-compact h4 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 3px;
    line-height: 1.3;
}

.news-item-compact .meta {
    font-size: 11px;
    color: var(--light);
}

.news-item-compact .summary {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
    margin-top: 4px;
}

.news-item-compact a {
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
    font-size: 11px;
}

/* --- 11. Traditions Tab --- */
.tradition-list {
    display: grid;
    gap: 0;
}

.tradition-item {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--rule-light);
}

.tradition-item:last-child {
    border-bottom: none;
}

.tradition-date {
    font-size: 13px;
    font-weight: bold;
    color: var(--accent);
}

.tradition-item h4 {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 2px;
}

.tradition-item .original-name {
    font-size: 12px;
    font-style: italic;
    color: var(--light);
    margin-bottom: 4px;
}

.tradition-item .desc {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.6;
}

.tradition-item .region {
    font-size: 11px;
    color: var(--light);
    margin-top: 4px;
}

/* --- 12. Calendar Tab --- */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 20px;
}

.cal-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--light);
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--rule);
}

.cal-day {
    min-height: 70px;
    padding: 6px;
    border: 1px solid var(--rule-light);
    background: var(--page);
    cursor: default;
    position: relative;
    transition: background 0.15s;
}

.cal-day:hover {
    background: var(--panel);
}

.cal-empty {
    background: transparent;
    border-color: transparent;
}

.cal-day-num {
    font-size: 14px;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.cal-today {
    background: rgba(179, 51, 51, 0.06);
    border-color: var(--accent);
}

.cal-today .cal-day-num {
    color: var(--accent);
}

.cal-has-events {
    cursor: pointer;
}

.cal-dot-row {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.cal-dot-festival { background: var(--accent); }
.cal-dot-tradition { background: #8b5cf6; }
.cal-dot-concert { background: #2563eb; }
.cal-dot-market { background: var(--sea); }
.cal-dot-sports { background: #ea580c; }
.cal-dot-community { background: var(--light); }

.cal-count {
    font-size: 10px;
    color: var(--light);
    font-weight: 700;
}

.cal-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 24px;
}

.cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cal-detail {
    background: var(--panel);
    border: 1px solid var(--rule-light);
    padding: 16px 20px;
    margin-top: 16px;
}

.cal-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
}

.cal-detail-header h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 18px;
    margin: 0;
}

.cal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--light);
    padding: 0 4px;
}

.cal-event-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--rule-light);
}

.cal-event-item:last-child {
    border-bottom: none;
}

/* --- 12b. Mobile Bottom Navigation --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--page);
    border-top: 1px solid var(--rule);
    z-index: 200;
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.bottom-nav {
    display: none;
    grid-template-columns: repeat(5, 1fr);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Libre Baskerville', Georgia, serif;
    color: var(--light);
    transition: color 0.2s;
}

.bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-icon {
    font-size: 18px;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- 12c. Map Tab --- */
#map-container {
    width: 100%;
    height: 500px;
    border: 1px solid var(--rule-light);
}

/* --- 13. Shared Layout Classes (used by admin and error states) --- */
.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.status-panel {
    background: var(--panel);
    border: 1px solid var(--rule-light);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-deep);
}

.hero-text {
    color: var(--muted);
    line-height: 1.6;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.85rem 1.25rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
}

.button-secondary {
    background: rgba(42, 122, 90, 0.1);
    border: 1px solid rgba(42, 122, 90, 0.25);
    color: var(--sea);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.section-heading {
    margin-bottom: 1rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.feature-grid article {
    background: var(--panel);
    border: 1px solid rgba(28, 43, 45, 0.08);
    padding: 1.2rem;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--rule-light);
    padding: 1.5rem;
}

.badge {
    display: inline-flex;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--sea);
    margin-bottom: 0.75rem;
}

h1, h2, h3, h4, p {
    margin-top: 0;
}

/* --- 14. Admin Styles --- */
.admin-header {
    margin-bottom: 1.5rem;
}

.admin-title {
    font-size: clamp(2rem, 5vw, 4rem);
    margin-bottom: 0.5rem;
}

.admin-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.admin-grid {
    grid-template-columns: 1fr;
}

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

.source-run-list {
    display: grid;
    gap: 1rem;
}

.source-run-card {
    background: var(--panel);
    border: 1px solid var(--rule-light);
    padding: 1.2rem;
}

.source-catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.source-catalog-card p {
    margin-bottom: 0.55rem;
}

.source-card-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: start;
}

.source-status {
    margin: 0;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.source-status-completed {
    background: rgba(42, 122, 90, 0.12);
    color: var(--sea);
}

.source-status-running {
    background: rgba(179, 51, 51, 0.12);
    color: var(--accent-deep);
}

.source-status-failed {
    background: rgba(140, 47, 28, 0.12);
    color: var(--accent-deep);
}

.source-url {
    font-family: "Courier New", monospace;
    font-size: 0.9rem;
    word-break: break-all;
    color: var(--muted);
}

.empty-state {
    margin-bottom: 0;
}

.error-text {
    color: var(--accent-deep);
    font-family: "Courier New", monospace;
    word-break: break-word;
}

/* --- 14. Responsive --- */
@media (max-width: 768px) {
    .today-grid,
    .day-events,
    .news-list-compact {
        grid-template-columns: 1fr;
    }

    .weather-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .col-divider {
        display: none;
    }

    .masthead {
        padding: 16px 16px 0;
    }

    .masthead-title {
        font-size: 36px;
    }

    .content {
        padding: 0 16px 32px;
    }

    .forecast-days {
        grid-template-columns: repeat(7, 1fr);
    }

    /* Hide top tabs on mobile, show bottom nav */
    .tabs {
        display: none;
    }

    .bottom-nav {
        display: grid;
    }

    /* Add bottom padding for fixed nav */
    .page {
        padding-bottom: 72px;
    }

    .tradition-item {
        grid-template-columns: 1fr;
    }

    .admin-summary,
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .source-catalog-grid {
        grid-template-columns: 1fr;
    }

    /* Compact weather on mobile */
    .weather-panel {
        margin: 0;
        padding: 12px 16px;
        border-left: none;
        border-right: none;
    }

    .weather-panel-title {
        font-size: 9px;
        margin-bottom: 10px;
        padding-bottom: 6px;
    }

    .forecast-day .day-temp { font-size: 12px; }
    .forecast-day .day-icon { font-size: 16px; }
    .forecast-day .day-name { font-size: 9px; }
    .forecast-day .day-rain { font-size: 9px; }

    .tide-section-label { font-size: 10px; }
    .tide-row { font-size: 11px; }
    .moon-icon { font-size: 32px; }

    /* Calendar compact on mobile */
    .cal-day {
        min-height: 48px;
        padding: 4px;
    }

    .cal-day-num { font-size: 12px; }
    .cal-count { font-size: 8px; }
    .cal-dot { width: 5px; height: 5px; }

    /* Type filter pills scroll on mobile */
    .type-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .type-pill {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Headline event */
    .headline-event h3 { font-size: 18px; }
    .today-date { font-size: 22px; }
}

@media (max-width: 480px) {
    .masthead-title {
        font-size: 28px;
        letter-spacing: 1px;
    }

    .masthead-date {
        font-size: 9px;
        letter-spacing: 2px;
    }

    .masthead-subtitle {
        font-size: 9px;
        letter-spacing: 2px;
    }

    .masthead-meta {
        flex-direction: column;
        gap: 4px;
        font-size: 10px;
    }

    .content {
        padding: 0 12px 24px;
    }

    .today-label { font-size: 9px; margin-top: 20px; }
    .today-date { font-size: 20px; margin-bottom: 14px; }
    .headline-event h3 { font-size: 16px; }
    .headline-event .desc { font-size: 12.5px; }
    .day-header { font-size: 15px; }

    .cal-day { min-height: 40px; padding: 3px; }
    .cal-day-num { font-size: 11px; }
    .cal-header { font-size: 9px; }
}
