/* WKND — a teletext-style weekend guide */

:root {
  --ink: #0c1420;
  --ink-raised: #101b2c;
  --paper: #f1efe6;
  --paper-dim: #c9c6ba;
  --cyan: #4fd7d0;
  --amber: #e8c64e;
  --red: #e15554;
  --line: rgba(241, 239, 230, 0.18);

  --cat-art: #d3599a;
  --cat-film: #4fd7d0;
  --cat-food: #e8c64e;
  --cat-literature: #9c8fd9;
  --cat-music: #59c2a6;
  --cat-outdoors: #7fbf5b;
  --cat-walks: #5b9bd9;

  --font: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono",
    "Roboto Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;

  --radius: 2px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(241, 239, 230, 0.035) 0px,
    rgba(241, 239, 230, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
}

.skip-link {
  position: absolute;
  left: 0;
  top: -3rem;
  background: var(--amber);
  color: var(--ink);
  padding: 0.6rem 1rem;
  font-family: var(--font);
  font-weight: 700;
  z-index: 100;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

#tune-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: repeating-linear-gradient(
    170deg,
    #0c1420 0px,
    #0c1420 2px,
    #1c2740 2px,
    #1c2740 4px
  );
  animation: tune-in 0.6s steps(6, end) forwards;
  pointer-events: none;
}

@keyframes tune-in {
  0% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  #tune-overlay {
    display: none;
  }
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

button,
input,
select {
  font-family: inherit;
}

a {
  color: var(--cyan);
}

/* Masthead */

.masthead {
  position: relative;
  z-index: 1;
  border-bottom: 3px solid var(--paper);
  padding: 1.5rem 1.25rem 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
}

.masthead-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.wordmark-block {
  min-width: 0;
}

.callsign {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--amber);
  line-height: 1;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--paper-dim);
  font-size: 0.95rem;
  max-width: 32ch;
}

.onair-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 2px solid var(--paper);
  color: var(--paper);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  align-self: flex-start;
}

.onair-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--red);
  flex: none;
}

.tuner {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem 1.25rem;
}

.tuner-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 200px;
  min-width: 160px;
}

.tuner-field label {
  font-size: 0.85rem;
  color: var(--paper-dim);
  font-weight: 700;
}

#search,
#category-filter {
  background: var(--ink-raised);
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  font-size: 1rem;
  min-height: 2.75rem;
}

#search::placeholder {
  color: var(--paper-dim);
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--ink-raised);
  color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  min-height: 2.75rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}

.saved-toggle:hover {
  background: #17233a;
}

.saved-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 2px solid var(--paper-dim);
  flex: none;
}

.saved-toggle[aria-pressed="true"] {
  background: var(--amber);
  color: var(--ink);
  border-color: var(--amber);
}

.saved-toggle[aria-pressed="true"] .saved-dot {
  background: var(--red);
  border-color: var(--red);
}

/* Main / empty state */

main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.empty-state {
  border: 2px dashed var(--paper-dim);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.empty-heading {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--amber);
}

.empty-body {
  margin: 0 0 1.25rem;
  color: var(--paper-dim);
}

#reset-filters {
  background: var(--amber);
  color: var(--ink);
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 2.75rem;
}

#reset-filters:hover {
  filter: brightness(1.08);
}

/* Guide pages */

.guide {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 800px) {
  .guide {
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .page + .page {
    border-left: 2px solid var(--line);
    padding-left: 2rem;
    margin-left: 2rem;
  }
}

.page h2 {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--cyan);
  color: var(--paper);
}

.page h2 .day-date {
  font-size: 1rem;
  font-weight: 400;
  color: var(--paper-dim);
}

.listing {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.no-programs {
  color: var(--paper-dim);
  border: 2px dashed var(--line);
  padding: 1rem;
  font-size: 0.9rem;
}

.program {
  margin: 0;
}

.open-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  width: 100%;
  text-align: left;
  background: var(--ink-raised);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper);
  padding: 0.85rem;
  cursor: pointer;
  min-height: 3rem;
}

.open-item:hover {
  border-color: var(--paper-dim);
}

.page-badge {
  flex: none;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  border-radius: var(--radius);
}

.program-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.program-time {
  font-size: 0.85rem;
  color: var(--cyan);
  font-weight: 700;
}

.program-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--paper);
}

.program-meta {
  font-size: 0.85rem;
  color: var(--paper-dim);
}

.program-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.chip {
  display: inline-block;
  border: 1px solid var(--paper-dim);
  color: var(--paper-dim);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius);
}

.chip.saved-chip {
  border-color: var(--amber);
  color: var(--amber);
}

/* Detail dialog */

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 14, 0.78);
  z-index: 50;
}

.detail {
  position: fixed;
  z-index: 51;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(600px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--ink);
  border: 3px solid var(--paper);
  padding: 1.5rem;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-channel {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}

.detail-channel .page-badge {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.2rem;
}

.detail-channel .category-name {
  font-weight: 700;
  color: var(--paper-dim);
}

.close-detail {
  flex: none;
  background: transparent;
  border: 2px solid var(--paper);
  color: var(--paper);
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: var(--radius);
}

.close-detail:hover {
  background: var(--ink-raised);
}

.detail h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--amber);
}

.detail-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 2px solid var(--line);
}

.detail-facts div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.detail-facts dt {
  font-size: 0.75rem;
  color: var(--paper-dim);
  font-weight: 700;
}

.detail-facts dd {
  margin: 0;
  font-weight: 700;
  color: var(--paper);
}

.detail-body {
  margin: 0 0 1.5rem;
  color: var(--paper);
}

.detail-body p {
  margin: 0 0 0.9rem;
  max-width: 62ch;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.save-item {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--amber);
  color: var(--ink);
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  min-height: 2.75rem;
}

.save-item:hover {
  filter: brightness(1.08);
}

.save-item[aria-pressed="true"] {
  background: var(--ink-raised);
  color: var(--paper);
  border: 2px solid var(--amber);
}

.save-item .saved-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--ink);
}

.save-item[aria-pressed="true"] .saved-dot {
  background: var(--red);
}

@media (max-width: 480px) {
  .detail-facts {
    grid-template-columns: 1fr;
  }

  .masthead {
    padding: 1.25rem 1rem 1rem;
  }

  main {
    padding: 1.25rem 1rem 3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
