/**
 * BahnDeutsch Theme — glassmorphism shell layout
 * Design tokens aligned with bahndeutsch-ui-system + bd-home homepage.
 */

/* ── Design tokens ── */
:root {
  --bd-t-bg: linear-gradient(180deg, #f4f7fb 0%, #eef3fa 46%, #e8eef8 100%);
  --bd-t-bg-solid: #eef1f8;
  --bd-t-glass: rgba(255, 255, 255, 0.72);
  --bd-t-glass-strong: rgba(255, 255, 255, 0.88);
  --bd-t-stroke: rgba(255, 255, 255, 0.78);
  --bd-t-stroke-soft: rgba(137, 159, 191, 0.22);
  --bd-t-shadow: 0 20px 48px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.04);
  --bd-t-shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.08);
  --bd-t-blur: blur(40px) saturate(180%);
  --bd-t-text: #1e293b;
  --bd-t-text-soft: #64748b;
  --bd-t-title: #0f172a;
  --bd-t-primary: #007aff;
  --bd-t-primary-strong: #0066d6;
  --bd-t-primary-soft: rgba(0, 122, 255, 0.12);
  --bd-t-radius-xl: 24px;
  --bd-t-radius-lg: 18px;
  --bd-t-radius-md: 14px;
  --bd-t-radius-sm: 10px;
  --bd-t-content: 1320px;
  --bd-t-content-narrow: 820px;
  --bd-t-header-h: 72px;
  --bd-t-focus-ring: 0 0 0 3px rgba(0, 122, 255, 0.28);
  --bd-t-font-body: var(--bd-font-body, "Vazirmatn", system-ui, sans-serif);
  --bd-t-font-display: var(--bd-font-display, "Estedad", system-ui, sans-serif);
}

/* ── Reset & base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--bd-t-text);
  background: var(--bd-t-bg-solid);
  background-image: var(--bd-t-bg);
  font-family: var(--bd-t-font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.bahndeutsch-theme {
  display: flex;
  flex-direction: column;
}

.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main {
  flex: 1 0 auto;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--bd-t-primary-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
  color: var(--bd-t-primary);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--bd-t-font-display);
  color: var(--bd-t-title);
  line-height: 1.25;
  margin-block: 0 0.65em;
}

p {
  margin: 0 0 1em;
}

/* ── Accessibility ── */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background: #fff;
  border-radius: var(--bd-t-radius-sm);
  box-shadow: var(--bd-t-shadow-soft);
  clip: auto !important;
  clip-path: none;
  color: var(--bd-t-title);
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  height: auto;
  inset-inline-start: 1rem;
  line-height: normal;
  padding: 0.75rem 1rem;
  text-decoration: none;
  top: 1rem;
  width: auto;
  z-index: 100000;
}

.skip-link:focus {
  position: fixed;
}

/* Global focus ring — keyboard users only */
:where(
  a,
  button,
  input,
  select,
  textarea,
  .bd-theme-btn,
  .bd-theme-search__submit,
  .page-numbers
):focus-visible {
  outline: none;
  box-shadow: var(--bd-t-focus-ring);
}

/* ── Buttons ── */
.bd-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.bd-theme-btn.is-primary {
  background: var(--bd-t-primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.28);
}

.bd-theme-btn.is-primary:hover,
.bd-theme-btn.is-primary:focus-visible {
  background: var(--bd-t-primary-strong);
  color: #fff;
  transform: translateY(-1px);
}

.bd-theme-btn.is-ghost {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--bd-t-stroke-soft);
  color: var(--bd-t-title);
  backdrop-filter: blur(12px);
}

.bd-theme-btn.is-ghost:hover,
.bd-theme-btn.is-ghost:focus-visible {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 122, 255, 0.25);
  color: var(--bd-t-primary-strong);
}

/* ── Site header ── */
body:not(.bd-theme-sticky-header) .site-header {
  position: relative;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 1px solid var(--bd-t-stroke-soft);
  background: var(--bd-t-glass);
  backdrop-filter: var(--bd-t-blur);
  -webkit-backdrop-filter: var(--bd-t-blur);
  box-shadow: var(--bd-t-shadow-soft);
}

