/* Site header web part — tokens from theme.css (--header-*) */
:root {
  --site-header-h: 56px;
}

.site-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: var(--site-header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  z-index: 1000;
}

html[data-theme="light"] .site-header {
  box-shadow: var(--header-shadow);
}

html[data-theme="light"] .site-header__brand:hover {
  color: #9a3412;
}

html[data-theme="light"] .visitors-pill {
  border-color: #e7e5e4;
  background: #fafaf9;
}

html[data-theme="light"] .lang-btn {
  border-color: #d6d3d1;
  background: #fff;
  color: #78716c;
}

html[data-theme="light"] .lang-btn:hover {
  color: #1c1917;
  border-color: #a8a29e;
}

html[data-theme="light"] .lang-btn.is-active,
html[data-theme="light"] .lang-btn[aria-pressed="true"] {
  color: #1d4ed8;
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

html[data-theme="light"] .persian-toggle__box {
  border-color: #d6d3d1;
  background: #fff;
}

html[data-theme="light"] .persian-toggle__text {
  color: #44403c;
}

html[data-theme="light"] .icon-btn {
  border-color: #e7e5e4;
  background: #fafaf9;
  color: #44403c;
}

html[data-theme="light"] .icon-btn:hover {
  background: #f5f5f4;
  border-color: #d6d3d1;
}

html[data-theme="light"] .subscribe-btn:hover {
  background: rgba(192, 86, 33, 0.08);
  color: #9a3412;
}

.site-header__inner {
  max-width: 1280px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 max(0.75rem, env(safe-area-inset-left, 0px)) 0 max(0.75rem, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.site-header__brand {
  justify-self: start;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--header-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-header__brand:hover {
  color: #fff;
}

.site-header__center {
  justify-self: center;
}

.visitors-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.visitors-pill__label {
  font-size: 0.8rem;
  color: var(--header-muted);
  font-weight: 500;
}

.visitors-pill__count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--header-accent);
  font-variant-numeric: tabular-nums;
}

.site-header__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  max-width: 100%;
}

.home-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(217, 119, 6, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.04) 100%);
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  box-shadow:
    0 0 0 1px rgba(217, 119, 6, 0.14),
    0 2px 10px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.home-chip:hover {
  border-color: rgba(245, 158, 11, 0.72);
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.24) 0%, rgba(217, 119, 6, 0.1) 100%);
  color: #fff;
  box-shadow:
    0 0 0 2px rgba(217, 119, 6, 0.22),
    0 4px 16px rgba(217, 119, 6, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html[data-theme="light"] .home-chip {
  border: 1.5px solid rgba(192, 86, 33, 0.32);
  background: linear-gradient(180deg, #fffaf5 0%, #fef3e8 100%);
  color: #9a3412;
  box-shadow:
    0 1px 3px rgba(24, 24, 27, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html[data-theme="light"] .home-chip:hover {
  border-color: rgba(192, 86, 33, 0.55);
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #7c2d12;
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
}

.lang-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--header-muted);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.lang-btn:hover {
  color: var(--header-text);
  border-color: rgba(255, 255, 255, 0.25);
}

.lang-btn.is-active,
.lang-btn[aria-pressed="true"] {
  color: #fff;
  border-color: var(--header-lang-active);
  box-shadow: 0 0 0 1px var(--header-lang-active), 0 0 12px rgba(79, 143, 247, 0.35);
}

.persian-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.persian-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.persian-toggle__box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.persian-toggle__input:checked + .persian-toggle__box {
  background: var(--header-lang-active);
  border-color: var(--header-lang-active);
}

.persian-toggle__text {
  font-size: 0.78rem;
  color: var(--header-text);
  white-space: nowrap;
}

.icon-btn {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--header-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

.theme-toggle .theme-icon--sun {
  display: none;
}

.theme-toggle.is-dark-active .theme-icon--moon {
  display: none;
}

.theme-toggle.is-dark-active .theme-icon--sun {
  display: block;
}

.subscribe-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--header-subscribe);
  color: var(--header-subscribe);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  transition: background 0.2s, color 0.2s;
}

.subscribe-btn:hover {
  background: rgba(232, 160, 32, 0.12);
  color: #f5b84a;
}

/* Page shell below header */
body.has-site-header {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.site-page-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 900px) {
  .site-header__inner {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }

  .site-header__brand {
    grid-column: 1;
    grid-row: 1;
  }

  .site-header__center {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .site-header__actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding-bottom: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .site-header__actions::-webkit-scrollbar {
    display: none;
  }

  :root {
    --site-header-h: 72px;
  }

  .persian-toggle__text {
    display: none;
  }
}

@media (max-width: 520px) {
  .subscribe-btn {
    display: none;
  }

  .site-header__brand {
    font-size: 0.88rem;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .visitors-pill {
    padding: 0.3rem 0.6rem;
  }
}

@media (max-width: 400px) {
  .visitors-pill__label {
    display: none;
  }

  .site-header__inner {
    gap: 0.45rem;
    padding-inline: max(0.5rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  }

  .site-header__actions {
    gap: 0.35rem;
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .site-header {
    height: auto;
    min-height: var(--site-header-h);
  }

  .site-header__inner {
    min-height: var(--site-header-h);
  }
}
