/* =========================================================================
   Media grids — every grid (profile tabs, saved, explore, hashtag, place,
   audio, search, "more posts") is Instagram's UNIFORM grid (2026-10-15,
   App\Web\Support\TileGrid; replaces the batch-4 justified rows): 3 equal
   columns, 2px gaps, every tile 3:4 (9:16 on reels-only grids: .is-reels),
   media object-fit: cover on its focal point (inline object-position).
   Paged chunks are display: contents, so a new page's tiles continue the
   grid and nothing already on screen moves.
   Muted video previews on the 2 most visible tiles (js/tile-preview.js),
   counts always visible bottom-left. Loaded after frame.css so it wins over
   reference.css / components.css.
   ========================================================================= */

.tile { position: relative; overflow: hidden; aspect-ratio: 3 / 4; background: transparent !important; background-image: none !important; }
.tile .tile-frame { position: absolute; inset: 0; display: block; overflow: hidden; background-color: var(--media-placeholder); background-size: cover; background-position: center; }
.tile img, .tile .tile-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover !important; }

.grid.ugrid, .profile-page .grid.ugrid.profile-grid, .discovery-layout .explore-inner > .grid.ugrid, .profile-layout .grid.ugrid.profile-grid { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 2px !important; grid-auto-flow: row !important; }
.ugrid .tiles-chunk { display: contents; }
.ugrid .tile, .profile-page .profile-grid.ugrid .tile { display: block; min-width: 0; aspect-ratio: 3 / 4 !important; border-radius: 0 !important; grid-column: auto !important; grid-row: auto !important; }
.ugrid.is-reels .tile, .profile-page .profile-grid.ugrid.is-reels .tile { aspect-ratio: 9 / 16 !important; }
/* Paging sentinels sit after every tile (a full-width row of their own would cut the last row short). */
.ugrid .grid-sentinel { order: 1; grid-column: 1 / -1; height: 1px; margin-top: -2px; }
.grid.ugrid.is-dim { opacity: .5; transition: opacity .15s; }

/* "Adjust preview" (App\Domain\Media\GridCrop): the owner's crop positions the poster and the video preview by the
   same rect, given per tile shape as % of the tile (3:4 --gc-*, 9:16 --gcr-*), instead of cover + object-position. */
.tile.has-crop img, .tile.has-crop .tile-video { inset: auto; left: var(--gc-l); top: var(--gc-t); width: var(--gc-w); height: var(--gc-h); max-width: none; max-height: none; object-fit: fill !important; }
.ugrid.is-reels .tile.has-crop img, .ugrid.is-reels .tile.has-crop .tile-video { left: var(--gcr-l); top: var(--gcr-t); width: var(--gcr-w); height: var(--gcr-h); }
.reel-thumb.has-crop .reel-thumb-link img, .reel-thumb.has-crop .reel-thumb-link .tile-video, .reels-block .reel-thumb.has-crop .reel-thumb-link img, .reels-block .reel-thumb.has-crop .reel-thumb-link .tile-video { position: absolute; inset: auto; left: var(--gc-l); top: var(--gc-t); width: var(--gc-w); height: var(--gc-h); max-width: none; max-height: none; object-fit: fill !important; }

/* Inline preview: hidden until it really plays (poster image underneath). */
.tile .tile-video { position: absolute; inset: 0; opacity: 0; transition: opacity .2s; pointer-events: none; background: transparent; }
.tile.is-playing .tile-video { opacity: 1; }

/* Explore / tag / place media grids: corner glyph; the loading skeleton stays a 3-column grid. */
.grid.media-grid-sk { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 2px !important; grid-auto-flow: row; }
.media-grid-sk > .tile { display: block; aspect-ratio: 3 / 4; border-radius: 0 !important; }
.media-chunk .tile .tile-hover { display: none !important; }
.media-chunk .tile .tile-type { top: 8px; right: 8px; }
.discovery-post .tile { aspect-ratio: 3 / 4; }

