/* ==========================================================================
   AuthorityOS — base.css
   Global styles. Loaded on every page. Consumes tokens.css variables only —
   no hardcoded colors/sizes here, so the whole theme re-themes from one file.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: var(--weight-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: var(--leading-body);
  transition: background-color var(--duration-base) var(--ease), color var(--duration-base) var(--ease);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading-bold);
  line-height: var(--leading-heading);
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
  letter-spacing: -0.01em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
}
.aos-skip-link:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto;
  background: var(--text-primary); color: var(--bg-primary);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); z-index: 9999;
}

/* ---- Header ---- */
.aos-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
}
.aos-header__inner {
  max-width: var(--container-max); margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
}
.aos-header__site-name {
  font-family: var(--font-heading); font-weight: var(--weight-heading-bold);
  font-size: var(--text-xl); color: var(--text-primary);
}
.aos-header__nav ul { display: flex; gap: var(--space-8); list-style: none; margin: 0; padding: 0; }
.aos-header__nav a {
  color: var(--text-primary); font-size: var(--text-sm); font-weight: var(--weight-body-medium);
}
.aos-header__nav a:hover { color: var(--accent); text-decoration: none; }
.aos-header__actions { display: flex; align-items: center; gap: var(--space-3); }

.aos-theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-primary);
  cursor: pointer; transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.aos-theme-toggle:hover { border-color: var(--border-strong); background: var(--bg-secondary); }
.aos-theme-toggle__icon--moon { display: none; }
:root[data-theme="dark"] .aos-theme-toggle__icon--sun { display: none; }
:root[data-theme="dark"] .aos-theme-toggle__icon--moon { display: block; }

/* Floating variant: used by the plugin build, which injects the toggle via
   wp_body_open/wp_footer rather than inline inside a theme's own header
   markup, since a plugin can't edit header.php. Fixed position keeps it
   reachable regardless of what the active theme's header looks like. */
.aos-theme-toggle--floating {
  position: fixed; top: var(--space-4); right: var(--space-4); z-index: 50;
  background: var(--bg-elevated); box-shadow: var(--shadow-md);
}
@media (max-width: 860px) {
  .aos-theme-toggle--floating { top: auto; bottom: calc(72px + var(--space-4)); }
}

.aos-header__mobile-toggle {
  display: none; width: 40px; height: 40px; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--text-primary);
}
.aos-header__hamburger, .aos-header__hamburger::before, .aos-header__hamburger::after {
  display: block; width: 20px; height: 2px; background: currentColor; position: relative; border-radius: 2px;
}
.aos-header__hamburger::before, .aos-header__hamburger::after { content: ''; position: absolute; }
.aos-header__hamburger::before { top: -6px; }
.aos-header__hamburger::after { top: 6px; }

@media (max-width: 860px) {
  .aos-header__nav { display: none; }
  .aos-header__nav.is-open {
    display: block; position: fixed; inset: var(--header-height) 0 0 0;
    background: var(--bg-primary); padding: var(--space-8) var(--space-6); z-index: 39; overflow-y: auto;
  }
  .aos-header__nav.is-open ul { flex-direction: column; gap: var(--space-2); }
  .aos-header__nav.is-open a { display: block; padding: var(--space-3) 0; font-size: var(--text-lg); }
  .aos-header__mobile-toggle { display: flex; }
}

/* ---- Breadcrumbs ---- */
.aos-breadcrumbs { border-bottom: 1px solid var(--border); background: var(--bg-secondary); }
.aos-breadcrumbs__inner {
  max-width: var(--container-max); margin: 0 auto; padding: var(--space-3) var(--space-6);
  font-size: var(--text-xs); color: var(--text-muted); display: flex; align-items: center; gap: var(--space-2);
  overflow-x: auto; white-space: nowrap;
}
.aos-breadcrumbs__inner a { color: var(--text-muted); }
.aos-breadcrumbs__inner a:hover { color: var(--accent); }
.aos-breadcrumbs__sep { color: var(--border-strong); }
.aos-breadcrumbs__current { color: var(--text-primary); font-weight: var(--weight-body-medium); }

/* ---- Sections & grid ---- */
.aos-section { max-width: var(--container-max); margin: 0 auto; padding: var(--space-16) var(--space-6); }
.aos-section > h2 { font-size: var(--text-2xl); margin-bottom: var(--space-8); }

.aos-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}

