/* RC88 · Motore del lettore video (.dp-), condiviso dalla Stanza riservata,
   più la grafica della schermata del vecchio Lettore video diretto, ora
   tolta dall'app: quelle regole restano inerti. Nessuna regola tocca il
   resto dell'app. I comandi del lettore stanno sotto il video, mai sopra. */

/* Il resto dell'app non ha una regola generale per gli elementi nascosti:
   senza questa, la schermata e il pulsante grande resterebbero visibili
   nonostante l'attributo hidden. */
.direct-page[hidden],
.direct-page [hidden] { display: none !important; }

.direct-page,
.dp-player {
  --dp-bg: #14161d;
  --dp-bg-soft: #1b1e27;
  --dp-surface: #21242e;
  --dp-surface-2: #2a2e3a;
  --dp-line: rgba(255, 255, 255, .13);
  --dp-text: #fffaf0;
  --dp-muted: #b3bac6;
  --dp-gold: #f6bf4d;
  --dp-gold-deep: #d88422;
  --dp-ink: #3f270c;
  --dp-danger: #ff9c85;
  --dp-ok: #8fdcb2;
  --dp-radius: 16px;
  --dp-radius-sm: 11px;
  --dp-gap: 14px;
}

.direct-page {
  display: block;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 40px) clamp(14px, 4vw, 40px) 72px;
  background: linear-gradient(180deg, var(--dp-bg) 0%, var(--dp-bg-soft) 100%);
  color: var(--dp-text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

.direct-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  display: grid;
  gap: clamp(14px, 2.4vw, 22px);
}

/* ---------- testata ---------- */
.direct-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.direct-eyebrow {
  margin: 0;
  color: var(--dp-gold);
  font-size: .72rem;
  font-weight: 950;
  letter-spacing: .14em;
}

.direct-title {
  margin: 8px 0 0;
  color: var(--dp-text);
  font: 900 clamp(1.7rem, 5vw, 2.6rem)/1.04 Georgia, "Times New Roman", serif;
}

.direct-lead {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--dp-muted);
  font-size: .95rem;
  line-height: 1.6;
}

.direct-head-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.direct-back {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius-sm);
  background: transparent;
  color: var(--dp-text);
  font: 850 .84rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.direct-back:hover { background: rgba(255, 255, 255, .08); }

.direct-status {
  min-height: 22px;
  margin: 0;
  color: var(--dp-muted);
  font-size: .85rem;
  font-weight: 750;
  line-height: 1.45;
}

.direct-status[data-kind="error"] { color: var(--dp-danger); }
.direct-status[data-kind="success"] { color: var(--dp-ok); }
/* Avviso informativo: non è un guasto, è una spiegazione. */
.direct-status[data-kind="note"] { color: var(--dp-accent, var(--dp-ok)); font-weight: 800; }

/* ---------- modulo ---------- */
.direct-form {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--dp-gap);
  padding: clamp(14px, 2.4vw, 20px);
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius);
  background: var(--dp-surface);
}

.direct-field { display: grid; gap: 7px; min-width: 0; }

.direct-field > span {
  color: var(--dp-gold);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.direct-field input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius-sm);
  background: #12141a;
  color: var(--dp-text);
  font: 600 .95rem/1.3 system-ui, sans-serif;
}

.direct-field input::placeholder { color: #6d7482; }

.direct-field input:focus-visible {
  outline: 3px solid rgba(246, 191, 77, .38);
  outline-offset: 1px;
  border-color: var(--dp-gold);
}

.direct-submit {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--dp-gold-deep);
  border-radius: var(--dp-radius-sm);
  background: linear-gradient(135deg, #fff0bd, var(--dp-gold) 58%, var(--dp-gold-deep));
  color: var(--dp-ink);
  font: 900 .9rem/1 system-ui, sans-serif;
  letter-spacing: .01em;
  cursor: pointer;
}

.direct-submit:hover { filter: brightness(1.05) saturate(1.06); }
.direct-submit:focus-visible { outline: 3px solid rgba(246, 191, 77, .5); outline-offset: 2px; }

.direct-hint {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--dp-gold);
  border-radius: 0 var(--dp-radius-sm) var(--dp-radius-sm) 0;
  background: rgba(246, 191, 77, .09);
  color: #d9d2c4;
  font-size: .82rem;
  line-height: 1.55;
}

