/* =============================================================
   OvdjeS.am — App shell (social network)
   Loaded AFTER ovdjesam.css + theme.css. Defines the responsive
   web-app chrome: left rail nav, mobile tab bar, feed/profile
   components. MOBILE-FIRST: the base (no media query) is the phone
   layout; min-width queries add the rail and aside.

   Glass on chrome (.main__head/.mobile-top/.tabbar) is supplied by
   theme.css via the --glass tokens — this file only sets layout.
   Content surfaces use semantic tokens so dark mode works.
   ============================================================= */

* { box-sizing: border-box; }
body { background: var(--surface); color: var(--text); }
::selection { background: var(--ovdje-orange-200); color: var(--ovdje-ink); }

a.plain { color: inherit; border-bottom: 0; }

/* density knob — overridden by Tweaks; layout/frame tokens */
:root {
  --feed-gap: 20px;
  --card-pad: 20px;
  --rail-w: 264px;
  --aside-w: 320px;
  --tabbar-h: 64px;
  --mobile-bottom-safe: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  --action-safe-bottom: calc(var(--mobile-bottom-safe) + 12px);
}
[data-density="compact"] { --feed-gap: 12px; --card-pad: 14px; }
[data-density="roomy"]   { --feed-gap: 28px; --card-pad: 26px; }

/* =============================================================
   APP FRAME — base = single column (phone)
   ============================================================= */
.app {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
}

/* ---------- LEFT RAIL (hidden on phone) ---------- */
.rail { display: none; }
.rail__logo { display: block; padding: 4px 8px 22px; }
.rail__logo img { height: 28px; display: block; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: var(--radius-pill);
  color: var(--text-dim); font-weight: 500; font-size: 15.5px;
  border-bottom: 0; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-warm), color var(--dur-fast) var(--ease-warm);
}
.nav__item i { font-size: 23px; width: 26px; text-align: center; }
.nav__item:hover { background: var(--surface-sunken); }
.nav__item.is-active { color: var(--text); font-weight: 600; }
.nav__item.is-active i { color: var(--accent-text); }
.nav__item .badge {
  margin-left: auto; background: var(--accent); color: var(--text-on-accent);
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px;
  border-radius: var(--radius-pill); display: grid; place-items: center; padding: 0 6px;
}

.rail__compose { margin-top: 16px; width: 100%; padding: 14px; font-size: 15.5px; font-weight: 600; }
.rail__spacer { flex: 1; }

/* pet switcher pinned bottom */
.petswitch {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--surface-raised);
  cursor: pointer; transition: background var(--dur-fast) var(--ease-warm);
}
.petswitch:hover { background: var(--surface-sunken); }
.petswitch__meta { min-width: 0; }
.petswitch__name { font-family: var(--font-display); font-weight: 700; font-size: 14px; line-height: 1.1; }
.petswitch__handle { font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.petswitch i { margin-left: auto; color: var(--text-faint); font-size: 16px; }

/* ---------- MAIN COLUMN ---------- */
.main { min-width: 0; background: var(--surface); }

.main__head { display: none; } /* phone uses .mobile-top; revealed ≥960 */
.main__head h1 { font-size: clamp(18px, 4.5vw, 22px); margin: 0; }
.main__head .sub { font-size: 13px; color: var(--text-faint); margin-top: 2px; }
.head__actions { display: flex; gap: 8px; align-items: center; }
.iconbtn {
  width: 44px; height: 44px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface-raised);
  display: grid; place-items: center; color: var(--text-dim); font-size: 19px;
  cursor: pointer; transition: background var(--dur-fast) var(--ease-warm);
}
.iconbtn:hover { background: var(--surface-sunken); }

/* phone body: reserve room for the fixed tab bar (fixes last-card-under-tabbar) */
.main__body { padding: 16px 16px calc(var(--action-safe-bottom) + 4px); scroll-padding-bottom: var(--action-safe-bottom); }
.col { max-width: 100%; margin: 0 auto; }