.admin-bar .site-header {
  top: var(--wp-admin--admin-bar--height, 32px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: var(--bd-t-content);
  margin-inline: auto;
  padding: 0.65rem clamp(1rem, 3vw, 1.75rem);
  min-height: var(--bd-t-header-h);
}

.site-header__start {
  flex-shrink: 0;
}

.site-branding {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--bd-t-title);
}

.site-branding:hover,
.site-branding:focus-visible {
  color: var(--bd-t-primary-strong);
}

.site-branding__logo .custom-logo-link {
  display: block;
  line-height: 0;
}

.site-branding__logo img,
.custom-logo {
  width: auto;
  max-height: 44px;
  border-radius: var(--bd-t-radius-sm);
}

.site-branding__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bd-t-primary-soft);
  color: var(--bd-t-primary);
}

.site-branding__name {
  font-family: var(--bd-t-font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Primary navigation ── */
.main-navigation {
  flex: 1 1 auto;
  min-width: 0;
}

.main-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-menu > .menu-item > a {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bd-t-text);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.main-menu > .menu-item > a:hover,
.main-menu > .menu-item > a:focus-visible,
.main-menu > .menu-item.current-menu-item > a,
.main-menu > .menu-item.current-menu-ancestor > a {
  background: var(--bd-t-primary-soft);
  color: var(--bd-t-primary-strong);
}

.main-menu .sub-menu {
  display: none;
}

/* ── Desktop dropdown menus ── */
@media (min-width: 1025px) {
  .main-menu > .menu-item-has-children {
    position: relative;
  }

  .main-menu > .menu-item-has-children > a {
    gap: 0.25rem;
  }

  .menu-item-caret::after {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-inline-start: 0.2rem;
    border-inline-end: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    opacity: 0.65;
  }

  .main-menu > .menu-item-has-children > .sub-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    inset-inline-start: 0;
    min-width: 220px;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.45rem;
    margin: 0;
    list-style: none;
    border-radius: var(--bd-t-radius-md);
    border: 1px solid var(--bd-t-stroke-soft);
    background: var(--bd-t-glass-strong);
    backdrop-filter: var(--bd-t-blur);
    box-shadow: var(--bd-t-shadow);
    z-index: 220;
  }

  .main-menu > .menu-item-has-children.is-open > .sub-menu,
  .main-menu > .menu-item-has-children:focus-within > .sub-menu {
    display: flex;
  }

  .main-menu .sub-menu .menu-item > a {
    display: block;
    padding: 0.55rem 0.85rem;
    border-radius: var(--bd-t-radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bd-t-text);
    text-decoration: none;
  }

  .main-menu .sub-menu .menu-item > a:hover,
  .main-menu .sub-menu .menu-item > a:focus-visible {
    background: var(--bd-t-primary-soft);
    color: var(--bd-t-primary-strong);
  }
}

/* Mobile submenu in drawer */
/* Mobile submenu accordion */
.bd-theme-mobile-drawer__nav .menu-item-has-children > .sub-menu {
  display: none;
}

.bd-theme-mobile-drawer__nav .menu-item-has-children.is-expanded > .sub-menu {
  display: flex;
}

.bd-theme-mobile-drawer__nav .menu-item-has-children > a {
  justify-content: space-between;
}

.bd-theme-mobile-drawer__nav .menu-item-has-children > a .menu-item-caret::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-inline-end: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
}

.bd-theme-mobile-drawer__nav .sub-menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.25rem 0 0.5rem;
  padding-inline-start: 1rem;
  list-style: none;
}

.bd-theme-mobile-drawer__nav .sub-menu a {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--bd-t-radius-sm);
  font-size: 0.875rem;
  color: var(--bd-t-text-soft);
  text-decoration: none;
}

/* ── Sticky header scroll state ── */
.site-header.is-scrolled {
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.88);
}

body.bd-theme-menu-open {
  overflow: hidden;
}

/* ── Breadcrumbs ── */
.bd-theme-breadcrumbs {
  margin-bottom: 1.25rem;
  font-size: 0.8125rem;
}

.bd-theme-breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--bd-t-text-soft);
}

.bd-theme-breadcrumbs__item:not(:last-child)::after {
  content: "/";
  margin-inline: 0.35rem;
  color: #9ab0cf;
  opacity: 0.85;
}

.bd-theme-breadcrumbs__item a {
  color: var(--bd-t-primary-strong);
  text-decoration: none;
  font-weight: 600;
}

