:root {
  --font: "Nunito", system-ui, sans-serif;
  --bg: #0f1116;
  --text: #f5f6fa;
  --card-bg: #181a21;
  --accent: #3d7bfd;
  --accent-hover: #2c5ecb;
  --border: #2b2e38;
  --muted: #9da5b4;
  --focus: 0 0 0 3px rgba(61, 123, 253, 0.35);
  --fade-fast: 160ms;
  --fade: 220ms;
  --bezier: cubic-bezier(0.25, 0.1, 0.25, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

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

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0 0 0.5em;
  font-weight: 700;
}
p {
  margin: 0 0 1em;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  align-self: center;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #14171f;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-self: stretch;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

#searchInput {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
#searchInput:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.button {
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  font-size: 0.9rem;
  line-height: 1;
  transition: background var(--fade) var(--bezier),
    transform var(--fade-fast) var(--bezier);
}
.button:hover {
  background: var(--accent-hover);
}
.button:active {
  transform: translateY(1px);
}
.button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button.secondary {
  background: #212530;
  border-color: var(--border);
  color: var(--text);
}
.button.tertiary {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.button.active {
  background: #204ebf;
  border-color: #1b42a3;
  color: #fff;
}

.suggestions {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  display: none;
  flex-direction: column;
  z-index: 20;
  max-height: 300px;
  overflow-y: auto;
}
.suggestions.open {
  display: flex;
}
.suggestion-item,
.suggestion-empty {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}
.suggestion-item:hover,
.suggestion-item.active {
  background: var(--accent);
  color: #fff;
}

.schedule-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  width: 100%;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity var(--fade) var(--bezier),
    transform var(--fade) var(--bezier);
}
.schedule-bar:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.schedule-bar span {
  grid-column: 2;
  justify-self: center;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}
.schedule-bar .bar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 0.5rem;
}
.schedule-bar .bar-actions .button {
  flex: 0 0 auto;
}

.home {
  padding: 1.5rem 1rem;
  text-align: center;
}
.home .section-title {
  margin-top: 1.5rem;
}

.section-title {
  font-size: 1.35rem;
}
.section-title--grid {
  grid-column: 1 / -1;
  text-align: center;
}

.teasers-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.teasers-controls {
  text-align: center;
  margin-top: 1rem;
}

.shows-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  margin: 10vh auto 12vh;
  max-width: 520px;
}
.empty-state .button {
  white-space: nowrap;
}

.show-card {
  background: var(--card-bg);
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--fade-fast) var(--bezier);
  will-change: transform;
}
.show-card:active {
  transform: translateY(1px);
}

.show-card img,
.card-preview-bg {
  width: 100%;
  display: block;
  object-fit: cover;
}

.card-content {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.card-title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.card-text {
  font-size: 0.875rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.card-text-full {
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
}

.card-actions {
  margin-top: auto;
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.fav-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) var(--bezier);
  z-index: 50;
}
.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.show-preview {
  position: fixed;
  top: 5%;
  left: 50%;
  transform: translateX(-50%) scale(0.98);
  width: 90%;
  max-width: 900px;
  min-height: 80vh;
  max-height: 90vh;
  background: var(--card-bg);
  border-radius: 0.5rem;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) var(--bezier),
    transform var(--fade) var(--bezier);
}
.show-preview.open {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  pointer-events: auto;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.close-btn {
  font-size: 1.4rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
}
.card-preview-bg {
  height: 200px;
  background-size: cover;
  background-position: center;
  margin: 0;
}
.preview-body {
  padding: 0 1rem 1rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
}

.tabbar {
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 2;
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
  margin: 0 0 1rem 0;
  padding-top: 0.75rem;
  will-change: transform;
}
.tabbar .button {
  margin-bottom: 0.25rem;
}

.teasers-highlight {
  outline: 2px solid rgba(61, 123, 253, 0.6);
  outline-offset: 3px;
  transition: outline var(--fade) var(--bezier);
}

.season-toggle {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.season-toggle::after {
  content: "⌄";
  font-weight: 900;
  transform: translateY(-1px);
}
.season-toggle[aria-expanded="true"]::after {
  content: "⌃";
}

.season-panel {
  display: none;
  padding-bottom: 0.5rem;
}
.season-panel.open {
  display: block;
}
.season-panel ul {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
}
.season-panel li {
  padding: 6px 0;
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: block;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fade) var(--bezier);
  z-index: 40;
}
.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.5);
  max-height: 80%;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transform: translateY(100%);
  transition: transform var(--fade) var(--bezier);
}
.bottom-sheet.open {
  transform: translateY(0);
}
.sheet-header,
.sheet-footer {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.sheet-footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
}
.sheet-body {
  padding: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.meta-chip {
  background: var(--border);
  border-radius: 0.25rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}
.page-indicator {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pagination-controls {
  display: flex;
  width: 100%;
  gap: 0.8rem;
  align-items: center;
  justify-content: center;
}
.pagination-controls .button {
  flex: 0 0 auto;
  min-height: 44px;
}

.skeleton-card {
  border-radius: 0.5rem;
  overflow: hidden;
  background: #151821;
  display: grid;
  grid-template-rows: 140px 1fr;
  animation: pulse 1.2s var(--bezier) infinite alternate;
}
.skel-thumb {
  background: #1b1f2a;
}
.skel-body {
  padding: 0.75rem;
}
.skel-line {
  height: 10px;
  background: #212635;
  border-radius: 4px;
  margin-bottom: 10px;
}
.skel-line.long {
  width: 80%;
}
.skel-line.mid {
  width: 60%;
}
.skel-line.short {
  width: 40%;
}

@keyframes pulse {
  from {
    opacity: 0.6;
  }
  to {
    opacity: 1;
  }
}

.no-scroll {
  overflow: hidden;
}

@media (any-hover: hover) {
  .fav-btn:hover {
    background: rgba(0, 0, 0, 0.75);
  }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-card {
    animation: none !important;
  }
  .button,
  .overlay,
  .show-preview,
  .bottom-sheet {
    transition: none !important;
  }
  html:focus-within {
    scroll-behavior: auto;
  }
}