/* ---------- area del lettore ---------- */
.direct-stage-host {
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius);
  background: #0b0c10;
  overflow: hidden;
}

.dp-player { display: grid; gap: 0; }

.dp-stage {
  position: relative;
  display: grid;
  place-items: center;
  background: #000;
  aspect-ratio: 16 / 9;
}

.dp-video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* Ovunque venga montato il lettore — stanza riservata, pannelli, pagine —
   l'attributo hidden deve valere davvero. Fuori dalla pagina del lettore
   non c'era alcuna regola: la freccia del play, disegnata con display grid,
   restava sempre in vista sopra il video. */
.dp-player [hidden] { display: none !important; }

.dp-big {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff0bd, var(--dp-gold) 60%, var(--dp-gold-deep));
  color: var(--dp-ink);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
  cursor: pointer;
}

.dp-big svg { width: 34px; height: 34px; fill: currentColor; margin-left: 3px; }
.dp-big:hover { transform: scale(1.04); }
.dp-big:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* Dopo due secondi senza gesti la freccia grande si ritira, come nei lettori
   televisivi: torna al primo movimento del mouse, al tocco o a un tasto. */
.dp-player .dp-big { transition: opacity .25s ease, visibility .25s ease; }
.dp-player.is-idle .dp-big {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .dp-player .dp-big { transition: none; }
}

.dp-overlay {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 11, 15, .84);
  backdrop-filter: blur(6px);
  color: var(--dp-text);
  font-size: .8rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}

.dp-overlay[data-kind="error"] { background: rgba(64, 12, 6, .92); color: #ffd9cd; }

/* ---------- barra dei comandi (sotto il video) ---------- */
.dp-bar {
  display: grid;
  gap: 8px;
  padding: 12px clamp(12px, 2.2vw, 18px) 14px;
  background: var(--dp-surface);
  border-top: 1px solid var(--dp-line);
}

.dp-seek-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.dp-time {
  color: var(--dp-muted);
  font: 700 .78rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.dp-seek { display: block; min-width: 0; }

.dp-seek input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.dp-seek input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--dp-gold) 0 var(--dp-played, 0%),
    rgba(255, 255, 255, .34) var(--dp-played, 0%) var(--dp-buffered, 0%),
    rgba(255, 255, 255, .13) var(--dp-buffered, 0%) 100%);
}

.dp-seek input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--dp-text);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .55);
}

.dp-seek input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .13);
}

.dp-seek input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--dp-gold);
}

.dp-seek input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--dp-text);
}

.dp-seek input[type="range"]:focus-visible { outline: 3px solid rgba(246, 191, 77, .45); outline-offset: 3px; border-radius: 999px; }

.dp-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dp-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius-sm);
  background: var(--dp-surface-2);
  color: var(--dp-text);
  cursor: pointer;
}

.dp-btn svg { width: 21px; height: 21px; fill: currentColor; }
.dp-btn:hover { background: #343948; }
.dp-btn:focus-visible { outline: 3px solid rgba(246, 191, 77, .45); outline-offset: 2px; }

.dp-btn-main {
  border-color: var(--dp-gold-deep);
  background: linear-gradient(135deg, #fff0bd, var(--dp-gold) 58%, var(--dp-gold-deep));
  color: var(--dp-ink);
}

.dp-btn-main:hover { filter: brightness(1.05); background: linear-gradient(135deg, #fff0bd, var(--dp-gold) 58%, var(--dp-gold-deep)); }

.dp-btn-text {
  width: auto;
  min-width: 58px;
  padding: 0 12px;
  font: 900 .84rem/1 system-ui, sans-serif;
}

.dp-volume {
  display: flex;
  align-items: center;
  min-width: 108px;
  flex: 0 1 150px;
}

.dp-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.dp-volume input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
}

.dp-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: var(--dp-text);
}

.dp-volume input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
}

.dp-volume input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--dp-text);
}

.dp-volume input[type="range"]:focus-visible { outline: 3px solid rgba(246, 191, 77, .45); outline-offset: 3px; }

