/* ============================================================
   WKND·TV — channel guide for the weekend
   A dim living room, a paper TV Guide on the table, a screen
   that lights up when you tune in.
   ============================================================ */

:root {
  --room: #16120e;
  --room-deep: #0c0a08;
  --paper: #f3e9d5;
  --paper-dim: #e6d8ba;
  --ink: #251d13;
  --ink-soft: #5b4d38;
  --signal: #e0552a;
  --signal-dark: #a83f1e;
  --phosphor: #3fd39a;
  --phosphor-dim: #176b4a;
  --tube: #071310;
  --tube-deep: #030807;
  --room-muted: #bcae92;

  --font-display: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-mono: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --ease-signature: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--room);
  background-image: radial-gradient(ellipse at 50% -10%, #2a2118 0%, var(--room) 55%);
  color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.detail-open {
  overflow: hidden;
}

::selection {
  background: var(--signal);
  color: var(--paper);
}

::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
::-webkit-scrollbar-track {
  background: var(--room-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--ink-soft);
  border: 3px solid var(--room-deep);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--signal);
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--phosphor);
  color: var(--room-deep);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  z-index: 500;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ---------------------------------------------------------- */
/* Station ID header                                           */
/* ---------------------------------------------------------- */

.station-id {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
  border-bottom: 1px solid #2c241a;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.wordmark__bars {
  display: inline-flex;
  height: 2.1rem;
  width: 2.6rem;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}
.wordmark__bars span {
  flex: 1;
}
.wordmark__bars span:nth-child(1) { background: #e6e0c8; }
.wordmark__bars span:nth-child(2) { background: #e0552a; }
.wordmark__bars span:nth-child(3) { background: #3fd39a; }
.wordmark__bars span:nth-child(4) { background: #4c7fd6; }
.wordmark__bars span:nth-child(5) { background: #251d13; }

.wordmark__text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  letter-spacing: -0.01em;
  color: var(--paper);
}
.wordmark__dot {
  color: var(--room-muted);
  padding: 0 0.05em;
}
.wordmark__tv {
  color: var(--signal);
}

.station-id__tagline {
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--room-muted);
}
.station-id__tagline span {
  color: var(--phosphor);
}

.on-air {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--signal);
  border: 1px solid var(--signal-dark);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}
.on-air__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 8px 1px var(--signal);
  animation: blink-dot 2.2s ease-in-out infinite;
}

@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------------------------------------------------------- */
/* Remote control bar                                          */
/* ---------------------------------------------------------- */

main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 4rem;
}

.remote {
  color-scheme: light;
  margin-top: 1.75rem;
  background: var(--paper);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.6), 0 2px 0 rgba(255, 255, 255, 0.04) inset;
}

.remote__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: end;
}

.remote__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--ink);
}
.remote__field--search {
  flex: 1 1 16rem;
}
.remote__field--select {
  flex: 0 1 13rem;
}

.remote__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.remote__control {
  position: relative;
  display: flex;
  align-items: center;
}
.remote__icon {
  position: absolute;
  left: 0.7rem;
  width: 1.05rem;
  height: 1.05rem;
  color: var(--ink-soft);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 0.65rem 0.8rem 0.65rem 2.2rem;
  border-radius: 8px;
  border: 1.5px solid var(--paper-dim);
  background: #fffcf4;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
#search-input::placeholder {
  color: var(--ink-soft);
}

#filter-select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  border: 1.5px solid var(--paper-dim);
  background: #fffcf4;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.remote__button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-signature), color 0.15s var(--ease-signature);
}
.remote__button:hover {
  background: var(--ink);
  color: var(--paper);
}
.remote__button--active {
  background: var(--phosphor-dim);
  border-color: var(--phosphor-dim);
  color: var(--paper);
}
.remote__button--active:hover {
  background: var(--phosphor);
  border-color: var(--phosphor);
  color: var(--room-deep);
}
.remote__icon svg,
.remote__button .remote__icon {
  position: static;
  width: 1.1rem;
  height: 1.1rem;
  color: inherit;
  flex-shrink: 0;
}

