/*!
 * NoCostTools — Header/Footer Critical CSS
 * Inlined design tokens + minimal navbar/footer styling to prevent CLS + FOUC
 * Loads BEFORE common.js fetches the header/footer HTML so first paint is styled.
 * Full styling is layered on top by /style.css + Bootstrap CDN after hydration.
 */

/* ============ Design Tokens (Light) ============ */
:root {
  --color-white: rgba(255, 255, 255, 1);
  --color-cream-50: rgba(252, 252, 249, 1);
  --color-cream-100: rgba(255, 255, 253, 1);
  --color-gray-200: rgba(245, 245, 245, 1);
  --color-gray-300: rgba(167, 169, 169, 1);
  --color-slate-500: rgba(98, 108, 113, 1);
  --color-charcoal-700: rgba(31, 33, 33, 1);
  --color-charcoal-800: rgba(38, 40, 40, 1);
  --color-slate-900: rgba(19, 52, 59, 1);
  --color-teal-300: rgba(50, 184, 198, 1);
  --color-teal-400: rgba(45, 166, 178, 1);
  --color-teal-500: rgba(33, 128, 141, 1);
  --color-teal-600: rgba(29, 116, 128, 1);
  --color-teal-700: rgba(26, 104, 115, 1);
  --color-brown-600-rgb: 94, 82, 64;
  --color-teal-500-rgb: 33, 128, 141;
  --color-slate-900-rgb: 19, 52, 59;
  --color-gray-300-rgb: 167, 169, 169;
  --color-gray-200-rgb: 245, 245, 245;
  --color-gray-400-rgb: 119, 124, 124;
  --color-teal-300-rgb: 50, 184, 198;

  --color-background: var(--color-cream-50);
  --color-surface: var(--color-cream-100);
  --color-text: var(--color-slate-900);
  --color-text-secondary: var(--color-slate-500);
  --color-primary: var(--color-teal-500);
  --color-primary-hover: var(--color-teal-600);
  --color-primary-active: var(--color-teal-700);
  --color-secondary: rgba(var(--color-brown-600-rgb), 0.12);
  --color-border: rgba(var(--color-brown-600-rgb), 0.2);
  --color-btn-primary-text: var(--color-cream-50);
  --color-card-border: rgba(var(--color-brown-600-rgb), 0.12);

  --font-family-base: "FKGroteskNeue", "Geist", "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-weight-medium: 500;
  --font-weight-semibold: 550;
  --line-height-normal: 1.5;

  --space-16: 16px;
  --space-24: 24px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04),
    0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04),
    0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --duration-fast: 150ms;
  --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);
  --focus-ring: 0 0 0 3px rgba(var(--color-teal-500-rgb), 0.4);

  --container-xl: 1280px;
  --color-focus-ring: rgba(var(--color-teal-500-rgb), 0.4);
}

/* ============ Dark Mode Tokens ============ */
@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) {
    --color-background: var(--color-charcoal-700);
    --color-surface: var(--color-charcoal-800);
    --color-text: var(--color-gray-200);
    --color-text-secondary: rgba(var(--color-gray-300-rgb), 0.7);
    --color-primary: var(--color-teal-300);
    --color-primary-hover: var(--color-teal-400);
    --color-primary-active: var(--color-teal-400);
    --color-secondary: rgba(var(--color-gray-400-rgb), 0.15);
    --color-border: rgba(var(--color-gray-400-rgb), 0.3);
    --color-btn-primary-text: var(--color-slate-900);
    --color-card-border: rgba(var(--color-gray-400-rgb), 0.2);
    --color-focus-ring: rgba(var(--color-teal-300-rgb), 0.4);
    --focus-ring: 0 0 0 3px var(--color-focus-ring);
  }
}

/* Manual dark theme switch */
[data-color-scheme="dark"] {
  --color-background: var(--color-charcoal-700);
  --color-surface: var(--color-charcoal-800);
  --color-text: var(--color-gray-200);
  --color-text-secondary: rgba(var(--color-gray-300-rgb), 0.7);
  --color-primary: var(--color-teal-300);
  --color-primary-hover: var(--color-teal-400);
  --color-primary-active: var(--color-teal-400);
  --color-secondary: rgba(var(--color-gray-400-rgb), 0.15);
  --color-border: rgba(var(--color-gray-400-rgb), 0.3);
  --color-btn-primary-text: var(--color-slate-900);
  --color-card-border: rgba(var(--color-gray-400-rgb), 0.2);
  --color-focus-ring: rgba(var(--color-teal-300-rgb), 0.4);
  --focus-ring: 0 0 0 3px var(--color-focus-ring);
}

/* ============ Base Reset ============ */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-family-base);
  background: var(--color-background);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  line-height: var(--line-height-normal);
}

/* ============ Layout Container (Bootstrap-equivalent) ============ */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-16);
}

