/* Promin — Lampa-style visual pass on top of the Phase 0 skeleton.
 *
 * Targets old Tizen/webOS Chromium (~47): no CSS Grid, no
 * backdrop-filter/blur, no CSS custom properties (var() landed in
 * Chrome 49). Flexbox only. Transitions are restricted to
 * transform/opacity to avoid layout thrashing on weak TV GPUs. Shadows
 * are flat (no blur radius) or omitted entirely.
 * 1rem == 10px at the 1280x720 baseline; app.ts rescales the root
 * font-size for other resolutions.
 */

html {
  font-size: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: #15171b;
  color: #e8ebf0;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.activity {
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- */
/* Home screen shell                                                 */
/* ---------------------------------------------------------------- */

.home-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---------------------------------------------------------------- */
/* Scroll: translate3d lanes (ported from Lampa scroll.scss).        */
/* The inner __body is moved with transform; NEVER native scroll —   */
/* old Tizen/webOS choke on scroll-behavior/scrollLeft transitions   */
/* but handle translate3d fine.                                      */
/* ---------------------------------------------------------------- */

.scroll {
  display: flex;
}

.scroll--over {
  overflow: hidden;
}

.scroll__content {
  width: 100%;
}

.scroll__body {
  transition: transform 0.3s;
  will-change: transform;
}

.scroll__body.notransition {
  transition: none;
}

/* Horizontal lane: cards laid out in a row inside __body. */
.scroll--horizontal .scroll__body {
  display: flex;
  flex-direction: row;
}

/* Focus-driven backdrop: two stacked layers cross-fade via opacity only
   (see styles.css header note + src/screens/home.ts). */
.background {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  overflow: hidden;
  background-color: #15171b;
}

.background__layer {
  position: absolute;
  top: -8%;
  left: -8%;
  right: -8%;
  bottom: -8%;
  opacity: 0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  transition: opacity 0.6s ease-out;
  will-change: opacity;
}

.background__layer.visible {
  opacity: 1;
}

.background__shade {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(180deg, rgba(21, 23, 27, 0.25) 0%, rgba(21, 23, 27, 0.7) 55%, #15171b 100%);
}

/* ---------------------------------------------------------------- */
/* Left icon rail                                                    */
/* ---------------------------------------------------------------- */

.menu {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 8.4rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 3.2rem;
}

.menu__list {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.menu__item {
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.4rem;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.06);
  transition: transform 0.12s ease-out;
}

.menu__ico {
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
}

.menu__ico svg {
  width: 100%;
  height: 100%;
}

.menu__item--current {
  background-color: rgba(255, 255, 255, 0.14);
}

.menu__item.selector.focus {
  background-color: #ffffff;
  color: #15171b;
  transform: scale(1.08);
}

/* ---------------------------------------------------------------- */
/* Top bar                                                           */
/* ---------------------------------------------------------------- */

.head {
  position: fixed;
  top: 0;
  left: 8.4rem;
  right: 0;
  height: 7.2rem;
  z-index: 15;
  display: flex;
  align-items: center;
  padding: 0 3.2rem;
  background-image: linear-gradient(180deg, rgba(15, 16, 20, 0.9) 0%, rgba(15, 16, 20, 0) 100%);
}

.head__logo {
  font-size: 2.2rem;
  font-weight: bold;
  letter-spacing: 0.2rem;
  color: #ffffff;
  margin-right: auto;
}

.head__time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.head__time-now {
  font-size: 2.2rem;
  font-weight: bold;
  line-height: 1;
  color: #ffffff;
}

.head__time-date {
  font-size: 1.3rem;
  color: #9aa3b2;
  margin-top: 0.4rem;
}

/* ---------------------------------------------------------------- */
/* Content: ribbons of cards                                         */
/* ---------------------------------------------------------------- */

/* Main vertical scroll area: everything below the head, right of the menu.
   Bounded height so the translate math (maxOffset uses .scroll.offsetHeight)
   clips correctly. */
.content {
  position: fixed;
  z-index: 1;
  left: 8.4rem;
  right: 0;
  top: 7.2rem;
  bottom: 0;
  overflow: hidden;
}

.content > .scroll {
  width: 100%;
  height: 100%;
}

.content .scroll__content {
  padding: 3.2rem 3.2rem 6rem 3.2rem;
}

.items-line {
  margin-bottom: 3.6rem;
}

.items-line__title {
  font-size: 2rem;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 1.4rem;
}

/* Horizontal lane viewport: clips the translated card strip. */
.items-line__body {
  position: relative;
  width: 100%;
}

.items-line__body > .scroll {
  width: 100%;
  overflow: hidden;
}

.card {
  flex: 0 0 auto;
  width: 15.6rem;
  margin-right: 1.6rem;
}

.card:last-child {
  margin-right: 0;
}

/* card__view is the poster frame; the focus ring is drawn on ::after,
   extending 0.5rem beyond it — exactly Lampa's card.scss (border ring,
   no scale). */
.card__view {
  position: relative;
  width: 100%;
  padding-bottom: 150%;
  border-radius: 0.8rem;
  background-color: #262931;
  margin-bottom: 0.9rem;
}

.card__img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.8rem;
}

.card__vote {
  position: absolute;
  right: 0.7rem;
  bottom: 0.7rem;
  background-color: rgba(0, 0, 0, 0.55);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: bold;
  padding: 0.3rem 0.8rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
}

.card__vote-icon {
  width: 1.1rem;
  height: 1.1rem;
  margin-right: 0.4rem;
  color: #ffcc4d;
  display: flex;
}

.card__vote-icon svg {
  width: 100%;
  height: 100%;
}

.card__title {
  font-size: 1.5rem;
  line-height: 1.3;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__year {
  font-size: 1.3rem;
  color: #8b93a3;
  margin-top: 0.3rem;
}

/* Focus ring: an ::after border that extends 0.5rem beyond the poster —
   ported verbatim from Lampa card.scss (.card.focus .card__view::after).
   No scale, no box-shadow/blur. */
.card.focus .card__view::after {
  content: "";
  position: absolute;
  top: -0.5rem;
  left: -0.5rem;
  right: -0.5rem;
  bottom: -0.5rem;
  border: 0.3rem solid #ffffff;
  border-radius: 1.1rem;
  pointer-events: none;
}

/* ---------------------------------------------------------------- */
/* Footer hints + toast                                              */
/* ---------------------------------------------------------------- */

.footer {
  position: fixed;
  left: 8.4rem;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: row;
  padding: 1.2rem 3.2rem;
  background-image: linear-gradient(0deg, rgba(15, 16, 20, 0.9) 0%, rgba(15, 16, 20, 0) 100%);
}

.hint {
  font-size: 1.4rem;
  color: #838ea0;
  margin-right: 3.2rem;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 6rem;
  transform: translateX(-50%) translateY(0.8rem);
  opacity: 0;
  background: #1a2030;
  color: #ffffff;
  border: 0.1rem solid #323b4d;
  border-radius: 0.6rem;
  padding: 1.2rem 2.4rem;
  font-size: 1.8rem;
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  white-space: nowrap;
  z-index: 30;
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================================================================ */
/* Shared: buttons, state messages, skeletons                        */
/* ================================================================ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 5rem;
  padding: 0 2.4rem;
  border-radius: 0.8rem;
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1.7rem;
  font-weight: bold;
  white-space: nowrap;
  transition: transform 0.12s ease-out;
}

.button__ico {
  width: 1.8rem;
  height: 1.8rem;
  margin-right: 1rem;
  display: flex;
}

.button__ico svg {
  width: 100%;
  height: 100%;
}

.button--accent {
  background-color: #ffffff;
  color: #15171b;
}

.button.selector.focus {
  background-color: #ffffff;
  color: #15171b;
  transform: scale(1.04);
}

.state-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 4rem 0;
}

.state-message--soft {
  align-items: center;
  color: #8b93a3;
}

.state-message__text {
  font-size: 2rem;
  color: #c7cede;
  margin-bottom: 2rem;
}

/* Skeleton placeholders — flat pulse via opacity (no blur/box-shadow). */
.skeleton-box,
.skeleton-line {
  background-color: #262931;
  border-radius: 0.6rem;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-line {
  height: 1.4rem;
  margin-top: 0.6rem;
}

.skeleton-line--short {
  width: 50%;
}

@keyframes skeleton-pulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.card--skeleton .card__view {
  padding-bottom: 150%;
}

.skeleton-strip {
  display: flex;
  flex-direction: row;
}

.skeleton-strip .card {
  width: 15.6rem;
}

.content__skeleton .items-line__title.skeleton-line {
  width: 22rem;
  height: 2rem;
}

/* Card fallbacks */
.card__noimg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  text-align: center;
  font-size: 1.3rem;
  color: #8b93a3;
  border-radius: 0.8rem;
}

.card__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0.5rem;
  background-color: rgba(0, 0, 0, 0.5);
  border-bottom-left-radius: 0.8rem;
  border-bottom-right-radius: 0.8rem;
  overflow: hidden;
}

.card__progress-fill {
  height: 100%;
  background-color: #ffcc4d;
}

/* ================================================================ */
/* Title screen                                                      */
/* ================================================================ */

.title-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.title-scroll {
  position: fixed;
  z-index: 1;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
}

.title-scroll > .scroll {
  width: 100%;
  height: 100%;
}

.title-scroll .scroll__content {
  padding: 6rem 6rem 6rem 8.4rem;
}

.title-header {
  display: flex;
  flex-direction: row;
  margin-bottom: 3.2rem;
}

.title-poster {
  flex: 0 0 auto;
  width: 26rem;
  height: 39rem;
  border-radius: 1rem;
  background-color: #262931;
  overflow: hidden;
  margin-right: 3.6rem;
}

.title-poster__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-info {
  flex: 1 1 auto;
  max-width: 90rem;
}

.title-info__name {
  font-size: 4rem;
  font-weight: bold;
  color: #ffffff;
  line-height: 1.1;
}

.title-info__original {
  font-size: 2rem;
  color: #8b93a3;
  margin-top: 0.6rem;
}

.title-info__meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.8rem;
}

.title-info__meta-item {
  font-size: 1.7rem;
  color: #c7cede;
  margin-right: 2rem;
  margin-bottom: 0.6rem;
  display: inline-flex;
  align-items: center;
}

.title-info__rating-icon {
  width: 1.5rem;
  height: 1.5rem;
  color: #ffcc4d;
  margin-right: 0.5rem;
  display: flex;
}

.title-info__rating-icon svg { width: 100%; height: 100%; }

.title-info__cert {
  border: 0.1rem solid #4a5468;
  border-radius: 0.4rem;
  padding: 0.1rem 0.6rem;
  font-size: 1.4rem;
}

.title-info__overview {
  font-size: 1.8rem;
  line-height: 1.5;
  color: #c7cede;
  margin-top: 2rem;
}

.title-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 2.8rem;
}

