/* TV & Film on the public site (docs/plugins/official/tv-film.md › On the site).
   It wears the theme: fonts and text colour are inherited, and muted text,
   rules and surfaces come from the custom properties themes share (--muted,
   --line, --surface, --radius), with fallbacks mixed from the text colour
   for themes without them. What it picks out (stars, hearts, the current
   tab, the tallest bar) is full white on a dark page and the text colour on
   a light one, where white wouldn't show: never the theme's accent. */

.tvf,
.tvf-row {
  --tvf-accent: light-dark(currentColor, #fff);
  --tvf-muted: var(--muted, color-mix(in oklab, currentColor 65%, transparent));
  --tvf-line: var(--line, color-mix(in oklab, currentColor 14%, transparent));
  --tvf-surface: var(--surface, color-mix(in oklab, currentColor 6%, transparent));
  --tvf-radius: var(--radius, 4px);
  --tvf-card: 8.75rem;
}

.tvf .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The section's own navigation */

.tvf-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--tvf-line);

  & a {
    padding-block: 0.25rem;
    color: var(--tvf-muted);
    text-decoration: none;
  }

  & a:hover,
  & a[aria-current="page"] {
    color: inherit;
  }

  & a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-color: var(--tvf-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.45em;
  }
}

.tvf-section {
  margin-top: clamp(2.5rem, 2rem + 3vw, 5rem);
}

.tvf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;

  & h2 {
    margin: 0;
  }
}

.tvf-count {
  margin: 0;
  color: var(--tvf-muted);
  font-variant-numeric: tabular-nums;
}

/* Poster cards: one row of as many as fit, or the whole grid */

.tvf-row,
.tvf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tvf-card), 1fr));
  gap: 1.5rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tvf-row {
  /* Rows after the first take no room, so the row shows what fits across. */
  grid-template-rows: auto;
  grid-auto-rows: 0;
  row-gap: 0;
  overflow: hidden;
}

@media (width < 40em) {
  .tvf-row,
  .tvf-grid {
    --tvf-card: 6.25rem;
    gap: 1.25rem 0.75rem;
  }

  .tvf-row {
    row-gap: 0;
  }
}

.tvf-card {
  display: grid;
  align-content: start;
  gap: 0.15rem;
  min-width: 0;
  font-size: 0.875rem;
  line-height: 1.35;
}

.tvf-card[hidden] {
  display: none;
}

.tvf-card__link {
  display: grid;
  gap: 0.5rem;
  color: inherit;
  text-decoration: none;
}

.tvf-card__title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 600;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.tvf-card__link:hover .tvf-card__title {
  text-decoration: underline;
}

.tvf-card__meta {
  color: var(--tvf-muted);
  font-variant-numeric: tabular-nums;
}

.tvf-card__rating,
.tvf-entry__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.5rem;
}

.tvf-poster {
  display: block;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border-radius: var(--tvf-radius);
  background: var(--tvf-surface);

  & img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms ease;
  }

  /* Until the script gives it its address. */
  & img:not([src]) {
    visibility: hidden;
  }
}

.tvf-card__link:hover .tvf-poster img,
.tvf-card__link:focus-visible .tvf-poster img {
  transform: scale(1.04);
}

.tvf-poster__none {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 0.75rem;
  color: var(--tvf-muted);
  font-size: 0.8rem;
  text-align: center;
}

