/* Guardian Books — Jellyfin / Media-style home (full-bleed rows + hero) */
:root {
  --bk-bg: #101010;
  --bk-surface: #1c1c1c;
  --bk-elevated: #252525;
  --bk-ink: #ffffff;
  --bk-muted: #aaa;
  --bk-accent: #00a4dc;
  --bk-accent-2: #3eb8e8;
  --bk-line: rgba(255, 255, 255, 0.08);
  --bk-radius: 6px;
  --bk-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Fixed inset — do not rely on clamp/vars alone; directory.css caps <main>. */
  --bk-pad: 48px;
}

body.books-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bk-bg);
  color: var(--bk-ink);
  font-family: var(--bk-ui);
}

/* Beat directory.css `header, main, footer { width: min(1120px, calc(100% - 48px)) }` */
body.books-body header,
body.books-body main,
body.books-body footer,
body.books-body .books-media-bar,
body.books-body .books-shell {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-inline: 0 !important;
}

body.books-body footer {
  color: var(--bk-muted);
  border-top: 1px solid var(--bk-line);
  padding-left: var(--bk-pad);
  padding-right: var(--bk-pad);
  max-width: none;
}

/* Media-style top bar — single row: user + search + tabs | logo */
.books-media-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding: 8px var(--bk-pad);
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(16, 16, 16, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bk-line);
}

.books-media-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.books-media-logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-left: auto;
  border-radius: 8px;
  line-height: 0;
}

.books-media-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: block;
}

.books-icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--bk-ink);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.books-icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.books-user-menu {
  position: relative;
}

.books-user-menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.books-user-menu > summary::-webkit-details-marker {
  display: none;
}

.books-user-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.75;
  margin-right: 4px;
}

.books-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: #1c1c1c;
  border: 1px solid var(--bk-line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.books-user-name {
  margin: 0 0 6px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--bk-line);
  font-weight: 700;
  font-size: 0.9rem;
}

.books-user-dropdown a,
.books-user-dropdown button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--bk-ink);
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  padding: 10px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}

.books-user-dropdown a:hover,
.books-user-dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.books-user-dropdown form {
  margin: 0;
}

.books-search-flyout {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 0 12px;
  min-width: 0;
  flex: 1 1 auto;
  max-width: min(320px, 55vw);
}

.books-search-flyout[hidden] {
  display: none !important;
}

.books-search-flyout input {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--bk-ink);
  padding: 10px 0;
  font: inherit;
  min-width: 0;
}

.books-search-flyout input:focus {
  outline: none;
}

.books-media-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  margin-left: 8px;
  padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.books-media-tabs::-webkit-scrollbar {
  display: none;
}

.books-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--bk-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
  white-space: nowrap;
}

.books-tab:hover {
  color: var(--bk-ink);
}

.books-tab[aria-selected="true"] {
  color: var(--bk-ink);
  background: rgba(255, 255, 255, 0.12);
}

/* Full page width — no centered column */
.books-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 120px;
  box-sizing: border-box;
}
.books-status {
  padding: 0 var(--bk-pad);
  color: var(--bk-muted);
  font-size: 0.9rem;
}

.books-btn {
  appearance: none;
  border: 0;
  border-radius: 4px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.books-btn-primary {
  background: var(--bk-accent);
  color: #000;
}

.books-btn-primary:hover {
  background: var(--bk-accent-2);
}

.books-btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--bk-ink);
  border: 0;
}

.books-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Hero — Media/Jellyfin style featured banner */
.books-hero {
  position: relative;
  width: 100%;
  min-height: clamp(320px, 48vw, 520px);
  margin: 0 0 12px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.books-hero-bg,
.books-hero-poster,
.books-hero-poster-ph {
  pointer-events: none;
}

.books-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  transform: scale(1.04);
  filter: saturate(1.05);
}

.books-hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(16, 16, 16, 0.92) 0%, rgba(16, 16, 16, 0.55) 42%, rgba(16, 16, 16, 0.2) 70%, transparent 100%),
    linear-gradient(0deg, #101010 0%, transparent 45%);
}

.books-hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: end;
  width: 100%;
  padding: 48px 48px 36px;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .books-hero-inner {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

.books-hero-poster {
  width: clamp(120px, 16vw, 200px);
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  background: var(--bk-elevated);
}

.books-hero-poster-ph {
  width: clamp(120px, 16vw, 200px);
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  background: linear-gradient(160deg, #2a3540, #14181c);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
}

.books-hero-copy {
  max-width: 640px;
  min-width: 0;
}

.books-hero-chip {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bk-accent-2);
  margin-bottom: 8px;
}

.books-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.books-hero-sub {
  margin: 0 0 18px;
  color: #ddd;
  font-size: 1rem;
  line-height: 1.45;
}

.books-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Horizontal Media rows — padded like Jellyfin (no scroll-snap; it skipped spacers) */
.books-section {
  width: 100%;
  margin: 28px 0 8px;
  box-sizing: border-box;
}

.books-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 48px !important;
  margin: 0 0 12px !important;
  box-sizing: border-box;
}

.books-section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.books-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  /* Hard inset via padding — always visible at scrollLeft=0 */
  padding: 4px 48px 18px !important;
  scroll-snap-type: none !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
  box-sizing: border-box;
}

.books-row-spacer {
  display: none !important; /* padding handles inset now */
}

