/* Layout: the app shell (side nav on desktop, bottom nav on phones), the top bar, the page and its grids.
   Direction-aware with logical properties: the same rules serve Persian (RTL) and English (LTR). */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }

/* side navigation */
.sidenav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-4); background: var(--surface); border-inline-end: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-2) var(--sp-5); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 44px; height: 44px; flex: none; }
.brand-name { font-weight: 800; font-size: 16px; line-height: 22px; }
.brand-sub { font-family: var(--font-en); font-size: var(--fs-small); color: var(--text-muted); line-height: 16px; }
.navlist { display: flex; flex-direction: column; gap: 6px; }
.navitem {
  position: relative; display: flex; align-items: center; gap: var(--sp-3); height: 48px; padding: 0 var(--sp-3);
  border-radius: var(--r-md); color: var(--text); opacity: 0.78; font-weight: 600;
  transition: background var(--t-hover) var(--ease), opacity var(--t-hover) var(--ease);
}
.navitem:hover { background: var(--nav-hover-bg); opacity: 1; text-decoration: none; }
button.navitem { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: start; }
.navitem[aria-current="page"] { background: var(--nav-active-bg); color: var(--primary-ink); opacity: 1; font-weight: 700; }
.navitem[aria-current="page"]::before {
  content: ''; position: absolute; inset-inline-start: -16px; top: 12px; width: 3px; height: 24px;
  border-radius: 3px; background: var(--primary);
}
.navitem .ico { width: 20px; height: 20px; }
.navitem .count { margin-inline-start: auto; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--line); }

/* top bar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h); padding: 0 var(--page-pad); background: var(--surface-glass);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.topbar .crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; color: var(--text-muted); }
.topbar .crumbs b { color: var(--text); font-weight: 700; }
.topbar .actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-3); }
.topbar .mobile-brand { display: none; }

/* page */
.page { width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--page-pad); display: flex; flex-direction: column; gap: var(--section-gap); }
.page-head { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.page-head .titles { flex: 1 1 auto; min-width: 0; }
.page-head p { color: var(--text-muted); margin-top: var(--sp-1); }
.grid { display: grid; gap: var(--card-gap); }
.grid.stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid.apps { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.grid.origins { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }

/* bottom navigation (phones) */
.bottomnav { display: none; }

/* sign-in page */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr); }
/* the art is 3:1; a tall panel shows about a third of it, and 10% keeps both the operator and the rocket in view */
.auth-art { position: relative; overflow: hidden; background: #0C242C url('../img/hero.webp') 10% center / cover no-repeat; }
.auth-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, #06171DCC, #06171D10 55%); }
.auth-art .tagline { position: absolute; inset-inline-start: var(--sp-10); bottom: var(--sp-10); z-index: 1; color: #F3FAFB; max-width: 420px; }
.auth-art .tagline h1 { font-size: var(--fs-display); line-height: var(--lh-display); }
.auth-art .tagline p { color: #A0BAC2; margin-top: var(--sp-2); }
.auth-panel { display: flex; flex-direction: column; padding: var(--sp-6) var(--sp-8); background: var(--surface); }
.auth-panel .prefs { display: flex; justify-content: flex-end; gap: var(--sp-2); }
.auth-panel .form-wrap { margin: auto 0; width: 100%; max-width: 400px; align-self: center; display: flex; flex-direction: column; gap: var(--sp-5); }
.auth-panel .foot { color: var(--text-subtle); text-align: center; }

@media (max-width: 1180px) {
  .grid.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}

/* phones and the WebView app: one column, a bottom navigation, no side nav */
@media (max-width: 760px) {
  :root { --page-pad: 16px; --section-gap: 20px; --card-gap: 12px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidenav { display: none; }
  .topbar { height: 56px; padding: 0 var(--page-pad); padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .topbar .crumbs { display: none; }
  .topbar .mobile-brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; }
  .topbar .mobile-brand .brand-mark { width: 32px; height: 32px; }
  .page { padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom)); }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.stats > :first-child { grid-column: 1 / -1; }
  .grid.apps, .grid.origins { grid-template-columns: minmax(0, 1fr); }
  .bottomnav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-muted); font-size: 11px; font-weight: 600; position: relative; }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav a .ico { width: 22px; height: 22px; }
  .bottomnav a[aria-current="page"] { color: var(--primary-ink); }
  .bottomnav a[aria-current="page"] .ico-wrap { background: var(--nav-active-bg); }
  .bottomnav .ico-wrap { display: grid; place-items: center; width: 52px; height: 30px; border-radius: var(--r-pill); transition: background var(--t-hover) var(--ease); }
  .bottomnav .count { position: absolute; top: 6px; inset-inline-end: calc(50% - 22px); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { min-height: 200px; }
  .auth-art .tagline { inset-inline-start: var(--sp-5); bottom: var(--sp-5); }
  .auth-art .tagline h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); }
  .auth-panel { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}