.title-actions .button {
  margin-right: 1.6rem;
  margin-bottom: 1.2rem;
}

.title-seasons {
  margin-top: 1.6rem;
}

.title-seasons__title {
  font-size: 2.2rem;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 1.4rem;
}

.title-seasons .scroll__body {
  display: flex;
  flex-direction: row;
}

.season-chip {
  flex: 0 0 auto;
  padding: 0 2rem;
  height: 4.6rem;
  line-height: 4.6rem;
  border-radius: 2.3rem;
  background-color: rgba(255, 255, 255, 0.08);
  color: #c7cede;
  font-size: 1.6rem;
  margin-right: 1.2rem;
  white-space: nowrap;
  transition: transform 0.12s ease-out;
}

.season-chip.focus {
  background-color: #ffffff;
  color: #15171b;
  transform: scale(1.05);
}

.title-episodes {
  margin-top: 2.4rem;
}

.title-episodes__loading {
  font-size: 1.7rem;
  color: #8b93a3;
  padding: 1.6rem 0;
}

.episode {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 1.4rem 1.6rem;
  border-radius: 0.8rem;
  margin-bottom: 0.8rem;
  background-color: rgba(255, 255, 255, 0.04);
  transition: transform 0.12s ease-out;
}

.episode.focus {
  background-color: rgba(255, 255, 255, 0.16);
  transform: scale(1.01);
}

