/* ==========================================================================
   Glint web — video, reels viewer, messenger and calls (loaded after reference.css and
   responsive.css). Kept separate so the owner's redesign files stay untouched.
   ========================================================================== */

/* --- Post videos: full frame (letterboxed, never cropped) + fullscreen ------------ */
.media.is-full-frame { background: #000 !important; }
.media.is-full-frame video { object-fit: contain; width: 100%; height: 100%; }
.media-fullscreen {
  position: absolute; right: 48px; bottom: 12px; width: 28px; height: 28px; border-radius: 50%; z-index: 3;
  display: grid; place-items: center; background: rgba(10, 12, 17, 0.72); color: #fff;
}
.media-video:not(:has(.media-sound)) .media-fullscreen { right: 12px; }
.media-video:fullscreen { aspect-ratio: auto !important; width: 100vw; height: 100vh; background: #000; }
.media-video:fullscreen video { object-fit: contain; }
.media-video:fullscreen .media-fullscreen { bottom: 24px; right: 64px; }
.media-video:fullscreen .media-sound { bottom: 24px; right: 24px; }

/* --- Reels: a centered, full-height 9:16 player ------------------------------------
   The owner's reels page keeps its "More to watch" list (left) and discovery rail (right);
   the player column now holds one full-height 9:16 item per screen, centered, with the
   For You | Following pill and the sound toggle on top. Vertical video fills the frame,
   wider video and photos are letterboxed over a blurred copy. Mobile: edge to edge. */
.reels-tabs {
  display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; pointer-events: auto;
  background: rgba(10, 12, 17, 0.42); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.reels-tabs a { padding: 7px 16px; border-radius: 999px; color: rgba(255, 255, 255, 0.82); font-weight: 600; font-size: var(--type-meta-size); line-height: 1.2; }
.reels-tabs a:hover { color: #fff; }
.reels-tabs a.is-active { background: rgba(255, 255, 255, 0.94); color: #0a0c11; }
.reels-hud { position: absolute; z-index: 6; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.reels-hud-sound { position: absolute; right: 12px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(10, 12, 17, 0.45); pointer-events: auto; }
.reel-media.is-letterbox { background: #000; }
.reel-backdrop { position: absolute; inset: -24px; background: center / cover no-repeat; filter: blur(28px) brightness(0.55); transform: scale(1.1); }
.reel-media > .media { position: relative; z-index: 1; background: transparent !important; }
.reel-media.is-letterbox > .media img, .reel-media.is-letterbox > .media video { object-fit: contain; }
.reel-media .reel-overlay { z-index: 3; }
.reel-count-pill { position: absolute; top: 56px; right: 12px; z-index: 3; display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: rgba(10, 12, 17, 0.55); color: #fff; font-size: 12px; font-weight: 600; }
/* Solid rail icons with counts; the follow pill and the music pill. */
.reel-action .icon { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45)); }
.reel-action .saved { color: var(--accent-selenium, var(--brand-400)); }
.reel-author .follow-link { border-radius: 999px; padding: 4px 12px; background: rgba(255, 255, 255, 0.12); font-weight: 600; }
.reel-audio { padding: 5px 12px; background: rgba(10, 12, 17, 0.45); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.reels-empty { height: 100%; display: grid; place-items: center; scroll-snap-align: start; }

@media (min-width: 1024px) {
  .page-reels .reels-heading, .page-reels .reels-top, .page-reels .sound-hint { display: none !important; }
  .reels-page { --reel-h: calc(100dvh - var(--header-h, 72px) - 24px); position: relative; }
  .reels-page .reels-scroller, .reels-page .reel { height: var(--reel-h) !important; min-height: 0 !important; }
  .reels-page .reel { padding: 0 !important; display: grid !important; place-items: center; }
  .reels-page .reel-stage { height: 100% !important; width: auto !important; display: block !important; position: relative; }
  .reels-page .reel-media { height: 100% !important; width: auto !important; max-width: none !important; aspect-ratio: 9 / 16 !important; border-radius: 16px; }
  .reels-page .reel-media > .media { height: 100% !important; aspect-ratio: auto !important; }
  .reels-page .reel-rail { position: absolute; right: 12px; bottom: 28px; z-index: 4; gap: 18px; }
  .reels-page .reel-action { color: #fff; }
  .reels-page .reel-disc { border-color: #fff; }
  .reels-page .reel-overlay { padding-right: 64px; }
  .reels-page .reels-hud { top: 24px; height: 44px; }
}
@media (min-width: 1264px) {
  .page-reels .reels-page { grid-template-rows: minmax(0, var(--reel-h)) !important; align-content: start; padding-top: 12px; }
  .page-reels .reels-discover { grid-column: 1; grid-row: 1; max-height: var(--reel-h) !important; }
  .page-reels .reels-scroller { grid-column: 2; grid-row: 1; }
  .page-reels .reels-page > .discovery-rail { grid-column: 3; grid-row: 1; max-height: var(--reel-h); }
  /* The HUD spans the player column: same grid cell as the scroller. */
  .page-reels .reels-hud { grid-column: 2; grid-row: 1; position: relative; top: 12px; align-self: start; justify-self: center; width: calc(var(--reel-h) * 9 / 16); }
}
@media (min-width: 1024px) and (max-width: 1263px) {
  .page-reels .reels-page { grid-template-rows: minmax(0, var(--reel-h)); padding-top: 12px; }
  .page-reels .reels-discover { grid-column: 1; grid-row: 1; }
  .page-reels .reels-scroller { grid-column: 2; grid-row: 1; }
  .page-reels .reels-hud { grid-column: 2; grid-row: 1; position: relative; top: 12px; align-self: start; justify-self: center; width: calc(var(--reel-h) * 9 / 16); }
}
@media (max-width: 1023px) {
  .reels-hud { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 0; right: 0; }
  .reel-media.is-letterbox > .media { height: 100%; }
}

/* --- Messenger: compact thread header and intro; the thread fills the height ---------- */
@media (min-width: 768px) {
  .dm-head { height: 60px; }
  .dm-head .avatar { --size: 40px; }
  .dm-intro { padding: 16px 16px 20px; gap: 4px; }
  .dm-intro .avatar, .dm-intro .dm-stack { --size: 64px; margin-bottom: 4px; }
  .dm-intro-title { font-size: var(--type-title-md-size); }
  .page-direct .main { overflow: hidden; }
}
.dm-call { flex: none; }
.dm-system.is-call { display: grid; justify-items: center; gap: 2px; }
.dm-system-call { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg-raised); color: var(--text-primary); font-weight: 600; }
.dm-system-call.is-missed { color: var(--status-danger); }
.dm-call-back { font-size: var(--type-meta-size); font-weight: 600; }

/* --- Calls: ringing modal and in-call view ------------------------------------------- */
.call-ring { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 17, 0.6); backdrop-filter: blur(6px); }
.call-ring-card { width: min(360px, 100%); display: grid; justify-items: center; gap: 6px; padding: 32px 24px 24px; border-radius: 22px; background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sheet); text-align: center; }
.call-ring-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin-bottom: 8px; animation: call-pulse 1.6s ease-in-out infinite; }
.call-ring-name { font-size: var(--type-title-lg-size); font-weight: 600; }
.call-ring-sub { color: var(--text-secondary); font-size: var(--type-body-size); }
.call-ring-actions { display: flex; gap: 40px; margin-top: 20px; }
@keyframes call-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-500) 50%, transparent); } 50% { box-shadow: 0 0 0 14px transparent; } }
@media (prefers-reduced-motion: reduce) { .call-ring-avatar { animation: none; } }

.call-btn { display: grid; justify-items: center; gap: 6px; }
.call-btn-circle { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.16); color: #fff; }
.call-btn-circle > span { display: grid; place-items: center; }
.call-btn-label { font-size: var(--type-meta-size); font-weight: 600; color: var(--text-primary); }
.call-ring .call-btn-circle { width: 64px; height: 64px; background: var(--bg-raised); color: var(--text-primary); }
.call-btn.is-off .call-btn-circle { background: #fff; color: #0a0c11; }
.call-btn.is-end .call-btn-circle { background: var(--status-danger); color: #fff; }
.call-btn.is-accept .call-btn-circle { background: var(--status-success); color: #fff; }

.call-view { position: fixed; inset: 0; z-index: 190; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #0a0c11; color: #fff; }
.call-stage { position: relative; min-height: 0; overflow: hidden; }
.call-remote { position: absolute; inset: 0; display: grid; gap: 4px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.call-remote[data-count="1"] { grid-template-columns: 1fr; }
.call-tile { position: relative; min-height: 0; background: #000; overflow: hidden; }
.call-tile video, .call-tile > div { width: 100% !important; height: 100% !important; object-fit: cover; }
.call-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; }
.call-peer-avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin-bottom: 8px; }
.call-peer-name { font-size: var(--type-title-lg-size); font-weight: 600; }
.call-peer-status { color: rgba(255, 255, 255, 0.72); font-variant-numeric: tabular-nums; }
.call-self { position: absolute; right: 16px; bottom: 16px; width: min(24vw, 200px); aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: #1b1f29; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); cursor: grab; touch-action: none; z-index: 2; }
.call-self video, .call-self > div { width: 100% !important; height: 100% !important; object-fit: cover; transform: scaleX(-1); }
.call-head { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; padding: 16px; background: linear-gradient(rgba(0, 0, 0, 0.5), transparent); font-weight: 600; }
.call-head-time { color: rgba(255, 255, 255, 0.8); }
.call-controls { display: flex; justify-content: center; gap: 24px; padding: 18px 16px calc(22px + env(safe-area-inset-bottom)); }

/* --- Reels viewer overlay ("expand" a video in place; glint.reelViewer) --------------- */
html.rv-open { overflow: hidden; }
.rv { position: fixed; inset: 0; z-index: 150; visibility: hidden; pointer-events: none; }
.rv.is-open { visibility: visible; pointer-events: auto; }
.rv-backdrop { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 320ms ease; }
.rv.is-open .rv-backdrop { opacity: 1; }
.rv.is-closing .rv-backdrop { opacity: 0; transition-duration: 280ms; }
.rv-close { position: absolute; top: 12px; right: 12px; z-index: 5; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, 0.08); opacity: 0; transition: opacity 200ms ease 120ms; }
.rv.is-open .rv-close { opacity: 1; }
.rv-scroller { position: absolute; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; opacity: 0; transition: opacity 160ms ease; }
.rv-scroller::-webkit-scrollbar { display: none; }
.rv.is-ready .rv-scroller { opacity: 1; }
.rv .reels-chunk { display: contents; }
.rv .reel { height: 100dvh !important; min-height: 0 !important; padding: 16px 0 !important; display: grid !important; place-items: center; scroll-snap-align: start; scroll-snap-stop: always; }
.rv .reel-stage { height: calc(100dvh - 32px) !important; width: auto !important; display: block !important; position: relative; }
.rv .reel-media { height: 100% !important; width: auto !important; max-width: 100vw !important; aspect-ratio: 9 / 16 !important; border-radius: 16px; }
.rv .reel-media > .media { height: 100% !important; width: 100%; aspect-ratio: auto !important; }
.rv .reel-media > .media.is-full-frame { border-radius: 0; }
.rv .reel-rail { position: absolute; right: 12px; bottom: 28px; z-index: 4; gap: 18px; }
.rv .reel-action { color: #fff; }
.rv .reel-overlay { padding-right: 64px; }
.rv .media-fullscreen { display: none; }
/* The rail and caption fade in once the video has landed. */
.rv .reel-rail, .rv .reel-overlay { opacity: 0; transition: opacity 220ms ease 60ms; }
.rv.is-ready .reel-rail, .rv.is-ready .reel-overlay { opacity: 1; }
/* The flying layer (FLIP): the clicked video, between the card and the player. */
.rv-fly { position: fixed; z-index: 160; overflow: hidden; transform-origin: 0 0; background: #000; border-radius: 16px; will-change: transform; }
.rv-fly > .media { width: 100% !important; height: 100% !important; aspect-ratio: auto !important; border-radius: 0; }
.rv-placeholder { border-radius: var(--radius-photo-feed); background: #000; }
@media (max-width: 767px) {
  .rv .reel { padding: 0 !important; }
  .rv .reel-stage { height: 100dvh !important; width: 100vw !important; }
  .rv .reel-media { width: 100vw !important; aspect-ratio: auto !important; border-radius: 0; }
  .rv-fly { border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .rv-backdrop, .rv-close, .rv-scroller, .rv .reel-rail, .rv .reel-overlay { transition: none !important; }
}
.rv-fly > .media video, .rv .reel-media > .media.is-in-viewer video { width: 100% !important; height: 100% !important; object-fit: contain; }
.rv .reel-media > .media.is-in-viewer { background: #000 !important; }
.rv-fly .media-fullscreen { display: none; }
