/* ==========================================================================
   Glint web — pages: feed, post, profile, explore, reels, stories, direct,
   create, settings, auth, legal, errors, styleguide.
   ========================================================================== */

/* --- Home feed ------------------------------------------------------------------- */

.feed-layout { display: flex; justify-content: center; gap: 64px; padding: 0 16px; }
.feed-col { width: 100%; max-width: var(--layout-web-feed-max); min-width: 0; padding-top: 8px; }
.feed-list { margin-top: 8px; }
@media (min-width: 1264px) { .feed-layout { padding-right: 0; } }
@media (max-width: 767px) {
  .feed-layout { padding: 0; }
  .feed-col { padding-top: 0; }
  .story-tray { padding: 8px 0 8px; border-bottom: 1px solid var(--border-subtle); }
  .story-track { padding-inline: var(--layout-feed-side-padding-mobile); scroll-padding-inline: var(--layout-feed-side-padding-mobile); }
  .post-card { margin-bottom: 8px; }
  .post-head { padding-inline: var(--layout-feed-side-padding-mobile); }
  .post-media { border-radius: 0; }
  .post-actions, .post-body { padding-inline: var(--layout-feed-side-padding-mobile); }
  .feed-section-title, .caught-up { padding-inline: 16px; }
  .upload-card { margin-inline: 12px; }
}

/* --- Post page (/p/{id}) ----------------------------------------------------------- */

.post-page-inner { max-width: var(--page-max); margin: 0 auto; padding: 32px 20px 48px; }
.post-page .post-detail:not(.in-modal) .pd-frame { border: 1px solid var(--border-subtle); border-radius: 4px; overflow: hidden; height: min(80vh, 720px); }
.post-page .post-detail:not(.in-modal) .pd-media { width: min(58%, calc(min(80vh, 720px) * var(--pd-ratio))); height: 100%; flex-shrink: 1; }
.post-page .post-detail:not(.in-modal) .pd-side { min-width: 0; }
.more-posts { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border-subtle); }
.more-posts h2 { font-size: var(--type-body-size); font-weight: 600; color: var(--text-secondary); margin-bottom: 16px; }
.more-posts h2 .username { color: var(--text-primary); }
@media (max-width: 767px) {
  .post-page-inner { padding: 0 0 24px; }
  .post-page .post-detail:not(.in-modal) .pd-frame { display: grid; grid-template-areas: "head" "media" "footer" "comments" "form"; height: auto; border: 0; border-radius: 0; }
  .post-page .post-detail:not(.in-modal) .pd-side { display: contents; }
  .post-page .post-detail:not(.in-modal) .pd-head { grid-area: head; border-bottom: 0; padding: 8px 12px; }
  .post-page .post-detail:not(.in-modal) .pd-media { grid-area: media; width: 100%; height: auto; background: none; }
  .post-page .post-detail:not(.in-modal) .pd-media > .media, .post-page .post-detail:not(.in-modal) .pd-media > .carousel { max-height: 72vh; max-height: 72dvh; }
  .post-page .post-detail:not(.in-modal) .pd-footer { grid-area: footer; border-top: 0; padding: 0 12px; }
  .post-page .post-detail:not(.in-modal) .pd-comments { grid-area: comments; overflow: visible; padding: 0 12px; }
  .post-page .post-detail:not(.in-modal) .pd-form { grid-area: form; position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); background: var(--bg-base); }
  .more-posts { margin-top: 24px; padding: 16px 0 0; }
  .more-posts h2 { padding: 0 12px; }
}

/* --- Profile ------------------------------------------------------------------------ */

