/* ------------------------------
   Global Theme Variables
------------------------------ */
:root {
  --card-bg: #ffffff;
  --page-bg: #f6f8fa;
  --text: #0f1720;
  --muted: #5b6b76;
  --accent: #0b76d1;
  --dark-bg: #111;
  --dark-text: #ffffff;
}

/* ------------------------------
   Reset & Base Layout
------------------------------ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.4;
}

/* Center main content */
main#root {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ------------------------------
   Header Banner
------------------------------ */
header {
  width: 100%;
  background: var(--dark-bg);
  color: var(--dark-text);
  text-align: center;
  padding: 1.5rem 1rem;
  margin: 0;
}

header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

header .attribution {
  margin: 0.3rem 0 0;
  color: #ccc;
}

header a {
  color: #4db8ff;
  text-decoration: none;
}

/* ------------------------------
   Toolbar (Search + Show + Episode)
------------------------------ */
#toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;     /* allows wrapping on small screens */
  gap: 1rem;
  max-width: 1200px;
  margin: 1rem auto;
  padding: 0 1rem;
}

#toolbar input,
#toolbar select,
#toolbar button {
  padding: 0.55rem;
  font-size: 1rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
}

#toolbar button {
  background-color: var(--card-bg);
  cursor: pointer;
}

#toolbar button:hover {
  background-color: #eee;
}

#toolbar input {
  max-width: 250px;
  width: 100%;
}

#toolbar select {
  max-width: 220px;
}

#search-count {
  width: 100%;
  text-align: center;
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ------------------------------
   Shows Grid (NEW)
------------------------------ */
.shows-root {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Wider for shows */
  align-items: start;
  padding: 0;
}

/* Show Cards (NEW) */
.show-card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(11, 16, 22, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  cursor: pointer; /* Indicate clickability */
}

.show-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(11, 16, 22, 0.08);
}

.show-media {
  width: 100%;
  height: 180px; /* Fixed height for image */
  object-fit: cover;
  background: #e9eef4;
}

.show-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.show-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.show-meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.show-summary {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; /* Limit summary lines for uniform height */
  text-overflow: ellipsis;
}


/* ------------------------------
   Episodes Grid
------------------------------ */
.episodes-root {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: start;
  padding: 0;
}

/* Loading message spanning full width */
.episodes-root > .loading {
  grid-column: 1 / -1;
  text-align: center;
  margin: 0;
  padding: 0.5rem;
  color: var(--muted);
}

/* ------------------------------
   Episode Cards
------------------------------ */
.episode-card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(11, 16, 22, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.episode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 18px rgba(11, 16, 22, 0.08);
}

/* Episode image */
.episode-media {
  width: 100%;
  height: 160px; /* Fixed height for image */
  object-fit: cover;
  background: #e9eef4;
}

/* Episode body */
.episode-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.episode-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.2;
}

.episode-meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.episode-summary {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  /* Line clamping for uniform height */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; 
  text-overflow: ellipsis;
}

/* Link */
.episode-body a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  margin-top: 0.5rem;
}

/* Error styling */
.error {
  color: red;
  font-weight: bold;
  text-align: center;
}

/* ------------------------------
   Footer Banner
------------------------------ */
footer {
  width: 100%;
  background: var(--dark-bg);
  color: var(--dark-text);
  text-align: center;
  padding: 1.25rem 1rem;
  margin-top: 2rem;
}

footer a {
  color: #4db8ff;
  text-decoration: none;
}

/* ------------------------------
   Mobile Adjustments
------------------------------ */
@media (max-width: 480px) {
  .episode-media {
    height: 140px;
  }
  .show-media {
    height: 160px;
  }

  main#root {
    padding: 0.75rem;
  }
}