/* ==========================================================================
   پوسته‌ی اپ: نوار بالا، نوار تب پایین (موبایل)، منوی کناری (دسکتاپ)
   ========================================================================== */

.app {
  min-height: 100dvh;
}

.stage {
  min-height: 100dvh;
}

.view {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s6));
  view-transition-name: view;
}

.app.no-tabbar .view,
.view.no-tabbar {
  padding-bottom: calc(var(--safe-bottom) + var(--s6));
}

.view.has-actionbar {
  padding-bottom: calc(88px + var(--safe-bottom));
}

.page {
  padding: 0 var(--gutter);
  max-width: 1120px;
  margin-inline: auto;
}

.page-narrow {
  max-width: 560px;
}

/* ---------- نوار بالا ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s1);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--s2) 0;
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  transition: box-shadow var(--t) ease, background-color var(--t) ease;
}

.topbar.is-scrolled {
  box-shadow: 0 1px 0 var(--line);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: var(--s2);
  transition: opacity var(--t) ease, transform var(--t) var(--ease);
}

.topbar.has-large .topbar-title {
  opacity: 0;
  transform: translateY(4px);
}

.topbar.has-large.is-scrolled .topbar-title {
  opacity: 1;
  transform: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-inline: var(--s2);
  flex: 1;
  min-width: 0;
}

.topbar-brand .mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.topbar-brand strong {
  font-size: 1.1rem;
  font-weight: 900;
}

.topbar-brand .tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.topbar-brand .tag.biz {
  background: var(--biz-soft);
  color: var(--biz);
}

/* نوار بالای شفاف روی تصویر کاور */
.topbar.over-media {
  position: fixed;
  inset-inline: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.topbar.over-media.is-scrolled {
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
}

.topbar.over-media:not(.is-scrolled) .icon-btn {
  background: rgba(10, 10, 12, 0.42);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar.over-media:not(.is-scrolled) .topbar-title {
  opacity: 0;
}

/* عنوان بزرگ (مثل iOS) */
.large-title {
  padding: var(--s2) var(--gutter) var(--s4);
  max-width: 1120px;
  margin-inline: auto;
}

.large-title h1 {
  font-size: var(--fs-2xl);
  font-weight: 900;
}

.large-title p {
  color: var(--text-3);
  margin-top: 2px;
}

/* ---------- نوار تب پایین ---------- */
.tabbar {
  position: fixed;
  z-index: 70;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 var(--s2) var(--safe-bottom);
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  box-shadow: 0 -1px 0 var(--line);
  transition: transform var(--t) var(--ease);
  view-transition-name: tabbar;
}

.app:not(.ready) .tabbar {
  transition: none;
}

.app.no-tabbar .tabbar,
body.kb-open .tabbar {
  transform: translateY(110%);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  transition: color var(--t-fast) ease;
}

.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 30px;
  border-radius: var(--r-full);
  transition: background-color var(--t) var(--ease), transform var(--t-fast) var(--ease);
}

.tab-icon svg {
  width: 22px;
  height: 22px;
}

.tab:active .tab-icon {
  transform: scale(0.9);
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active .tab-icon {
  background: var(--surface-3);
}

.tab .dot-badge {
  top: -2px;
  left: 6px;
}

/* دکمه‌ی میانی (ثبت پروژه) */
.tab.is-cta .tab-icon {
  width: 52px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--biz);
  color: #0B1220;
}

[data-theme="light"] .tab.is-cta .tab-icon {
  color: #fff;
}

.tab.is-cta {
  color: var(--text-2);
}

.app[data-area="pro"] .tab.is-cta .tab-icon {
  background: var(--accent);
  color: #fff;
}

/* ---------- منوی کناری (دسکتاپ) ---------- */
.rail {
  display: none;
}

@media (min-width: 1024px) {
  :root {
    --gutter: 32px;
  }

  .tabbar {
    display: none;
  }

  .view {
    padding-bottom: var(--s10);
  }

  .rail {
    position: fixed;
    z-index: 70;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: var(--rail-w);
    display: flex;
    flex-direction: column;
    gap: var(--s1);
    padding: var(--s5) var(--s3);
    background: var(--bg);
    border-inline-end: 1px solid var(--line);
  }

  .stage {
    margin-inline-start: var(--rail-w);
  }

  .rail-brand {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s2) var(--s3) var(--s5);
  }

  .rail-brand .mark {
    width: 36px;
    height: 36px;
  }

  .rail-brand strong {
    font-size: 1.15rem;
    font-weight: 900;
    display: block;
    line-height: 1.3;
  }

  .rail-brand span {
    font-size: var(--fs-xs);
    color: var(--text-3);
    font-weight: 600;
  }

  .rail-link {
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: 44px;
    padding: 0 var(--s3);
    border-radius: var(--r-md);
    color: var(--text-2);
    font-weight: 700;
    position: relative;
    transition: background-color var(--t-fast) ease, color var(--t-fast) ease;
  }

  .rail-link svg {
    width: 22px;
    height: 22px;
  }

  .rail-link:hover {
    background: var(--surface-1);
    color: var(--text);
  }

  .rail-link.is-active {
    background: var(--surface-2);
    color: var(--text);
  }

  .rail-link .dot-badge {
    position: static;
    margin-inline-start: auto;
    box-shadow: none;
  }

  .rail-link.is-cta {
    margin: var(--s2) 0;
    background: var(--biz);
    color: #0B1220;
    justify-content: center;
  }

  .app[data-area="pro"] .rail-link.is-cta {
    background: var(--accent);
    color: #fff;
  }

  .rail-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: var(--s1);
  }

  .topbar {
    padding-inline: var(--s5);
  }

  /* لوگو در منوی کناری هست؛ تکرارش در نوار بالا لازم نیست */
  .topbar-brand {
    visibility: hidden;
  }

  .topbar.over-media {
    inset-inline-start: var(--rail-w);
  }

  .large-title {
    padding-top: var(--s6);
  }
}

