/**
 * Suffah — one UI for every device (Phase 30).
 * The mobile layout (top bar, bottom nav, floating compose button, account
 * drawer) is used at every screen width. On tablets and desktops it sits in
 * fills the full width (scaled up on large screens). Loaded after ui-refresh.css.
 */
:root { --column-width: 100%; }

/* No sidebars: the drawer and bottom nav replace them. */
.sidebar-left, .sidebar-right { display: none !important; }
.app-shell { display: block; width: 100%; max-width: none; margin: 0; min-height: 100vh; }
.main-content { border-left: 0; border-right: 0; padding-bottom: calc(var(--mobile-nav-height) + var(--space-6)); }

/* Top bar (previously mobile only) */
.mobile-topbar { position: sticky; top: 0; z-index: var(--z-sticky-header); display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 var(--space-4); background: var(--bg-primary); }
.mobile-topbar__side { display: inline-flex; align-items: center; justify-content: flex-start; width: 44px; height: 44px; color: var(--text-primary); }
.mobile-topbar__side--end { justify-content: flex-end; }
.mobile-topbar__logo { display: inline-flex; color: var(--color-accent); }
.mobile-topbar__login { font-weight: var(--weight-bold); color: var(--color-accent); font-size: var(--text-sm); }
.mobile-topbar ~ .main-header { display: none; }
.mobile-topbar ~ .tabs { top: 52px; }

/* Bottom nav + compose button, full width */
.mobile-nav { display: block; left: 0; right: 0; width: 100%; transform: none; border-top: 1px solid var(--border-color); }
.mobile-nav .nav-item { width: 100%; height: 100%; justify-content: center; padding: 0; border-radius: 0; position: relative; }
.mobile-nav .nav-item[aria-current="page"] { color: var(--text-primary); }
.compose-fab { display: inline-flex; right: var(--space-4); width: 56px; height: 56px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }
.compose-fab .icon { width: 28px; height: 28px; stroke-width: 2.2; }

/* Pill + drawer + toasts */
.new-posts-pill { top: 112px; }
.drawer:not([hidden]) { display: block; }
.toast-container { left: var(--space-4); right: var(--space-4); transform: none; max-width: none; }

/* Page background outside the column */
body { background: var(--bg-secondary, var(--bg-primary)); }
.main-content, .mobile-nav { background: var(--bg-primary); }

/* Bigger screens: scale the whole interface up so it fills the width
   proportionally (everything is rem-based) instead of leaving empty margins. */
@media (min-width: 900px)  { html { font-size: 112.5%; } }
@media (min-width: 1280px) { html { font-size: 125%; } }
@media (min-width: 1800px) { html { font-size: 150%; } }

/* On wide screens keep each post's action row compact instead of spread across the screen */
@media (min-width: 900px) { .post-card__actions { max-width: 640px; } }

/* Touch-friendly targets everywhere */
.btn-icon { width: 44px; height: 44px; }

/* Single image: keep its own shape (aspect-ratio is set inline), rounded like X */
.post-card .media-grid--1 img, .post-detail .media-grid--single img { width: 100%; height: auto; max-height: none; object-fit: cover; aspect-ratio: 4 / 3; }
.post-card .media-grid--1 { width: 100%; max-width: 560px; }
.post-detail .media-grid--single { max-width: 640px; }

/* Multi-image grids: fixed 16:9 box whose rows/columns can shrink (minmax(0,1fr)),
   so every image fits inside it instead of spilling out and being clipped. */
