/**
 * Radio Classics Schedule - Vintage Radio Western Theme
 * A sleek, modern design with old-time radio and western influences
 */

/* CSS Custom Properties for Theming */
:root {
  /* Light theme - warm vintage tones */
  --bg-primary: #faf6f1;
  --bg-secondary: #f0e9df;
  --bg-tertiary: #e6ddd0;
  --bg-card: #ffffff;
  --text-primary: #2c1810;
  --text-secondary: #5c4033;
  --text-muted: #8b7355;
  --border-color: #c9b99a;
  --border-accent: #8b6914;
  --accent-primary: #8b4513;
  --accent-secondary: #a0522d;
  --accent-gold: #b8860b;
  --accent-hover: #6b3410;
  --now-playing-bg: linear-gradient(135deg, #2c1810 0%, #4a2c17 100%);
  --now-playing-text: #faf6f1;
  --today-bg: #fff8e7;
  --today-border: #daa520;
  --focus-outline: #8b4513;
  --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.1);
  --shadow-md: 0 4px 12px rgba(44, 24, 16, 0.15);
  --shadow-lg: 0 8px 24px rgba(44, 24, 16, 0.2);
  --gradient-gold: linear-gradient(135deg, #daa520 0%, #b8860b 50%, #cd853f 100%);
  --gradient-warm: linear-gradient(180deg, #faf6f1 0%, #f0e9df 100%);

  /* Typography - Larger sizes for accessibility */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-size-xs: 0.95rem;
  --font-size-sm: 1.1rem;
  --font-size-base: 1.25rem;
  --font-size-lg: 1.4rem;
  --font-size-xl: 1.6rem;
  --font-size-2xl: 1.9rem;
  --font-size-3xl: 2.5rem;
  --font-size-4xl: 3.2rem;
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-wide: 0.05em;
  --letter-spacing-wider: 0.1em;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Borders & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* Dark theme - rich warm darks */
[data-theme="dark"] {
  --bg-primary: #1a1410;
  --bg-secondary: #252019;
  --bg-tertiary: #302920;
  --bg-card: #1f1a14;
  --text-primary: #f5f0e8;
  --text-secondary: #d4c4a8;
  --text-muted: #a89070;
  --border-color: #4a3f30;
  --border-accent: #b8860b;
  --accent-primary: #daa520;
  --accent-secondary: #cd853f;
  --accent-gold: #ffd700;
  --accent-hover: #f0c040;
  --now-playing-bg: linear-gradient(135deg, #2c1810 0%, #4a2c17 100%);
  --now-playing-text: #faf6f1;
  --today-bg: #2a2418;
  --today-border: #b8860b;
  --focus-outline: #daa520;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --gradient-gold: linear-gradient(135deg, #b8860b 0%, #8b6914 50%, #a0522d 100%);
  --gradient-warm: linear-gradient(180deg, #1a1410 0%, #252019 100%);
}

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

/* Reset and Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background: var(--gradient-warm);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-primary);
  color: white;
  text-decoration: none;
  z-index: 1000;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
}

/* Decorative top border */
header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-gold);
}

h1 {
  font-family: var(--font-display);
  font-size: var(--font-size-4xl);
  font-weight: 700;
  margin: 0 0 var(--space-2) 0;
  color: var(--text-primary);
  letter-spacing: var(--letter-spacing-tight);
  line-height: var(--line-height-tight);
}

.subtitle {
  font-size: var(--font-size-lg);
  color: var(--text-muted);
  margin: 0 0 var(--space-8) 0;
  font-weight: 500;
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}

/* Search */
.search-wrapper {
  max-width: 500px;
  margin: 0 auto var(--space-6) auto;
}

.search-container {
  position: relative;
}

#show-search {
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  font-family: var(--font-body);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-base);
}

#show-search:hover {
  border-color: var(--accent-primary);
}

#show-search:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.2);
}

#show-search::placeholder {
  color: var(--text-muted);
}

button {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-sm);
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
}

button:hover {
  background-color: var(--bg-tertiary);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.3);
}

/* Main Content */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* Schedule Info Section */
.schedule-info {
  text-align: center;
  margin-bottom: var(--space-8);
}

