/* ==========================================================================
   MEDIADROME — stylesheet inspired by the 1983 Videodrome poster
   Electric-blue CRT field, horizontal raster lines, hard white headline
   type, and one flesh-red accent borrowed from the airbrushed figure.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,100..900&family=Barlow+Semi+Condensed:wght@400;500;600&display=swap");

:root {
  /* Palette */
  --blue-field: #1e5bd8;     /* the main poster blue */
  --blue-deep: #0b2a8a;      /* edges, shadows */
  --blue-ink: #050f3f;       /* panels, darkest blue */
  --white: #f4f9ff;          /* title white, faintly blue */
  --flesh: #c2412f;          /* the figure's skin / wound: use sparingly */
  --flesh-dark: #7d2218;

  /* Type */
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Barlow Semi Condensed", "Helvetica Neue", Arial, sans-serif;

  /* Scale */
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.375rem;
  --step-2: 1.875rem;
  --step-3: clamp(2.5rem, 7vw, 4.5rem);
  --step-4: clamp(3.25rem, 13vw, 9rem);

  /* Raster */
  --scan-gap: 3px;
}

/* ---------- Base ---------- */

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

html {
  background: var(--blue-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--white);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  background:
    radial-gradient(ellipse 70% 40% at 25% 0%, rgba(95, 162, 255, 0.55), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 100%, var(--blue-deep), transparent 75%),
    var(--blue-field);
  background-attachment: fixed;
}

/* Raster lines across the whole screen, like the poster's video texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(3, 12, 60, 0.28) 0,
    rgba(3, 12, 60, 0.28) 1px,
    transparent 1px,
    transparent var(--scan-gap)
  );
}

/* A slow horizontal sync bar rolling down the tube */
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 22vh;
  z-index: 99;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(200, 225, 255, 0.07) 50%,
    transparent
  );
  animation: sync-roll 11s linear infinite;
}

@keyframes sync-roll {
  from { transform: translateY(-30vh); }
  to   { transform: translateY(130vh); }
}

::selection {
  background: var(--flesh);
  color: var(--white);
}

/* ---------- Typography ---------- */

h1, h2, h3 {
  margin: 0 0 0.5em;
  font-family: var(--font-display);
  font-weight: 600;
  font-stretch: 100%;
  line-height: 1;
  letter-spacing: -0.01em;
}

h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p {
  max-width: 62ch;
  margin: 0 0 1em;
}

a {
  color: var(--white);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--blue-ink);
  background: var(--white);
  text-decoration: none;
}

/* ---------- Layout ---------- */

.app {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
  padding-block: 1.5rem 4rem;
}

.search-input {
  display: block;
  width: 100%;
  padding: 1.1rem 1.4rem;
  font: inherit;
  font-size: var(--step-1);
  color: var(--white);
  background: var(--blue-ink);
  border: 3px solid var(--white);
  border-radius: 0;
}

.search-input::placeholder {
  color: rgba(244, 249, 255, 0.6);
}

.search-input:focus {
  outline: 3px solid var(--flesh);
  outline-offset: 2px;
}

.site-header {
  padding-bottom: 1.25rem;
  margin-bottom: 2.5rem;
  border-bottom: 3px solid var(--white);
}

/* The one loud moment: the title, cut by raster lines, with a CRT bloom */
.site-title {
  margin: 0;
  font-size: var(--step-4);
  white-space: nowrap;
  overflow: hidden;
  font-weight: 900;
  font-stretch: 112%;
  line-height: 0.85;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  filter: drop-shadow(0 0 0.35em rgba(150, 195, 255, 0.65));
}

.site-title a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.site-title a:hover {
  color: inherit;
  background: transparent;
}

.site-title a:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 0.1em;
}

/* Marquee: the text is repeated twice, so shifting by half the track loops seamlessly */
.site-title-track {
  display: inline-block;
  /* background-clip:text only paints inside the box; pad so glyph overhang isn't clipped */
  padding: 0.05em 0.12em 0.05em 0;
  color: transparent;
  animation: site-title-scroll 14s linear infinite;
  background: repeating-linear-gradient(
    to bottom,
    var(--white) 0,
    var(--white) 3px,
    rgba(244, 249, 255, 0.72) 3px,
    rgba(244, 249, 255, 0.72) 4px
  );
  -webkit-background-clip: text;
  background-clip: text;
}

