/* PROTECTED AREA v0.0.569: Library gallery card sizing/layout is working. Do not globally replace card sizing for unrelated hover-control work. */
/* PROTECTED HOVER CONTROL AREA v0.0.570: Future hover icons must not change library card sizing/layout or section card display. */
/* PROTECTED WORKING AREA v0.0.365: Library card layout, card-row gutters, and side arrows are confirmed working. Do not rewrite during Music fixes. */
.library-view {
  width: 100%;
  max-width: none;
  margin-top: clamp(8px, 1vh, 14px);
}

.library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 16px;
}

.library-kicker {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.library-title {
  display: none;
}

.library-path {
  display: none;
}

.library-back-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.library-back-button[hidden] {
  display: none;
}

.library-back-button:hover,
.library-back-button:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.library-back-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.library-back-icon-button img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.library-back-icon-button:hover,
.library-back-icon-button:focus-visible {
  outline: none;
  filter: brightness(1.18);
}

.library-row-stage {
  position: relative;
  width: 100%;
}

.library-row-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0 18px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.library-row-wrap::-webkit-scrollbar {
  display: none;
}


.library-card-controls {
  display: flex;
  justify-content: flex-end;
  min-height: 36px;
  margin: 0 0 10px;
}

.library-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.library-scroll-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 34px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.library-scroll-button:hover,
.library-scroll-button:focus-visible {
  outline: none;
  color: var(--accent);
}

.library-scroll-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.library-scroll-button[hidden] {
  display: none;
}

.library-row {
  display: flex;
  gap: 18px;
  min-width: min-content;
}

.library-card-button {
  position: relative;
  flex: 0 0 clamp(325px, 22.5vw, 488px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 20px 55px rgba(0,0,0,0.28);
}

.library-card-button:hover,
.library-card-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.library-card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.64;
}

.library-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.78));
}

.library-card-copy {
  position: absolute;
  left: auto;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  max-width: 72%;
  text-align: right;
}

.library-card-title {
  display: block;
  font-size: clamp(20px, 2.5vw, 30px);
  font-weight: 900;
  line-height: 1.02;
}

.library-card-subtitle {
  display: block;
  margin-top: 6px;
  color: rgba(255,255,255,0.74);
  font-size: 13px;
  font-weight: 700;
}


@media (max-width: 700px) {
  .library-view {
    margin-top: 2vh;
  }

  .library-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-card-button {
    flex-basis: min(88vw, 375px);
    border-radius: 0;
  }

  
.library-card-controls {
  display: flex;
  justify-content: flex-end;
  min-height: 36px;
  margin: 0 0 10px;
}

.library-heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .library-scroll-button {
    width: 32px;
    height: 32px;
    font-size: 32px;
  }
}

@media (min-width: 1600px) {
  .library-row {
    gap: 24px;
  }

  .library-card-button {
    flex-basis: clamp(425px, 22.5vw, 488px);
    border-radius: 0;
  }

  .library-scroll-button {
    width: 36px;
    height: 36px;
    font-size: 38px;
  }
}

/* v0.0.355: match tightened library section spacing and remove duplicate right-side card back icon. */
.library-view {
  margin-top: clamp(1px, 0.25vh, 4px);
}

.library-heading {
  min-height: 24px;
  margin-bottom: 8px;
}

.library-heading #libraryBackButton,
.library-heading .library-back-icon-button {
  display: none !important;
}

/* v0.0.357: remove the duplicate right-side card back icon from main and sub library card controls. Header-left back remains the only back control. */
.library-card-controls #libraryBackButton,
.library-card-controls .library-back-icon-button {
  display: none !important;
}


/* v0.0.363: TV-friendly side arrows for library card rails. */
.library-row-stage-with-arrows {
  position: relative;
}

.library-scroll-side {
  position: absolute;
  top: 50%;
  z-index: 6;
  transform: translateY(-50%);
  width: clamp(42px, 2.7vw, 58px);
  height: clamp(72px, 5.6vw, 112px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255,255,255,0.86);
  font-size: clamp(42px, 3.5vw, 68px);
  line-height: 1;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 36px rgba(0,0,0,0.35);
}

.library-scroll-side-left {
  left: clamp(6px, 0.7vw, 14px);
}

.library-scroll-side-right {
  right: clamp(6px, 0.7vw, 14px);
}