.profile-inner { max-width: var(--page-max); margin: 0 auto; padding: 30px 20px 0; }
.profile-header { display: grid; grid-template-columns: 290px 1fr; align-items: start; margin-bottom: 44px; }
.profile-avatar { display: flex; justify-content: center; padding-top: 4px; }
.profile-avatar .mobile-avatar { display: none; }
.profile-main { display: grid; gap: 20px; min-width: 0; }
.profile-title-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; min-width: 0; }
.profile-username { font-size: 20px; font-weight: 400; line-height: 1.2; gap: 8px; }
.profile-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-actions .icon-btn { margin: 0; }
.btn-icon { padding: 0; width: var(--button-height); }
.profile-stats { display: flex; gap: 40px; font-size: var(--type-body-size); }
.profile-stats strong { font-weight: 600; }
.profile-stats a:hover { opacity: 0.8; }
.profile-bio { display: grid; gap: 4px; font-size: var(--type-body-size); }
.profile-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; line-height: 1.3; }
.profile-pronouns { font-family: var(--font-ui); font-weight: 400; font-size: var(--type-meta-size); color: var(--text-secondary); margin-left: 8px; }
.profile-bio-text { white-space: normal; overflow-wrap: anywhere; }
.profile-link { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-400); font-weight: 600; width: fit-content; }
.profile-link:hover { text-decoration: underline; }
.profile-mutuals { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: var(--type-meta-size); color: var(--text-secondary); }
.profile-mutuals strong { color: var(--text-primary); font-weight: 600; }
.profile-suggested { margin: -24px 0 32px; }
.suggest-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.suggest-strip .suggest-card { flex: 0 0 176px; }
.highlights { margin-bottom: 44px; }
.highlights-track { display: flex; gap: 28px; overflow-x: auto; scrollbar-width: none; padding: 4px 16px; }
.highlight { display: grid; justify-items: center; gap: 10px; width: 87px; }
.highlight-cover { width: 87px; height: 87px; border-radius: 50%; padding: 4px; border: 1px solid var(--border-subtle); display: grid; place-items: center; }
.highlight-cover img { width: 77px; height: 77px; border-radius: 50%; object-fit: cover; background: var(--bg-raised); }
.highlight-cover.is-new { color: var(--text-secondary); }
.highlight-title { font-size: var(--type-meta-size); font-weight: 600; max-width: 87px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-tabs { display: flex; justify-content: center; gap: 60px; border-top: 1px solid var(--border-subtle); }
.profile-tab { display: flex; align-items: center; gap: 6px; height: 52px; margin-top: -1px; border-top: 1px solid transparent; color: var(--text-secondary); font-size: var(--type-micro-size); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.profile-tab .icon { width: 14px; height: 14px; }
.profile-tab.is-active { color: var(--text-primary); border-top-color: var(--text-primary); }
.profile-state { border-top: 1px solid var(--border-subtle); padding: 24px 0 48px; }
.profile-tabs + .profile-state { border-top: 0; }
.profile-footer { padding: 48px 0 32px; }
.profile-footer .site-footer { justify-items: center; }
.saved-bar { display: grid; gap: 12px; padding: 4px 0 16px; }
.saved-bar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.saved-col-actions .dialog { width: min(400px, 100%); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-subtle); font-size: var(--type-meta-size); font-weight: 600; white-space: nowrap; }
.chip span { color: var(--text-secondary); font-weight: 400; }
.chip.is-on { background: var(--text-primary); color: var(--bg-base); border-color: var(--text-primary); }
.chip.is-on span { color: inherit; opacity: 0.7; }

@media (max-width: 1023px) {
  .profile-header { grid-template-columns: 200px 1fr; }
}
@media (max-width: 767px) {
  .profile-inner { padding: 12px 0 0; }
  .profile-header { grid-template-columns: 86px 1fr; column-gap: 20px; row-gap: 12px; padding: 0 16px; margin-bottom: 16px; }
  .profile-avatar .desktop-avatar { display: none; }
  .profile-avatar .mobile-avatar { display: inline-block; }
  .profile-main { display: contents; }
  .profile-title-row { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-start; gap: 10px; align-self: center; }
  .profile-username { display: none; }
  .profile-actions { display: grid; grid-template-columns: 1fr 1fr auto auto; width: 100%; gap: 6px; }
  .profile-actions > .follow, .profile-actions > .follow .btn { width: 100%; }
  .profile-actions .btn { width: 100%; }
  .profile-actions .icon-btn { margin: 0 -4px; }
  /* Audit WL-01: beside the avatar the buttons didn't fit a phone (Share profile was off-screen at 390px).
     Instagram's phone layout: avatar + counts on one row, bio, then the buttons full width. */
  .profile-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
  .profile-actions .btn { min-width: 0; padding-inline: 8px; white-space: nowrap; }
  .profile-actions .btn.btn-icon { width: 36px; padding: 0; }
  .profile-stats { grid-column: 1 / -1; grid-row: 3; justify-content: space-around; gap: 0; padding: 12px 0; border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); margin: 0 -16px; text-align: center; }
  .profile-stats li { display: grid; font-size: var(--type-meta-size); color: var(--text-secondary); }
  .profile-stats strong { color: var(--text-primary); font-size: var(--type-body-size); }
  .profile-stats a { display: grid; }
  .profile-bio { grid-column: 1 / -1; grid-row: 2; }
  .profile-header .profile-title-row { grid-column: 1 / -1; grid-row: 3; align-self: start; margin-top: 4px; }
  .profile-layout .profile-header.profile-header, .profile-header.profile-header { padding-bottom: 16px; }
  .profile-header .profile-stats { grid-column: 2; grid-row: 1; align-self: end; margin: 0; padding: 0 0 8px; border: 0; }
  .highlights { margin-bottom: 16px; }
  .highlights-track { gap: 16px; }
  .highlight, .highlight-title { width: 64px; max-width: 64px; }
  .highlight-cover { width: 64px; height: 64px; padding: 3px; }
  .highlight-cover img { width: 56px; height: 56px; }
  .profile-tabs { gap: 0; justify-content: space-around; }
  .profile-tab span { display: none; }
  .profile-tab .icon { width: 24px; height: 24px; }
  .profile-tab { flex: 1; justify-content: center; height: 44px; border-top: 0; border-bottom: 1px solid transparent; }
  .profile-tab.is-active { border-bottom-color: var(--text-primary); }
  .saved-bar { padding: 12px 16px; }
  .profile-suggested { margin: 0 0 16px; padding: 0 12px; }
}

