/* reels.css - the Reels tab (10/11). Its own file so the kid-theme lane can keep editing kid-themes.css. Colors come
   from each person's theme (--theme / --bg / --accent from tenants.json, --kid-title-font from kid-themes.css), so
   every kid's Reels looks like their own app. Phone first (390x844, iPhone PWA). */

/* the pane fills the screen above the tab bar; the feed scrolls, not the page */
.pane-container:has(> #pane-reels:not([hidden])) { padding: 0; overflow: hidden; }
#pane-reels:not([hidden]) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.reels-root { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.reels-root > .kt-note { padding: 24px 16px; }

.reels-top {
  position: absolute; z-index: 3; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 85%, transparent), transparent);
  pointer-events: none;
}
.reels-top > * { pointer-events: auto; }
.reels-brand {
  font-family: var(--kid-title-font, inherit); font-weight: 800; font-size: 20px; letter-spacing: .02em;
  color: var(--text); text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}
.reels-pack {
  font-size: 12px; font-weight: 700; color: var(--bg); background: var(--accent);
  padding: 3px 9px; border-radius: 999px;
}
.reels-pack:empty { display: none; }
.reels-top-btn {
  margin-left: auto; font: inherit; font-size: 13px; font-weight: 700; color: var(--text);
  background: color-mix(in srgb, var(--surface, #141820) 70%, transparent); border: 1px solid var(--border-subtle, #252c3a);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}

.reels-feed {
  flex: 1 1 auto; min-height: 0; height: 100%;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scroll-snap-type: y mandatory; scrollbar-width: none;
}
.reels-feed::-webkit-scrollbar { display: none; }
.reels-empty { padding: 90px 24px; text-align: center; color: var(--muted); }

.reel-card {
  position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    linear-gradient(180deg, var(--theme, #141820), var(--bg));
}
.reel-card + .reel-card { border-top: 1px solid color-mix(in srgb, var(--accent) 12%, transparent); }

/* the 9:16 player (or the poster before a tap) */
.reel-stage {
  position: relative; height: min(100%, calc(100vw * 16 / 9)); aspect-ratio: 9 / 16; max-width: 100%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.reel-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.reel-poster { display: flex; flex-direction: column; align-items: center; gap: 14px; user-select: none; }
.reel-emoji { font-size: 84px; line-height: 1; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .45)); animation: reel-bob 3s ease-in-out infinite; }
.reel-play {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; padding-left: 5px;
  color: var(--bg); background: var(--accent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent);
}
.reel-tap { font-size: 13px; font-weight: 700; color: var(--muted); }
.reel-sound-hint {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 56px); left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 999px; padding: 4px 10px;
  pointer-events: none; animation: reel-fade 4s forwards;
}

/* bottom-left: why chip, channel + follow, title */
.reel-meta {
  position: absolute; z-index: 2; left: 0; right: 64px; bottom: 0; padding: 40px 14px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, .72), transparent); pointer-events: none;
}
.reel-meta > * { pointer-events: auto; }
.reel-chip {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px;
  color: var(--bg); background: var(--accent);
}
.reel-chip-fun, .reel-chip-followed { color: var(--text); background: rgba(255, 255, 255, .16); }
.reel-chip-agent { background: linear-gradient(90deg, var(--accent), #ffd166); }
.reel-by { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: #fff; font-size: 15px; }
.reel-title { margin-top: 6px; color: #f1f5f9; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel-follow {
  font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; border-radius: 999px; padding: 4px 12px;
  color: #fff; background: transparent; border: 1.5px solid #fff;
}
.reel-follow.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.reel-follow:disabled { opacity: .6; }

/* right rail: like + save (kept on this phone only) */
.reel-side { position: absolute; z-index: 2; right: 10px; bottom: 24px; display: flex; flex-direction: column; gap: 14px; }
.reel-side-btn {
  width: 46px; height: 46px; border-radius: 50%; font-size: 20px; cursor: pointer;
  background: rgba(0, 0, 0, .38); border: 1px solid rgba(255, 255, 255, .18); filter: grayscale(1) opacity(.8);
  transition: transform .15s ease, filter .15s ease;
}
.reel-side-btn.on { filter: none; transform: scale(1.08); border-color: var(--accent); }
.reel-side-btn:active { transform: scale(.92); }

/* quiz + end cards */
.reel-panel {
  width: min(92%, 420px); padding: 22px 18px; border-radius: 22px; text-align: center;
  background: color-mix(in srgb, var(--surface, #141820) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.reel-kicker { font-size: 13px; font-weight: 800; color: var(--accent); letter-spacing: .02em; }
.reel-q { margin-top: 10px; font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.35; }
.reel-choices { display: grid; gap: 10px; margin-top: 16px; }
.reel-choice {
  font: inherit; font-size: 15px; text-align: left; cursor: pointer; padding: 12px 14px; border-radius: 14px;
  color: var(--text); background: rgba(255, 255, 255, .06); border: 1.5px solid var(--border-subtle, #252c3a);
}
.reel-choice b { color: var(--accent); margin-right: 6px; }
.reel-choice.right { border-color: #4ade80; background: rgba(74, 222, 128, .16); }
.reel-choice.wrong { border-color: #f87171; background: rgba(248, 113, 113, .14); }
.reel-quiz-out { margin-top: 12px; min-height: 1.4em; font-size: 14px; color: var(--text); }
.reel-end-burst { font-size: 54px; animation: reel-pop .6s ease-out; }
.reel-end-title { margin-top: 6px; font-family: var(--kid-title-font, inherit); font-size: 24px; color: var(--text); }
.reel-end-line { margin-top: 10px; font-size: 16px; color: var(--text); }
.reel-end-note { margin-top: 14px; font-size: 13px; color: var(--muted); }

/* channels sheet */
.reels-sheet { position: absolute; inset: 0; z-index: 5; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; }
.reels-sheet[hidden] { display: none; }
.reels-sheet-card {
  width: 100%; max-height: 78%; overflow-y: auto; padding: 16px 16px calc(16px + var(--safe-bottom, 0px));
  background: var(--surface, #141820); border-radius: 22px 22px 0 0; border-top: 2px solid var(--accent);
}
.reels-sheet-head { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--text); }
.reels-sheet-note { margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.reels-sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border-subtle, #252c3a); color: var(--text); }
.reels-sheet-row .reel-follow { color: var(--text); border-color: var(--border-subtle, #3a4250); }
.reels-sheet-row .reel-follow.on { color: var(--bg); border-color: var(--accent); }

/* "Shared with you" row under the top bar + share sheet (10/11) */
.reels-shared {
  position: absolute; z-index: 3; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 50px);
  display: flex; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 2px 14px 6px;
}
.reels-shared::-webkit-scrollbar { display: none; }
.reels-shared[hidden] { display: none; }
.reels-shared-label { flex: 0 0 auto; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.reels-shared-chip {
  flex: 0 0 auto; max-width: 200px; display: flex; gap: 6px; align-items: center; font: inherit; font-size: 12px; cursor: pointer;
  color: var(--text); background: color-mix(in srgb, var(--surface, #141820) 80%, transparent);
  border: 1px solid var(--border-subtle, #252c3a); border-radius: 999px; padding: 5px 10px;
}
.reels-shared-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.reels-shared-chip.new { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.reel-chip-gift { background: linear-gradient(90deg, #ffd166, var(--accent)); color: #1a1a1a; }
.reel-chip-shared { background: #ff9ec4; color: #2a0f1c; }
.reels-people { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.reels-person {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; padding: 8px 14px; border-radius: 999px;
  color: var(--text); background: rgba(255, 255, 255, .06); border: 1.5px solid var(--border-subtle, #252c3a);
}
.reels-person[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.reels-note {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; color: var(--text);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border-subtle, #252c3a);
}
.reels-share-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.reels-send {
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; padding: 10px 22px; border-radius: 999px; border: 0;
  color: var(--bg); background: var(--accent);
}
.reels-send:disabled { opacity: .45; cursor: not-allowed; }
.reels-share-actions .reels-top-btn { margin-left: 0; }
.reels-share-out { margin-top: 10px; min-height: 1.3em; font-size: 14px; color: var(--text); }
.reels-shared-note { margin: 4px 0 10px; font-size: 16px; font-style: italic; color: var(--text); }
.reels-shared-stage { position: relative; width: min(100%, 300px); aspect-ratio: 9 / 16; margin: 0 auto; border-radius: 14px; overflow: hidden; }

@keyframes reel-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes reel-pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@keyframes reel-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .reel-emoji, .reel-end-burst, .reel-sound-hint { animation: none; }
  .reel-side-btn { transition: none; }
}