.site-title-track span {
  padding-right: 0.6em;
}

@keyframes site-title-scroll {
  to { transform: translateX(-50%); }
}

/* ---------- Tags and item lists ---------- */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  display: inline-block;
  padding: 0.0625rem 0.625rem;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--white);
  background: transparent;
  border: 1px solid rgba(244, 249, 255, 0.7);
  border-radius: 999px;
}

.tag a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.tag a:hover {
  color: var(--blue-ink);
}

.item-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.list-item {
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(5, 15, 63, 0.82), rgba(11, 42, 138, 0.55));
  border: 1px solid rgba(244, 249, 255, 0.55);
  border-radius: 10px / 14px;
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.35);
}

.list-item-poster-link {
  display: block;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  color: var(--white);
  background: rgba(5, 15, 63, 0.75);
  text-decoration: none;
}

.list-item-poster-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item-poster-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 1rem;
  place-items: center;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 700;
}

.list-item-info {
  padding: 1rem;
}

.list-item-info-link {
  display: block;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.list-item-info-link:hover {
  color: var(--white);
  background: rgba(5, 15, 63, 0.55);
}

.list-item-info h3 {
  margin-bottom: 0.5rem;
}

.list-item-info .item-facts {
  font-size: var(--step--1);
}

.list-item-poster-link:hover {
  background: rgba(5, 15, 63, 0.95);
}

.list-item-poster-link:focus-visible {
  position: relative;
  z-index: 1;
}

/* ---------- Status messages ---------- */

.notice {
  max-width: 62ch;
  padding: 0.75rem 1rem;
  background: rgba(5, 15, 63, 0.75);
  border-left: 6px solid var(--white);
}

.notice-error {
  background: var(--flesh-dark);
  border-left-color: var(--flesh);
}

/* Loading state: a small CRT set whose static and filling signal show request progress. */
.loading-tv {
  display: flex;
  margin-inline: auto;
  align-items: center;
  gap: 1.25rem;
  max-width: 32rem;
  padding: 1rem;
  background: rgba(5, 15, 63, 0.75);
  border: 1px solid rgba(244, 249, 255, 0.55);
  border-radius: 10px / 14px;
  box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.35);
}

.loading-tv-set {
  position: relative;
  flex: 0 0 7rem;
  padding: 0.65rem 1.45rem 0.65rem 0.65rem;
  background: var(--blue-ink);
  border: 3px solid var(--white);
  border-radius: 16px / 20px;
  box-shadow: 0 0 0.8rem rgba(150, 195, 255, 0.7);
}

.loading-tv-screen {
  position: relative;
  min-height: 4.25rem;
  overflow: hidden;
  background:
    linear-gradient(115deg, transparent 40%, rgba(244, 249, 255, 0.3) 50%, transparent 60%),
    repeating-linear-gradient(to bottom, #85b9ff 0 2px, #2e6de4 2px 4px);
  border: 2px solid var(--blue-deep);
  border-radius: 7px / 10px;
  box-shadow: inset 0 0 1rem var(--blue-ink);
  animation: tv-flicker 0.16s steps(2, end) infinite;
}

.loading-tv-static,
.loading-tv-scanline {
  position: absolute;
  inset: 0;
}

.loading-tv-static {
  opacity: 0.45;
  background:
    repeating-linear-gradient(35deg, transparent 0 3px, rgba(244, 249, 255, 0.5) 3px 4px),
    repeating-linear-gradient(-30deg, transparent 0 4px, rgba(5, 15, 63, 0.55) 4px 5px);
  animation: tv-static 0.12s steps(2, end) infinite;
}

.loading-tv-scanline {
  height: 25%;
  background: linear-gradient(transparent, rgba(244, 249, 255, 0.65), transparent);
  animation: tv-scan 1.1s linear infinite;
}

.loading-tv-controls {
  position: absolute;
  top: 1.1rem;
  right: 0.35rem;
  display: grid;
  gap: 0.35rem;
}

.loading-tv-controls span {
  width: 0.5rem;
  aspect-ratio: 1;
  background: var(--flesh);
  border: 1px solid var(--flesh-dark);
  border-radius: 50%;
}

.loading-tv-antenna {
  position: absolute;
  bottom: 100%;
  width: 2px;
  height: 1.5rem;
  background: var(--white);
  transform-origin: bottom;
}

.loading-tv-antenna-left {
  left: 2.8rem;
  transform: rotate(-35deg);
}

.loading-tv-antenna-right {
  left: 3.75rem;
  transform: rotate(35deg);
}

.loading-tv-copy {
  display: grid;
  flex: 1;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.65rem;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
}

.loading-tv-copy > :first-child {
  grid-column: 1 / -1;
}

.loading-tv-progress {
  height: 0.65rem;
  overflow: hidden;
  background: var(--blue-deep);
  border: 1px solid rgba(244, 249, 255, 0.7);
}

.loading-tv-progress span {
  display: block;
  width: var(--loading-progress);
  height: 100%;
  background: var(--white);
  box-shadow: 0 0 0.55rem rgba(150, 195, 255, 0.95);
  transition: width 300ms ease-out;
}

.loading-tv-percent {
  font-variant-numeric: tabular-nums;
}

@keyframes tv-flicker {
  0%, 100% { filter: brightness(1.05) contrast(1.1); }
  45% { filter: brightness(0.72) contrast(1.4); }
  70% { filter: brightness(1.35) contrast(0.95); }
}

@keyframes tv-static {
  to { transform: translate(6px, -4px); }
}

@keyframes tv-scan {
  from { transform: translateY(-100%); }
  to { transform: translateY(400%); }
}

/* ---------- Accessibility ---------- */

:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
    display: none;
  }

  .site-title-track {
    animation: none;
  }

  .loading-tv-screen,
  .loading-tv-static,
  .loading-tv-scanline {
    animation: none;
  }

  .loading-tv-progress span {
    transition: none;
  }
}