.tvf-stars {
  color: var(--tvf-accent);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.tvf-liked {
  color: var(--tvf-accent);
}

.tvf-tag {
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--tvf-line);
  border-radius: 99px;
  color: var(--tvf-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Search and filters */

.tvf-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
  margin-bottom: 1.75rem;
  padding: 1rem;
  border-radius: var(--tvf-radius);
  background: var(--tvf-surface);
}

.tvf-filters[hidden] {
  display: none;
}

.tvf-field {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.tvf-field--search {
  flex: 1 1 14rem;
}

.tvf-field__label {
  color: var(--tvf-muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tvf-filters input[type="search"],
.tvf-filters select,
.tvf-reset,
.tvf-more button {
  min-height: 2.5rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--tvf-line);
  border-radius: var(--tvf-radius);
  background: var(--bg, Canvas);
  color: inherit;
  font: inherit;
}

.tvf-filters input[type="search"] {
  width: 100%;
}

.tvf-filters select {
  max-width: 100%;
}

.tvf-filters :focus-visible,
.tvf-more button:focus-visible {
  outline: 2px solid var(--tvf-accent);
  outline-offset: 1px;
}

.tvf-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  white-space: nowrap;

  & input {
    accent-color: var(--tvf-accent);
  }
}

.tvf-reset,
.tvf-more button {
  cursor: pointer;
}

.tvf-reset:hover,
.tvf-more button:hover {
  border-color: currentColor;
}

.tvf-more {
  margin-top: 2rem;
  text-align: center;
}

.tvf-credit {
  margin-top: clamp(3rem, 2rem + 4vw, 6rem);
  color: var(--tvf-muted);
  font-size: 0.8rem;
}

/* The diary */

.tvf-month {
  margin-top: 2.5rem;
}

.tvf-month__name {
  margin: 0;
  padding-block: 0.75rem;
  border-top: 1px solid var(--tvf-line);
  font-size: 1.1rem;
}

.tvf-diary,
.tvf-viewings,
.tvf-cast,
.tvf-figures,
.tvf-bars,
.tvf-columns,
.tvf-legend {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tvf-entry {
  display: grid;
  grid-template-columns: 7rem 3.25rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  align-items: start;
  padding-block: 0.9rem;
  border-top: 1px solid var(--tvf-line);
}

.tvf-entry__day {
  padding-top: 0.15rem;
  color: var(--tvf-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.tvf-entry__title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;

  & a {
    color: inherit;
    text-decoration: none;
  }

  & a:hover {
    text-decoration: underline;
  }
}

.tvf-entry__year,
.tvf-title__year {
  color: var(--tvf-muted);
  font-weight: 400;
}

.tvf-entry__meta {
  margin: 0.3rem 0 0;
  font-size: 0.875rem;
}

.tvf-entry__review {
  max-width: 42rem;
  margin: 0.5rem 0 0;
  color: var(--tvf-muted);
}

@media (width < 40em) {
  .tvf-entry {
    grid-template-columns: 3.25rem minmax(0, 1fr);
  }

  .tvf-entry__day {
    grid-column: 1 / -1;
  }
}

/* A film or series */

.tvf-title__banner {
  overflow: hidden;
  max-height: min(60vh, 34rem);
  margin-bottom: -4rem;
  border-radius: var(--tvf-radius);
  mask-image: linear-gradient(#000 55%, transparent);

  & img {
    display: block;
    width: 100%;
    height: auto;
  }
}

.tvf-title__body {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem 3rem;
  margin-top: 2rem;
}

.tvf-title__poster {
  width: min(60%, 14rem);
  box-shadow: 0 1rem 2.5rem -1rem rgb(0 0 0 / 0.5);
}

@media (width >= 48em) {
  .tvf-title__body {
    grid-template-columns: 15rem minmax(0, 1fr);
    align-items: start;
  }

  .tvf-title__poster {
    width: 100%;
  }
}

.tvf-title__text {
  max-width: 46rem;

  & h1 {
    margin: 0;
  }
}

.tvf-title__crumb,
.tvf-title__original,
.tvf-title__links {
  margin: 0 0 0.5rem;
  color: var(--tvf-muted);
  font-size: 0.875rem;
}

.tvf-title__rating {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  font-size: 1.25rem;
}

.tvf-title__tagline {
  margin: 1.25rem 0 0;
  color: var(--tvf-muted);
  font-style: italic;
}

.tvf-title__overview {
  margin: 0.75rem 0 0;
  font-size: 1.05rem;
}

.tvf-title__heading {
  margin: 2.5rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tvf-line);
  font-size: 1.1rem;
}

.tvf-title__links {
  margin-top: 2rem;
}

.tvf-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1.5rem;
  margin: 1.75rem 0 0;

  & dt {
    color: var(--tvf-muted);
  }

  & dd {
    margin: 0;
  }
}

.tvf-cast {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.4rem 1.5rem;
}

.tvf-cast__role {
  color: var(--tvf-muted);
  font-size: 0.875rem;
}

.tvf-viewing {
  padding-block: 0.9rem;
  border-top: 1px solid var(--tvf-line);

  &:first-child {
    padding-top: 0;
    border-top: 0;
  }

  & .tvf-entry__meta {
    margin-top: 0;
  }
}

.tvf-viewing__when {
  font-weight: 600;
}

.tvf-review {
  margin: 0.6rem 0 0;
  white-space: pre-line;
}

.tvf-spoiler {
  margin-top: 0.6rem;

  & summary {
    color: var(--tvf-muted);
    cursor: pointer;
  }
}

/* Statistics */

.tvf-stats {
  display: grid;
  gap: clamp(3rem, 2.5rem + 3vw, 6rem);
}

.tvf-panel {
  min-width: 0;
}

.tvf-panel__head {
  display: grid;
  gap: 0.5rem;
  max-width: 44rem;
  margin-bottom: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--tvf-line);

  & h2 {
    margin: 0;
  }
}

.tvf-panel__note,
.tvf-panel__fact {
  max-width: 44rem;
  margin: 0;
  color: var(--tvf-muted);

  & a {
    color: inherit;
  }
}

.tvf-panel__fact {
  margin-top: 1.75rem;
}

.tvf-panel__sub {
  margin: 2.25rem 0 0.35rem;
  font-size: 1rem;
}

.tvf-panel__sub + .tvf-panel__note {
  margin-bottom: 1.25rem;
}

.tvf-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1.75rem 1.5rem;
}

.tvf-figure {
  display: grid;
  gap: 0.2rem;
}

.tvf-figure__value {
  font-family: var(--font-heading, inherit);
  font-size: clamp(2rem, 1.5rem + 2vw, 3.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
}

.tvf-figure__label {
  color: var(--tvf-muted);
  font-size: 0.875rem;
}

.tvf-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem 3rem;
}

@media (width >= 56em) {
  .tvf-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tvf-bars {
  display: grid;
  gap: 0.6rem;
}

.tvf-bars__row {
  display: grid;
  grid-template-columns: minmax(6rem, 13rem) minmax(2rem, 1fr) max-content;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.925rem;
}

.tvf-bars__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  & a {
    color: inherit;
  }
}

.tvf-bars__track {
  height: 0.6rem;
  border-radius: 99px;
  background: var(--tvf-surface);
}

.tvf-bars__bar {
  display: block;
  width: calc(var(--scale) * 1%);
  min-width: 0.6rem;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in oklab, currentColor 45%, transparent);
}