/* Explore page chrome: search pill + saved, chip row. */
.explore-ig-inner { max-width: 860px; margin: 0 auto; padding: 20px 20px 48px; }
.explore-ig-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.explore-ig-search { flex: 1; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px; border-radius: 12px; background: var(--fr-input, var(--bg-elevated, #f0f2f5)); color: var(--fr-muted, var(--text-secondary)); font-size: 16px; line-height: 1; text-decoration: none; }
.explore-ig-search .icon { flex: none; width: 20px; height: 20px; color: var(--fr-text, var(--text-primary)); }
.explore-ig-search span { display: flex; align-items: center; height: 100%; }
.explore-ig-saved { flex: none; display: grid; place-items: center; width: 44px; height: 44px; color: var(--fr-text, var(--text-primary)); border-radius: 12px; }
.explore-ig-saved:hover { background: var(--fr-input, var(--bg-elevated)); }
.explore-ig-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 0 12px; padding-bottom: 2px; }
.explore-ig-chips::-webkit-scrollbar { display: none; }
.explore-ig-chip { flex: none; display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong, var(--fr-line, #d0d4da)); background: transparent; color: var(--fr-text, var(--text-primary)); font: 500 15px/1 inherit; font-family: inherit; white-space: nowrap; cursor: pointer; text-decoration: none; }
.explore-ig-chip.is-icon { width: 44px; padding: 0; }
.explore-ig-chip.is-icon .icon { width: 20px; height: 20px; }
.explore-ig-chip.is-active { background: color-mix(in srgb, var(--fr-text, currentColor) 12%, transparent); border-color: transparent; font-weight: 600; }
.explore-ig-chip:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

@media (min-width: 768px) {
  /* Desktop: the page background is grey, so the pill sits on the card colour. */
  .explore-ig-search { background: var(--fr-card, var(--bg-base, #fff)); border: 1px solid var(--fr-line, var(--border-subtle, #e3e6ea)); }
}

@media (max-width: 767px) {
  .explore-ig-inner { padding: 8px 0 24px; }
  .explore-ig-top, .explore-ig-chips { padding: 0 12px; }
  .explore-ig-top { margin-bottom: 10px; }
  .explore-ig-chips { margin-bottom: 10px; }
}

/* Tile counts (GridTile), like the app: always visible bottom-left of the picture over a subtle gradient (👁 views on
   videos/reels, ♥ likes on photos), on every grid and at every width; no hover overlay. */
.tile .tile-hover { display: none !important; }
.tile .tile-stat, .media-chunk .tile .tile-stat, .profile-page .profile-grid .tile .tile-stat {
  display: flex; opacity: 1 !important; position: absolute; left: 0; right: 0; bottom: 0; align-items: center; gap: 4px;
  padding: 24px 8px 7px; color: #fff; font-size: 14px; font-weight: 600; line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .55); background: linear-gradient(transparent, rgba(0, 0, 0, .38)); pointer-events: none;
}
.tile .tile-stat .icon { width: 16px; height: 16px; flex: none; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .45)); }
@media (max-width: 767px) { .tile .tile-stat, .media-chunk .tile .tile-stat, .profile-page .profile-grid .tile .tile-stat { padding: 18px 6px 5px; font-size: 13px; } .tile .tile-stat .icon { width: 14px; height: 14px; } }

/* Profile tabs (batch 3 item 32), like Instagram's app: no underline and no full-width divider; the
   selected tab is a bright filled icon (+ label on desktop), the others dimmed outline icons. */
.profile-page .profile-tabs { border: 0 !important; box-shadow: none; }
.profile-page .profile-tab, .profile-page .profile-tab.is-active { border: 0 !important; box-shadow: none; margin-top: 0; }
.profile-page .profile-tab::after, .profile-page .profile-tab::before { content: none !important; }
.profile-page .profile-tab { color: var(--text-secondary); opacity: .62; transition: opacity 150ms, color 150ms; }
.profile-page .profile-tab:hover { opacity: .85; }
.profile-page .profile-tab.is-active { color: var(--text-primary); opacity: 1; font-weight: 700; }
.profile-page .profile-tab .icon { width: 20px; height: 20px; }
@media (max-width: 767px) { .profile-page .profile-tab .icon { width: 26px; height: 26px; } }

/* Profile suggestions row (batch 3 item 29): "Follow some accounts to get started" (own) / "Similar accounts". */
.profile-page .profile-suggested { margin: 0 0 20px; }
.profile-page .ps-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 4px 10px; }
.profile-page .ps-head h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.profile-page .ps-head .link-btn { font-size: 15px; font-weight: 600; color: var(--brand-500); }
.profile-page .profile-suggested .suggest-strip { gap: 8px; scroll-snap-type: x proximity; }
.profile-page .profile-suggested .suggest-card { position: relative; flex: 0 0 168px; gap: 4px; padding: 18px 12px 12px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: 14px; scroll-snap-align: start; }
.profile-page .ps-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--text-secondary); }
.profile-page .ps-x:hover { background: var(--bg-raised); color: var(--text-primary); }
.profile-page .ps-avatar { margin-bottom: 6px; }
.profile-page .ps-name { max-width: 100%; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.profile-page .ps-reason { max-width: 100%; font-size: 13px; color: var(--text-secondary); }
.profile-page .profile-suggested .follow, .profile-page .profile-suggested .follow .btn { width: 100%; margin-top: 8px; }
.profile-actions .btn-icon.is-on { color: var(--brand-500); }
@media (max-width: 767px) { .profile-page .profile-suggested { padding: 0 12px; } .profile-page .profile-suggested .suggest-card { flex-basis: 150px; } }

/* "Adjust preview" dialog (livewire/shell/grid-preview, js/grid-preview.js): the media under a 3:4 tile frame,
   the outside dimmed (the frame's huge shadow), rule-of-thirds lines; sized by the viewport height so it fits
   short laptop screens (1093×530) and phones. */
.gp-dialog { width: min(520px, 100%); max-height: calc(100dvh - 24px); }
.gp-dialog .dialog-head .head-action.start { left: 16px; right: auto; }
[dir="rtl"] .gp-dialog .dialog-head .head-action.start { left: auto; right: 16px; }
.gp-stage { position: relative; flex: none; height: clamp(200px, calc(100dvh - 210px), 560px); overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.gp-stage:active { cursor: grabbing; }
.gp-media { position: absolute; max-width: none; max-height: none; pointer-events: none; }
.gp-frame { position: absolute; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6); outline: 1.5px solid rgba(255, 255, 255, .95); pointer-events: none; }
.gp-grid { position: absolute; inset: 0; background:
  linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255, 255, 255, .55) calc(33.333% - .5px), rgba(255, 255, 255, .55) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255, 255, 255, .55) calc(66.666% - .5px), rgba(255, 255, 255, .55) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
  linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255, 255, 255, .55) calc(33.333% - .5px), rgba(255, 255, 255, .55) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255, 255, 255, .55) calc(66.666% - .5px), rgba(255, 255, 255, .55) calc(66.666% + .5px), transparent calc(66.666% + .5px)); }
.gp-auto { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 4px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; font-weight: 600; pointer-events: none; }
.gp-controls { display: flex; align-items: center; gap: 10px; padding: 10px 16px 4px; color: var(--text-secondary); }
.gp-zoom { flex: 1; min-width: 0; accent-color: var(--brand-500); }
.gp-reset { flex: none; }
.gp-hint { padding: 2px 16px 12px; text-align: center; color: var(--text-secondary); font-size: 13px; }
@media (max-width: 767px) {
  .gp-overlay { padding: 12px; }
  .gp-stage { height: clamp(220px, calc(100dvh - 230px), 520px); }
}