.remote__count {
  margin: 0.85rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  min-height: 1.1em;
}

/* ---------------------------------------------------------- */
/* Guide — day pages and listings                               */
/* ---------------------------------------------------------- */

.day-page {
  margin-top: 2.5rem;
}

.day-page__heading {
  margin: 0 0 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--paper);
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--signal-dark);
}

.listings {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--paper);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.6);
}

.listing {
  display: grid;
  grid-template-columns: 4.5rem 8.5rem 1fr 9rem;
  gap: 1rem;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px dashed var(--paper-dim);
  transition: background-color 0.15s var(--ease-signature);
}
.listing:last-child {
  border-bottom: none;
}
.listing:hover {
  background: #ece0c5;
}

.listing__channel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.3rem;
}
.listing__ch-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: rgba(243, 233, 213, 0.65);
}
.listing__ch-number {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--phosphor);
  text-shadow: 0 0 6px rgba(63, 211, 154, 0.55);
}

.listing__time {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.listing__time-range {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink);
}
.listing__free {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--signal-dark);
  color: var(--paper);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}

.listing__info {
  min-width: 0;
}
.listing__title {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.listing__summary {
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
  max-width: 60ch;
}
.listing__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  line-height: 1.4;
}
.badge--category {
  background: rgba(224, 85, 42, 0.14);
  color: var(--signal-dark);
  border: 1px solid rgba(224, 85, 42, 0.5);
}
.badge--format {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--ink-soft);
}

.listing__action {
  display: flex;
  justify-content: flex-end;
}
.listing__tune {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-signature), transform 0.15s var(--ease-signature);
  white-space: nowrap;
}
.listing__tune:hover {
  background: var(--signal-dark);
  transform: translateY(-1px);
}
.listing__tune:active {
  transform: translateY(0);
}

/* ---------------------------------------------------------- */
/* No signal / empty state                                     */
/* ---------------------------------------------------------- */

.no-signal {
  margin-top: 2.5rem;
  text-align: center;
  padding: 2.5rem 1.5rem 3rem;
}

.no-signal__screen {
  width: min(100%, 22rem);
  aspect-ratio: 4 / 3;
  margin: 0 auto 1.5rem;
  border-radius: 10px;
  background-color: #0f0f10;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 1px, transparent 1px, transparent 3px),
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.12), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1), transparent 45%),
    radial-gradient(circle at 60% 20%, rgba(255, 255, 255, 0.08), transparent 35%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 6px solid var(--ink);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.7);
}
.no-signal__glyph {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  color: #f4f4f4;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.no-signal__heading {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 0.5rem;
  color: var(--paper);
}
.no-signal__body {
  margin: 0 auto 1.25rem;
  max-width: 32ch;
  color: var(--room-muted);
}
.no-signal__reset {
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  border: 1.5px solid var(--phosphor);
  background: transparent;
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-signature), color 0.15s var(--ease-signature);
}
.no-signal__reset:hover {
  background: var(--phosphor);
  color: var(--room-deep);
}

/* ---------------------------------------------------------- */
/* CRT detail overlay                                           */
/* ---------------------------------------------------------- */

.crt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 3, 2, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
  overflow-y: auto;
}
.crt-overlay[hidden] {
  display: none;
}