#week-range {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 600;
  margin: 0 0 var(--space-6) 0;
  color: var(--text-primary);
}

/* Now Playing */
.now-playing {
  display: inline-block;
  background: var(--now-playing-bg);
  color: var(--now-playing-text);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-lg);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.now-playing::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-gold);
}

.now-playing:empty {
  display: none;
}

.now-playing.clickable {
  cursor: pointer;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.now-playing.clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.now-playing.clickable:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 3px;
}

/* Coming Up Section */
.coming-up {
  margin-top: var(--space-6);
}

.coming-up:empty {
  display: none;
}

.coming-up-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 var(--space-3) 0;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wider);
}

.coming-up-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.coming-up-list li {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.coming-up-list li:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* The whole card is a button that jumps to the show in the table */
.coming-up-jump {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  background: none;
  border: none;
  border-radius: inherit;
  font: inherit;
  font-size: inherit;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
}

.coming-up-jump:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 2px;
}

.coming-up-time {
  font-weight: 700;
  color: var(--accent-primary);
  margin-right: var(--space-2);
}

[data-theme="dark"] .coming-up-time {
  color: var(--accent-gold);
}

/* Table Container */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-8);
}

.table-container:focus {
  outline: none;
  box-shadow: var(--shadow-lg), 0 0 0 3px rgba(139, 69, 19, 0.2);
}

/* Schedule Table */
#schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
}

#schedule-table th,
#schedule-table td {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

#schedule-table th {
  background: var(--bg-secondary);
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--border-accent);
}

/* Header date display */
.header-date {
  display: block;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--accent-primary);
  margin-top: var(--space-1);
}

[data-theme="dark"] .header-date {
  color: var(--accent-gold);
}

#schedule-table td {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: background-color var(--transition-fast);
}

#schedule-table tbody tr:hover td {
  background: var(--bg-secondary);
}

#schedule-table tbody tr:nth-child(even) td {
  background: var(--bg-primary);
}

#schedule-table tbody tr:nth-child(even):hover td {
  background: var(--bg-secondary);
}

/* Time Column */
#schedule-table td:first-child,
#schedule-table th:first-child {
  font-weight: 600;
  white-space: nowrap;
  min-width: 140px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border-right: 2px solid var(--border-accent);
  position: sticky;
  left: 0;
  z-index: 5;
}

#schedule-table th:first-child {
  z-index: 15;
}

/* Today's Column */
.today-column {
  background: var(--today-bg) !important;
  border-left: 2px solid var(--today-border) !important;
  border-right: 2px solid var(--today-border) !important;
}

#schedule-table th.today-column {
  background: var(--today-bg) !important;
  border-top: 2px solid var(--today-border);
}

/* Current Time Slot */
.current-slot {
  background: linear-gradient(135deg, rgba(218, 165, 32, 0.2) 0%, rgba(184, 134, 11, 0.15) 100%) !important;
  font-weight: 600;
  color: var(--text-primary) !important;
  position: relative;
}

.current-slot::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-gold);
}

/* Brief flash when a cell is jumped to from "now playing" / "coming up" */
.slot-flash {
  animation: slot-flash 1.6s ease-out;
}