/* ---- Cards ---- */
.aos-card {
  display: block; color: inherit; text-decoration: none;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-base) var(--ease), transform var(--duration-base) var(--ease), border-color var(--duration-base) var(--ease);
}
.aos-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.aos-card img { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; }
.aos-card h2, .aos-card h3 {
  font-size: var(--text-lg); font-weight: var(--weight-heading);
  margin: var(--space-4) var(--space-5) var(--space-1); line-height: 1.35;
}
.aos-card__meta, .aos-card__rating {
  display: block; margin: 0 var(--space-5) var(--space-4);
  font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--weight-body-medium);
}

.aos-button {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--text-inverse);
  font-family: var(--font-body); font-weight: var(--weight-body-medium); font-size: var(--text-sm);
  padding: var(--space-3) var(--space-6); border-radius: var(--radius-full); border: none; cursor: pointer;
  transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.aos-button:hover { background: var(--accent-hover); color: var(--text-inverse); text-decoration: none; transform: translateY(-1px); }

/* ---- Footer ---- */
.aos-newsletter { background: var(--bg-secondary); padding: var(--space-24) var(--space-6); text-align: center; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.aos-newsletter__inner { max-width: 560px; margin: 0 auto; }
.aos-newsletter h2 { font-size: var(--text-2xl); }
.aos-newsletter p { color: var(--text-muted); margin-bottom: var(--space-6); }

.aos-footer { max-width: var(--container-max); margin: 0 auto; padding: var(--space-12) var(--space-6) var(--space-24); }
.aos-footer__trust { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-8); max-width: var(--measure-max); }
.aos-footer__columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-6); }
.aos-footer__col h4 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: var(--space-3); }
.aos-footer__legal ul { display: flex; gap: var(--space-4); list-style: none; margin: var(--space-8) 0 0; padding: 0; font-size: var(--text-xs); }
.aos-footer__legal a { color: var(--text-muted); }
.aos-footer__copyright { margin-top: var(--space-4); font-size: var(--text-xs); color: var(--text-muted); }

/* ---- Mobile bottom nav ---- */
.aos-bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: var(--space-2) var(--space-2) max(var(--space-2), env(safe-area-inset-bottom));
  justify-content: space-around; align-items: center;
}
.aos-bottom-nav__item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--text-muted); font-size: 11px; font-family: var(--font-body);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); cursor: pointer;
  min-width: 56px; min-height: 44px; justify-content: center;
}
.aos-bottom-nav__item:hover, .aos-bottom-nav__item:active { color: var(--accent); text-decoration: none; }

@media (max-width: 860px) {
  .aos-bottom-nav { display: flex; }
  body { padding-bottom: 72px; }
}

/* ---- Search overlay ---- */
.aos-search-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--text-primary) 40%, transparent);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh var(--space-6);
}
.aos-search-overlay[hidden] { display: none; }
.aos-search-overlay__panel {
  background: var(--bg-elevated); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; padding: var(--space-6); position: relative;
}
.aos-search-overlay__close {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: 32px; height: 32px; border-radius: var(--radius-full); border: none;
  background: var(--bg-secondary); color: var(--text-primary); font-size: 20px; cursor: pointer;
}
.aos-search-overlay .search-form { display: flex; gap: var(--space-2); margin-top: var(--space-4); }
.aos-search-overlay input[type="search"] {
  flex: 1; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: var(--text-base); background: var(--bg-primary); color: var(--text-primary);
}
.aos-search-overlay button[type="submit"] {
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-md); border: none;
  background: var(--accent); color: var(--text-inverse); font-weight: var(--weight-body-medium); cursor: pointer;
}

/* ---- Floating mobile TOC button + drawer (article pages) ---- */
.aos-mobile-toc-fab {
  display: none; position: fixed; bottom: 88px; right: var(--space-4); z-index: 44;
  width: 48px; height: 48px; border-radius: var(--radius-full);
  background: var(--accent); color: var(--text-inverse); border: none;
  align-items: center; justify-content: center; box-shadow: var(--shadow-lg); cursor: pointer;
}
@media (max-width: 860px) {
  .aos-mobile-toc-fab { display: flex; }
}
.aos-mobile-toc-drawer {
  position: fixed; inset: auto 0 0 0; z-index: 55;
  background: var(--bg-elevated); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto;
  padding: var(--space-2) var(--space-6) var(--space-8);
}
.aos-mobile-toc-drawer[hidden] { display: none; }
.aos-mobile-toc-drawer__handle {
  width: 40px; height: 4px; background: var(--border-strong); border-radius: var(--radius-full);
  margin: var(--space-3) auto var(--space-4);
}
.aos-mobile-toc-drawer__content .aos-toc ul { list-style: none; margin: 0; padding: 0; }
.aos-mobile-toc-drawer__content .aos-toc li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); font-size: var(--text-base); }
.aos-mobile-toc-drawer__content .aos-toc a { color: var(--text-primary); }