.episode__num {
  flex: 0 0 auto;
  width: 4.4rem;
  font-size: 2.2rem;
  font-weight: bold;
  color: #ffffff;
}

.episode__name {
  font-size: 1.8rem;
  color: #ffffff;
}

.episode__date {
  font-size: 1.4rem;
  color: #8b93a3;
  margin-top: 0.3rem;
}

.title-skeleton {
  display: flex;
  flex-direction: row;
}

.title-skeleton__poster {
  flex: 0 0 auto;
  width: 26rem;
  height: 39rem;
  margin-right: 3.6rem;
}

.title-skeleton__info {
  flex: 1 1 auto;
  max-width: 60rem;
}

.title-skeleton__info .skeleton-line {
  height: 2.4rem;
  margin-bottom: 1.4rem;
}

/* ================================================================ */
/* Catalog screen                                                    */
/* ================================================================ */

.catalog-screen { position: relative; width: 100%; height: 100%; overflow: hidden; }

.filter-bar {
  position: fixed;
  z-index: 15;
  left: 8.4rem;
  right: 0;
  top: 0;
  height: 8.4rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 3.2rem;
  background-image: linear-gradient(180deg, rgba(15, 16, 20, 0.95) 0%, rgba(15, 16, 20, 0) 100%);
}

.filter-btn {
  min-width: 16rem;
  height: 5.4rem;
  padding: 0 1.8rem;
  border-radius: 0.8rem;
  background-color: rgba(255, 255, 255, 0.07);
  margin-right: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.12s ease-out;
}