.bd-theme-breadcrumbs__item a:hover,
.bd-theme-breadcrumbs__item a:focus-visible {
  color: var(--bd-t-primary);
}

.bd-theme-breadcrumbs__item span {
  color: var(--bd-t-text);
  font-weight: 600;
}

/* ── Comments ── */
.bd-theme-comments {
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--bd-t-stroke-soft);
}

.bd-theme-comments__title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.bd-theme-comments__list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.bd-theme-comment {
  margin-bottom: 1.25rem;
}

.bd-theme-comment__body {
  padding: 1rem 1.15rem;
  border-radius: var(--bd-t-radius-md);
  border: 1px solid var(--bd-t-stroke-soft);
  background: rgba(255, 255, 255, 0.55);
}

.bd-theme-comment__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.bd-theme-comment__avatar {
  border-radius: 50%;
}

.bd-theme-comment__author {
  display: block;
  font-style: normal;
  font-weight: 700;
  color: var(--bd-t-title);
}

.bd-theme-comment__date {
  display: block;
  font-size: 0.75rem;
  color: var(--bd-t-text-soft);
}

.bd-theme-comment__content {
  font-size: 0.9375rem;
}

.bd-theme-comment__reply a {
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.bd-theme-comment-form {
  margin-top: 1.5rem;
}

.bd-theme-comment-form__title {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
}

.bd-theme-comment-form input[type="text"],
.bd-theme-comment-form input[type="email"],
.bd-theme-comment-form input[type="url"],
.bd-theme-comment-form textarea {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--bd-t-radius-sm);
  border: 1px solid var(--bd-t-stroke-soft);
  font-family: inherit;
  font-size: 0.9375rem;
}

.bd-theme-comment-form input[type="submit"] {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  background: var(--bd-t-primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.site-header__login.is-account {
  color: var(--bd-t-primary-strong);
  border-color: rgba(0, 122, 255, 0.22);
  background: rgba(0, 122, 255, 0.08);
}

/* ── Header actions ── */
.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.site-header__search {
  min-width: 0;
}

.bd-theme-search {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 180px;
  max-width: 240px;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--bd-t-stroke-soft);
  background: rgba(255, 255, 255, 0.6);
}

.bd-theme-search__input:focus-visible {
  outline: none;
}

.bd-theme-search:focus-within {
  border-color: rgba(0, 122, 255, 0.35);
  box-shadow: var(--bd-t-focus-ring);
  background: rgba(255, 255, 255, 0.85);
}

.bd-theme-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--bd-t-title);
  outline: none;
}

.bd-theme-search__input::placeholder {
  color: var(--bd-t-text-soft);
}

.bd-theme-search__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bd-t-text-soft);
  cursor: pointer;
}

.bd-theme-search__submit:hover,
.bd-theme-search__submit:focus-visible {
  color: var(--bd-t-primary);
}

.site-header__lang .bd-lang-switcher.is-compact {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.site-header__lang .bd-lang-switcher.is-compact .bd-lang-switcher-options .bd-lang-switcher-btn {
  min-height: 34px;
  padding: 0.35rem 0.65rem;
  border-color: var(--bd-t-stroke-soft);
  background: rgba(255, 255, 255, 0.65);
  color: var(--bd-t-title);
}

.site-header__lang .bd-lang-switcher.is-compact .bd-lang-switcher-options .bd-lang-switcher-btn:hover,
.site-header__lang .bd-lang-switcher.is-compact .bd-lang-switcher-options .bd-lang-switcher-btn:focus-visible {
  border-color: rgba(0, 122, 255, 0.35);
  background: var(--bd-t-primary-soft);
  color: var(--bd-t-primary-strong);
}

.site-header__lang .bd-lang-switcher.is-compact .bd-lang-switcher-options .bd-lang-switcher-btn.is-active {
  background: var(--bd-t-primary);
  border-color: var(--bd-t-primary);
  color: #fff;
}

.site-header__lang .bd-lang-switcher.is-compact {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.site-header__login {
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0.75rem;
}

.site-header__login-label {
  display: none;
}

.site-header__toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  padding-inline: 0.65rem;
}

/* ── Mobile drawer ── */
.bd-theme-mobile-drawer[hidden] {
  display: none !important;
}

.bd-theme-mobile-drawer.is-open {
  display: block;
}

.bd-theme-mobile-drawer__panel {
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

html[dir="rtl"] .bd-theme-mobile-drawer__panel {
  transform: translateX(-100%);
}

.bd-theme-mobile-drawer.is-open .bd-theme-mobile-drawer__panel {
  transform: translateX(0);
}

.bd-theme-mobile-drawer__backdrop {
  opacity: 0;
  transition: opacity 0.22s ease;
}

.bd-theme-mobile-drawer.is-open .bd-theme-mobile-drawer__backdrop {
  opacity: 1;
}

.bd-theme-mobile-drawer__backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
}

.bd-theme-mobile-drawer__panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 301;
  width: min(320px, 88vw);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bd-t-glass-strong);
  backdrop-filter: var(--bd-t-blur);
  border-inline-start: 1px solid var(--bd-t-stroke-soft);
  box-shadow: var(--bd-t-shadow);
  overflow-y: auto;
}