/* ---------- Item detail ---------- */

.item {
  display: grid;
  gap: 2rem;
}

.item-title {
  margin: 0 0 0.25rem;
  font-size: var(--step-3);
  font-weight: 900;
  line-height: 0.95;
}

.item-subtitle,
.item-facts {
  margin: 0;
  color: rgba(244, 249, 255, 0.78);
}

.item-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.item-backdrop {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px / 14px;
  border: 1px solid rgba(244, 249, 255, 0.55);
}

.item-hero {
  position: relative;
}

.item-poster {
  display: block;
  width: 100%;
  max-width: 18rem;
  height: auto;
  border-radius: 10px / 14px;
  border: 1px solid rgba(244, 249, 255, 0.55);
}

.item-poster-column {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.item-tags h3 {
  margin-bottom: 0.5rem;
}

/* Header overlays the lower left of the backdrop on a translucent panel */
.item-hero .item-header {
  position: absolute;
  bottom: 4%;
  left: 3%;
  max-width: 70%;
  padding: 0.75rem 1rem;
  background: rgba(5, 15, 63, 0.7);
  border-radius: 10px / 14px;
  backdrop-filter: blur(4px);
}

/* A tube screen: dark glass, soft inner glow, slightly rounded corners */
.panel {
  padding: 1.25rem;
  background: linear-gradient(160deg, rgba(5, 15, 63, 0.82), rgba(11, 42, 138, 0.55));
  border: 1px solid rgba(244, 249, 255, 0.55);
  border-radius: 10px / 14px;
  box-shadow:
    inset 0 0 36px rgba(0, 0, 0, 0.45),
    0 0 0 4px rgba(5, 15, 63, 0.55);
}

/* The flesh-red accent, used only for personal status */
.status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status li {
  padding: 0.25rem 0.75rem;
  font-weight: 600;
  background: var(--flesh);
  border-left: 6px solid var(--flesh-dark);
}

.status .rating-status {
  background: var(--blue-ink);
  border-left-color: var(--blue-deep);
}

.trailer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--white);
  text-decoration: none;
}

.trailer-link svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.trailer-link:hover {
  color: var(--blue-ink);
  background: transparent;
}

.trailer-link:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 2px;
}

.credits {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.375rem 1rem;
  margin: 0;
}

.credits dt {
  font-family: var(--font-display);
  font-weight: 700;
}

.credits dd {
  margin: 0;
}

.cast {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 14rem;
}

.cast li {
  break-inside: avoid;
  margin-bottom: 0.25rem;
}

.cast-character {
  color: rgba(244, 249, 255, 0.78);
}

/* ---------- Rating: five TVs, tuned in by the rating ---------- */