/* --- Explore, tag, place, audio, people --------------------------------------------- */

.explore-inner { max-width: var(--page-max); margin: 0 auto; padding: 24px 20px 48px; }
.explore-search-bar { display: none; }
.fake-search { width: 100%; }
.fake-search .input { display: flex; align-items: center; color: var(--text-secondary); padding-left: 36px; height: 36px; min-height: 36px; }
.hub-header { display: flex; align-items: center; gap: 40px; padding: 16px 0 32px; }
.hub-header.is-place { justify-content: space-between; gap: 16px; padding-top: 20px; }
.hub-cover { width: 152px; height: 152px; flex: none; display: grid; place-items: center; background: var(--bg-raised) center / cover; border-radius: 8px; color: var(--text-secondary); }
.hub-cover.is-round { border-radius: 50%; }
.hub-text { display: grid; gap: 6px; min-width: 0; }
.hub-title { font-size: var(--type-title-lg-size); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.hub-sub { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: var(--type-body-size); }
.hub-sub strong { color: var(--text-primary); font-weight: 600; }
.hub-tabs { margin-bottom: 16px; }
.hub-tabs .tab-btn { margin-right: 24px; }
.map-header { position: relative; height: 220px; overflow: hidden; border-radius: 12px; background: var(--bg-raised); margin: 0; }
.map-tiles { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.map-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; }
[data-theme="dark"] .map-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
@media (prefers-color-scheme: dark) { [data-theme="system"] .map-tiles { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); } }
.map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); color: var(--brand-500); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.map-attribution { position: absolute; right: 6px; bottom: 4px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--bg-base) 80%, transparent); font-size: 10px; color: var(--text-secondary); }
.narrow-inner { max-width: 600px; margin: 0 auto; padding: 24px 0 48px; }
.section-title { font-size: var(--type-title-md-size); font-weight: 600; padding: 0 16px 12px; }
@media (max-width: 767px) {
  .explore-search-bar { display: flex; }
  .explore-inner { padding: 0 0 24px; }
  .hub-header { gap: 20px; padding: 16px; }
  .hub-cover { width: 86px; height: 86px; }
  .hub-header.is-place { flex-wrap: wrap; }
  .hub-tabs { padding: 0 16px; }
  .map-header { border-radius: 0; height: 180px; }
  .narrow-inner { padding: 0 0 24px; }
  .search-page .panel-inner .panel-head { position: sticky; top: var(--topbar-h); background: var(--bg-base); z-index: 5; }
}

/* --- Reels ----------------------------------------------------------------------------- */

