/* ==========================================================================
   TVRDb Listings CSS - Unified Variables for Light, Dark & System Modes
   ========================================================================== */

.prog-time {
  font-weight: bold;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--text-main) !important;
}

.prog-end-time {
  display: block;
  font-weight: normal;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.listings-container a:not(.button):not([style*="color:red"]):not(.js-delete-durations) {
  color: var(--link-color) !important;
}

.prog-title {
  font-weight: bold;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--link-color) !important;
}

.prog-title:hover { 
  text-decoration: underline overline; 
}

.listings-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 15px;
  text-align: left;
}

/* ==========================================================================
   1. Two-Tier Filter Panel (Categories & Channel Drawers)
   ========================================================================== */

.filter-panel {
  background: var(--header-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  margin-bottom: 16px;
  overflow: hidden;
}

.category-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid var(--card-border);
}

.cat-tab {
  background: var(--header-bg);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-weight: bold;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  transition: all 0.15s ease;
}

.cat-tab.has-active {
  border-color: var(--accent-color);
}

.cat-tab.is-open {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.cat-badge {
  font-size: 0.75rem;
  background: rgba(128, 128, 128, 0.2);
  padding: 1px 6px;
  border-radius: 10px;
}
.cat-tab.is-open .cat-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Collapsible Channel Drawers */
.channel-drawer {
  display: none;
  padding: 12px 14px;
}
.channel-drawer.is-open {
  display: block;
}

.drawer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.drawer-hint {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 0.8rem;
}

.btn-mini {
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-mini:hover { border-color: var(--accent-color); }

/* Sub-Action Buttons (.btn-sub) with Soft Pastel Tint */
.btn-sub {
    background: rgba(153, 0, 51, 0.06); /* Soft pastel burgundy tint in light mode */
    color: var(--text-main);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.btn-sub:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(153, 0, 51, 0.12);
}

.selector-panel {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100%;
}

/* Channel Pills with Visible Soft Pastel Backgrounds (Dropping low opacity) */
.channel-pill {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background: var(--header-bg); /* Clear, visible pastel/neutral base */
    transition: all 0.12s ease;
}

.channel-pill.is-active {
    border-color: var(--accent-color);
    background: rgba(153, 0, 51, 0.1); /* Richer pastel fill when active */
}

/* Dark Mode Pastel Adjustments */
[data-theme="dark"] .btn-sub,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .btn-sub {
        background: rgba(0, 230, 118, 0.07); /* Soft pastel green tint in dark mode */
    }
    :root:not([data-theme="light"]) .btn-sub:hover {
        background: rgba(0, 230, 118, 0.15);
    }
    :root:not([data-theme="light"]) .channel-pill.is-active {
        background: rgba(0, 230, 118, 0.12);
    }
}

/* Split Channel Pills (Toggle On/Off + Jump Link) */
.channel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-toggle {
  background: none;
  border: none;
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.channel-pill.is-active .pill-toggle {
  font-weight: bold;
  color: var(--accent-color);
}

.pill-jump {
  display: none;
  align-items: center;
  padding: 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 1px solid var(--card-border);
}
.channel-pill.is-active .pill-jump {
  display: inline-flex;
}
.pill-jump:hover {
  background: var(--accent-color);
  color: #fff;
}

/* Base style for jump arrows (handles Light Mode) */
.channel-pill .pill-jump {
    color: #444444; /* A crisp, legible dark neutral for light mode */
    font-weight: bold;
    text-decoration: none;
    padding: 0 4px;
    transition: color 0.2s ease;
}

.channel-pill .pill-jump:hover {
    color: #000000; /* Darker on hover in light mode */
}

/* Dark Mode Override */
@media (prefers-color-scheme: dark) {
    .channel-pill .pill-jump {
        color: #b8860b; /* Your archive gold for dark mode */
    }
    
    .channel-pill .pill-jump:hover {
        color: #ff4500; /* Bright highlight on hover in dark mode */
    }
}

/* ==========================================================================
   2. Listings Toolbar (Search, Hours, Theme, Layout)
   ========================================================================== */

.listings-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px;
  background: var(--bg-color4);
  border: 1px solid var(--card-border);
  border-radius: 6px;
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-muted);
}

.listings-toolbar input[type="search"] {
  padding: 6px 12px;
  width: 250px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-main);
}

.toolbar-select {
  padding: 4px 8px;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 0.85rem;
}

.dday-selector {
  background: var(--header-bg);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--card-border);
}

.dday-btn {
  background: transparent;
  border: none;
  padding: 5px 10px;
  font-size: 0.82rem;
  border-radius: 4px;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease;
}

.dday-btn.is-active {
  background: var(--accent-color);
  color: #ffffff;
  font-weight: bold;
}


/* ==========================================================================
   3. Responsive CSS Grid & Channel Cards
   ========================================================================== */

.listings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
  align-items: start;
}

.listings-grid.single-column {
  grid-template-columns: 1fr;
  margin: 0 auto;
} 

.category-cards-grid {
    display: grid;
    /* Reduced minmax slightly so 3 columns trigger more easily on standard displays */
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    align-items: start;
    width: 100%;
    margin-bottom: 30px;
}

#listings-grid.single-column .category-cards-grid {
    grid-template-columns: 1fr;
    margin-left: auto;
    margin-right: auto;
}

/* Force category headers to span across all columns in the grid */
.category-listings-header {
    grid-column: 1 / -1;
    margin-top: 20px;
    margin-bottom: 10px;
}

.channel-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  overflow: hidden;
  overflow-anchor: none;
}

.channel-card.is-hidden {
  display: none;
}

.channel-header {
  background: var(--header-bg);
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
}

.channel-header h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--accent-color);
}

.channel-meta-links {
  font-size: 0.8rem;
  display: flex;
  gap: 10px;
}

