/* tv.css — LiveMath TV.
 *
 * The page came from the standalone /expo/ app: Bootstrap for layout, a dark
 * header bar of its own, and a dark "featured" band. It now runs inside the
 * lm26 chrome like every other page, so Bootstrap is gone, the bands are light,
 * and the handful of grid primitives it used are provided here — all scoped to
 * .tv-page so nothing leaks into the shared header and footer.
 *
 * The single most important rule in this file is the thumbnail sizing: these
 * images come from the database and some of them are missing, so anything
 * without an explicit box renders at the browser's natural size for a broken
 * image and blows the layout apart.
 */

/* ---------- grid primitives (were Bootstrap) ---------- */
.tv-page .container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0; }
.tv-page .row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.25rem;
}
.tv-page [class*="col-"] { grid-column: auto; }   /* the grid does the sizing now */
.tv-page .text-muted   { color: var(--text-soft); }
.tv-page .text-center  { text-align: center; }
.tv-page .text-truncate{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-page .d-flex       { display: flex; }
.tv-page .fw-semibold  { font-weight: 600; }
.tv-page .mt-4 { margin-top: 1.5rem; }
.tv-page .mb-1 { margin-bottom: .25rem; }
.tv-page .mb-5 { margin-bottom: 2.5rem; }
.tv-page .mx-1 { margin: 0 .3rem; }
.tv-page .ms-2 { margin-left: .5rem; }
.tv-page .p-5  { padding: 2.5rem; }

/* ---------- search + breadcrumb ---------- */
.tv-search { display: flex; gap: .5rem; max-width: 460px; margin: 0 0 1.75rem; }
.tv-search input {
  flex: 1; padding: .55rem .8rem; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cdd8e6; border-radius: var(--r-sm);
}
.tv-search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(63,169,255,.18); }
.tv-search button {
  padding: .55rem 1.2rem; font: inherit; color: #fff; background: var(--blue);
  border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.tv-crumbs { font-size: .9rem; color: var(--text-soft); margin: 0 0 1.5rem; }
.tv-crumbs a { color: var(--blue); }

/* ---------- section headings ---------- */
.tv-page .section-hdr,
.tv-page .featured-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
/* The featured band was dark navy; on a light page it read as a hole. */
.tv-page .featured-section { background: none; padding: 0; margin: 0 0 2.5rem; }

/* ---------- video cards ---------- */
.tv-page .video-card {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tv-page .video-card:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 12px 30px -20px rgba(19,36,58,.55);
}
/* THE load-bearing rule: a fixed 16:9 box regardless of what the image is,
   or whether it loads at all. */
.tv-page .thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--paper-2);
  overflow: hidden;
}
.tv-page .thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  /* A missing thumbnail shows an empty tile, never a broken-image glyph
     stretched to the browser's default size. */
  color: transparent;
  font-size: 0;
}
.tv-page .play-icon {
  position: absolute; inset: 0; margin: auto;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(19,36,58,.62);
  pointer-events: none;
}
.tv-page .play-icon::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 0; height: 0;
  border-left: 15px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  transform: translateX(2px);
}
.tv-page .duration-badge {
  position: absolute; right: .5rem; bottom: .5rem;
  padding: .12rem .4rem;
  background: rgba(10,19,32,.82); color: #fff;
  border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px;
}
.tv-page .card-body { padding: .8rem .9rem 1rem; }
.tv-page .card-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 600; line-height: 1.25;
  color: var(--ink); margin: 0 0 .35rem;
}
.tv-page .card-path,
.tv-page .card-creator,
.tv-page .creator-date { font-size: .8rem; color: var(--text-soft); line-height: 1.4; }
.tv-page .card-kw { margin-top: .4rem; }
.tv-page .kw-badge,
.tv-page .badge {
  display: inline-block;
  padding: .1rem .45rem; margin: 0 .25rem .25rem 0;
  background: var(--paper-2); color: var(--text-soft);
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
}

/* ---------- category cards ---------- */
.tv-page .cat-card {
  display: block; height: 100%;
  padding: 1.1rem 1.15rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tv-page .cat-card:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
  box-shadow: 0 10px 26px -18px rgba(19,36,58,.5);
}
.tv-page .cat-icon { width: 26px; height: 26px; margin-bottom: .5rem; color: var(--blue); }
.tv-page .cat-icon svg { width: 100%; height: 100%; fill: currentColor; }
.tv-page .cat-name {
  display: block;
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 600;
  color: var(--ink);
}
.tv-page .cat-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-soft); }
.tv-page a.cat-card, .tv-page a.cat-card:hover { text-decoration: none; }

.tv-page .nb-link, .tv-page .yt-link { font-size: .85rem; }

/* ---------- video dialog (replaces Bootstrap's .modal) ---------- */
#videoModal {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10,19,32,.72);
  padding: 4vh 1rem; overflow-y: auto;
}
#videoModal.is-open { display: block; }
#videoModal .modal-dialog {
  max-width: 900px; margin: 0 auto;
  background: var(--ink); color: #fff;
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
}
#videoModal .modal-header {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.12);
}
#videoModal .btn-close {
  margin-left: auto; width: 32px; height: 32px; flex: none;
  background: rgba(255,255,255,.12); border: 0; border-radius: 50%;
  color: #fff; font-size: 1.15rem; line-height: 1; cursor: pointer;
}
#videoModal .btn-close::before { content: "\00d7"; }
#videoModal .btn-close:hover { background: rgba(255,255,255,.22); }
#videoModal .video-container { background: #000; }
#videoModal .video-container video,
#videoModal .video-container iframe {
  display: block; width: 100%; aspect-ratio: 16/9; border: 0;
}
#videoModal .modal-body { padding: 1rem 1.1rem 1.25rem; font-size: .95rem; }
#videoModal .video-meta-title { font-family: var(--font-display); font-size: 1.15rem; margin: 0 0 .4rem; }
#videoModal .video-meta-desc, #videoModal .video-creator-meta { color: #cfe0f5; }