.filter-btn.focus {
  background-color: #ffffff;
  transform: scale(1.03);
}

.filter-btn__label {
  font-size: 1.2rem;
  color: #8b93a3;
}

.filter-btn.focus .filter-btn__label { color: #4a5468; }

.filter-btn__value {
  font-size: 1.7rem;
  font-weight: bold;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-btn.focus .filter-btn__value { color: #15171b; }

.catalog-grid {
  position: fixed;
  z-index: 1;
  left: 8.4rem;
  right: 0;
  top: 8.4rem;
  bottom: 0;
  overflow: hidden;
}

.catalog-grid > .scroll { width: 100%; height: 100%; }

.catalog-grid__body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  padding: 2.4rem 3.2rem 6rem 3.2rem;
}

.catalog-grid__body .card {
  width: 15.6rem;
  margin-right: 1.6rem;
  margin-bottom: 2.4rem;
}

.catalog-grid__skeleton {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.catalog-grid__skeleton .card {
  width: 15.6rem;
  margin-right: 1.6rem;
  margin-bottom: 2.4rem;
}

/* Modal select (remote-driven) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 40;
  background-color: rgba(10, 11, 14, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: 46rem;
  max-height: 70%;
  background-color: #1a2030;
  border: 0.1rem solid #323b4d;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal__list {
  overflow: hidden;
  padding: 1rem 0;
}

.modal__item {
  padding: 1.4rem 2.4rem;
  font-size: 1.9rem;
  color: #c7cede;
  transition: transform 0.1s ease-out;
}

.modal__item--current { color: #ffffff; }

.modal__item--current::before {
  content: "\2022";
  margin-right: 1rem;
  color: #ffcc4d;
}

.modal__item.focus {
  background-color: #ffffff;
  color: #15171b;
}

.modal__item.focus::before { color: #15171b; }

/* ================================================================ */
/* Search screen                                                     */
/* ================================================================ */

.search-screen { position: relative; width: 100%; height: 100%; overflow: hidden; }

.search-panel {
  position: fixed;
  z-index: 1;
  left: 8.4rem;
  right: 0;
  top: 0;
  bottom: 0;
  padding: 3.2rem;
  display: flex;
  flex-direction: column;
}

.search-query {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 6rem;
  border-bottom: 0.2rem solid #323b4d;
  margin-bottom: 2.4rem;
}

.search-query__text {
  font-size: 2.6rem;
  color: #ffffff;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-query__text--empty { color: #6a7488; }

.search-query__spinner {
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  border: 0.3rem solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  opacity: 0;
}

.search-query__spinner.is-active {
  opacity: 1;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.search-columns {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  overflow: hidden;
}

.keyboard {
  flex: 0 0 auto;
  width: 54rem;
  margin-right: 3.2rem;
}

.keyboard__grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

/* Буквенные ряды ЙЦУКЕН/QWERTY: до 12 клавиш в ряд, чуть компактнее. */
.keyboard__row {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.keyboard__row .key {
  width: 3.9rem;
  height: 4.2rem;
  margin: 0.25rem;
  font-size: 1.8rem;
}

.keyboard__grid--digits { margin-top: 1rem; }
.keyboard__grid--controls { margin-top: 1rem; }

.key {
  width: 4.4rem;
  height: 4.4rem;
  margin: 0.4rem;
  border-radius: 0.6rem;
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out;
}

.key.focus {
  background-color: #ffffff;
  color: #15171b;
  transform: scale(1.08);
}

.key--wide { width: 7rem; font-size: 1.5rem; }
.key--space { width: 14rem; font-size: 1.5rem; }

.search-results {
  flex: 1 1 auto;
  overflow: hidden;
}

.search-results > .scroll { width: 100%; height: 100%; }

.search-results__body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}

.search-results__body .card {
  width: 14.4rem;
  margin-right: 1.4rem;
  margin-bottom: 2rem;
}