.bd-theme-mobile-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.bd-theme-mobile-drawer__nav .main-menu {
  flex-direction: column;
  align-items: stretch;
}

.bd-theme-mobile-drawer__nav .main-menu > .menu-item > a {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--bd-t-radius-md);
}

.bd-theme-mobile-drawer__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Content area ── */
.bd-theme-content {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 1.75rem);
}

.bd-theme-content--fullbleed {
  padding: 0;
  max-width: none;
}

.bd-theme-content__inner {
  max-width: var(--bd-t-content);
  margin-inline: auto;
}

.bd-theme-content__inner--narrow {
  max-width: var(--bd-t-content-narrow);
}

/* Fullbleed plugin shortcodes break out of theme container */
.bd-theme-content--fullbleed .entry-content > .bd-home,
.bd-theme-content--fullbleed .bd-home,
.bd-theme-content--fullbleed .bd-auth-wrapper,
.bd-theme-content--fullbleed .bd-profile-wrapper {
  width: 100vw;
  max-width: 100vw;
  margin-inline: calc(50% - 50vw);
}

/* ── Articles ── */
.bd-theme-article {
  background: var(--bd-t-glass);
  backdrop-filter: var(--bd-t-blur);
  border: 1px solid var(--bd-t-stroke-soft);
  border-radius: var(--bd-t-radius-xl);
  box-shadow: var(--bd-t-shadow-soft);
  padding: clamp(1.5rem, 4vw, 2.5rem);
}

.entry-header {
  margin-bottom: 1.25rem;
}

.entry-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 0.35em;
}

.entry-title a {
  color: inherit;
  text-decoration: none;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--bd-t-text-soft);
}

.entry-meta a {
  color: var(--bd-t-primary-strong);
  text-decoration: none;
}

.entry-featured {
  margin: 0 0 1.5rem;
  border-radius: var(--bd-t-radius-lg);
  overflow: hidden;
}

.entry-featured img {
  display: block;
  width: 100%;
  height: auto;
}

.entry-content {
  font-size: 1.0625rem;
  line-height: 1.75;
}

/* Prose — readable long-form content */
.entry-content :where(p, ul, ol, blockquote, pre, table, figure) {
  margin-block: 0 1.15em;
}

.entry-content :where(h2, h3, h4) {
  margin-top: 1.75em;
  scroll-margin-top: calc(var(--bd-t-header-h) + 1rem);
}

.entry-content :where(ul, ol) {
  padding-inline-start: 1.35em;
}

.entry-content :where(li + li) {
  margin-top: 0.35em;
}

.entry-content :where(blockquote) {
  margin-inline: 0;
  padding: 0.85rem 1.15rem;
  border-inline-start: 3px solid var(--bd-t-primary);
  border-radius: var(--bd-t-radius-sm);
  background: rgba(0, 122, 255, 0.06);
  color: var(--bd-t-text);
}

.entry-content :where(a) {
  font-weight: 600;
}

.entry-content :where(img, video, iframe) {
  border-radius: var(--bd-t-radius-md);
}

.entry-content :where(pre, code) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.entry-content :where(pre) {
  padding: 1rem 1.15rem;
  overflow-x: auto;
  border-radius: var(--bd-t-radius-md);
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--bd-t-stroke-soft);
}

