/* =========================================================
   GLOBAL
   ========================================================= */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 2rem;

  font-family:
    Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  background:
    radial-gradient(circle at top left, #1e293b 0%, transparent 35%),
    linear-gradient(135deg, #0f172a, #111827 55%, #1e1b4b);

  color: #e2e8f0;
}


/* =========================================================
   MAIN
   ========================================================= */

#root {
  width: min(1500px, 100%);
  margin: 0 auto;
}


/* =========================================================
   VIEWS
   ========================================================= */

#shows-view,
#episodes-view {
  width: 100%;
}


/* =========================================================
   CONTROLS
   ========================================================= */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;

  margin-bottom: 2rem;
  padding: 1.25rem;

  background: rgba(30, 41, 59, 0.9);

  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;

  box-shadow:
    0 15px 40px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);

  backdrop-filter: blur(10px);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;

  min-width: 220px;
}

.control-group label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;

  color: #94a3b8;
}

.control-group input,
.control-group select {
  min-height: 44px;

  padding: 0.65rem 0.9rem;

  font: inherit;
  font-size: 0.95rem;

  color: #e2e8f0;
  background: #0f172a;

  border: 1px solid #475569;
  border-radius: 10px;

  outline: none;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

.control-group input {
  min-width: 280px;
}

.control-group input::placeholder {
  color: #64748b;
}

.control-group input:focus,
.control-group select:focus {
  border-color: #818cf8;

  box-shadow:
    0 0 0 3px rgba(129, 140, 248, 0.18);

  background: #111827;
}

.control-group select {
  cursor: pointer;
}


/* =========================================================
   SELECTED SHOW
   ========================================================= */

#selected-show {
  display: flex;
  align-items: center;

  min-height: 44px;

  padding: 0.65rem 0;

  color: #a5b4fc;

  font-size: 1.2rem;
  font-weight: 800;

  line-height: 1.4;
}


/* =========================================================
   BACK TO SHOWS
   ========================================================= */

#back-to-shows {
  min-height: 44px;

  padding: 0.65rem 1rem;

  border: 1px solid #475569;
  border-radius: 10px;

  background: #1e293b;
  color: #e2e8f0;

  font: inherit;
  font-weight: 600;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

#back-to-shows:hover {
  background: #334155;
  border-color: #818cf8;

  transform: translateX(-3px);
}

#back-to-shows:focus-visible {
  outline: 3px solid rgba(129, 140, 248, 0.45);
  outline-offset: 2px;
}


/* =========================================================
   EPISODE COUNT
   ========================================================= */

#episode-count {
  margin: 0 0 0 auto;

  color: #a5b4fc;

  font-size: 0.9rem;
  font-weight: 700;
}


/* =========================================================
   SHOW LIST
   ========================================================= */

#show-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

  width: 100%;
}


/* =========================================================
   SHOW CARD
   ========================================================= */

.show-card {
  width: min(1400px, 100%);
  margin: 0 auto;

  padding: 0;

  background:
    linear-gradient(145deg,
      rgba(30, 41, 59, 0.98),
      rgba(15, 23, 42, 0.98));

  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;

  overflow: hidden;

  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.25);

  cursor: pointer;

  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.show-card:hover {
  transform: translateY(-5px);

  border-color: rgba(129, 140, 248, 0.7);

  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(129, 140, 248, 0.1);
}


/* =========================================================
   SHOW TITLE
   ========================================================= */

.show-card h2 {
  margin: 0;

  padding: 1rem 1.5rem;

  background:
    linear-gradient(135deg,
      #4f46e5,
      #7c3aed);

  color: #ffffff;

  font-size: 1.25rem;
  font-weight: 700;

  line-height: 1.4;
}


/* =========================================================
   SHOW CONTENT
   ========================================================= */

.show-content {
  display: grid;

  grid-template-columns:
    210px minmax(0, 1fr) 220px;

  gap: 1.5rem;

  padding: 1.5rem;

  align-items: stretch;
}


/* =========================================================
   SHOW IMAGE
   ========================================================= */

.show-image {
  display: flex;

  align-items: flex-start;
  justify-content: center;
}

.show-image img {
  display: block;

  width: 210px;
  height: auto;

  max-width: 100%;

  object-fit: contain;

  border-radius: 12px;

  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.3);
}


/* =========================================================
   SHOW SUMMARY
   ========================================================= */

.show-summary {
  min-width: 0;

  color: #cbd5e1;

  line-height: 1.7;
  font-size: 0.95rem;
}

.show-summary .summary {
  padding: 0;
}

.show-summary .summary p {
  margin-top: 0;
}


/* =========================================================
   SHOW DETAILS
   ========================================================= */

