/* =============================================================================
   KilusNa — LAYOUT
   header · primary nav · mobile search · mobile drawer · page grid ·
   sidebars · panels · footer
   (Mobile-first: everything below is the ≤639px base. All breakpoint changes
   — including the ≥1024 / ≥1280 rail rules — live in mobile.css.)
   ============================================================================= */

/* ===== Header (sticky, 60px row + optional nav row) ======================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: var(--rule) solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: var(--header-h);
  padding: 0 var(--s4);
}

.header-menu {
  width: 44px;
  height: 44px;
  margin-left: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-btn);
  color: var(--body);
  transition: background .15s ease, color .15s ease;
}

.header-menu:hover { background: var(--hover); color: var(--text); }
.header-menu svg { width: 24px; height: 24px; }

.header-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.header-logo-img {
  height: 40px;
  width: auto;
  max-width: min(48vw, 220px);
  object-fit: contain;
  border-radius: var(--r-btn);
}

/* Pill search — visible ≥768 (rule lives in mobile.css) */
.header-search {
  position: relative;
  display: none;
  align-items: center;
  gap: var(--s2);
  flex: 1 1 auto;
  max-width: 440px;
  min-height: 46px;
  margin-left: auto;
  padding-left: 16px;
  background: var(--card);
  border: 1px solid var(--input-border);
  border-radius: var(--r-pill);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.header-search:focus-within {
  border-color: var(--accent-text);
  box-shadow: var(--ring);
}

.header-search-icon {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.header-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--fs-sm);
  color: var(--text);
}

.search-deep-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}

.search-deep-btn:hover { background: var(--accent-soft); color: var(--accent-text); }
.search-deep-btn svg { width: 18px; height: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-shrink: 0;
}

/* Auth buttons are hidden <640 (mobile.css reveals them) */

/* ===== Primary nav row (≥1024) =========================================== */
.nav-bar {
  display: none;
  background: var(--card);
  border-top: var(--rule) solid var(--border);
}

.nav-bar-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s1);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s2) var(--s4);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--body);
  transition: background .15s ease, color .15s ease;
}

.nav-link svg { width: 16px; height: 16px; color: var(--accent-text); }
.nav-link:hover { color: var(--accent-text); }
.nav-link.active,
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

/* ===== Mobile search (≤767 — base) ======================================= */
.mobile-search {
  display: block;
  padding: var(--s2) var(--s4);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.mobile-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 46px;
  padding-left: 16px;
  background: var(--card);
  border: 1px solid var(--input-border);
  border-radius: var(--r-pill);
}

.mobile-search-wrapper:focus-within {
  border-color: var(--accent-text);
  box-shadow: var(--ring);
}

.mobile-search-icon { width: 16px; height: 16px; color: var(--faint); }

.mobile-search-wrapper input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--fs-sm);
}

/* ===== Mobile drawer (≤1023 — base) ====================================== */
.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: 120;
  visibility: hidden;
}

.mobile-nav.open { visibility: visible; }

.mobile-nav-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity .2s ease;
}

.mobile-nav.open .mobile-nav-backdrop { opacity: 1; }

.mobile-nav-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 18rem;
  max-width: 86vw;
  background: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  transform: translateX(-100%);
  transition: transform .2s ease;
}

.mobile-nav.open .mobile-nav-drawer { transform: none; }

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}

.mobile-nav-logo {
  height: 32px;
  width: auto;
  border-radius: 6px;
}

.mobile-nav-close {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}

.mobile-nav-close:hover { background: var(--hover); color: var(--text); }
.mobile-nav-close svg { width: 20px; height: 20px; }

.mobile-nav-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s3);
}

/* ===== Page grid ========================================================= */
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  max-width: var(--max-w);
  margin: var(--gap) auto;
  padding: 0 var(--gap);
  align-items: start;
}

/* Rails are revealed per breakpoint in mobile.css (left ≥1024, right ≥1280) */
.sidebar-left,
.sidebar-right { display: none; }

/* Rails scroll (wheel / touch / keyboard via their tabindex="0") but never
   draw a scrollbar. These class selectors outrank the global `*`
   scrollbar-width and the `::-webkit-scrollbar` sizing rules in base_theme.css
   — and layout.css loads after it — so the rails win in both themes; every
   other scroller (modal, drawer, tabs, dropdown) keeps the thin themed bar. */
.sidebar-left,
.sidebar-right { scrollbar-width: none; }

.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar { display: none; }

.sidebar-left-inner,
.sidebar-right-inner { min-width: 0; }

.main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* Panels: only the active one renders (SPA behaviour) */
.content-panel { display: none; }

.content-panel.panel-active {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  animation: panel-in .18s ease-out;
}

.content-panel:focus { outline: none; }

/* Right-rail cards are relocated here by JS below 1280 so nothing is lost */
.rail-below {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.rail-below:empty { display: none; }

/* ===== Footer ============================================================ */
.site-footer {
  margin-top: var(--s7);
  padding: var(--s6) var(--s4) var(--s5);
  background: var(--card);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--faint);
}

.footer-logo {
  height: 32px;
  width: auto;
  margin: 0 auto;
  border-radius: 6px;
}

.footer-socials-title {
  margin-top: var(--s3);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
}

.social-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s5);
  margin-top: var(--s3);
}

.social-row a {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}

.social-row a:hover { background: var(--hover); color: var(--accent-text); }
.social-row svg { width: 18px; height: 18px; }

.footer-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  margin-top: var(--s3);
  font-size: var(--fs-xs);
  color: var(--muted);
}

.footer-soon {
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-badge);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  border-radius: var(--r-pill);
}

.footer-bottom {
  max-width: var(--max-w);
  margin: var(--s4) auto 0;
  font-size: var(--fs-xs);
  color: var(--faint);
}

.footer-bottom a {
  color: var(--muted);
  transition: color .15s ease;
}

.footer-bottom a:hover { color: var(--accent-text); text-decoration: underline; }
