/* ThunderFlix — acabamento: nada cortado, nada sobreposto (carregado depois de nf.css). */

/* 1. Logótipos nos cartões: cabem sempre inteiros dentro do cartão */
.nfBoxTitle{min-width:0;overflow:hidden}
.nfBoxTitle .nfBoxLogo{height:auto!important;width:auto!important;max-height:100%!important;max-width:78%!important;
  min-width:0!important;min-height:0!important;flex:0 1 auto;object-fit:contain;object-position:left bottom}
.nfArt{overflow:hidden}
.nfTopBadge{max-width:22%}

/* 2. Anéis de foco nunca cortados */
html.tv-mode .hero-copy{overflow:visible!important}
html.tv-mode .hero-copy p{overflow:hidden}
html.tv-mode .hero-actions{padding:6px 10px 6px 8px!important;margin:-6px 0 -6px -8px!important}
html.tv-mode #topbar{padding-left:max(14px,2.2vw)!important;padding-right:max(14px,2.2vw)!important}
.playerTop{padding-left:max(30px,3vw)!important}
html.tv-mode .playerControls{padding-left:max(28px,3.2vw)!important;padding-right:max(28px,3.2vw)!important}
html.tv-mode :is(button,a,[tabindex="0"]):focus{outline-offset:-2px}
html.tv-mode .tfControlHead{padding-right:max(20px,3vw)!important}

/* 3. Sinopse do destaque: termina sempre com reticências dentro do ecrã */
.hero-copy p{overflow-wrap:anywhere}
html.tv-mode .hero-copy{max-width:calc(100vw - 8vw)}

/* 4. Ficha do filme/série no Fire TV: ecrã inteiro, tudo visível e organizado */
html.tv-mode .nfDtBox{width:100vw!important;max-width:100vw!important;margin:0!important;border-radius:0!important;border:0!important;min-height:100vh}
html.tv-mode .nfDtMedia{aspect-ratio:auto!important;height:62vh}
html.tv-mode .nfDtShade{background:linear-gradient(0deg,var(--nf-panel) 0%,rgba(10,14,15,.55) 30%,rgba(10,14,15,0) 62%),
  linear-gradient(90deg,rgba(6,10,11,.82) 0%,rgba(6,10,11,.35) 45%,transparent 70%)!important}
html.tv-mode .nfDtHeroCopy{left:5vw!important;right:42vw!important;bottom:4vh!important}
html.tv-mode .nfDtLogo{max-width:70%!important;max-height:15vh!important;margin-bottom:2.2vh!important;object-position:left bottom}
html.tv-mode .nfDtTitle{font-size:5.4vh!important;line-height:1.1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
html.tv-mode .nfDtBtns{font-size:2.3vh!important;padding:6px 8px;margin:-6px -8px}
html.tv-mode .nfDtBody{padding:0 5vw 6vh!important;position:relative;z-index:4}
html.tv-mode .nfDtCols{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr)!important;gap:4vw!important;margin:0 0 3vh!important;font-size:2.2vh!important}
html.tv-mode .nfDtDesc{font-size:2.45vh!important;line-height:1.45!important}
html.tv-mode .nfDtRight{font-size:2.15vh!important;line-height:1.45!important}
html.tv-mode .nfDtMeta{font-size:2.2vh}
html.tv-mode .nfDtClose{top:3vh!important;right:3vw!important}
html.tv-mode .nfDetails h3{font-size:3vh!important}
html.tv-mode .nfDetails{scroll-padding:12vh 0}

/* 5. Leitor: menus como painel lateral, nunca por cima do texto nem da barra */
.tfSheetHost{position:absolute;inset:0;z-index:70;pointer-events:none}
.tfSheetHost .playerMenu{position:absolute!important;top:0!important;right:0!important;bottom:0!important;left:auto!important;
  width:clamp(290px,31vw,470px)!important;max-height:none!important;border-radius:0!important;margin:0!important;
  padding:max(26px,7vh) max(20px,2.4vw) max(26px,6vh)!important;overflow-y:auto!important;pointer-events:auto;
  background:linear-gradient(90deg,rgba(7,10,11,.9),rgba(7,10,11,.98) 14%)!important;backdrop-filter:none!important;
  box-shadow:-30px 0 60px rgba(0,0,0,.55)!important;border-left:1px solid rgba(121,246,255,.18);
  display:flex;flex-direction:column;gap:2px;animation:tfSheetIn .22s cubic-bezier(.2,.8,.2,1)}