.entry-content :where(table) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.entry-content :where(th, td) {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--bd-t-stroke-soft);
  text-align: start;
}

.entry-content :where(th) {
  background: rgba(255, 255, 255, 0.55);
  font-weight: 700;
}

.entry-content > *:first-child {
  margin-top: 0;
}

.entry-content > *:last-child {
  margin-bottom: 0;
}

.entry-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bd-t-stroke-soft);
  font-size: 0.875rem;
  color: var(--bd-t-text-soft);
}

.entry-footer__label {
  font-weight: 600;
  color: var(--bd-t-title);
}

/* ── Post grid cards ── */
.bd-theme-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1.25rem;
}

.bd-theme-card {
  display: flex;
  flex-direction: column;
  background: var(--bd-t-glass);
  backdrop-filter: var(--bd-t-blur);
  border: 1px solid var(--bd-t-stroke-soft);
  border-radius: var(--bd-t-radius-lg);
  box-shadow: var(--bd-t-shadow-soft);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .bd-theme-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .bd-theme-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bd-t-shadow);
  }

  .bd-theme-card:hover .bd-theme-card__media img {
    transform: scale(1.03);
  }
}

.bd-theme-card:focus-within {
  box-shadow: var(--bd-t-shadow), var(--bd-t-focus-ring);
}

.bd-theme-card__media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: rgba(0, 122, 255, 0.06);
}

.bd-theme-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (hover: hover) and (pointer: fine) {
  .bd-theme-card__media img {
    transition: transform 0.3s ease;
  }
}

.bd-theme-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.15rem 1.25rem 1.25rem;
}

.bd-theme-card__title {
  font-size: 1.125rem;
  margin-bottom: 0.35em;
}

.bd-theme-card__title a {
  color: var(--bd-t-title);
  text-decoration: none;
}

.bd-theme-card__title a:hover,
.bd-theme-card__title a:focus-visible {
  color: var(--bd-t-primary-strong);
}

.bd-theme-card__excerpt {
  flex: 1;
  font-size: 0.9375rem;
  color: var(--bd-t-text-soft);
  margin-bottom: 0.85rem;
}

.bd-theme-card__link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--bd-t-primary-strong);
  text-decoration: none;
}

.bd-theme-card__arrow::after {
  content: "→";
}

html[dir="rtl"] .bd-theme-card__arrow::after {
  content: "←";
}

.bd-theme-card__link:hover,
.bd-theme-card__link:focus-visible {
  color: var(--bd-t-primary);
}

/* ── Archive pages ── */
.bd-theme-content--archive {
  padding-top: clamp(1rem, 2.5vw, 1.75rem);
}

