
:root {
  --bg: #06070a;
  --panel: #11141b;
  --panel-soft: rgba(17, 20, 27, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f7fb;
  --text-soft: #aeb7c7;
  --accent: #d72234;
  --accent-strong: #ff6a4e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --shell: min(1200px, calc(100vw - 24px));
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(215, 34, 52, 0.16), transparent 28%),
    linear-gradient(180deg, #08090c 0%, #0c0f14 48%, #07080b 100%);
}

body.modal-open {
  overflow: hidden;
}

body.overlay-open {
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
  border: 0;
}

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: var(--shell);
  margin: 0 auto;
  padding: 14px 0;
  background: rgba(6, 7, 10, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}

.brand-copy {
  font-family: "Bebas Neue", sans-serif;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
}

.search-bar input {
  min-width: 0;
  min-height: 48px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
}

.search-bar input::placeholder {
  color: #7f8797;
}

.page-shell {
  width: var(--shell);
  margin: 0 auto;
  padding: 8px 0 40px;
}

.home-sections {
  display: grid;
  gap: 1rem;
}

.featured,
.content-section {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}

.featured {
  min-height: 440px;
  margin-bottom: 1rem;
}

.featured-backdrop,
.featured-overlay {
  position: absolute;
  inset: 0;
}

.featured-backdrop {
  background:
    linear-gradient(180deg, rgba(6, 7, 10, 0.15), rgba(6, 7, 10, 0.45)),
    linear-gradient(90deg, rgba(6, 7, 10, 0.92) 0%, rgba(6, 7, 10, 0.34) 60%, rgba(6, 7, 10, 0.86) 100%);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.featured-overlay {
  background: linear-gradient(180deg, rgba(7, 8, 12, 0.14), rgba(7, 8, 12, 0.84));
}

.featured-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 440px;
  padding: 22px;
}

.featured h1 {
  margin: 0.7rem 0 0.45rem;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(3rem, 11vw, 5.6rem);
  letter-spacing: 0.04em;
  line-height: 0.92;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.featured-description {
  max-width: 52ch;
  margin: 0.9rem 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.featured-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
}

.content-section {
  padding: 18px;
  margin-bottom: 1rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-head-player {
  align-items: flex-start;
}

.section-meta {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.media-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.media-rail::-webkit-scrollbar,
.results-grid::-webkit-scrollbar {
  height: 8px;
}

.media-rail::-webkit-scrollbar-thumb,
.results-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.media-card {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease;
}

.media-card:hover,
.media-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(255, 106, 78, 0.36);
  outline: none;
}

.media-card__poster,
.media-card__fade {
  position: absolute;
  inset: 0;
}

.media-card__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card__fade {
  background:
    linear-gradient(180deg, rgba(5, 6, 9, 0.08), rgba(5, 6, 9, 0.1) 38%, rgba(5, 6, 9, 0.95) 100%);
}

.media-card__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 300px;
  padding: 0.85rem;
}

.media-card__body {
  margin-top: auto;
}

.media-card__body h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.media-card__body p {
  margin: 0;
  color: rgba(245, 247, 251, 0.75);
  font-size: 0.85rem;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.pill-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--text-soft);
  text-align: center;
}

.download-container {
  display: none;
}

.download-container.active {
  display: flex;
}

.tv-controls {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tv-controls.active {
  display: grid;
}

.tv-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.tv-controls select {
  min-height: 46px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  color-scheme: dark;
  outline: none;
}

.tv-controls select option {
  background: #10131a;
  color: #f5f7fb;
}

.player-frame-wrap {
  position: relative;
  overflow: hidden;
  min-height: min(56vw, 520px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at top left, rgba(215, 34, 52, 0.16), transparent 24%),
    #090b10;
}

.player-frame-wrap::before {
  content: "Seleziona un titolo per iniziare";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  color: var(--text-soft);
  text-align: center;
  pointer-events: none;
}

.player-frame-wrap.is-active::before {
  opacity: 0;
}

#playerFrame {
  width: 100%;
  height: 100%;
  min-height: inherit;
  border: 0;
  opacity: 0;
  transition: opacity 180ms ease;
}

.player-frame-wrap.is-active #playerFrame {
  opacity: 1;
}

