/* All Time Stats */

html, body {
  overflow-x: hidden;
}

#all-time-stats {
  text-align: center;
  margin: 4rem auto 2rem;
  max-width: var(--max-width-lg);
}

#all-time-stats h2 {
  font-size: var(--font-size-xxl);
  margin-bottom: 0.25rem;
}

#all-time-stats h3 {
  font-size: var(--font-size-md);
  font-weight: normal;
  color: #888;
  margin-bottom: 2rem;
}

.stat-block {
  display: flex;
  justify-content: center;
  gap: 5rem;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-family: var(--font-slab);
  font-size: var(--font-size-jumbo);
  font-weight: bold;
  display: block;
}

.stat-label {
  font-size: 0.9rem;
  color: #666;
}

/* Genre Stats */

#genre-stats {
  margin: 2rem;
  min-width: var(--max-width-sm);
  max-width: var(--max-width-md);
}

#genre-stats h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: 1.5rem;
}

.bar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.bar-list li {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.bar-label {
  flex: 0 0 150px;
  font-size: 0.95rem;
  font-weight: 500;
}

.bar-count {
  margin-left: 0.5rem;
  font-size: 0.85rem;
  color: #666;
  width: 30px;
  text-align: right;
}

.bar-fill {
  flex: 1;
  background: none;
  overflow: hidden;
  margin: 0 0.5rem;
  height: 8px;
  position: relative;
}

.bar-fill::before {
  content: "";
  display: block;
  height: 100%;
  background-color: #333;
  width: var(--bar-percent);
  transition: width 0.3s ease;
}

/* Top Directors */

#top-directors {
  margin: 4rem auto 2rem;
  max-width: 1200px;
  padding: 0 1rem;
}

#top-directors h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: 2rem;
}

#director-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  justify-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

#yearly-director-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  justify-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.person-card {
  padding: 1rem;
  border-radius: 8px;
  width: 100%;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.person-photo {
  width: 200px;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.person-name {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
}

.person-count {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-md);
  font-size: 0.85rem;
  color: var(--color-secondary);
  margin-bottom: 0.5rem;
}

.person-films {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-sm);
  font-size: var(--font-size-xl);
  color: var(--color-secondary);
  line-height: 1.4;
}

.film-list-ul {
  padding-left: 0;
  margin: 0.25rem 0 0;
  list-style: none;
  font-size: var(--font-size-sm);
  color: var(--color-secondary);
  line-height: 1.4;
}

.film-list-ul li {
  margin-bottom: 0.25rem;
}


/* Top Actors */

#top-actors {
  margin: 4rem auto 2rem;
  max-width: 1200px;
  padding: 0 1rem;
}

#top-actors h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: 2rem;
}

#yearly-actor-grid,
#actor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3rem;
  justify-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

/* Top Films */

#top-films {
  margin: 4rem auto 2rem;
  max-width: 1200px;
  padding: 0 1rem;
}

#top-films h2 {
  text-align: center;
  font-size: var(--font-size-xl);
  margin-bottom: 2rem;
}

#film-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2rem;
  justify-items: center;
  max-width: 960px;
  margin: 0 auto;
}

.film-card {
  text-align: center;
  max-width: 160px;
}

.film-poster {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.film-count {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #555;
}

/* Yearly Stats */

#watched-movie-grid {
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-sm);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2rem;
  justify-items: center;
  max-width: 960px;
  margin: 0 auto;
}