.library-scroll-side:hover,
.library-scroll-side:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0,0,0,0.58);
  outline: none;
}

.library-scroll-side:disabled {
  opacity: 0.24;
}

.library-scroll-side[hidden] {
  display: none;
}

/* v0.0.536: balanced fixed arrow gutters so all big arrows sit in clean left/right columns. */
.library-row-stage-with-arrows {
  --ninja-row-arrow-size: clamp(50px, 3.4vw, 66px);
  --ninja-row-arrow-gutter: clamp(72px, 4.6vw, 88px);
  padding-left: var(--ninja-row-arrow-gutter);
  padding-right: var(--ninja-row-arrow-gutter);
}

.library-row-stage-with-arrows .library-row-wrap {
  padding-left: 0;
  padding-right: 0;
}

.library-row-stage-with-arrows .library-scroll-side-left {
  left: 0;
}

.library-row-stage-with-arrows .library-scroll-side-right {
  right: 0;
}

/* v0.0.534: lock Ninja arrow art in place, slightly smaller, with no hover jump or orange backing. */
.library-scroll-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.library-scroll-side.library-scroll-button {
  width: var(--ninja-row-arrow-size, clamp(50px, 3.4vw, 66px));
  height: var(--ninja-row-arrow-size, clamp(50px, 3.4vw, 66px));
  border: 0;
  border-radius: 999px;
  background: transparent !important;
  color: transparent;
  font-size: 0;
  backdrop-filter: none;
  box-shadow: none;
  filter: drop-shadow(0 0 11px rgba(55, 255, 120, 0.22));
  transition: filter 140ms ease, opacity 140ms ease;
}

.library-scroll-side.library-scroll-button:hover,
.library-scroll-side.library-scroll-button:focus-visible {
  transform: translateY(-50%);
  background: transparent !important;
  border-color: transparent;
  outline: none;
  filter: drop-shadow(0 0 13px rgba(55, 255, 120, 0.35)) brightness(1.08);
}

.library-scroll-side.library-scroll-button:disabled {
  opacity: 0.24;
  transform: translateY(-50%);
  background: transparent !important;
  filter: grayscale(0.9) drop-shadow(0 0 5px rgba(0, 0, 0, 0.35));
}

/* v0.0.564 — top library cards follow the Web/TV Size control. */
body:not(.shell-device-phone) .library-card-button {
  flex-basis: clamp(var(--ninja-library-card-min, 325px), var(--ninja-library-card-fluid, 22.5vw), var(--ninja-library-card-max, 488px));
}

body:not(.shell-device-phone) .library-row {
  gap: clamp(var(--ninja-grid-col-gap-min, 16px), var(--ninja-grid-col-gap-fluid, 1.2vw), var(--ninja-grid-col-gap-max, 26px));
}

body:not(.shell-device-phone) .library-card-title {
  font-size: clamp(var(--ninja-library-title-min, 20px), var(--ninja-library-title-fluid, 2.5vw), var(--ninja-library-title-max, 30px));
}

body:not(.shell-device-phone) .library-card-subtitle,
body:not(.shell-device-phone) .library-kicker,
body:not(.shell-device-phone) .library-back-button {
  font-size: var(--ninja-small-copy-font, 13px);
}

/* v0.0.564 — valid fixed tokens for scaled library card text. */
body:not(.shell-device-phone) .library-card-title {
  font-size: clamp(var(--ninja-library-title-min, 20px), var(--ninja-library-title-fluid, 2.5vw), var(--ninja-library-title-max, 30px));
}

body:not(.shell-device-phone) .library-card-subtitle,
body:not(.shell-device-phone) .library-kicker,
body:not(.shell-device-phone) .library-back-button {
  font-size: var(--ninja-small-copy-font, 13px);
}

/* v0.0.572: Phone-only arrow removal. Keep the protected gallery render/card code untouched. */
@media (max-width: 700px) {
  body.shell-device-phone .library-row-stage-with-arrows {
    padding-left: 0;
    padding-right: 0;
  }

  body.shell-device-phone .library-row-stage-with-arrows .library-scroll-side {
    display: none !important;
  }

  body.shell-device-phone .library-row-stage-with-arrows .library-row-wrap {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }

  body.shell-device-phone .library-card-button {
    flex-basis: min(100%, 375px);
  }
}