.tfSheetHost .playerMenu.hidden{display:none!important}
@keyframes tfSheetIn{from{transform:translateX(24px);opacity:0}to{transform:none;opacity:1}}
.tfSheetHost .playerMenu strong{font-size:clamp(16px,2.6vh,22px)!important;margin:0 0 1.6vh!important;letter-spacing:.02em}
.tfSheetHost .playerMenu button,.tfSheetHost .playerMenu summary{display:flex!important;align-items:center;gap:.6em;width:100%!important;
  font-size:clamp(13px,2.2vh,18px)!important;padding:.75em .9em!important;border-radius:8px!important;color:#e9f4f5;
  background:transparent;border:0;text-align:left!important;cursor:pointer;line-height:1.25}
.tfSheetHost .playerMenu button[aria-checked="true"]{color:#9ff8ff;font-weight:700}
.tfSheetHost .playerMenu button[aria-checked="true"]::before{content:"✓";width:1em;flex:0 0 1em}
.tfSheetHost .playerMenu button:not([aria-checked="true"])::before{content:"";width:1em;flex:0 0 1em}
.tfSheetHost .playerMenu :is(button,summary,input,select):focus{outline:none!important;background:#f2fbfb!important;color:#041012!important}
.tfSheetHost .subtitleSync{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:6px!important;
  margin-top:1.6vh!important;padding-top:1.6vh!important}
.tfSheetHost .subtitleSync span{grid-column:1/-1;font-size:clamp(12px,1.9vh,15px)!important;color:#9fb2b4}
.tfSheetHost .subtitleSync b{display:flex;align-items:center;justify-content:center;font-size:clamp(12px,2vh,16px)!important}
.tfSheetHost .subtitleSync button{justify-content:center;padding:.6em .2em!important;font-size:clamp(12px,2vh,16px)!important}
.tfSheetHost .subtitleSync button::before{display:none!important}
.tfSheetHost .subtitleStatus{font-size:clamp(12px,2vh,16px);color:#a9b9bb;padding:.6em .9em;line-height:1.4}

/* 6. Legendas próprias: uma de cada vez, nunca sobrepostas aos controlos nem ao painel */
video::-webkit-media-text-track-container{display:none!important}
video::cue{color:transparent!important;background:transparent!important;text-shadow:none!important}
.tfSubs{position:absolute;left:6%;right:6%;bottom:7%;z-index:22;text-align:center;pointer-events:none;
  font:600 clamp(16px,2.6vw,46px)/1.3 "Segoe UI",Roboto,system-ui,sans-serif;color:#fff;
  text-shadow:0 0 3px #000,0 0 3px #000,0 2px 6px rgba(0,0,0,.9);transition:bottom .22s ease,right .22s ease,left .22s ease}
.tfSubs span{display:inline-block;padding:.04em .32em;border-radius:6px;background:rgba(0,0,0,.32);white-space:pre-line;max-width:100%}
.controlsVisible .tfSubs{bottom:calc(var(--tfCtrlH,150px) + 2vh)}
.tfSheetOpen .tfSubs{right:calc(clamp(290px,31vw,470px) + 3%);left:3%}
.tfScrubbing .tfSubs{opacity:0}

/* 7. Miniaturas ao percorrer a barra de tempo */
.tfScrub{position:absolute;z-index:30;bottom:calc(100% + 10px);transform:translateX(-50%);pointer-events:none;display:none;
  width:clamp(170px,19vw,320px);border-radius:10px;overflow:hidden;background:#05090a;border:2px solid rgba(255,255,255,.9);
  box-shadow:0 10px 30px rgba(0,0,0,.6)}
.tfScrubbing .tfScrub{display:block}
.tfScrub i{display:block;aspect-ratio:16/9;background:#0b1214 center/cover no-repeat;transition:opacity .15s}
.tfScrub b{display:block;text-align:center;font:700 clamp(12px,2.1vh,18px)/1 system-ui,sans-serif;color:#fff;padding:.45em 0;background:rgba(0,0,0,.75)}
.tfScrub em{position:absolute;right:.5em;top:.4em;font:800 clamp(10px,1.6vh,14px)/1 system-ui;color:#9ff8ff;font-style:normal;text-shadow:0 1px 3px #000}
.playerTimelineWrap{position:relative}

/* 8. Fire TV: fluidez — sem desfocagens nem brilhos caros, só transform/opacity na GPU */
html.tv-mode *,html.tv-mode *::before,html.tv-mode *::after{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
html.tv-mode .nfTopBadge,html.tv-mode .nfNewBadge,html.tv-mode .tfSugGlow{box-shadow:none!important;animation:none!important}
html.tv-mode .card.nfCard .nfArt{transition:transform .14s ease-out,box-shadow .14s ease-out!important;will-change:transform}
html.tv-mode .row:not(.grid){transition:transform .2s ease-out!important;will-change:transform}
html.tv-mode .nfCard .nfImg{transition:opacity .2s!important}
html.tv-mode .nfDetails::backdrop{backdrop-filter:none!important;background:rgba(0,0,0,.86)!important}

/* 9. Classificação no fim do filme (canto inferior direito, por cima dos créditos, sem tapar o centro) */
.tfRate{position:absolute;right:4vw;bottom:8vh;z-index:40;width:clamp(260px,26vw,420px);padding:2.2vh 1.6vw;border-radius:14px;
  background:rgba(6,10,11,.92);border:1px solid rgba(121,246,255,.28);box-shadow:0 16px 50px rgba(0,0,0,.6);color:#fff;
  display:flex;flex-direction:column;gap:1vh;animation:tfSheetIn .3s ease-out}
.tfRate small{color:#9fb2b4;font-size:clamp(11px,1.8vh,14px);letter-spacing:.06em;text-transform:uppercase}
.tfRate strong{font-size:clamp(15px,2.6vh,22px);line-height:1.2;overflow-wrap:anywhere}
.tfRateStars{display:flex;gap:.25em;font-size:clamp(26px,5vh,46px);cursor:pointer;outline:none;padding:.1em .15em;border-radius:10px;width:max-content}
.tfRateStars:focus{box-shadow:0 0 0 2px #9ff8ff}
.tfRateStars i{width:1em;height:1em;display:block;background:linear-gradient(90deg,#3a4446 0 100%);
  -webkit-mask:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l3 6.9 7.5.7-5.7 5 1.7 7.4L12 18l-6.5 4 1.7-7.4L1.5 9.6 9 8.9z"/></svg>') center/contain no-repeat;
  mask:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2l3 6.9 7.5.7-5.7 5 1.7 7.4L12 18l-6.5 4 1.7-7.4L1.5 9.6 9 8.9z"/></svg>') center/contain no-repeat}
.tfRateStars i.full{background:#ffd34d}
.tfRateStars i.half{background:linear-gradient(90deg,#ffd34d 0 50%,#3a4446 50% 100%)}
.tfRateValue{font-size:clamp(12px,2vh,16px);color:#d5e5e6}
.tfRateBtns{display:flex;gap:.6em}
.tfRateBtns button{flex:1;border:0;border-radius:8px;padding:.6em .8em;font:700 clamp(12px,2vh,16px)/1.1 system-ui,sans-serif;background:#1d2a2c;color:#e9f4f5}
.tfRateBtns button:focus{outline:none;background:#f2fbfb;color:#041012}

/* 10. Telemóvel: a barra de categorias desliza com um esbatido no fim (nada aparece "cortado") */
@media(max-width:760px){
  #topbar nav{-webkit-mask-image:linear-gradient(90deg,#000 0,#000 calc(100% - 34px),transparent);mask-image:linear-gradient(90deg,#000 0,#000 calc(100% - 34px),transparent);padding-right:30px}
}
.tfEmptyView{display:none!important}

/* 11. Extras dentro da ficha do filme */
.nfDtExtras{margin-top:1.4em}
.nfDtExGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:.6em}
.nfDtEx{display:flex;align-items:center;gap:.8em;text-align:left;padding:.75em .9em;border-radius:10px;border:1px solid rgba(255,255,255,.1);
  background:rgba(255,255,255,.05);color:#fff;cursor:pointer;min-width:0}
.nfDtEx:hover,.nfDtEx:focus{outline:none;background:#f2fbfb;color:#041012}
.nfDtExPlay{flex:0 0 2em;height:2em;border-radius:50%;display:grid;place-items:center;background:rgba(121,246,255,.18);font-size:.85em}
.nfDtExText{display:flex;flex-direction:column;min-width:0}
.nfDtExText strong{font-size:.95em;line-height:1.25;overflow-wrap:anywhere}
.nfDtExText small{font-size:.78em;opacity:.7;margin-top:.15em}
html.tv-mode .nfDtEx{font-size:2.2vh}

/* Content ident (real video, 3.5 s) before every film/episode */
.identVideo{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#000;z-index:6;display:block}
.identVideo.hidden{display:none}
/* trailer player built behind the ident (buffers while the ident plays) */
.trailerStage.tfPrebuffer{opacity:0;pointer-events:none}
/* Trailer before the film: no YouTube look — bigger than the screen so its logo/title bar stay outside the frame */
.trailerPlayerHost{overflow:hidden}
.trailerPlayerHost iframe{position:absolute;left:-11%;top:-11%;width:122%!important;height:122%!important;left:calc((1 - var(--tfFill,1.22)) * 50%);top:calc((1 - var(--tfFill,1.22)) * 50%);width:calc(var(--tfFill,1.22) * 100%)!important;height:calc(var(--tfFill,1.22) * 100%)!important;transform:none!important;pointer-events:none}
.trailerStage.tfYtHold .trailerPlayerHost iframe{opacity:0}
.trailerPlayerHost iframe{transition:opacity .5s ease}

/* ---- pt-PT subtitles on every trailer (drawn by the app; never over buttons or logos) ---- */
.tfTrSubs{position:absolute;z-index:4;pointer-events:none;opacity:0;transition:opacity .18s ease;color:#fff;font-weight:600;
  text-shadow:0 1px 2px #000,0 0 6px rgba(0,0,0,.9);line-height:1.25}
.tfTrSubs.on{opacity:1}
.tfTrSubs span{display:inline-block;padding:.08em .4em;border-radius:6px;background:rgba(0,0,0,.45)}
/* details page: right side of the picture, above the action row (the logo and buttons are on the left) */
.nfDtMedia .tfTrSubs{right:4%;left:auto;max-width:44%;bottom:30%;text-align:right;font-size:clamp(13px,1.35vw,22px)}
/* home hero: right side, clear of the title/synopsis/buttons block on the left */
.nfHero .tfTrSubs,#hero .tfTrSubs{right:4%;left:auto;max-width:40%;bottom:24%;text-align:right;font-size:clamp(13px,1.3vw,22px)}
/* hover preview card: small, centred at the bottom of the picture */
.nfPvMedia .tfTrSubs{left:4%;right:4%;bottom:6%;text-align:center;font-size:12px}
/* trailer before the film: like film subtitles */
.tfTrSubsStage{left:8%;right:8%;bottom:8%;text-align:center;font-size:clamp(16px,2.2vw,34px);z-index:7}
html.tv-mode .nfDtMedia .tfTrSubs{font-size:3.1vh}
html.tv-mode .nfHero .tfTrSubs,html.tv-mode #hero .tfTrSubs{font-size:3.1vh}
@media (max-width:700px){
  .nfDtMedia .tfTrSubs{left:auto;right:4%;max-width:46%;top:72px;bottom:auto;text-align:right;font-size:13px}
  .nfHero .tfTrSubs,#hero .tfTrSubs{left:4%;right:4%;max-width:none;top:14%;bottom:auto;text-align:center;font-size:13px}
}

/* Fire TV / TV: trailer frame exactly the screen (no zoom: the TV WebView would draw the picture off-centre) */
html.tv-mode .trailerPlayerHost iframe{left:0!important;top:0!important;width:100%!important;height:100%!important;transform:none!important}

/* Player open: nothing behind it paints or animates (smooth video on Fire TV) */
html.tf-playing body > :not(#playerDialog){visibility:hidden!important}
html.tf-playing body > :not(#playerDialog),html.tf-playing body > :not(#playerDialog) *{animation-play-state:paused!important;transition:none!important}
/* trailer end: quick fade instead of a hard cut */
.trailerStage{transition:opacity .9s ease}
.trailerStage.tfTrailerOut{opacity:0}

/* our own trailer copy (no YouTube player) */
.tfTrailerVideo{position:absolute;display:block;background:#000;object-fit:cover;border:0;pointer-events:none;
  left:calc((1 - var(--tfVidFill,1)) * 50%);top:calc((1 - var(--tfVidFill,1)) * 50%);
  width:calc(var(--tfVidFill,1) * 100%);height:calc(var(--tfVidFill,1) * 100%)}

/* Barra do filme: tempo do filme à esquerda, duração total à direita; parte vista (cor), parte já carregada (mais clara), resto */
.playerTimelineWrap{gap:12px}
.playerTimelineWrap .playerTimeCur{min-width:0;text-align:left}
.playerTimelineWrap #playerTime{min-width:0;text-align:right}
.playerTimeline{-webkit-appearance:none;appearance:none;background:transparent;height:22px;margin:0;cursor:pointer;--played:0%;--loaded:0%}
.playerTimeline::-webkit-slider-runnable-track{height:5px;border-radius:3px;background:linear-gradient(to right,var(--accent) 0 var(--played),rgba(255,255,255,.62) var(--played) var(--loaded),rgba(255,255,255,.2) var(--loaded) 100%)}
.playerTimeline::-moz-range-track{height:5px;border-radius:3px;background:linear-gradient(to right,var(--accent) 0 var(--played),rgba(255,255,255,.62) var(--played) var(--loaded),rgba(255,255,255,.2) var(--loaded) 100%)}
.playerTimeline::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;margin-top:-5px;border-radius:50%;background:var(--accent);border:0;box-shadow:0 0 0 3px rgba(0,0,0,.35)}
.playerTimeline::-moz-range-thumb{width:15px;height:15px;border-radius:50%;background:var(--accent);border:0}
.playerTimeline:focus{outline:none}
.playerTimeline:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 6px rgba(121,246,255,.38)}
.playerTimeline:focus-visible::-moz-range-thumb{box-shadow:0 0 0 6px rgba(121,246,255,.38)}
html.tv-mode .playerTimeline:focus::-webkit-slider-thumb{box-shadow:0 0 0 6px rgba(121,246,255,.45)}
/* ±10 s: manter o dedo carregado não abre o menu do sistema */
.skip10Btn{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}

/* ===== TV smoothness (measured on the Fire TV: the main thread was busy ~60% of the time while browsing) =====
   1) no endless animations on the TV: each one repaints every frame over a page with thousands of elements
   2) shelves far from the screen are skipped by the browser (content-visibility) until they come near */
html.tv-mode #tfSugBtn,html.tv-mode #tfSugBtn *,html.tv-mode #tfSugBtn::before,html.tv-mode #tfSugBtn::after,
html.tv-mode .card.nfCard:focus .nfArt,html.tv-mode .tfpAurora,html.tv-mode .tfpGrid,html.tv-mode .tfpRing,
html.tv-mode .tfProfileCard .tfpTile::before,html.tv-mode .pill.working{animation:none!important}
html.tv-mode .shelf,html.tv-mode .nfDynShelf{content-visibility:auto;contain-intrinsic-size:auto 360px}
/* Trailer before the film: always the whole picture, never zoomed. On the Fire TV a video element larger
   than the screen is drawn shifted (picture cut on the left and a black band on the right). */
.tfTrailerVideo{left:0!important;top:0!important;width:100%!important;height:100%!important;object-fit:contain!important;transform:none!important}

/* Uncluttered player: playback left, settings right; volume belongs to the device. */
#playerDialog #muteBtn,#playerDialog #volumeSlider,#playerDialog #favoriteBtn{display:none!important}
#playerDialog .playerControlRow{gap:24px;margin-top:18px;flex-wrap:wrap}
#playerDialog .playerControlGroup{gap:16px;flex-shrink:0;max-width:100%}
#playerDialog .playerControlGroup:last-child{margin-left:auto}
#playerDialog .playerIconBtn{width:44px;min-width:44px;height:44px;padding:0 8px;flex-shrink:0}
#playerDialog .playerIconBtn.wideBtn{width:auto;font-size:13px!important;gap:8px;padding:0 14px;display:flex;align-items:center;justify-content:center}
#playerDialog .playerTimeline{min-width:0;flex:1}
#playerDialog .playerControls{padding-top:48px}
#playerDialog .playerControlRow button:focus-visible{outline:2px solid #b4faff;outline-offset:3px;background:rgba(255,255,255,.16)}
#playerDialog.tfTrailerFocus .playerTop,#playerDialog.tfTrailerFocus #playerControls,#playerDialog.tfTrailerFocus .tfSheetHost{visibility:hidden!important;pointer-events:none!important}
#playerDialog.tfTrailerFocus #trailerPlayerHost{pointer-events:none}
#playerDialog.tfTrailerFocus #skipTrailerBtn{outline:2px solid white;outline-offset:4px;background:rgba(15,18,20,.88);color:white}
@media(max-width:600px){
 #playerDialog .playerControlRow{gap:12px;margin-top:12px}
 #playerDialog .playerControlGroup{gap:10px}
 #playerDialog .playerIconBtn.wideBtn{padding:0 10px;font-size:12px!important}
 #playerDialog .playerControls{padding:36px 16px 16px}
}
