/* Shared interaction geometry. Editorial artwork and hero composition stay local. */
:root {
  --ui-control-size: 44px;
  --ui-radius-card: var(--radius-cover, 12px);
  --ui-radius-dialog: 22px;
  --ui-poster-ratio: 2 / 3;
  --ui-landscape-ratio: 16 / 9;
  --ui-card-title-size: clamp(12px, .95vw, 14px);
  --ui-focus-color: var(--accent-bright, #ff304c);
  --ui-hover-shadow: 0 0 0 1px #e3133266, 0 8px 28px #e3133233;
  --motion-fast: 160ms;
  --motion-base: 220ms;
  --motion-enter: 300ms;
  --motion-ease: cubic-bezier(.2, .7, .2, 1);
}

:is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-focus-color);
  outline-offset: 4px;
}
:is(.topbar, #app-sidebar, #streaming-services, #catalog-discovery, #sagas-hub, #home-shelves, dialog) :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline-color: var(--ui-focus-color);
  scroll-margin-top: calc(var(--header-height, 80px) + 100px);
  scroll-margin-bottom: 32px;
}
.home-shelves .hs-poster, #catalog-discovery .dx-poster:is([data-kind='movie'], [data-kind='series']) {
  aspect-ratio: var(--ui-poster-ratio);
  border-radius: var(--ui-radius-card);
}
#streaming-services .ss-card-visual { aspect-ratio: var(--ui-poster-ratio); border-radius: var(--ui-radius-card); }
:is(.home-shelves .hs-card-title, #streaming-services .ss-card-title) {
  display: -webkit-box;
  min-height: 2.8em;
  max-height: 2.8em;
  overflow: hidden;
  white-space: normal;
  font-size: var(--ui-card-title-size);
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.home-shelves .hs-cell > .hs-favorite-toggle,
#catalog-discovery .dx-title-cell > .dx-favorite-toggle,
#streaming-services .ss-card-save {
  top: 4px; right: 4px;
  width: var(--ui-control-size); min-width: var(--ui-control-size);
  height: var(--ui-control-size); min-height: var(--ui-control-size);
  border-radius: 10px;
}
.hs-cell > .movie-seen-toggle, .dx-title-cell > .movie-seen-toggle,
.sj-page .sj-film-art .sj-seen-toggle, #streaming-services .ss-card-watched {
  top: 4px; left: 4px; bottom: auto;
  width: var(--ui-control-size); min-width: var(--ui-control-size);
  height: var(--ui-control-size); min-height: var(--ui-control-size);
  border-radius: 10px;
}
#streaming-services .ss-card-watched { background: #090a0c30; }
.service-rating { min-height: 20px; gap: 5px; font-variant-numeric: tabular-nums; }
:is(.hs-poster, .dx-poster, .ss-card-visual, .sg-universe, .sg-actor-card) {
  transition: box-shadow var(--motion-base) var(--motion-ease), translate var(--motion-base) var(--motion-ease);
}
#streaming-services .ss-card:focus-within .ss-card-visual { box-shadow: var(--ui-hover-shadow); }
:is(.sg-universe, .sg-actor-card):focus-visible { box-shadow: var(--ui-hover-shadow); }
@media (hover: hover) and (pointer: fine) {
  #streaming-services .ss-card:hover:where(body[data-input-modality="mouse"] *) .ss-card-visual { box-shadow: var(--ui-hover-shadow); translate: 0 -5px; }
  #streaming-services .ss-card-watched:not([aria-pressed='true']) { opacity: 0; }
  #streaming-services .ss-card:is(:hover:where(body[data-input-modality="mouse"] *), :focus-within) .ss-card-watched { opacity: .9; }
}
@media (pointer: coarse), (hover: none) {
  :is(.home-shelves, #catalog-discovery, #sagas-hub, #streaming-services) :is(.movie-seen-toggle, .catalog-favorite-toggle, .ss-card-save, .ss-card-watched) { opacity: 1; }
  :is(.hs-arrow, .sg-filter, .sj-tab, .sj-select, .sj-auto-next, .infinite-scroll-more) { min-height: var(--ui-control-size); }
}

/* Stable, centered dialogs share the same close affordance and entry timing. */
dialog:not(#player-screen) {
  border-color: var(--line);
  border-radius: var(--ui-radius-dialog);
  color: var(--text);
  box-shadow: var(--dialog-shadow, 0 28px 100px #0008);
}
dialog:not(#player-screen)[open] { animation: ui-dialog-enter 180ms var(--motion-ease) both; }
dialog:not(#player-screen)::backdrop { animation: ui-backdrop-enter 160ms ease both; }
.ui-dialog-close {
  display: grid; place-items: center; flex: 0 0 var(--ui-control-size);
  width: var(--ui-control-size); min-width: var(--ui-control-size); height: var(--ui-control-size);
  min-height: var(--ui-control-size); padding: 0; border: 1px solid var(--line);
  border-radius: 50%; background: var(--hover); color: var(--text-muted); font-size: 23px; font-weight: 400; line-height: 1;
  box-shadow: none; transition: color var(--motion-fast), border-color var(--motion-fast), background var(--motion-fast);
}
.ui-dialog-close:is(:hover:where(body[data-input-modality="mouse"] *), :focus-visible) { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
@keyframes ui-dialog-enter { from { opacity: 0; scale: .98; } to { opacity: 1; scale: 1; } }
@keyframes ui-backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
/* Compact controls keep native selects and accessible names. */
#player-screen #player-surface .player-toolbar button.player-icon-button,
#player-screen #player-surface .player-toolbar .player-select-icon {
  position: relative; display: grid; place-items: center; flex: 0 0 40px;
  width: 40px; min-width: 40px; height: 40px; min-height: 40px; margin: 0; padding: 0;
  border: 0; border-radius: 50%; background: #ffffff05; color: #b5bec8; box-shadow: none; font-size: 0;
}
#player-screen #player-surface .player-toolbar button.player-icon-button::before,
#player-screen #player-surface .player-toolbar .player-select-icon::before { content: ''; position: static; display: block; width: 19px; height: 19px; margin: 0; background: currentColor; mask: var(--player-control-icon) center / contain no-repeat; }
#player-favorite { --player-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round' d='M6 3h12v18l-6-4-6 4z'/%3E%3C/svg%3E"); }
#player-audio { --player-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='m11 5-6 4H2v6h3l6 4V5ZM15 8a6 6 0 0 1 0 8m3-11a10 10 0 0 1 0 14'/%3E%3C/svg%3E"); }
#player-fullscreen { --player-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' d='M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5'/%3E%3C/svg%3E"); }
#player-screen .player-fit-icon { --player-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath fill='none' stroke='black' stroke-width='1.4' d='M8 9h8v6H8z'/%3E%3C/svg%3E"); }
#player-screen .player-quality-icon { --player-control-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.6'%3E%3Cpath d='M3 7h18M3 17h18'/%3E%3Ccircle cx='8' cy='7' r='3' fill='white'/%3E%3Ccircle cx='16' cy='17' r='3' fill='white'/%3E%3C/g%3E%3C/svg%3E"); }
#player-screen #player-surface .player-select-icon > span { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#player-screen #player-surface .player-select-icon select { position: absolute; inset: 0; opacity: 0; width: 100%; max-width: none; height: 100%; min-height: 40px; margin: 0; padding: 0; cursor: pointer; }
#player-screen #player-surface .player-toolbar button.player-icon-button:is(:hover:where(body[data-input-modality="mouse"] *), :focus-visible),
#player-screen #player-surface .player-toolbar .player-select-icon:is(:hover:where(body[data-input-modality="mouse"] *), :focus-within) { color: #f3f2ef; background: #e3133212; box-shadow: 0 0 18px #e313321b; }
#player-screen #player-surface .player-toolbar #player-favorite[aria-pressed='true'] { color: #f02a4d; background: #e3133210; }
#player-screen .player-select-icon:focus-within { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
#player-screen #player-surface .player-toolbar button.player-icon-button[hidden], #player-screen #player-surface .player-toolbar .player-select-icon[hidden] { display: none; }

/* Later saga/service styles must not resize or expose the mobile drawer. */
@media (min-width: 721px) {
  #app-sidebar :is(.sidebar-navigation, .sidebar-live, .sidebar-sports) { grid-template-columns: minmax(0, 1fr); min-width: 0; }
  body:not(.sidebar-peeking) #app-sidebar :is(.sidebar-action, .sidebar-family, .sidebar-sport-item, .service-nav-button) { max-width: 100%; min-width: 0; }
  body.sidebar-peeking:not(.mobile-shell-active) #app-sidebar { background: var(--canvas); box-shadow: 16px 0 32px rgb(0 0 0 / .18); }
}
@media (max-width: 720px) {
  body.sagas-visible { --header-height: 154px; }
  html:has(body.sidebar-open), body.sidebar-open { overflow: hidden; overscroll-behavior: none; }
  body:is(.sidebar-open, .sidebar-closing) #app-sidebar,
  body.sagas-visible:is(.sidebar-open, .sidebar-closing) #app-sidebar,
  body.streaming-active:is(.sidebar-open, .sidebar-closing) #app-sidebar {
    position: fixed; inset: var(--header-height) auto 0 0; z-index: 60;
    width: min(280px, calc(100vw - 48px)); max-width: calc(100vw - 48px); padding: 16px 16px 24px;
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    background: color-mix(in srgb, var(--canvas, #090b0f) 96%, transparent); backdrop-filter: blur(18px);
    border-right: 1px solid var(--line); border-radius: 0 18px 0 0;
  }
  body.sidebar-open #sidebar-backdrop { position: fixed; inset: var(--header-height) 0 0; z-index: 55; background: #0008; backdrop-filter: blur(3px); }
  body.sidebar-open #app-sidebar #sidebar-toggle { margin: 0 0 12px auto; width: 40px; height: 40px; min-height: 40px; border-radius: 50%; background: #ffffff07; }
  body.sidebar-open #app-sidebar #sidebar-toggle::before,
  body.sidebar-open #app-sidebar #sidebar-toggle::after { content: ''; display: block; position: absolute; inset: auto; top: 50%; left: 50%; width: 14px; height: 1.5px; margin: 0; border: 0; background: currentColor; mask: none; transform: translate(-50%, -50%) rotate(45deg); }
  body.sidebar-open #app-sidebar #sidebar-toggle::after { transform: translate(-50%, -50%) rotate(-45deg); }
  body.sidebar-open #app-sidebar .sagas-nav-button { width: 100%; min-height: 44px; padding: 10px 12px; }
  body.sidebar-open #app-sidebar { --scrollbar-thumb: #7b828944; --scrollbar-thumb-hover: #a1a8af66; --scrollbar-thumb-active: #a1a8af88; }
}
@media (prefers-reduced-motion: reduce) {
  dialog:not(#player-screen)[open], dialog:not(#player-screen)::backdrop { animation: none; }
  :is(.hs-poster, .dx-poster, .ss-card-visual, .sg-universe, .sg-actor-card, .ui-dialog-close) { transition: none; translate: none !important; }
}