/* Programme Rows */
.prog-list {
  padding: 8px 14px;
}

.prog-item {
  display: grid;
  grid-template-columns: 75px 1fr;
  column-gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}
.prog-item:last-child { border-bottom: none; }

.prog-title-row {
  line-height: 1.3;
}

.prog-title {
  font-weight: bold;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text-main);
}
.prog-title:hover { text-decoration: underline; }

.film-icon {
  width: 20px;
  height: 20px;
  vertical-align: text-bottom;
  margin-right: 3px;
}

.admin-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  font-size: 0.8rem;
}
.admin-actions a {
  color: #d00;
  text-decoration: none;
  font-weight: bold;
}

.prog-subtitle {
  font-style: italic;
  font-size: 0.92rem;
  margin-top: 2px;
  color: var(--text-muted);
}

.prog-synopsis {
  font-size: 0.92rem;
  color: var(--text-main);
  margin-top: 3px;
  line-height: 1.4;
}

.channel-footer {
  padding: 8px 14px;
  background: var(--header-bg);
  border-top: 1px solid var(--card-border);
  font-size: 0.85rem;
}

.channel-skeleton {
  padding: 30px 14px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.title-with-icon {
    display: inline-flex;
    align-items: center; /* Forces perfect vertical centering */
    gap: 8px;            /* Adds nice spacing between icon and text */
}

.theme-icon {
    width: 32px;
    height: 32px;
    display: block; /* No vertical-align needed inside flex */
}

[data-theme="light"] .dark-img,
[data-theme="dark"] .light-img {
    display: none;
}

.listings-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* Left, Center, Right columns */
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

/* Empty spacer mirrors the button's width to keep the center dead-center */
.header-spacer {
    visibility: hidden;
}

/* Group the arrows and date together so they center as one unit */
.date-nav-group {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.toolbar-toggle-btn {
    justify-self: end; /* Pins the button to the far right of the grid */
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--card-border);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.toolbar-toggle-btn:hover {
    background: var(--accent-color);
	color: #fff;
}

/* Toolbar Collapsed & Expanded States */

.member-toolbar {
    max-height: 2000px; /* Adjust based on toolbar height */
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, margin 0.3s ease-in-out;
    opacity: 1;
}

.member-toolbar.is-collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    pointer-events: none; /* Prevents interaction when hidden */
}

.toolbar-close-btn {
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

.toolbar-close-btn:hover {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}

@media (max-width: 768px) {
    .listings-header-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    /* Hide the desktop spacer on mobile */
    .header-spacer {
        display: none;
    }

    /* Make the date navigation take up the full top row and stay centered */
    .date-nav-group {
        width: 100%;
        justify-content: center;
    }

    /* Drop the customize button to the next line and make it easy to tap */
    .toolbar-toggle-btn {
        width: auto;
        text-align: center;
        justify-self: auto;
    }
}

.broadcast-notes-container {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.post-it-note {
    background-color: #fef08a; /* Classic sticky note yellow */
    color: #1e293b;            /* Dark text for high contrast */
    padding: 12px 14px;
    border-radius: 4px;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.08);
    font-size: 0.9rem;
    position: relative;
    border-left: 4px solid #eab308; /* Slightly darker yellow accent edge */
}

/* Dark mode override so Post-It notes don't blast white/yellow in dark environments */
[data-theme="dark"] .post-it-note {
    background-color: #3f3f46;
    color: #f4f4f5;
    border-left-color: #a1a1aa;
    box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.3);
}

.note-text {
    margin: 0 0 6px 0;
    line-height: 1.4;
}

.note-source-link {
    display: inline-block;
    font-size: 0.85rem;
    color: #2563eb;
    margin-bottom: 6px;
    text-decoration: underline;
}

[data-theme="dark"] .note-source-link {
    color: #60a5fa;
}

.note-meta {
    font-size: 0.75rem;
    opacity: 0.8;
    text-align: right;
    font-style: italic;
}

.bulletin-box {
	display: inline-block;
    border:2px solid;
	padding:4px;
    font-size: 0.75rem;
	width: 100%;
	}

/* --- INLINE BADGE STYLE --- */
.optout-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 1px 6px;
    margin-right: 6px;
    border-radius: 4px;
    background: #eef2f7;
    color: #334e68;
    border: 1px solid #cbd5e1;
    vertical-align: middle;
}

.theme-dark .optout-badge {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}

/* --- VARIATIONS FOOTER STYLE --- */
.channel-optouts-footer {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #475569;
}

.optouts-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 8px;
}

.optout-group { margin-bottom: 6px; }
.optout-region { color: #334155; margin-right: 4px; }
.optout-time { font-weight: 600; }
.optout-title { font-style: italic; color: inherit; text-decoration: none; }
.optout-title:hover { text-decoration: underline; color: #2563eb; }

.theme-dark .channel-optouts-footer {
    border-top-color: #334155;
    color: #94a3b8;
}
.theme-dark .optouts-heading { color: #64748b; }
.theme-dark .optout-region { color: #cbd5e1; }


/* The main header block for strands like "For Schools" */
.strand-banner {
    background-color: var(--header-bg);
    color: var(--text-main);
    padding: 5px 10px;
    margin: 10px 0 5px 0;
    font-weight: bold;
    font-family: sans-serif;
    border-left: 4px solid #666;
    font-size: 0.95em;
    display: block;
    clear: both;
}

/* Indents the individual programmes that fall under a strand */
.prog-item.is-stranded {
    background-color: var(--bg-color3);
    margin-left: 12px;
    border-left: 1px dotted var(--card-border);
    padding-left: 8px;
}

.channel-card:target,
.category-listings-header:target {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.channel-card,
.category-listings-header {
    scroll-margin-top: 120px;
}