.details-shell {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
}

.details-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 10, 0.78);
  backdrop-filter: blur(18px);
}

.details-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1.2rem;
  width: min(980px, 100%);
  max-height: min(88vh, 760px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(12, 14, 19, 0.98);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
  overflow: hidden auto;
}

.details-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
}

.details-media {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  min-height: 420px;
  border: 1px solid var(--line);
  background: #0d1016;
}

.details-visual {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 7, 10, 0.12), rgba(6, 7, 10, 0.7)),
    linear-gradient(90deg, rgba(6, 7, 10, 0.12), rgba(6, 7, 10, 0.38)),
    #0d1016;
  background-position: center;
  background-size: cover;
}

.details-poster-wrap {
  position: absolute;
  inset: auto 18px 18px 18px;
  display: flex;
  justify-content: flex-start;
}

.details-poster {
  width: min(220px, 52%);
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
}

.details-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 8px 16px 0;
  min-width: 0;
}

.details-copy h2 {
  margin: 0.8rem 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.details-description,
.details-cast {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.details-description {
  margin-top: 1rem;
}

.details-cast {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.3rem;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.8rem 1.1rem;
  border-radius: 999px;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.ghost-button {
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.primary-button:hover,
.ghost-button:hover,
.primary-button:focus-visible,
.ghost-button:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 7, 10, 0.86);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.modal-shell.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.modal-card h2 {
  margin: 0 0 0.45rem;
}

.modal-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.modal-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
  color: var(--text-soft);
}

.modal-input-wrap input {
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
}

.modal-feedback,
.browser-tip {
  margin-bottom: 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.browser-tip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
}

.modal-feedback {
  border: 1px solid rgba(215, 34, 52, 0.28);
  background: rgba(215, 34, 52, 0.1);
  color: #ffd4d9;
}

#username-submit[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 720px) {
  .topbar {
    padding: 12px 0;
  }

  .search-bar {
    grid-template-columns: 1fr;
  }

  .featured {
    min-height: 340px;
  }

  .featured-content {
    min-height: 340px;
    padding: 18px;
  }

  .featured-actions,
  .tv-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .featured-actions {
    display: grid;
  }

  .featured-actions > *,
  .download-container,
  .download-container a,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .section-head,
  .section-head-player {
    flex-direction: column;
    align-items: flex-start;
  }

  .details-panel {
    grid-template-columns: 1fr;
    width: min(100%, 640px);
    max-height: calc(100dvh - 24px);
    padding: 14px;
    border-radius: 20px;
  }

  .details-media {
    min-height: 230px;
    aspect-ratio: 16 / 10;
  }

  .details-copy {
    padding: 6px 0 0;
  }

  .details-copy h2 {
    font-size: clamp(1.7rem, 7vw, 2.4rem);
  }

  .details-description,
  .details-cast {
    font-size: 0.94rem;
    line-height: 1.6;
  }

  .details-actions {
    display: grid;
    width: 100%;
  }

  .details-actions > * {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .topbar {
    gap: 0.7rem;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-copy {
    font-size: 1.7rem;
  }

  .results-grid,
  .tv-controls {
    grid-template-columns: 1fr;
  }

  .content-section {
    padding: 14px;
  }

  .featured-content {
    min-height: 320px;
    padding: 16px;
  }

  .featured h1 {
    font-size: clamp(2.3rem, 13vw, 3.6rem);
  }

  .featured-description {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .details-shell {
    padding: 10px;
    place-items: start center;
  }

  .details-panel {
    max-height: calc(100dvh - 20px);
    padding: 12px;
    gap: 0.85rem;
  }

  .details-media {
    min-height: 190px;
  }

  .details-poster-wrap {
    inset: auto 12px 12px 12px;
  }

  .details-poster {
    width: 112px;
    border-radius: 12px;
  }

  .details-close {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    font-size: 1.4rem;
  }

  .media-rail {
    grid-auto-columns: minmax(136px, 1fr);
  }

  .media-card,
  .media-card__content {
    min-height: 260px;
  }
}

@media (min-width: 721px) {
  .home-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .search-bar {
    width: min(560px, 100%);
  }

  .results-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .media-rail {
    grid-auto-columns: minmax(190px, 1fr);
  }
}