.crt {
  position: relative;
  width: min(100%, 42rem);
  max-height: calc(100vh - 3rem);
  background: linear-gradient(155deg, #3a2f22, #1c1712);
  border-radius: 28px;
  padding: 1.1rem;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  animation: power-on 0.4s var(--ease-signature);
}

@keyframes power-on {
  from {
    opacity: 0;
    transform: scale(0.97);
    filter: brightness(2.4) blur(2px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: brightness(1) blur(0);
  }
}

.crt__screen {
  position: relative;
  z-index: 1;
  background: radial-gradient(120% 120% at 50% 0%, #0c1f19 0%, var(--tube) 55%, var(--tube-deep) 100%);
  border-radius: 18px;
  padding: 1.6rem 1.6rem 2rem;
  overflow-y: auto;
  max-height: calc(100vh - 5.5rem);
  color: var(--paper);
}

.crt__scanlines {
  position: absolute;
  z-index: 2;
  inset: 1.1rem;
  border-radius: 18px;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.035) 0px,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}
.crt__vignette {
  position: absolute;
  z-index: 2;
  inset: 1.1rem;
  border-radius: 18px;
  pointer-events: none;
  box-shadow: inset 0 0 90px 20px rgba(0, 0, 0, 0.65);
}

.crt__osd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}
.crt__channel-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--phosphor);
  border: 1px solid var(--phosphor-dim);
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: rgba(63, 211, 154, 0.08);
}
.crt__now {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: #a9d9c6;
}
.crt__close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid rgba(243, 233, 213, 0.4);
  color: var(--paper);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-signature);
}
.crt__close:hover {
  background: rgba(243, 233, 213, 0.14);
}
.crt__close svg {
  width: 0.85rem;
  height: 0.85rem;
}

.crt__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.15;
  color: var(--paper);
}
.crt__location {
  margin: 0 0 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #8fd8b9;
}

.crt__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}
.crt__badges .badge--format {
  border-color: rgba(243, 233, 213, 0.4);
  color: var(--paper);
}
.crt__badges .badge--price {
  background: rgba(63, 211, 154, 0.08);
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor);
}

.rec-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid rgba(224, 85, 42, 0.6);
  background: rgba(224, 85, 42, 0.08);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: 1.4rem;
  transition: background-color 0.15s var(--ease-signature), border-color 0.15s var(--ease-signature);
}
.rec-button:hover {
  background: rgba(224, 85, 42, 0.18);
}
.rec-button__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1.5px solid var(--signal);
  flex-shrink: 0;
}
.rec-button--recording {
  border-color: var(--signal);
  background: rgba(224, 85, 42, 0.22);
}
.rec-button--recording .rec-button__dot {
  background: var(--signal);
  box-shadow: 0 0 10px 2px rgba(224, 85, 42, 0.7);
  animation: blink-dot 1.4s ease-in-out infinite;
}

.crt__body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: #ece3d1;
  max-width: 62ch;
}
.crt__body p {
  margin: 0 0 1em;
}
.crt__body p:last-child {
  margin-bottom: 0;
}

.crt__cc {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(243, 233, 213, 0.15);
}
.cc-badge {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1.5px solid var(--phosphor);
  color: var(--phosphor);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  line-height: 1.3;
}
.crt__cc p {
  margin: 0;
  font-size: 0.88rem;
  color: #a9d9c6;
  line-height: 1.55;
}

/* ---------------------------------------------------------- */
/* Responsive: mobile                                           */
/* ---------------------------------------------------------- */

@media (max-width: 640px) {
  .station-id {
    flex-direction: column;
    gap: 0.75rem;
  }

  .remote__row {
    flex-direction: column;
    align-items: stretch;
  }
  .remote__field--select {
    flex-basis: auto;
  }
  .remote__button {
    justify-content: center;
  }

  .listing {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'channel time'
      'info info'
      'action action';
    row-gap: 0.75rem;
  }
  .listing__channel {
    grid-area: channel;
    flex-direction: row;
    justify-content: flex-start;
    width: fit-content;
    padding: 0.35rem 0.6rem;
  }
  .listing__time {
    grid-area: time;
    align-items: flex-end;
  }
  .listing__info {
    grid-area: info;
  }
  .listing__action {
    grid-area: action;
  }
  .listing__tune {
    width: 100%;
  }

  .crt {
    border-radius: 20px;
    padding: 0.8rem;
  }
  .crt__screen {
    padding: 1.2rem 1.1rem 1.6rem;
    border-radius: 14px;
  }
  .crt__scanlines,
  .crt__vignette {
    inset: 0.8rem;
    border-radius: 14px;
  }
  .crt__close span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ---------------------------------------------------------- */
/* Reduced motion                                               */
/* ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .on-air__dot {
    animation: none;
    opacity: 1;
  }
  .rec-button--recording .rec-button__dot {
    animation: none;
  }
  .crt {
    animation: none;
  }
}