@keyframes slot-flash {
  0%, 30% {
    background: linear-gradient(135deg, rgba(218, 165, 32, 0.55) 0%, rgba(184, 134, 11, 0.45) 100%);
    box-shadow: inset 0 0 0 2px var(--accent-gold);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* Search Highlight */
.search-match {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
  color: #2c1810;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

[data-theme="dark"] .search-match {
  background: linear-gradient(135deg, #b8860b 0%, #daa520 100%);
  color: #1a1410;
}

/* Hidden Rows */
.hidden-row {
  display: none;
}

/* No Results */
.no-results {
  text-align: center;
  padding: var(--space-12);
  color: var(--text-muted);
}

.no-results p {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
}

.no-results button {
  margin-top: var(--space-4);
}

/* Error Message */
.error-message {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 2px solid #ef4444;
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  color: #991b1b;
}

[data-theme="dark"] .error-message {
  background: linear-gradient(135deg, #2a1a1a 0%, #3a1a1a 100%);
  border-color: #dc2626;
  color: #fca5a5;
}

/* Loading Message */
.loading-message {
  text-align: center;
  font-size: var(--font-size-xl);
  padding: var(--space-12);
  color: var(--text-muted);
}

/* Footer */
footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--text-muted);
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-gold);
}

footer p {
  margin: var(--space-2) 0;
}

footer a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

[data-theme="dark"] footer a {
  color: var(--accent-gold);
}

footer a:focus {
  outline: none;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.footer-note {
  font-size: var(--font-size-sm);
  font-style: italic;
  opacity: 0.8;
}

/* Collapsible "add to home screen" tip */
.install-tip {
  max-width: 32rem;
  margin: 0 auto var(--space-6);
  text-align: left;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--space-3);
  padding: 0 var(--space-5);
}

.install-tip summary {
  cursor: pointer;
  padding: var(--space-4) 0;
  font-weight: 600;
  color: var(--text-secondary);
  list-style-position: inside;
}

.install-tip summary:hover {
  color: var(--accent-primary);
}

.install-tip summary:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  border-radius: var(--space-1);
}

[data-theme="dark"] .install-tip summary:hover {
  color: var(--accent-gold);
}

.install-tip-body {
  padding-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

.install-tip-body p {
  margin: var(--space-2) 0;
}

.install-platform {
  font-size: var(--font-size-sm);
}

/* Hide the tip once the page is launched as an installed app */
@media (display-mode: standalone) {
  .install-tip {
    display: none;
  }
}

.install-tip[hidden] {
  display: none;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
  border: 3px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Print Styles */
@media print {
  body {
    font-size: 11pt;
    color: black;
    background: white;
  }

  header::before,
  footer::before,
  .now-playing::before,
  .current-slot::after {
    display: none;
  }

  header .controls,
  .skip-link,
  #theme-toggle,
  #today-btn,
  #show-search,
  .coming-up,
  footer {
    display: none;
  }

  .table-container {
    box-shadow: none;
    border: 1px solid #000;
  }

  #schedule-table th,
  #schedule-table td {
    border: 1px solid #000;
  }

  .today-column,
  .current-slot {
    background: none !important;
  }
}

/* Responsive */
@media screen and (max-width: 768px) {
  html {
    font-size: 16px;
  }

  /* Compact header on mobile - minimize wasted space */
  header {
    padding: var(--space-3) var(--space-4);
  }

  header::before {
    height: 2px;
  }

  h1 {
    font-size: var(--font-size-lg);
    margin-bottom: 0;
  }

  .subtitle {
    display: none;
  }

  /* Compact schedule info */
  .schedule-info {
    margin-bottom: var(--space-4);
  }

  #week-range {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-3);
  }

  main {
    padding: var(--space-3) var(--space-3);
  }

  .now-playing {
    font-size: var(--font-size-base);
    padding: var(--space-2) var(--space-3);
  }

  .coming-up {
    margin-top: var(--space-3);
  }

  .coming-up-label {
    margin-bottom: var(--space-2);
  }

  .coming-up-list {
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
  }

  .coming-up-list li {
    width: 100%;
    max-width: 350px;
    text-align: center;
    padding: var(--space-2) var(--space-3);
  }

  /* Search bar compact */
  .search-wrapper {
    margin-bottom: var(--space-4);
  }

  #show-search {
    padding: var(--space-2) var(--space-4);
  }

  .table-container {
    border-radius: var(--radius-md);
    margin-left: calc(var(--space-3) * -1);
    margin-right: calc(var(--space-3) * -1);
  }

  #schedule-table {
    min-width: 800px;
  }

  #schedule-table th,
  #schedule-table td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
  }

  #schedule-table td:first-child,
  #schedule-table th:first-child {
    min-width: 110px;
  }

  /* Compact footer */
  footer {
    padding: var(--space-4) var(--space-4);
  }

  footer::before {
    height: 2px;
  }

  footer p {
    margin: var(--space-1) 0;
    font-size: var(--font-size-xs);
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }

  [data-theme="dark"] {
    --border-color: #ffffff;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