/* segmented tabs under header */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-sunken); border-radius: var(--radius-pill); }
.segmented button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 9px 14px; border-radius: var(--radius-pill);
  font-family: var(--font-body); font-weight: 600; font-size: 14px; color: var(--text-faint);
  transition: all var(--dur-fast) var(--ease-warm);
}
.segmented button.is-active { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-sm-c); }

/* ---------- RIGHT ASIDE (hidden until wide) ---------- */
.aside { display: none; }
.aside::-webkit-scrollbar { width: 0; }

/* ---------- MOBILE TOP BAR + TAB BAR (visible on phone) ---------- */
.mobile-top {
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--glass-border);
}
.mobile-top img { height: 26px; }
.mobile-top .head__actions { gap: 6px; }

.tabbar {
  display: flex; align-items: center; justify-content: space-around;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  border-top: 1px solid var(--glass-border);
}
.tabbar a { color: var(--text-disabled); font-size: 25px; border-bottom: 0; display: grid; place-items: center; width: 48px; height: 48px; }
.tabbar a.is-active { color: var(--accent-text); }
.tabbar .compose-fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--text-on-accent);
  box-shadow: var(--shadow-md-c); margin-top: -12px; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 24px;
}

/* =============================================================
   DESKTOP — rail + main (+ optional aside)
   ============================================================= */
@media (min-width: 960px) {
  :root {
    --mobile-bottom-safe: 0px;
    --action-safe-bottom: 0px;
  }
  .app {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    max-width: 1180px;
    margin: 0 auto;
  }
  .app.has-aside { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

  .rail {
    display: flex; flex-direction: column;
    position: sticky; top: 0; align-self: start;
    height: 100vh; height: 100dvh;
    padding: 22px 16px 16px;
    border-right: 1px solid var(--border);
    background: var(--surface);
  }
  .main { border-right: 1px solid var(--border); }
  .app:not(.has-aside) .main { border-right: 0; }

  .main__head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    position: sticky; top: 0; z-index: 20;
    padding: 16px 28px;
    border-bottom: 1px solid var(--glass-border);
  }
  .main__body { padding: 24px 28px 120px; }
  .col { max-width: 600px; }

  .mobile-top, .tabbar { display: none; }
}

@media (min-width: 1100px) {
  .app.has-aside { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--aside-w); max-width: 1380px; }
  .app.has-aside .aside {
    display: flex; flex-direction: column; gap: 18px;
    position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; overflow-y: auto;
    padding: 24px 22px;
  }
}

/* =============================================================
   AVATARS  (gradient placeholders w/ animal glyph)
   ============================================================= */