.rating {
  --rating: 0;                 /* set per item, 0 to 5, halves allowed */
  position: relative;
  display: inline-block;
  font-size: 1.25rem;
  line-height: 1;
  white-space: nowrap;
}

/* Unlit TVs: dead static, dimmed and desaturated */
.rating::before {
  content: "📺📺📺📺📺";
  filter: grayscale(1) brightness(0.55);
  opacity: 0.5;
}

/* Lit TVs: the same row, clipped to the rating, with a CRT glow */
.rating::after {
  content: "📺📺📺📺📺";
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--rating) / 5 * 100%);
  overflow: hidden;
  filter: drop-shadow(0 0 5px rgba(150, 195, 255, 0.85));
}

/* ---------- Person profile ---------- */

.person-profile {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.person-media {
  display: grid;
  gap: 0.75rem;
  width: 12rem;
  max-width: 100%;
}

.birthday-reminder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--white);
  border-radius: 0.5rem;
  background: var(--blue-deep);
  color: var(--white);
  font-size: 0.85rem;
  text-align: center;
  text-decoration: none;
}

.birthday-reminder:hover {
  background: var(--blue-field);
  color: var(--white);
}

.person-photo {
  width: 12rem;
  max-width: 100%;
  border-radius: 0.5rem;
}

.person-details {
  flex: 1 1 18rem;
  display: grid;
  gap: 0.5rem;
}

.person-biography {
  margin: 0.5rem 0 0;
  max-width: 60ch;
  line-height: 1.5;
  white-space: pre-line;
}

/* ---------- Calendar ---------- */
.calendar {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.5rem;
}

.calendar-day {
  --line-gap: 6px;
  position: relative;
  min-height: 9rem;
  padding: 0.5rem;
  border: 1px solid var(--blue-deep);
  border-radius: 0.375rem;
  background:
    repeating-linear-gradient(to bottom, rgba(244, 249, 255, 0.07) 0 1px, transparent 1px var(--line-gap)),
    var(--blue-ink);
  overflow: hidden;
}

/* Yesterday: denser, brighter raster lines */
.calendar-day-yesterday {
  --line-gap: 2px;
  border-color: var(--white);
  background:
    repeating-linear-gradient(to bottom, rgba(244, 249, 255, 0.28) 0 1px, transparent 1px var(--line-gap)),
    var(--blue-field);
}

.calendar-date {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  text-transform: uppercase;
  line-height: 1;
}

.calendar-weekday {
  font-size: var(--step--1);
  letter-spacing: 0.08em;
}

.calendar-daynum {
  font-size: var(--step-2);
  font-weight: 800;
}

.calendar-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.375rem;
  font-size: var(--step--1);
  line-height: 1.2;
}

.calendar-events a {
  color: var(--white);
}

@media (max-width: 800px) {
  .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.calendar-posters {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
  gap: 0.25rem;
}

.calendar-posters a {
  display: block;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--white);
  overflow: hidden;
  background: var(--blue-deep);
}

.calendar-posters img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.calendar-poster-placeholder {
  display: block;
  padding: 0.125rem;
  font-size: 0.5rem;
  line-height: 1.1;
  overflow: hidden;
  color: var(--white);
}

.calendar-posters a.calendar-cake-link {
  text-decoration: none;
  border: 0;
  background: none;
  aspect-ratio: auto;
}

.calendar-cake {
  display: block;
  text-align: center;
  font-size: 1.5rem;
  line-height: 3.75rem;
}

.birthday-grid {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 1rem;
}

.birthday-grid a {
  display: block;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--white);
  overflow: hidden;
  background: var(--blue-deep);
}

.birthday-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.birthday-name {
  display: block;
  margin-top: 0.25rem;
  text-align: center;
  font-weight: bold;
}

.birthday-year {
  display: block;
  text-align: center;
}

.carousel {
  list-style: none;
  margin: 1rem 0;
  padding: 0 0 0.5rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.carousel li {
  flex: 0 0 8rem;
  scroll-snap-align: start;
}

.carousel a {
  display: block;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--white);
  overflow: hidden;
  background: var(--blue-deep);
}

.carousel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-placeholder {
  display: block;
  padding: 0.5rem;
  overflow: hidden;
}

.tag-cloud {
  justify-content: center;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1.5rem;
}

.section-heading {
  margin: 0 0 0.5rem;
  font-size: var(--step-1);
}