/* ---------- نوار اقدام چسبان پایین (مثل Airbnb) ---------- */
.actionbar {
  position: fixed;
  z-index: 65;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--gutter) calc(var(--s3) + var(--safe-bottom));
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  box-shadow: 0 -1px 0 var(--line);
}

.actionbar .btn {
  flex: 1;
}

.actionbar-info {
  flex: 1;
  min-width: 0;
}

.actionbar-info strong {
  display: block;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actionbar-info span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actionbar-info span {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

@media (min-width: 1024px) {
  .actionbar {
    inset-inline-start: var(--rail-w);
    justify-content: flex-end;
  }

  .actionbar .btn {
    flex: 0 0 auto;
    min-width: 180px;
  }
}

/* ---------- جابه‌جایی صفحه‌ها (درون‌اپ با startViewTransition) ---------- */
::view-transition-old(view) {
  animation: vtOut 160ms ease both;
}

::view-transition-new(view) {
  animation: vtIn 260ms var(--ease) both;
}

.vt-forward::view-transition-new(view) {
  animation-name: vtPushIn;
}

.vt-back::view-transition-new(view) {
  animation-name: vtPopIn;
}

@keyframes vtOut {
  to { opacity: 0; }
}

@keyframes vtIn {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes vtPushIn {
  from { opacity: 0; transform: translateX(-24px); }
}

@keyframes vtPopIn {
  from { opacity: 0; transform: translateX(24px); }
}

/* بدون پشتیبانی View Transitions */
.view.enter {
  animation: vtIn 260ms var(--ease) both;
}

/* ---------- شبکه‌ها ---------- */
.grid {
  display: grid;
  gap: var(--s3);
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cards {
  display: grid;
  gap: var(--s4);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .grid-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stack > * + * {
  margin-top: var(--s3);
}

.hstack {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.spacer {
  flex: 1;
}
