/* ===============================
   VUMC YouTube Grid – clean reset
   (grid + inline play + expand/close)
   =============================== */

/* Base & layout */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
:root {
  --gap: 12px;
  --radius: 14px;
  --maxw: 1200px;
  --bg: #f7f7f9;
  --fg: #111;
  --muted: #666;
  --card: #fff;
  --border: #eee;
}

/* Safe-area for notched phones */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 16px; }

/* Header */
.header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.title { margin: 0; font-size: 18px; font-weight: 700; }
.searchbox { display: flex; align-items: center; }
.searchbox input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  width: 260px;
}

/* Grid */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width:700px){ .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width:1000px){ .grid { grid-template-columns: repeat(4, 1fr); } }

/* Cards */
.card {
  position: relative; /* for overlay buttons */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: #ddd;
  overflow: hidden;
  cursor: pointer;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Play overlay icon */
.playbtn {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(to top, rgba(0,0,0,.35), rgba(0,0,0,0));
  pointer-events: none;
}
.triangle {
  width: 0; height: 0;
  border-left: 18px solid #fff;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

/* Card meta */
.meta { padding: 10px 12px 12px; display: grid; gap: 6px; }
.vtitle { font-size: 14px; font-weight: 600; line-height: 1.25; }
.subtle { color: var(--muted); font-size: 12px; }

/* Refresh button (optional) */
.controls { display: grid; place-items: center; margin: 16px 0 6px; }
.btn {
  padding: 10px 14px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

/* ===== Expand / Close overlay buttons (only appear when an iframe is present) ===== */
.card .expandbtn,
.card .closebtn { display: none; }

.card iframe ~ .expandbtn,
.card iframe ~ .closebtn {
  display: inline-flex;
  position: absolute;
  z-index: 50;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.card iframe ~ .expandbtn { right: 10px; top: calc(10px + var(--safe-top)); }
.card iframe ~ .closebtn  { right: 10px; top: calc(48px + var(--safe-top)); }

@media (hover:hover){
  .card iframe ~ .expandbtn:hover,
  .card iframe ~ .closebtn:hover {
    background: rgba(0,0,0,.7);
  }
}

/* ===== CSS fallback expand (used when Fullscreen API is blocked) ===== */
.card.expanded {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  border-radius: 0;
  margin: 0;
}
.card.expanded .thumb {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  background: #000;
}
.card.expanded .meta,
.card.expanded .playbtn { display: none; }

/* Accessibility & motion */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
