/* Cyneflix v229 — centralized responsive/accessibility foundation.
   Additive system layer: preserves the existing palette, typography and logos. */
:root {
  --v229-content-max: 1840px;
  --v229-page-gutter: clamp(14px, 3.8vw, 52px);
  --px: var(--v229-page-gutter);
  --v229-section-gap: clamp(20px, 3.2vw, 44px);
  --v229-card-gap: clamp(8px, 1.25vw, 18px);
  --v229-control-min: 40px;
  --v229-watch-toolbar-height: 54px;
  --v229-focus-color: var(--accent, #e50914);
  --v229-safe-top: env(safe-area-inset-top, 0px);
  --v229-safe-right: env(safe-area-inset-right, 0px);
  --v229-safe-bottom: env(safe-area-inset-bottom, 0px);
  --v229-safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
  scroll-padding-top: calc(var(--nav-h, 64px) + 12px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  overflow-x: clip;
  padding-left: max(0px, var(--v229-safe-left));
  padding-right: max(0px, var(--v229-safe-right));
}

/* Let flex/grid children shrink instead of forcing the page wider. */
main, section, article, aside, header, footer,
.row, .grid, .watch-main, .watch-player-layout, .watch-info,
.player-shell, .player-cap-copy, .card-body, .card-info,
.manga-layout, .music-layout, .wp-layout {
  min-width: 0;
}
img, video, canvas, svg, iframe { max-width: 100%; }
button, input, select, textarea { max-width: 100%; font: inherit; }
button, a, select, input[type="button"], input[type="submit"] { touch-action: manipulation; }

/* Keep keyboard position visible below the fixed global navigation. */
:focus-visible {
  outline: 2px solid var(--v229-focus-color);
  outline-offset: 3px;
}
:where(button, a, input, select, textarea, [role="button"]):focus:not(:focus-visible) {
  outline: none;
}

/* Fluid text wrapping protects narrow layouts from long titles/metadata. */
:where(h1, h2, h3, h4, p, .card-title, .overview, .description, .player-cap-title) {
  min-width: 0;
  overflow-wrap: break-word;
}

/* Safe-area accommodation for fixed bottom navigation and drawer content. */
#btm-nav, .bottom-nav, .mobile-bottom-nav {
  padding-bottom: max(0px, var(--v229-safe-bottom));
}
/* The root scroll padding reserves nav + breathing room; the watch-page
   target adds only the remainder needed for the 54px source toolbar. */
body.watch-page .watch-info,
body.watch-page #ep-section,
body.watch-page #watch-main {
  scroll-margin-top: calc(var(--v229-watch-toolbar-height) - 12px) !important;
}
.mobile-menu {
  padding-bottom: max(32px, var(--v229-safe-bottom));
  padding-left: max(0px, var(--v229-safe-left));
}

/* Give absolute card actions a real containing box. Without this, the
   global button max-width reset collapses bookmark controls to their border. */
.card-hover-overlay .cho-actions {
  width: 32px;
  height: 32px;
  margin: 0;
  align-items: center;
  justify-content: center;
}
.card-hover-overlay .cho-actions > .wl-btn {
  position: relative;
  inset: auto;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  max-width: none;
  flex: 0 0 30px;
}

/* Preserve horizontal carousels while preventing them from widening the page. */
.row, .home-row, .card-row, .carousel, .scroll-row, .row-track {
  max-width: 100%;
}
body.watch-page .watch-player-layout {
  max-width: var(--v229-content-max);
}

@media (max-width: 480px) {
  :root {
    --v229-page-gutter: 14px;
    --v229-section-gap: 22px;
    --v229-card-gap: 8px;
    --v229-control-min: 40px;
  }
  body { min-width: 320px; }
  input, select, textarea { min-width: 0; }
  .player-cap-copy { min-width: 0; }
}

@media (pointer: coarse) {
  .card-hover-overlay {
    display: block;
    opacity: 1;
    padding: 0;
    background: transparent;
    pointer-events: none;
  }
  .card-hover-overlay .cho-info { display: none; }
  .card-hover-overlay .cho-actions {
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
  }
  .card-hover-overlay .cho-actions > .wl-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-basis: 44px;
    opacity: 1;
    transform: none;
  }
  #main-nav .nav-icon-btn, #main-nav .nav-hamburger {
    min-width: 44px;
    min-height: 44px;
  }
  .srv-bar-right > button {
    min-height: var(--v229-control-min);
  }
  .ep-open-drawer, .ep-sort-btn, .ep-mark-btn {
    min-width: var(--v229-control-min);
    min-height: var(--v229-control-min);
  }
  .ep-season-pill, .nw-season, .tt-btn, .row-view-all {
    min-height: 40px;
  }
  .row-view-all { display: inline-flex; align-items: center; justify-content: center; }
  #btm-nav a, #btm-nav button, .bottom-nav a, .bottom-nav button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