.dp-fallback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .05);
  border-top: 1px solid var(--dp-line);
}

.dp-fallback[hidden],
.dp-fallback-text[hidden],
.dp-fallback .dp-btn[hidden],
.dp-fallback a[hidden] { display: none !important; }

.dp-fallback-text {
  flex: 1 1 240px;
  min-width: 0;
  color: var(--dp-muted);
  font-size: .82rem;
  line-height: 1.45;
}

.dp-fallback .dp-btn { min-height: 42px; }

.dp-fallback a {
  color: var(--dp-gold);
  font-size: .84rem;
  font-weight: 850;
  text-underline-offset: 3px;
}

/* Schermo intero: video grande, comandi sempre raggiungibili sotto. */
.dp-player:fullscreen,
.dp-player:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  background: #000;
}

.dp-player:fullscreen .dp-stage,
.dp-player:-webkit-full-screen .dp-stage {
  flex: 1 1 auto;
  aspect-ratio: auto;
  min-height: 0;
}

.dp-player:fullscreen .dp-bar,
.dp-player:-webkit-full-screen .dp-bar { background: #16181f; }

/* ---------- elenco dei video ---------- */
.direct-library {
  display: grid;
  gap: 12px;
  padding: clamp(14px, 2.4vw, 20px);
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius);
  background: var(--dp-surface);
}

.direct-library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.direct-library-head h2 {
  margin: 0;
  color: var(--dp-text);
  font: 900 clamp(1.1rem, 3vw, 1.4rem)/1.1 Georgia, "Times New Roman", serif;
}

.direct-count {
  color: var(--dp-gold);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .05em;
}

.direct-empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--dp-line);
  border-radius: var(--dp-radius-sm);
  color: var(--dp-muted);
  font-size: .86rem;
  line-height: 1.5;
}

.direct-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.direct-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.direct-item-play {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 9px 13px;
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius-sm);
  background: rgba(255, 255, 255, .04);
  color: var(--dp-text);
  text-align: left;
  cursor: pointer;
}

.direct-item-play:hover { background: rgba(255, 255, 255, .09); border-color: rgba(246, 191, 77, .5); }
.direct-item-play:focus-visible { outline: 3px solid rgba(246, 191, 77, .45); outline-offset: 2px; }

.direct-item.is-current .direct-item-play { border-color: var(--dp-gold); background: rgba(246, 191, 77, .12); }

.direct-item-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(246, 191, 77, .18);
  color: var(--dp-gold);
}

.direct-item-icon svg { width: 16px; height: 16px; fill: currentColor; margin-left: 2px; }

.direct-item-text { display: grid; gap: 3px; min-width: 0; }

.direct-item-text strong {
  color: var(--dp-text);
  font-size: .9rem;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.direct-item-text small {
  color: var(--dp-muted);
  font-size: .74rem;
  overflow-wrap: anywhere;
}

.direct-item-remove {
  width: 46px;
  border: 1px solid var(--dp-line);
  border-radius: var(--dp-radius-sm);
  background: rgba(255, 255, 255, .04);
  color: var(--dp-muted);
  cursor: pointer;
}

.direct-item-remove svg { width: 18px; height: 18px; }
.direct-item-remove:hover { background: rgba(255, 156, 133, .14); color: var(--dp-danger); border-color: rgba(255, 156, 133, .45); }
.direct-item-remove:focus-visible { outline: 3px solid rgba(255, 156, 133, .45); outline-offset: 2px; }

/* ---------- telefono ---------- */
@media (max-width: 780px) {
  .direct-form { grid-template-columns: 1fr; align-items: stretch; }
  .direct-submit { width: 100%; }
}

@media (max-width: 520px) {
  .direct-page { padding: 16px 12px 56px; }
  .direct-head { gap: 12px; }
  .direct-back { flex: 1 1 100%; }
  .dp-btn { width: 44px; height: 44px; }
  .dp-volume { flex: 1 1 100%; min-width: 0; order: 9; }
  .dp-time { font-size: .72rem; }
  .dp-big { width: 64px; height: 64px; }
  .dp-big svg { width: 28px; height: 28px; }
}