/* ============ Header / Navbar Critical CSS ============ */
/* Reserve space to prevent CLS — navbar is ~76px tall on desktop, ~64px on mobile */
#header-placeholder {
  min-height: 76px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1030;
}

@media (max-width: 991.98px) {
  #header-placeholder { min-height: 64px; }
}

/* Hide the placeholder's reserved space once header loads (avoids double-padding) */
#header-placeholder:not(:empty) {
  min-height: 0;
  background: transparent;
  border-bottom: none;
  box-shadow: none;
}

.custom-header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Navbar essentials — minimal Bootstrap equivalents */
.custom-navbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background-color: transparent;
  font-family: var(--font-family-base);
  --bs-navbar-color: var(--color-text);
  --bs-navbar-hover-color: var(--color-primary);
  --bs-navbar-brand-color: var(--color-text);
}

.navbar-brand {
  display: inline-block;
  padding-top: 0.3125rem;
  padding-bottom: 0.3125rem;
  margin-right: 1rem;
  font-size: 1.25rem;
  line-height: inherit;
  white-space: nowrap;
  text-decoration: none;
  color: var(--color-text);
}

.navbar-brand img { vertical-align: middle; }

.navbar-toggler {
  padding: 0.25rem 0.75rem;
  font-size: 1.25rem;
  line-height: 1;
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--color-text);
}

.navbar-toggler-icon {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='%23134252' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.navbar-nav {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  list-style: none;
}

@media (min-width: 992px) {
  .navbar-nav {
    flex-direction: row;
    margin-bottom: 0;
  }
  .navbar-expand-lg .navbar-nav { flex-direction: row; }
  .navbar-expand-lg .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
  }
  .navbar-expand-lg .navbar-toggler { display: none; }
}

.navbar-collapse {
  flex-basis: 100%;
  flex-grow: 1;
  align-items: center;
}

.navbar-collapse:not(.show) { display: none; }

.nav-item { display: flex; align-items: center; }

.nav-link {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
  font-weight: var(--font-weight-medium);
}

.nav-link:hover,
.nav-link:focus { color: var(--color-primary); }

/* Dropdown essentials */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle::after {
  display: inline-block;
  margin-left: 0.255em;
  vertical-align: 0.255em;
  content: "";
  border-top: 0.3em solid currentColor;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0.125rem 0 0;
  font-size: 1rem;
  color: var(--color-text);
  text-align: left;
  background-color: var(--color-surface);
  background-clip: padding-box;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  box-shadow: var(--shadow-md);
}

.dropdown-menu.show { display: block; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.25rem 1rem;
  clear: both;
  font-weight: 400;
  color: var(--color-text);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
  color: var(--color-text);
  background-color: var(--color-secondary);
  text-decoration: none;
}

.dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid var(--color-border);
}

.dropdown-header {
  display: block;
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* Buttons (minimal) */
.btn {
  display: inline-block;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  background-color: transparent;
  border: 1px solid transparent;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  border-radius: 0.25rem;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; }

.btn-outline-light {
  --bs-btn-color: var(--color-text);
  --bs-btn-border-color: var(--color-border);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-outline-light:hover {
  color: var(--color-primary);
  background-color: var(--color-secondary);
  border-color: var(--color-primary);
}

.btn-primary {
  color: var(--color-btn-primary-text);
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-close {
  width: 0.8em;
  height: 0.8em;
  padding: 0.25em;
  color: currentColor;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3E%3Cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3E%3C/svg%3E")
    center / 0.8em auto no-repeat;
  border: 0;
  border-radius: 0.375rem;
  cursor: pointer;
  opacity: 0.6;
}

.btn-close:hover { opacity: 1; }

/* Announcement banner */
.announcement-banner {
  background-color: var(--color-primary);
  padding: 0.5rem 0;
}

.announcement-banner.text-white { color: var(--color-white) !important; }

/* Mobile search bar */
.mobile-search-bar {
  background: var(--color-surface);
  padding: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.mobile-search-bar.d-none { display: none !important; }

/* Dark mode toggle button styling */
.dark-mode-toggle { color: var(--color-text); }

/* ============ Footer Critical CSS ============ */
#footer-placeholder {
  min-height: 320px;
  background: var(--color-surface);
  margin-top: auto;
}

@media (max-width: 767.98px) {
  #footer-placeholder { min-height: 480px; }
}

#footer-placeholder:not(:empty) {
  min-height: 0;
}

.custom-footer {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-family-base);
  padding: 2rem 0;
  margin-top: 2rem;
}

/* Grid for footer layout */
.row {
  --bs-gutter-x: 1.5rem;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(-1 * var(--bs-gutter-y));
  margin-right: calc(-0.5 * var(--bs-gutter-x));
  margin-left: calc(-0.5 * var(--bs-gutter-x));
}

.row > * {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-right: calc(var(--bs-gutter-x) * 0.5);
  padding-left: calc(var(--bs-gutter-x) * 0.5);
  margin-top: var(--bs-gutter-y);
}

.col-md-2 { flex: 0 0 auto; width: 16.66667%; }
.col-md-4 { flex: 0 0 auto; width: 33.33333%; }

@media (min-width: 768px) {
  .col-md-2 { flex: 0 0 auto; width: 16.66667%; }
  .col-md-4 { flex: 0 0 auto; width: 33.33333%; }
  .mb-md-0 { margin-bottom: 0 !important; }
}

@media (max-width: 767.98px) {
  .col-md-2, .col-md-4 { flex: 0 0 100%; width: 100%; max-width: 100%; }
  .mb-md-0 { margin-bottom: 1rem !important; }
}

/* Footer text styling */
.custom-footer h2,
.custom-footer h3,
.custom-footer h6 {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-16);
}