.show-details {
  align-self: stretch;

  padding: 1rem 1.1rem;

  background: rgba(15, 23, 42, 0.75);

  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 12px;
}

.show-details p {
  margin: 0;

  padding: 0.65rem 0;

  color: #cbd5e1;

  font-size: 0.9rem;

  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.show-details p:last-child {
  border-bottom: none;
}


/* =========================================================
   EPISODE LIST
   ========================================================= */

#episode-list {
  display: grid;

  grid-template-columns:
    repeat(auto-fit, minmax(300px, 1fr));

  gap: 1.5rem;

  width: 100%;
}


/* =========================================================
   EPISODE CARD
   ========================================================= */

#episode-list article {
  display: flex;
  flex-direction: column;

  width: 100%;
  max-width: 420px;

  min-width: 0;

  justify-self: center;

  background:
    linear-gradient(145deg,
      #1e293b,
      #0f172a);

  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;

  overflow: hidden;

  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.25);

  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}

#episode-list article:hover {
  transform: translateY(-5px);

  border-color: rgba(129, 140, 248, 0.5);

  box-shadow:
    0 18px 35px rgba(0, 0, 0, 0.35);
}


/* =========================================================
   EPISODE TITLE
   ========================================================= */

#episode-list article h2 {
  display: flex;

  align-items: center;
  justify-content: center;

  min-height: 5rem;

  margin: 0;
  padding: 1rem;

  text-align: center;

  background:
    linear-gradient(135deg,
      #4f46e5,
      #7c3aed);

  color: #ffffff;

  font-size: 1.05rem;
  font-weight: 700;

  line-height: 1.4;
}


/* =========================================================
   EPISODE IMAGE
   ========================================================= */

#episode-list article img {
  display: block;

  width: 100%;
  height: auto;
}


/* =========================================================
   EPISODE SUMMARY
   ========================================================= */

#episode-list article .summary {
  flex: 1;

  padding: 1.2rem;

  color: #cbd5e1;

  line-height: 1.65;
  font-size: 0.94rem;
}

#episode-list article .summary p {
  margin-top: 0;
}


/* =========================================================
   TVMAZE LINK
   ========================================================= */

#episode-list article a {
  align-self: flex-start;

  margin: 0 1.2rem 1.2rem;

  padding: 0.6rem 1rem;

  background: #4f46e5;
  color: #ffffff;

  border-radius: 999px;

  text-decoration: none;

  font-size: 0.9rem;
  font-weight: 700;

  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

#episode-list article a:hover {
  background: #6366f1;

  transform: translateY(-2px);
}


/* =========================================================
   LOADING / ERROR
   ========================================================= */

.loading,
.error {
  display: flex;

  align-items: center;
  justify-content: center;

  min-height: 300px;
  width: 100%;

  color: #a5b4fc;

  font-size: 1.1rem;
  font-weight: 600;

  text-align: center;
}

.error {
  color: #fca5a5;
}


/* =========================================================
   FOOTER
   ========================================================= */

footer {
  width: min(1500px, 100%);

  margin: 3rem auto 0;
  padding: 1.25rem;

  text-align: center;

  color: #94a3b8;

  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

footer a {
  color: #a5b4fc;

  font-weight: 600;

  text-decoration: none;

  transition: color 0.2s ease;
}

footer a:hover {
  color: #c4b5fd;
  text-decoration: underline;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {
  body {
    padding: 1.25rem;
  }

  .show-content {
    grid-template-columns:
      180px minmax(0, 1fr);
  }

  .show-image img {
    width: 180px;
    height: auto;
  }

  .show-details {
    grid-column: 1 / -1;
  }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {
  body {
    padding: 0.75rem;
  }

  .controls {
    align-items: stretch;

    padding: 1rem;

    border-radius: 14px;
  }

  #selected-show {
    width: 100%;

    justify-content: center;

    text-align: center;
  }

  .control-group {
    width: 100%;

    min-width: 0;
  }

  .control-group input,
  .control-group select {
    width: 100%;

    min-width: 0;
  }

  #back-to-shows {
    width: 100%;
  }

  #episode-count {
    width: 100%;

    margin: 0;

    text-align: center;
  }

  .show-content {
    grid-template-columns: 1fr;

    gap: 1rem;

    padding: 1rem;
  }

  .show-image {
    justify-content: center;
  }

  .show-image img {
    width: 100%;
    max-width: 320px;
    height: auto;

    aspect-ratio: 16 / 9;
  }

  .show-details {
    grid-column: auto;
  }

  .show-card h2 {
    padding: 0.9rem 1rem;

    font-size: 1.1rem;
  }

  #episode-list {
    grid-template-columns: 1fr;
  }

  #episode-list article {
    max-width: 420px;
  }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

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

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}