.bd-theme-archive-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: var(--bd-t-radius-xl);
  border: 1px solid color-mix(in srgb, var(--bd-archive-accent, #007aff) 18%, white);
  background:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--bd-archive-accent, #007aff) 22%, transparent), transparent 42%),
    radial-gradient(circle at 88% 0%, color-mix(in srgb, var(--bd-archive-accent, #007aff) 14%, transparent), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.78));
  box-shadow: var(--bd-t-shadow);
}

.bd-theme-archive-hero__backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bd-theme-archive-hero__orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.45;
}

.bd-theme-archive-hero__orb--one {
  width: 220px;
  height: 220px;
  top: -70px;
  inset-inline-end: -40px;
  background: color-mix(in srgb, var(--bd-archive-accent, #007aff) 55%, white);
}

.bd-theme-archive-hero__orb--two {
  width: 180px;
  height: 180px;
  bottom: -60px;
  inset-inline-start: -30px;
  background: color-mix(in srgb, var(--bd-archive-accent, #007aff) 35%, #dbeafe);
}

.bd-theme-archive-hero__inner {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.bd-theme-archive-hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.65rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bd-archive-accent, #007aff) 12%, white);
  color: color-mix(in srgb, var(--bd-archive-accent, #007aff) 78%, #0f172a);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.bd-theme-archive-hero__title {
  margin: 0 0 0.45em;
  font-size: clamp(1.75rem, 4vw, 2.65rem);
  line-height: 1.15;
}

.bd-theme-archive-hero__desc {
  color: var(--bd-t-text-soft);
  font-size: 1.02rem;
  line-height: 1.75;
  max-width: 62ch;
}

.bd-theme-archive-hero__desc p:last-child {
  margin-bottom: 0;
}

.bd-theme-archive-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: center;
  margin-top: 1.15rem;
}

.bd-theme-archive-hero__stat {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--bd-t-stroke-soft);
  color: var(--bd-t-title);
  font-size: 0.8125rem;
  font-weight: 600;
}

.bd-theme-archive-hero__stat-icon {
  display: inline-flex;
  color: var(--bd-archive-accent, #007aff);
}

.bd-theme-archive-hero__parent {
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.bd-theme-archive-hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.bd-theme-archive-hero__chip {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--bd-archive-accent, #007aff) 24%, white);
  background: rgba(255, 255, 255, 0.82);
  color: var(--bd-t-title);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

@media (hover: hover) and (pointer: fine) {
  .bd-theme-archive-hero__chip:hover,
  .bd-theme-archive-hero__chip:focus-visible {
    transform: translateY(-1px);
    box-shadow: var(--bd-t-shadow-soft);
    background: #fff;
    color: color-mix(in srgb, var(--bd-archive-accent, #007aff) 70%, #0f172a);
  }
}

.bd-theme-post-grid--archive {
  gap: clamp(1rem, 2vw, 1.5rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.bd-theme-card--archive {
  --bd-card-accent: var(--bd-t-primary);
  position: relative;
  min-height: 100%;
}

.bd-theme-card--archive::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--bd-card-accent), color-mix(in srgb, var(--bd-card-accent) 35%, white));
}

.bd-theme-card__media {
  position: relative;
}

.bd-theme-card__media.is-placeholder {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--bd-card-accent) 28%, white), transparent 55%),
    linear-gradient(145deg, color-mix(in srgb, var(--bd-card-accent) 12%, white), rgba(255, 255, 255, 0.9));
}

.bd-theme-card__placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.bd-theme-card__placeholder-glyph {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid color-mix(in srgb, var(--bd-card-accent) 22%, white);
  color: color-mix(in srgb, var(--bd-card-accent) 75%, #0f172a);
  font-family: var(--bd-t-font-display);
  font-size: 2rem;
  font-weight: 800;
  box-shadow: var(--bd-t-shadow-soft);
}

.bd-theme-card__badge {
  position: absolute;
  inset-inline-start: 0.85rem;
  bottom: 0.85rem;
  max-width: calc(100% - 1.7rem);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(8px);
}

.bd-theme-card__cta {
  margin-top: auto;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bd-card-accent) 10%, white);
  border: 1px solid color-mix(in srgb, var(--bd-card-accent) 18%, white);
}

@media (hover: hover) and (pointer: fine) {
  .bd-theme-card__cta:hover,
  .bd-theme-card__cta:focus-visible {
    background: color-mix(in srgb, var(--bd-card-accent) 16%, white);
    transform: translateX(2px);
  }

  html[dir="rtl"] .bd-theme-card__cta:hover,
  html[dir="rtl"] .bd-theme-card__cta:focus-visible {
    transform: translateX(-2px);
  }
}

.entry-meta__reading::before {
  content: "•";
  margin-inline: 0.35rem;
  color: var(--bd-t-text-soft);
}

/* ── Archive header (legacy fallback) ── */
.bd-theme-archive-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--bd-t-stroke-soft);
}

.bd-theme-archive-header__title {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  margin-bottom: 0.25em;
}

.bd-theme-archive-header__desc,
.bd-theme-archive-header__query {
  color: var(--bd-t-text-soft);
  margin: 0;
}

/* ── Pagination ── */
.bd-theme-pagination,
.navigation.pagination {
  margin-top: 2.5rem;
}

.bd-theme-pagination .nav-links,
.navigation.pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.bd-theme-pagination .page-numbers,
.navigation.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--bd-t-stroke-soft);
  background: rgba(255, 255, 255, 0.65);
  color: var(--bd-t-title);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.bd-theme-pagination .page-numbers.current,
.navigation.pagination .page-numbers.current {
  background: var(--bd-t-primary);
  border-color: var(--bd-t-primary);
  color: #fff;
}

.post-navigation {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--bd-t-stroke-soft);
}

.post-navigation .nav-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.post-navigation a {
  display: block;
  padding: 1rem 1.15rem;
  border-radius: var(--bd-t-radius-md);
  border: 1px solid var(--bd-t-stroke-soft);
  background: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  color: var(--bd-t-title);
}

.post-navigation .nav-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--bd-t-text-soft);
  margin-bottom: 0.25rem;
}

.post-navigation .nav-title {
  font-weight: 600;
}

/* ── Error / empty states ── */
.bd-theme-error,
.bd-theme-empty {
  text-align: center;
  padding: clamp(2rem, 6vw, 4rem) 1.5rem;
  background: var(--bd-t-glass);
  backdrop-filter: var(--bd-t-blur);
  border: 1px solid var(--bd-t-stroke-soft);
  border-radius: var(--bd-t-radius-xl);
  box-shadow: var(--bd-t-shadow-soft);
}

.bd-theme-error__code {
  font-family: var(--bd-t-font-display);
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 700;
  color: var(--bd-t-primary);
  opacity: 0.35;
  margin: 0 0 0.25em;
  line-height: 1;
}

.bd-theme-error__title {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

.bd-theme-error__text {
  color: var(--bd-t-text-soft);
  max-width: 36ch;
  margin-inline: auto;
  margin-bottom: 1.25rem;
}

.bd-theme-error__search {
  max-width: 360px;
  margin: 0 auto 1.5rem;
}

.bd-theme-error__search .bd-theme-search {
  max-width: none;
  min-width: 0;
  width: 100%;
}

.bd-theme-error__actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.bd-theme-empty .bd-theme-search {
  max-width: 420px;
  margin: 1rem auto 0;
  min-width: 0;
  width: 100%;
}

/* ── Site footer ── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--bd-t-stroke-soft);
  background: var(--bd-t-glass);
  backdrop-filter: var(--bd-t-blur);
}

.site-footer__inner {
  max-width: var(--bd-t-content);
  margin-inline: auto;
  padding: clamp(2rem, 5vw, 3rem) clamp(1rem, 3vw, 1.75rem);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem 2.5rem;
}

.site-footer__tagline {
  margin: 0.65rem 0 0;
  color: var(--bd-t-text-soft);
  font-size: 0.9375rem;
  max-width: 36ch;
}

.footer-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-menu a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bd-t-text);
  text-decoration: none;
}

.footer-menu a:hover,
.footer-menu a:focus-visible {
  color: var(--bd-t-primary-strong);
}

.site-footer__meta {
  grid-column: 1 / -1;
  padding-top: 1.25rem;
  border-top: 1px solid var(--bd-t-stroke-soft);
}

.site-footer__copy {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--bd-t-text-soft);
}

.site-footer__copy a {
  color: var(--bd-t-title);
  font-weight: 600;
  text-decoration: none;
}

/* ── No-chrome / canvas / fullbleed pages ── */
body.bd-theme-no-chrome .site-header,
body.bd-theme-no-chrome .site-footer,
body.bd-canvas-site .site-header,
body.bd-canvas-site .site-footer {
  display: none !important;
}

body.bd-theme-no-chrome .bd-theme-content:not(.bd-theme-content--archive),
body.bd-theme-fullbleed-page .bd-theme-content:not(.bd-theme-content--archive) {
  padding: 0;
}

body.bd-theme-no-chrome .bd-theme-content--archive,
body.bd-theme-fullbleed-page .bd-theme-content--archive {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 1.75rem);
}

body.bd-theme-no-chrome .site-main,
body.bd-theme-fullbleed-page .site-main {
  flex: 1;
}

/* ── Widgets ── */
.bd-widget {
  background: var(--bd-t-glass);
  border: 1px solid var(--bd-t-stroke-soft);
  border-radius: var(--bd-t-radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.bd-widget__title {
  font-size: 1rem;
  margin-bottom: 0.75em;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .site-header__search {
    display: none;
  }

  .main-navigation {
    display: none;
  }

  .site-header__toggle {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  .site-header__lang {
    display: none;
  }

  .site-footer__inner {
    grid-template-columns: 1fr;
  }

  .post-navigation .nav-links {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1025px) {
  .site-header__login-label {
    display: inline;
  }
}

@media (max-width: 480px) {
  .site-branding__name {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .bd-theme-mobile-drawer__panel,
  .bd-theme-mobile-drawer__backdrop {
    transition: none !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