.custom-footer h2 { font-size: 1.1rem; }
.custom-footer h3 { font-size: 1rem; }

.custom-footer p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.custom-footer .text-muted { color: var(--color-text-secondary) !important; }

.custom-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-standard);
}

.custom-footer a:hover,
.custom-footer a:focus { color: var(--color-primary); }

.custom-footer .social-icons a {
  color: var(--color-text-secondary);
  font-size: var(--font-size-lg);
  display: inline-block;
  margin-right: 0.75rem;
  transition: color var(--duration-fast) var(--ease-standard);
}

.custom-footer .social-icons a:hover { color: var(--color-primary); }

.custom-footer hr {
  border-color: var(--color-border);
  opacity: 1;
  margin: 1.5rem 0;
}

.custom-footer .text-white { color: var(--color-white) !important; }
.custom-footer .text-warning { color: var(--color-warning) !important; }
.custom-footer .text-dark { color: var(--color-text) !important; }
.custom-footer .bg-warning {
  background-color: var(--color-warning) !important;
  color: var(--color-text) !important;
}
.custom-footer .bg-success {
  background-color: var(--color-primary) !important;
  color: var(--color-btn-primary-text) !important;
}

/* List reset */
.list-unstyled { padding-left: 0; list-style: none; }
.list-unstyled li { margin-bottom: 0.5rem; }

.list-inline { padding-left: 0; list-style: none; margin-left: -0.5rem; }
.list-inline-item { display: inline-block; margin-right: 0.5rem; }

/* Input group for newsletter */
.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.input-group > .form-control {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

.input-group > .btn { z-index: 2; }

.form-control {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
  background-clip: padding-box;
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  border-color: var(--color-primary);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.form-control::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 0.35em 0.65em;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  color: var(--color-white);
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem;
}

.badge.bg-success { background-color: var(--color-primary) !important; }

/* Utility classes */
.d-flex { display: flex !important; }
.d-none { display: none !important; }
.d-inline-block { display: inline-block !important; }
.d-lg-none { display: flex !important; }
@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-flex { display: flex !important; }
}
.d-md-none { display: none !important; }

.me-2 { margin-right: 0.5rem !important; }
.me-auto { margin-right: auto !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-auto { margin-left: auto !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-md-0 { margin-bottom: 0 !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
.text-center { text-align: center !important; }
.text-md-start { text-align: left !important; }
.text-md-end { text-align: right !important; }
.text-decoration-none { text-decoration: none !important; }
.text-decoration-underline { text-decoration: underline !important; }
.text-white { color: var(--color-white) !important; }
.text-muted { color: var(--color-text-secondary) !important; }
.text-warning { color: var(--color-warning) !important; }
.bg-secondary { background-color: var(--color-text-secondary) !important; }
.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }
.small, small { font-size: 0.875em; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.gap-2 { gap: 0.5rem !important; }
.input-group { flex-wrap: wrap; }
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

@media (max-width: 767.98px) {
  .text-md-start, .text-md-end { text-align: center !important; }
  .mb-md-0 { margin-bottom: 1.5rem !important; }
}

/* Honeypot hidden field */
[aria-hidden="true"][style*="left:-9999px"] {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

/* ============ Skeleton Loading Placeholder ============ */
.header-skeleton,
.footer-skeleton {
  background: linear-gradient(90deg,
    var(--color-surface) 0%,
    rgba(var(--color-brown-600-rgb), 0.04) 50%,
    var(--color-surface) 100%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.header-skeleton {
  width: 100%;
  height: 76px;
  border-bottom: 1px solid var(--color-border);
}

.footer-skeleton {
  width: 100%;
  height: 320px;
  border-top: 1px solid var(--color-border);
}

@media (max-width: 991.98px) {
  .header-skeleton { height: 64px; }
}

@media (max-width: 767.98px) {
  .footer-skeleton { height: 480px; }
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .header-skeleton,
  .footer-skeleton { animation: none; }
}

/* ============ Fallback no-JS state ============ */
/* If JavaScript is disabled or fails, the skeleton stays but is invisible;
   header/footer don't load. We show a minimal noscript notice. */
.noscript-notice {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.noscript-notice a { color: var(--color-primary); text-decoration: underline; }