.tvf-bars__row[data-max] .tvf-bars__bar {
  background: var(--tvf-accent);
}

.tvf-bars__value {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.tvf-bars__share,
.tvf-legend__count {
  color: var(--tvf-muted);
  font-size: 0.8rem;
}

.tvf-columns {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: clamp(0.2rem, 1vw, 0.75rem);
}

.tvf-columns__col {
  display: grid;
  grid-template-rows: auto 9rem auto;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.8rem;
  text-align: center;
}

.tvf-columns__value {
  font-variant-numeric: tabular-nums;
}

.tvf-columns__value--none {
  color: transparent;
}

.tvf-columns__track {
  display: flex;
  align-items: end;
  border-radius: var(--tvf-radius);
  background: var(--tvf-surface);
}

.tvf-columns__bar {
  display: block;
  width: 100%;
  height: calc(var(--scale) * 1%);
  border-radius: inherit;
  background: color-mix(in oklab, currentColor 45%, transparent);
}

.tvf-columns__col[data-max] .tvf-columns__bar {
  background: var(--tvf-accent);
}

.tvf-columns__label {
  overflow: hidden;
  color: var(--tvf-muted);
  text-overflow: ellipsis;
  white-space: nowrap;

  & a {
    color: inherit;
  }
}

.tvf-columns--dense .tvf-columns__value {
  font-size: 0.7rem;
}

.tvf-split {
  display: flex;
  gap: 3px;
  overflow: hidden;
  height: 1.25rem;
  border-radius: 99px;
}

.tvf-split__part {
  flex: var(--share) 0 0;
  background: color-mix(in oklab, currentColor 40%, transparent);

  &:first-child {
    background: var(--tvf-accent);
  }
}

.tvf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: 0.9rem;

  & li {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
  }
}

.tvf-legend__swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: color-mix(in oklab, currentColor 40%, transparent);
}

.tvf-legend li:first-child .tvf-legend__swatch {
  background: var(--tvf-accent);
}

@media (prefers-reduced-motion: reduce) {
  .tvf-poster img {
    transition: none;
  }
}