@media (max-width: 768px) {
  .stat-block {
    flex-direction: row !important;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .stat-item {
    flex: 1;
    text-align: center;
  }

  .stat-value {
    font-size: var(--font-size-jumbo);
  }

  .stat-label {
    font-size: 0.75rem;
  }

  #genre-stats {
    margin: 1rem;
    width: 80%;
    max-width: 80%;
    min-width: 0;
    box-sizing: border-box;
  }


  .bar-label {
    flex: 0 0 clamp(90px, 30vw, 150px);
    font-size: 0.9rem;
  }

  .bar-count {
    width: clamp(25px, 10vw, 30px);
    font-size: 0.75rem;
  }

  .bar-fill {
    height: 10px;
    margin: 0 0.5rem;
    flex: 1;
  }

  .bar-fill::before {
    background-color: #333;
    width: var(--bar-percent);
  }

  .bar-list {
      list-style: none;
      padding: 0;
      margin: 0;
    }

  /* Director, Actor, Film Grids → 2 columns */
  #director-grid,
  #yearly-actor-grid,
  #yearly-director-grid,
  #actor-grid,
  #film-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    justify-items: center;
    margin: 0 auto;
    padding: 0 1rem;
    }

    #watched-movie-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 100%;
    padding: 0 1rem;
    gap: .5rem;
  }

  .person-card {
    width: 100%;
    max-width: 10rem;
    text-align: center;
  }

  .person-photo {
    width: 150px;
    height: auto;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 0.75rem;
  }

    .film-list-ul {
      font-size: var(--font-size-xxs);
      color: var(--color-secondary);
      line-height: 1;
    }

    .film-list-ul li {
      margin-bottom: 0.5rem;
    }


  .film-card {
    max-width: 100%;
  }
}


/* Powered By Section */

.powered-by {
  margin: 2rem;
}

.powered-and,
.powered-by p {
  text-align: center;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-size: var(--font-size-sm);
  color: var(--color-secondary);
  letter-spacing: var(--letter-spacing-sm);
}

.powered-and {
  margin-right: 1rem;
}

.powered-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-xs);
}

  .logo-letterboxd img,
  .logo-tmdb img {
    width: 20rem;
  }

body.dark-mode .powered-by p {
  color: var(--color-white);
}


body.dark-mode {
  background: #111;
  color: #eee;
}

body.dark-mode h2,
body.dark-mode h3,
body.dark-mode .stat-label,
body.dark-mode .bar-label,
body.dark-mode .bar-count,
body.dark-mode .person-name,
body.dark-mode .person-count,
body.dark-mode .film-count {
  color: var(--color-off-white);
}

body.dark-mode .bar-fill {
  background: none;
}

body.dark-mode .bar-fill::before {
  background-color: #fff;
}


body.dark-mode .person-films,
body.dark-mode .film-list-ul,
body.dark-mode .film-list-ul li {
  color: #aaa;
}

@media (max-width: 600px) {
  .powered-logos {
    flex-direction: column;
    gap: var(--spacing-xs);
  }

  .powered-and {
    display: none;
  }

  .logo-letterboxd img,
  .logo-tmdb img {
    width: 20rem;
  }
}


.tmdb-loading-msg {
  font-family: var(--font-slab);
  text-transform: uppercase;
  font-weight: bold;
  text-align: center;
  margin: 2.5rem 0 1.5rem 0;
  color: #181818;
  background: #fff;
  border: 1px solid #181818;
  border-radius: 1em;
  padding: 2rem;
  font-size: 2rem;
  letter-spacing: 0.06em;
  box-shadow: 0 2px 10px 0 #00000012;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  position: relative;
  overflow: hidden;
}

.tmdb-loading-msg .loader-dots {
  display: inline-block;
  width: 1.4em;
  height: 1.4em;
  position: relative;
}

.tmdb-loading-msg .loader-dots span {
  display: block;
  position: absolute;
  width: 0.3em;
  height: 0.3em;
  background: #181818;
  border-radius: 50%;
  opacity: 0.82;
  animation: loader-bounce 1.2s infinite both;
}
.tmdb-loading-msg .loader-dots span:nth-child(1) { left: 0;        animation-delay: 0s; }
.tmdb-loading-msg .loader-dots span:nth-child(2) { left: 0.45em;  animation-delay: 0.2s; }
.tmdb-loading-msg .loader-dots span:nth-child(3) { left: 0.9em;   animation-delay: 0.4s; }

@keyframes loader-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.6;}
  40% { transform: scale(1.1); opacity: 1;}
}

.tmdb-loading-msg .blink {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0.6; }
}

/* DARK MODE OVERRIDE */
body.dark-mode .tmdb-loading-msg {
  color: #fff;
  background: #181818;
  border: 1px solid #fff;
  box-shadow: 0 2px 10px 0 #ffffff14;
}

body.dark-mode .tmdb-loading-msg .loader-dots span {
  background: #fff;
}