.books-row::-webkit-scrollbar {
  display: none;
}

.books-card {
  flex: 0 0 auto;
  scroll-snap-align: none !important;
  width: clamp(118px, 12vw, 160px);
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.books-card:hover .books-card-cover {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.books-card-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: #202020;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.books-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.books-card-cover-ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: end start;
  padding: 10px;
  box-sizing: border-box;
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 1.25;
  background:
    linear-gradient(160deg, rgba(0, 164, 220, 0.28), transparent 55%),
    linear-gradient(0deg, #1d2430, #12151b);
}

.books-card-title {
  margin: 8px 0 2px;
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.books-card-sub {
  margin: 0;
  color: var(--bk-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search / filtered grid — still full width */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 18px 14px;
  padding: 12px 48px 24px !important;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .books-section-head,
  .books-row,
  .books-grid {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
}

.books-grid .books-card {
  width: auto;
}

.books-empty {
  margin: 24px var(--bk-pad);
  border: 1px dashed var(--bk-line);
  border-radius: 8px;
  padding: 40px 22px;
  text-align: center;
  color: var(--bk-muted);
  background: rgba(255, 255, 255, 0.03);
}

/* Detail */
.books-detail {
  display: grid;
  gap: 28px;
  padding: 12px var(--bk-pad) 40px;
  width: 100%;
  box-sizing: border-box;
  max-width: none;
}

@media (min-width: 840px) {
  .books-detail {
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
  }
}

.books-detail-cover {
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  background: #202020;
  overflow: hidden;
  position: relative;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  max-width: 240px;
}

.books-detail-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.books-detail h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.books-detail .by {
  color: var(--bk-muted);
  margin: 0 0 14px;
}

.books-detail .books-actions {
  margin-bottom: 14px;
}


.books-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 18px;
  margin: 0 0 18px;
  padding: 14px 0;
  border-top: 1px solid var(--bk-line);
  border-bottom: 1px solid var(--bk-line);
}

.books-meta-item {
  min-width: 0;
}

.books-meta-item span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bk-muted);
  margin-bottom: 4px;
}

.books-meta-item strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--bk-ink);
  line-height: 1.35;
}

.books-desc {
  margin: 0 0 20px;
  color: #d6d6d6;
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 52rem;
  white-space: pre-wrap;
}

.books-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Bottom player — same layout as Music (.music-player) */
.books-player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 42%) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  background: #181818;
  border-top: 1px solid #282828;
  padding: 10px 18px;
  min-height: 90px;
  box-sizing: border-box;
}

.books-player[hidden] {
  display: none !important;
}

.books-player > .books-now {
  justify-self: start;
  min-width: 0;
  max-width: 100%;
}

.books-player > .books-controls {
  justify-self: center;
  width: 100%;
  max-width: 560px;
}

.books-player > .books-player-actions {
  justify-self: end;
}

.books-now {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.books-now:hover .books-now-text strong {
  text-decoration: underline;
}

.books-ph {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: #333 center / cover no-repeat;
  flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.books-now-text {
  min-width: 0;
}

.books-now-text strong,
.books-now-text span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.books-now-text span {
  color: var(--bk-muted);
  font-size: 0.82rem;
}

.books-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.books-buttons {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.books-buttons button {
  border: 0;
  background: transparent;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.9;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
}

.books-buttons button:hover {
  opacity: 1;
  transform: scale(1.06);
}

.books-buttons .play {
  background: #fff;
  color: #000;
  width: 42px;
  height: 42px;
  font-size: 1rem;
  opacity: 1;
}

.books-seek {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--bk-muted);
  font-size: 0.75rem;
}

.books-seek input[type="range"] {
  flex: 1;
  accent-color: var(--bk-accent);
}

.books-player-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.books-expand-btn {
  border: 0;
  background: transparent;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.85;
}

.books-expand-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 720px) {
  .books-player {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 8px 12px;
    padding: 10px 14px 12px;
    min-height: 0;
  }
  .books-player > .books-now {
    grid-column: 1;
    grid-row: 1;
  }
  .books-player > .books-player-actions {
    grid-column: 2;
    grid-row: 1;
  }
  .books-player > .books-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
  }
}

.books-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 164, 220, 0.18);
  color: var(--bk-accent-2);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.books-companions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--bk-line);
}

.books-companions h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

.books-companion-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.books-companion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.books-companion-row:hover {
  background: rgba(255, 255, 255, 0.1);
}

.books-companion-row img {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--bk-elevated);
}

.books-companion-meta {
  min-width: 0;
  flex: 1;
}

.books-companion-meta strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.books-companion-meta span {
  color: var(--bk-muted);
  font-size: 0.78rem;
}

.books-link-panel {
  margin-top: 18px;
  padding: 14px;
  border-radius: 6px;
  background: var(--bk-elevated);
  border: 1px solid var(--bk-line);
}

.books-link-panel label {
  display: block;
  font-size: 0.82rem;
  color: var(--bk-muted);
  margin-bottom: 8px;
}

.books-link-panel select {
  width: 100%;
  max-width: 420px;
  background: var(--bk-surface);
  color: var(--bk-ink);
  border: 1px solid var(--bk-line);
  border-radius: 4px;
  padding: 10px 12px;
  font: inherit;
  margin-bottom: 10px;
}
