/* ===== Top bar (responsive) ===== */
:root {
  --tb-h: 64px;
  --tb-h-m: 48px;
  --gap: 10px;
  --btn-fs: 14px;
  --btn-fs-m: 13px;
  --btn-py: 0.5em;
  --btn-py-m: 0.4em;
  --btn-px: 1em;
  --btn-px-m: 0.9em;
  --radius: 12px;
  --topbar-offset: var(--tb-h);
}

.page {
  padding-top: var(--topbar-offset);
}

[id] {
  scroll-margin-top: calc(var(--topbar-offset) + 12px);
}

@media (max-width: 768px) {
  :root {
    --topbar-offset: var(--tb-h-m);
    --tb-h: var(--tb-h-m);
    --btn-fs: var(--btn-fs-m);
    --btn-py: var(--btn-py-m);
    --btn-px: var(--btn-px-m);
    --radius: 10px;
  }
}

/* Topbar styling */
.topbar {
  position: sticky;
  top: 0;
  z-index: 9999;
  background: linear-gradient(180deg, #7D7878, #666262);
  color: #222;
  padding-top: max(env(safe-area-inset-top), 0px);
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.topbar__inner {
  height: var(--tb-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 clamp(10px, 3vw, 24px);
}

/* Brand */
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .5px;
  font-size: clamp(16px, 2.2vw, 20px);
}

/* Buttons */
.btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: auto !important;
  min-height: 0;
  line-height: 1;
  font-size: var(--btn-fs);
  padding: var(--btn-py) var(--btn-px);
  border-radius: var(--radius);
  border: 1px solid #3a3a3a;
  background: #3b3b3b;
  color: #f3f3f3;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
}

.btn:hover {
  background: #4a4a4a;
  border-color: #565656;
  transform: translateY(-1px);
}
.btn:active { transform: none; }

.btn--primary {
  background: #4c694c;
  border-color: #577257;
}
.btn--primary:hover {
  background: #597a59;
}

/* Cart badge */
.cart {
  position: relative;
  padding-right: calc(var(--btn-px) + 18px);
}
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #B0B090;
  color: #1b1b1b;
  font-weight: 700;
  font-size: 12px;
  border: 1px solid #A9B3A7;
}

/* Hamburger */
.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--gap);
}
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  background: #343434;
  color: #fff;
  align-items: center;
  justify-content: center;
}
.nav-toggle__bar {
  width: 18px;
  height: 2px;
  background: #fff;
  position: relative;
  display: block;
}
.nav-toggle__bar::before,
.nav-toggle__bar::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #fff;
}
.nav-toggle__bar::before { top: -6px; }
.nav-toggle__bar::after  { top: 6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Mobile nav (slide down) ===== */
@media (max-width: 768px) {
  .topbar__inner {
    gap: 6px;
  }

  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .nav {
    position: fixed;
    top: var(--tb-h);
    left: 0;
    right: 0;
    z-index: 9998;
    display: grid;
    gap: 8px;
    padding: 10px clamp(10px, 4vw, 16px);
    background: #1f1f1f;
    border-bottom: 1px solid #303030;
    transform: translateY(-110%);
    transition: transform .2s ease;
  }

  .topbar.nav-open .nav {
    transform: translateY(0);
  }

  .btn {
    height: auto !important;
    min-height: 0;
  }

  .badge {
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    top: -5px;
    right: -5px;
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .btn, .nav {
    transition: none;
  }
}
