/* ==========================================================================
   Site chrome: header, navigation, footer, bottom nav
   ========================================================================== */

.site-header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: color-mix(in srgb, var(--c-surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--c-line);
  padding-top: env(safe-area-inset-top);
}
.site-header__inner { display: flex; align-items: center; gap: var(--s-6); min-height: var(--header-h); }

.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--c-ink); text-decoration: none; flex: 0 1 auto; }
.brand:hover { color: var(--c-ink); }
.brand__mark { width: 42px; height: 42px; flex: none; }
.brand__mark svg { width: 100%; height: 100%; }
.brand__text { display: grid; line-height: 1.25; }
.brand__text strong { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); }
.brand__text { min-width: 0; }
.brand__text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__short { display: none; }
@media (max-width: 480px) {
  .site-header .brand__full { display: none; }
  .site-header .brand__short { display: inline; }
}
.brand__text small { font-size: var(--fs-2xs); color: var(--c-ink-3); }

.main-nav { flex: 1; min-width: 0; }
.main-nav ul { list-style: none; display: flex; gap: var(--s-1); justify-content: safe center; }
.main-nav a {
  position: relative; display: block;
  padding: var(--s-2) var(--s-3);
  color: var(--c-ink-2); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  border-radius: var(--radius-sm);
}
.main-nav a:hover { color: var(--c-primary); }
.main-nav a[aria-current="page"] { color: var(--c-primary); font-weight: 700; }
.main-nav a[aria-current="page"]::after { content: ""; position: absolute; inset-inline: var(--s-3); bottom: -2px; height: 2px; background: var(--c-primary); border-radius: 2px; }

.header-tools { display: flex; align-items: center; gap: var(--s-1); flex: none; margin-inline-start: auto; }
.main-nav { overflow: hidden; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 var(--s-3);
  border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--c-ink-2); font-size: var(--fs-xs); font-weight: 600;
}
.tool-btn:hover { background: var(--c-primary-50); color: var(--c-primary); }
.header-auth { display: flex; gap: var(--s-2); margin-inline-start: var(--s-2); }
.header-tools .menu-btn { display: none; }

@media (max-width: 1480px) { .site-header .user-hello { display: none; } }
@media (max-width: 1440px) {
  .site-header__inner { gap: var(--s-4); }
  .main-nav a { padding-inline: var(--s-2); }
}
@media (max-width: 1180px) {
  .brand__text small { display: none; }
  .main-nav a { padding-inline: var(--s-2); }
}
@media (max-width: 1240px) {
  .main-nav { display: none; }
  .header-tools .menu-btn { display: inline-grid; }
}
@media (max-width: 899px) {
  :root { --header-h: 60px; }
  .site-header__inner { gap: var(--s-3); }
  .header-auth, .header-tools .tool-theme-desktop { display: none; }
  .tool-lang-desktop { padding-inline: var(--s-2); }
  .brand__mark { width: 36px; height: 36px; }
  .brand__text strong { font-size: var(--fs-md); }
}

/* ---------- bottom navigation (mobile) ---------- */
.bottom-nav { display: none; }
@media (max-width: 899px) {
  body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-bottom);
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--c-surface);
    border-top: 1px solid var(--c-line);
  }
  .bn-item {
    position: relative;
    display: grid; justify-items: center; align-content: center; gap: 2px;
    color: var(--c-ink-3); text-decoration: none; font-size: 11px; font-weight: 500;
  }
  .bn-item .i { width: 22px; height: 22px; }
  .bn-item[aria-current="page"] { color: var(--c-primary); font-weight: 700; }
  .bn-item[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 32px; height: 3px; border-radius: 0 0 3px 3px; background: var(--c-primary); }
  .bn-item .count-dot { top: 6px; inset-inline-end: calc(50% - 20px); }
}

/* ---------- footer ---------- */
.site-footer { background: var(--c-deep); color: var(--c-on-deep); margin-top: var(--s-16); --focus: var(--c-sand); }
.site-footer a { color: var(--c-on-deep-2); text-decoration: none; }
.site-footer a:hover { color: var(--c-on-deep); text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--s-8); padding-block: var(--s-12) var(--s-8); }
.footer-brand p { color: var(--c-on-deep-2); font-size: var(--fs-sm); max-width: 36ch; margin-top: var(--s-4); }
.footer-brand .brand { color: var(--c-on-deep); }
.footer-brand .brand__text small { color: var(--c-on-deep-2); display: block; }
.footer-col h2 { font-size: var(--fs-sm); color: var(--c-on-deep); margin-bottom: var(--s-3); }
.footer-col ul { list-style: none; display: grid; gap: var(--s-2); font-size: var(--fs-sm); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); padding-block: var(--s-5); display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--c-on-deep-2); }
.footer-switches { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.footer-switches button { border: 1px solid rgba(255,255,255,.25); background: transparent; color: var(--c-on-deep); border-radius: var(--radius-sm); padding: 6px 12px; font-size: var(--fs-xs); display: inline-flex; align-items: center; gap: 6px; }
.footer-switches button:hover { border-color: rgba(255,255,255,.6); }
.footer-switches .i { width: 16px; height: 16px; }
@media (max-width: 899px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---------- page shells ---------- */
.with-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-6); align-items: start; }
.with-aside > aside { position: sticky; top: calc(var(--header-h) + var(--s-4)); display: grid; gap: var(--s-5); }
@media (max-width: 1060px) {
  .with-aside { grid-template-columns: minmax(0, 1fr); }
  .with-aside > aside { position: static; }
}

/* Small screens: the brand may shorten; account lives in the bottom nav and drawer */
.brand { min-width: 0; flex: none; }
@media (max-width: 640px) { .brand { flex: 0 1 auto; } }
.brand__text { min-width: 0; }
.brand__text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  .site-header .menu[data-menu] { display: none; }
  .header-tools { gap: 0; }
  .header-tools .icon-btn { width: 40px; }
}