.av {
  border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; overflow: hidden; position: relative;
  background: linear-gradient(140deg, var(--ovdje-orange), var(--ovdje-rust));
}
.av i { font-size: 0.52em; }
.av--teal   { background: linear-gradient(140deg, var(--ovdje-teal), var(--ovdje-teal-700)); }
.av--beagle { background: linear-gradient(140deg, var(--ovdje-beagle-200), var(--ovdje-beagle)); }
.av--rust   { background: linear-gradient(140deg, #FFB36B, var(--ovdje-rust)); }
.av--ink    { background: linear-gradient(140deg, #34434F, var(--ovdje-ink)); }
.av--cream  { background: linear-gradient(140deg, #FFE7C2, var(--ovdje-orange-200)); color: var(--ovdje-beagle); }
.av--ring   { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* species tint helpers for media blocks */
.media-fill { display: grid; place-items: center; color: rgba(255,255,255,0.92); position: relative; overflow: hidden; }
.fill-orange { background: linear-gradient(145deg, var(--ovdje-orange) 0%, var(--ovdje-rust) 100%); }
.fill-teal   { background: linear-gradient(145deg, var(--ovdje-teal) 0%, var(--ovdje-teal-700) 100%); }
.fill-beagle { background: linear-gradient(145deg, var(--ovdje-beagle-200) 0%, var(--ovdje-beagle) 100%); }
.fill-ink    { background: linear-gradient(150deg, #243441 0%, var(--ovdje-ink) 100%); }
.fill-dawn   { background: linear-gradient(160deg, #FFD89A 0%, #FFB36B 45%, var(--ovdje-rust) 100%); }
.fill-dusk   { background: linear-gradient(160deg, #FFB36B 0%, #F0671E 50%, #7A2E12 100%); }
.media-fill .ghost { position: absolute; font-size: 46%; opacity: 0.16; right: -6%; bottom: -10%; transform: rotate(-12deg); }

/* =============================================================
   POST CARD  (solid content surface — never glass)
   ============================================================= */
.post {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm-c);
  overflow: hidden; margin-bottom: var(--feed-gap);
  transition: transform var(--dur-base) var(--ease-warm), box-shadow var(--dur-base) var(--ease-warm);
}
.post__head { display: flex; align-items: center; gap: 11px; padding: var(--card-pad); padding-bottom: 12px; }
.post__id { min-width: 0; }
.post__name { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; line-height: 1.15; display: flex; align-items: center; gap: 6px; }
.post__name .species { color: var(--accent-text); font-size: 14px; }
.post__meta { font-size: 12.5px; color: var(--text-faint); font-family: var(--font-mono); }
.post__menu { margin-left: auto; color: var(--text-faint); font-size: 20px; cursor: pointer; padding: 10px; margin-right: -10px; }
.post__caption { padding: 0 var(--card-pad) 14px; font-size: clamp(14.5px, 4.2vw, 15px); line-height: var(--leading-normal); color: var(--text); }
.post__caption .first { font-weight: 500; }
.post__media { width: 100%; aspect-ratio: 4 / 3; font-size: 120px; background: var(--surface-sunken); }
.post__media.tall { aspect-ratio: 4 / 5; }
.post__media.wide { aspect-ratio: 16 / 9; }
.post__media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.react { display: flex; align-items: center; gap: 4px; padding: 6px max(8px, calc(var(--card-pad) - 6px)); }
.react__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  position: relative; border: 0; background: transparent; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 8px 12px; border-radius: var(--radius-pill);
  color: var(--text-dim); font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
  transition: all var(--dur-fast) var(--ease-warm);
}
.react__btn i { font-size: 19px; }
.react__btn:hover { background: var(--surface-sunken); }
.react__btn:active { transform: scale(0.98); }
.react__btn.is-on { color: var(--ovdje-rust); }
.react__btn.is-on i { color: var(--ovdje-rust); }
.react__btn.snout.is-on { color: var(--accent-text); }
.react__btn.snout.is-on i { color: var(--accent-text); }
.react__btn.is-busy { opacity: 0.7; pointer-events: none; }
.btn.is-busy { opacity: 0.72; pointer-events: none; }
.react__spacer { flex: 1; }

/* =============================================================
   GRID & CARD FEED VARIANTS (Tweaks) — mobile-first 1-col
   ============================================================= */
.feed[data-layout="grid"] { display: grid; grid-template-columns: 1fr; gap: var(--feed-gap); }
.feed[data-layout="grid"] .post { margin-bottom: 0; }
.feed[data-layout="grid"] .post__caption { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed[data-layout="cards"] .post { box-shadow: var(--shadow-md-c); border-radius: var(--radius-xl); }
.feed[data-layout="cards"] .post__media { aspect-ratio: 4 / 5; }
@media (min-width: 620px) { .feed[data-layout="grid"] { grid-template-columns: repeat(2, 1fr); } }

/* =============================================================
   GENERIC PILLS / CHIPS / TILES
   ============================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 7px 13px;
  font-size: 13px; font-weight: 600; color: var(--text-dim);
}
.chip i { color: var(--accent-text); font-size: 15px; }
.chip--ghost { background: transparent; }
.chip--active { background: var(--ovdje-ink); color: #fff; border-color: var(--ovdje-ink); }
.chip--active i { color: var(--ovdje-orange); }

.tag-pill { display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:600; color: var(--accent-text); }

/* composer trigger */
.composer-trigger {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: var(--feed-gap);
  box-shadow: var(--shadow-sm-c); cursor: text; color: var(--text-faint); font-size: 15px;
  transition: transform var(--dur-base) var(--ease-warm), box-shadow var(--dur-base) var(--ease-warm);
}
.composer-trigger .grow { flex: 1; }
.composer-trigger .btn { padding: 9px 16px; font-size: 14px; }

/* aside card */
.acard {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm-c);
  transition: transform var(--dur-base) var(--ease-warm), box-shadow var(--dur-base) var(--ease-warm);
}
.acard h3 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.acard h3 i { color: var(--accent-text); font-size: 18px; }
.acard__row { display: flex; align-items: center; gap: 11px; padding: 9px 0; }
.acard__row + .acard__row { border-top: 1px solid var(--border); }
.acard__row .nm { font-family: var(--font-display); font-weight: 700; font-size: 14px; line-height: 1.1; }
.acard__row .ds { font-size: 12px; color: var(--text-faint); }
.acard__row .follow { margin-left: auto; }

/* =============================================================
   MODAL / COMPOSER  (chrome — scrollable, keyboard-safe)
   ============================================================= */
.modal-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: var(--scrim);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 64px 16px;
}
.modal {
  width: 100%; max-width: 540px;
  max-height: min(90dvh, 720px);
  display: flex; flex-direction: column;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg-c); overflow: hidden;
  animation: modalIn var(--dur-slow) var(--ease-warm);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.modal__head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal__head strong { font-family: var(--font-display); font-size: 16px; }
.modal__body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal__foot { flex: none; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.composer-area {
  flex: 1; border: 0; outline: 0; resize: none; min-height: 120px;
  font-family: var(--font-body); font-size: 18px; line-height: 1.5; color: var(--text);
  background: transparent;
}
.composer-area::placeholder { color: var(--text-disabled); }
.composer-tools { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.composer-tools .iconbtn { color: var(--accent-text); }

/* phone: modal becomes a bottom sheet anchored to the bottom, keyboard-safe */
@media (max-width: 600px) {
  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 100dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
}

/* =============================================================
   TOAST  (adaptive inverse pill)
   ============================================================= */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--surface-inverse); color: var(--text-on-inverse); padding: 13px 20px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg-c);
  opacity: 0; pointer-events: none; transition: all var(--dur-base) var(--ease-warm); z-index: 100;
  display: flex; align-items: center; gap: 9px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast i { color: var(--accent); font-size: 18px; }
@media (min-width: 961px) { .toast { bottom: 32px; } }
.save-status {
  color: var(--text-faint);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}
.save-status[data-save-state="saving"] { color: var(--accent-text); }
.save-status[data-save-state="saved"] { color: var(--success); }
.save-status[data-save-state="error"] { color: var(--danger); }

@media (hover: hover) {
  .post:hover { transform: translateY(-2px); box-shadow: var(--shadow-md-c); }
  .acard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md-c); }
  .composer-trigger:hover { transform: translateY(-1px); box-shadow: var(--shadow-md-c); }
}

/* =============================================================
   NO-RELOAD NAV — progress bar + View-Transition names
   ============================================================= */
/* #view receives focus after a swap for screen readers — no visible ring on the container */
#view:focus { outline: none; }

#nav-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--accent); box-shadow: var(--shadow-orange);
  transform-origin: 0 50%; z-index: 200; opacity: 0;
  transition: width var(--dur-slow) var(--ease-out), opacity var(--dur-fast) linear;
  pointer-events: none;
}
html[data-navigating] #nav-progress { opacity: 1; }

@supports (view-transition-name: x) {
  #view  { view-transition-name: view; }
  .rail  { view-transition-name: rail; }
  .tabbar{ view-transition-name: tabbar; }
  .toast { view-transition-name: toast; }
  #nav-progress { view-transition-name: none; }
  ::view-transition-old(view), ::view-transition-new(view) {
    animation-duration: var(--dur-base); animation-timing-function: var(--ease-warm);
  }
}