.post-card .media-grid--2, .post-card .media-grid--3, .post-card .media-grid--4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); aspect-ratio: 16 / 9; }
.post-card .media-grid--3, .post-card .media-grid--4 { grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
.post-card .media-grid--2 img, .post-card .media-grid--3 img, .post-card .media-grid--4 img { height: 100%; min-height: 0; max-height: none; aspect-ratio: auto; }

/* ---- Phase 40: quote embed + reply context in the feed ---- */
.quote-embed { display: block; margin: 10px 0 4px; padding: 12px; border: 1px solid var(--border-color); border-radius: 16px; color: inherit; text-decoration: none; overflow: hidden; }
.quote-embed--gone { color: var(--text-tertiary); }
.quote-embed__head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.quote-embed__head .avatar { width: 20px; height: 20px; font-size: 11px; flex: none; }
.quote-embed__head .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.quote-embed__name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.quote-embed__handle, .quote-embed__time { color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.quote-embed__time { flex: none; }
.quote-embed__replying, .post-card__replying { color: var(--text-tertiary); margin-top: 4px; }
.quote-embed__replying span, .post-card__replying span { color: var(--color-accent); }
.quote-embed__text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; }
.quote-embed__text--muted { color: var(--text-tertiary); }
.quote-embed__img { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin-top: 8px; }
/* self-reply threads: a line joins the avatar to the post above */
.post-card--thread { position: relative; border-top-color: transparent; }
.post-card--thread .post-card__avatar { position: relative; }
.post-card--thread::before { content: ""; position: absolute; left: 36px; top: 0; height: 10px; width: 2px; background: var(--border-color); }

/* ---- Phase 41: global bottom sheet ---- */
/* ---- bottom sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; }
.sheet__panel { position: relative; width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; background: var(--bg-primary, #fff); color: var(--text-primary, #0f1419); border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .2s ease-out; }
.sheet.is-open .sheet__backdrop { opacity: 1; }
.sheet.is-open .sheet__panel { transform: none; }
.sheet__handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border-color, #cfd9de); margin: 4px auto 12px; touch-action: none; cursor: grab; }
.sheet__title { margin: 0 0 6px; font-size: 1.25rem; font-weight: 800; }
.sheet__desc { margin: 0 0 12px; color: var(--text-tertiary, #536471); line-height: 1.35; }
.sheet__list { display: flex; flex-direction: column; }
.sheet__row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 4px; background: none; border: 0; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.sheet__row span { flex: 1; }
.sheet__tick { color: var(--color-accent, #1d9bf0); display: inline-flex; font-style: normal; }
.sheet__textarea { width: 100%; box-sizing: border-box; padding: 12px; border-radius: 12px; border: 1px solid var(--border-color, #cfd9de); background: transparent; color: inherit; font: inherit; resize: vertical; }
.sheet__save { width: 100%; margin-top: 12px; }


.sheet__row { text-decoration: none; }
.sheet__row svg { flex: none; }
.sheet__row--sep { border-top: 1px solid var(--border-color, #cfd9de); margin-top: 6px; padding-top: 18px; }
.sheet__panel .sheet__list { padding-bottom: 4px; }
/* X-style dark pill toast at the top */
.toast-container { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
.toast { background: #3b444c; color: #fff; border-radius: 14px; padding: 14px 18px; font-weight: 600; }
.toast.toast--error { background: var(--color-danger); }
.toast-container { z-index: 1400; }

/* ---- Phase 45: choice rows in bottom sheets ---- */
.sheet__radio { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-primary); display: inline-flex; align-items: center; justify-content: center; }
.sheet__radio.is-on { border-color: var(--color-accent); }
.sheet__radio.is-on::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--color-accent); }
.sheet__choice { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 14px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sheet__choice strong { display: block; font-size: 1.15rem; font-weight: 600; }
.sheet__choice small { display: block; margin-top: 4px; color: var(--text-tertiary); font-size: 1rem; line-height: 1.3; }
.sheet__sub { margin: -2px 0 8px; color: var(--text-tertiary); font-size: 1.15rem; }

/* Phase 47 — "Accounts" sheet (drawer ⋮) */
.xacct { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 4px; }
.xacct[hidden] { display: none; }
.xacct form { margin: 0; }
.xacct__row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 4px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.xacct__row.is-current { cursor: default; }
.xacct__row .avatar { flex: none; width: 52px; height: 52px; font-size: 1.2rem; overflow: hidden; }
.xacct__who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.xacct__who strong { font-size: 1.15rem; font-weight: 800; display: inline-flex; align-items: center; gap: 4px; }
.xacct__who small { color: var(--text-tertiary, #536471); font-size: 1.05rem; }
.xacct__check { flex: none; width: 32px; height: 32px; border-radius: 50%; background: #00ba7c; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.xacct__btn { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1px solid var(--border-color, #cfd9de); border-radius: 999px; color: var(--text-primary); font-size: 1.1rem; font-weight: 700; text-decoration: none; }

.sheet__panel[aria-label="Verified account"] .sheet__title,
.sheet__panel[aria-label="Accounts"] .sheet__title { font-size: 1.9rem; margin: 6px 0 14px; }

/* Phase 49 — new-posts pill: white arrow circle + author avatars (no text) */
.new-posts-pill { gap: 6px; padding: 6px 12px 6px 6px; box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.new-posts-pill__arrow { width: 32px; height: 32px; border-radius: 50%; background: #fff; color: var(--color-accent); display: inline-flex; align-items: center; justify-content: center; }
.new-posts-pill__avatars .avatar { width: 34px; height: 34px; margin-left: -10px; border: 2px solid #fff; font-size: 13px; overflow: hidden; }
.new-posts-pill__avatars .avatar img { width: 100%; height: 100%; object-fit: cover; }
.new-posts-pill .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phase 53: device display preferences */
:root[data-contrast-high] { --text-tertiary: var(--text-secondary); --border-color: var(--border-color-strong); }
:root[data-reduce-motion] *, :root[data-reduce-motion] *::before, :root[data-reduce-motion] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