.reels-page { position: relative; }
.reels-top { position: fixed; top: 16px; right: 24px; z-index: 25; display: flex; align-items: center; gap: 16px; }
.reels-title { display: none; }
.reels-scroller { height: 100vh; height: 100dvh; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.reels-scroller::-webkit-scrollbar { display: none; }
.reels-chunk { display: contents; }
.reel { height: 100vh; height: 100dvh; scroll-snap-align: start; scroll-snap-stop: always; display: grid; place-items: center; padding: 16px 0; }
.reel-stage { position: relative; display: flex; align-items: flex-end; gap: 16px; height: calc(100vh - 32px); height: calc(100dvh - 32px); }
.reel-media { position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: calc(100vw - var(--sidebar-w) - 120px); border-radius: 8px; overflow: hidden; background: #000; touch-action: manipulation; }
.reel-media > .media { height: 100%; aspect-ratio: auto !important; }
.reel-media .media-sound { display: none; }
.reel-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 48px 16px 16px; display: grid; gap: 8px; color: #fff; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.reel-overlay a, .reel-overlay button, .reel-overlay .caption-text { pointer-events: auto; }
.reel-overlay .username, .reel-overlay .username-row { color: #fff; }
.reel-overlay .caption-text { color: #fff; font-size: var(--type-body-size); cursor: pointer; }
.reel-overlay .mention, .reel-overlay .hashtag { color: #fff; font-weight: 600; }
.reel-author { display: flex; align-items: center; gap: 10px; }
.reel-author .follow-link { color: #fff; border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 8px; padding: 3px 10px; font-size: var(--type-meta-size); }
.reel-audio { display: inline-flex; align-items: center; gap: 6px; max-width: 80%; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); font-size: var(--type-meta-size); color: #fff; }
.reel-rail { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-bottom: 8px; }
.reel-action { display: grid; justify-items: center; gap: 4px; color: var(--text-primary); }
.reel-action .icon { width: 26px; height: 26px; }
.reel-action.action-like .liked { color: var(--accent-flash); }
.reel-action.pop { animation: pop var(--motion-pop) ease-out; }
.reel-count { font-size: var(--type-micro-size); font-weight: 600; }
.reel-disc { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-primary); border: 2px solid var(--text-primary); background: var(--bg-raised) center / cover; animation: disc-spin 4s linear infinite; }
@keyframes disc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reel-disc { animation: none !important; } }
/* Sponsored reel: CTA bar over the caption, "Ad" in the rail where the disc sits. */
.reel-ad-who { display: grid; min-width: 0; line-height: 1.25; }
.reel-ad-label { font-size: var(--type-meta-size); color: rgba(255, 255, 255, 0.85); }
.reel-overlay .ad-cta { border-radius: 8px; color: var(--on-brand); pointer-events: auto; }
.reel-ad-badge { display: grid; place-items: center; min-width: 28px; height: 20px; padding: 0 6px; border-radius: 4px; border: 1.5px solid currentColor; color: var(--text-primary); font-size: var(--type-micro-size); font-weight: 700; letter-spacing: 0.02em; }
.sound-hint {
  position: fixed; left: calc(50% + var(--sidebar-w) / 2); top: 50%; z-index: 26; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: rgba(10, 12, 17, 0.8); color: #fff; font-weight: 600; font-size: var(--type-body-size);
}
@media (max-width: 767px) {
  .reels-scroller { height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom)); }
  .reel { height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-bottom)); padding: 0; }
  .reel-stage { width: 100%; height: 100%; }
  .reel-media { width: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
  .reel-rail { position: absolute; right: 8px; bottom: 16px; z-index: 4; }
  .reel-action { color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
  .reel-disc { border-color: #fff; }
  .reel-ad-badge { color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
  .reel-overlay { padding-right: 64px; }
  .reels-top { top: 0; left: 0; right: 0; height: var(--topbar-h); padding: 0 16px; justify-content: space-between; color: #fff; }
  .reels-title { display: block; font-size: var(--type-title-md-size); font-weight: 600; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
  .reels-top .icon-btn { color: #fff; }
  .sound-hint { left: 50%; }
  .page-reels .main { padding-bottom: 0; }
}

/* --- Styleguide (local) -------------------------------------------------------------- */

.styleguide { padding: 32px 24px 64px; }
.sg-top { margin-bottom: 24px; display: grid; gap: 6px; }
.sg-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sg-theme { background: var(--bg-base); color: var(--text-primary); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 20px; min-width: 0; }
.sg-theme-title { font-size: var(--type-title-lg-size); font-weight: 600; margin-bottom: 8px; }
.sg-section { padding: 20px 0; border-top: 1px solid var(--border-subtle); display: grid; gap: 10px; }
.sg-section h3 { font-size: var(--type-meta-size); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sg-swatch { display: grid; gap: 2px; font-size: 11px; }
.sg-swatch span { height: 40px; border-radius: 8px; border: 1px solid var(--border-subtle); }
.sg-swatch small { color: var(--text-secondary); }
.sg-icons { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.sg-feed .post-card { max-width: 470px; }
.sg-burst { display: grid; gap: 10px; justify-items: start; }
.sg-empties { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.sg-empties .empty { border: 1px solid var(--border-subtle); border-radius: 12px; padding: 24px 12px; }
.sg-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.sg-filters div { display: grid; gap: 4px; font-size: 11px; }
.sg-filter-swatch { height: 24px; border-radius: 4px; }
@media (max-width: 1263px) { .sg-columns { grid-template-columns: 1fr; } }
.sg-filter-swatch { display: flex; overflow: hidden; }
.sg-filter-swatch i { flex: 1; }
@media (max-width: 767px) { .is-guest .page-header { top: 52px; } }
.sg-chat { display: grid; gap: 4px; max-width: 520px; }

/* Audit WL-02: the count in "2 posts" on #tag / place heroes used --text-primary (near-black) on the dark photo hero. */
.tag-hero .hub-sub strong, .place-hero .hub-sub strong { color: #fff; }
