/* ============================================================
   SWORD FORGE ATELIER — UNIFIED FULL-WIDTH SITE HEADER
   ============================================================ */

/* Prevent horizontal page panning/sliding into off-screen elements */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  html,
  body {
    overflow-x: hidden;
  }
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--ui-surface, rgba(251, 248, 242, 0.95));
  border-bottom: 1px solid var(--ui-line, rgba(184, 124, 36, 0.16));
  transition: background-color 260ms ease, border-color 260ms ease;
  box-sizing: border-box;
}

/* Pinned to viewport without filter interference when drawer is active */
.navbar.has-drawer-open {
  position: fixed !important;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--ui-surface, #fbf8f2);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 74px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 3rem);
  box-sizing: border-box;
  gap: 16px;
  position: relative;
  z-index: 1001;
}

/* Brand & Swatch Cluster (Left) */
.nav-left-cluster {
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.8vw, 24px);
  flex-shrink: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo-icon {
  width: clamp(130px, 18vw, 210px);
  height: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-logo-icon img {
  width: 100%;
  height: auto;
  display: block;
}

/* Theme Swatches */
.header-theme-swatches {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9999px;
  background: var(--ui-surface-2, #ede5d8);
  border: 1px solid var(--ui-line, #ddd4c4);
  transition: background-color 260ms ease, border-color 260ms ease;
  flex-shrink: 0;
}

.theme-swatch-circle {
  appearance: none;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid var(--ui-line, #ddd4c4);
  background: var(--swatch-a) linear-gradient(90deg, var(--swatch-a) 0 50%, var(--swatch-b) 50% 100%);
  position: relative;
  transition: transform 140ms ease, border-color 140ms ease;
  outline: none;
}

.theme-swatch-circle::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid transparent;
  border-radius: 50%;
  transition: border-color 140ms ease;
}

.theme-swatch-circle:hover {
  transform: translateY(-1px);
}

.theme-swatch-circle.selected {
  border-color: var(--ui-accent-strong, #8c5d1c);
}

.theme-swatch-circle.selected::after {
  border-color: var(--ui-accent-strong, #8c5d1c);
}

.theme-swatch-circle[data-theme-id="parchment-gold"] { --swatch-a:#ab7425; --swatch-b:#f6f0e7; }
.theme-swatch-circle[data-theme-id="olive-earth"]    { --swatch-a:#45603f; --swatch-b:#91ab7b; }
.theme-swatch-circle[data-theme-id="light-word"]     { --swatch-a:#4e6e91; --swatch-b:#a9c8df; }
.theme-swatch-circle[data-theme-id="rose-ligure"]    { --swatch-a:#704553; --swatch-b:#c99ba4; }
.theme-swatch-circle[data-theme-id="slate-emerald"]  { --swatch-a:#3b4b43; --swatch-b:#a8c9af; }
.theme-swatch-circle[data-theme-id="sunset-fire"]    { --swatch-a:#54281f; --swatch-b:#c47b59; }
.theme-swatch-circle[data-theme-id="heavenly-blue"]  { --swatch-a:#29445e; --swatch-b:#88a9cb; }

/* Desktop Navigation Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 32px);
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-drawer-content {
  display: contents;
}

.nav-link {
  font-family: var(--font-serif, 'EB Garamond', Georgia, serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ui-muted, #787065);
  transition: color 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ui-ink, #1f2126);
  transform: translateY(-1px);
}

.nav-link.active {
  color: var(--ui-accent-strong, #8c5d1c);
}

/* Right Actions */
.nav-right-actions {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 16px);
  flex-shrink: 0;
}

.btn-primary.nav-donate-btn,
.navbar .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 9999px;
  background-color: var(--ui-accent, #ab7425);
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-primary.nav-donate-btn:hover,
.navbar .btn-primary:hover {
  background-color: var(--ui-accent-strong, #8c5d1c);
  transform: translateY(-1px);
}

/* Mobile Toggle Hamburger */
.nav-mobile-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: var(--ui-surface-2, #ede5d8);
  border: 1px solid var(--ui-line, #ddd4c4);
  border-radius: 12px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  color: var(--ui-ink, #1f2126);
  transition: background-color 0.2s ease, border-color 0.2s ease;
  outline: none;
  box-sizing: border-box;
}

.nav-mobile-toggle:focus-visible {
  outline: 2px solid var(--ui-accent, #ab7425);
  outline-offset: 2px;
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 220ms ease, opacity 220ms ease;
  transform-origin: center;
}

.nav-mobile-toggle.is-active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-mobile-toggle.is-active .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-mobile-toggle.is-active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* BACKDROP: Layered behind drawer at z-index 995 */
.nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 995 !important;
  background: rgba(20, 20, 22, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease-out;
}

.nav-drawer-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Desktop Dropdowns */
.nav-item-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 0;
}

.dropdown-caret {
  transition: transform 200ms ease;
  opacity: 0.65;
  flex-shrink: 0;
}

.nav-item-dropdown:hover .dropdown-caret,
.nav-item-dropdown.open .dropdown-caret {
  transform: rotate(180deg);
  opacity: 1;
}

.nav-flyout-panel {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  width: min(600px, calc(100vw - 32px));
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 18px 45px -6px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s 180ms;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-flyout-panel::after {
  content: "";
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
  pointer-events: auto;
}

.nav-item-dropdown:hover .nav-flyout-panel,
.nav-item-dropdown.open .nav-flyout-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}

.nav-flyout-panel::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--ui-surface);
  border-top: 1px solid var(--ui-line);
  border-left: 1px solid var(--ui-line);
  z-index: 1;
}

.flyout-two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.flyout-card-tile {
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  border-radius: var(--radius-md, 14px);
  padding: 16px 18px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 180ms ease;
  box-sizing: border-box;
}

/* Full-width card spanning both columns */
.flyout-card-tile.tile-span-all {
  grid-column: 1 / -1;
}

.flyout-card-tile:hover {
  background: var(--ui-surface);
  border-color: var(--ui-accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.flyout-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flyout-tile-title {
  display: block;
  font-family: var(--font-serif, 'EB Garamond', Georgia, serif);
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--ui-ink);
  line-height: 1.2;
}

.flyout-tile-desc {
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.82rem;
  color: var(--ui-muted);
  line-height: 1.45;
  margin: 0;
}

.mobile-drawer-header,
.mobile-drawer-section,
.mobile-drawer-footer {
  display: none;
}

/* ============================================================
   RESPONSIVE DESIGN (MOBILE SLIDE DRAWER & ACCORDIONS)
   ============================================================ */
@media (max-width: 1040px) {
  .nav-mobile-toggle {
    display: inline-flex;
  }

  .nav-drawer-backdrop {
    display: block;
  }

  .nav-links {
    position: fixed !important;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(390px, 100vw);
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--ui-surface, #fbf8f2) !important;
    border-left: 1px solid var(--ui-line, rgba(184, 124, 36, 0.2));
    box-shadow: -8px 0 36px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
    overscroll-behavior: contain;
    z-index: 1005 !important;
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    /* Off-screen and fully deactivated */
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
                opacity 280ms ease,
                visibility 0s 280ms;
  }

  .nav-links.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
                opacity 280ms ease,
                visibility 0s 0s;
  }

  .mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--ui-surface, #fbf8f2);
    border-bottom: 1px solid var(--ui-line, #ddd4c4);
    flex-shrink: 0;
    z-index: 2;
  }

  .mobile-drawer-title {
    font-family: var(--font-serif, 'EB Garamond', Georgia, serif);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ui-ink, #1f2126);
  }

  .mobile-drawer-close {
    background: var(--ui-surface-2, #ede5d8);
    border: 1px solid var(--ui-line, #ddd4c4);
    color: var(--ui-ink, #1f2126);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 140ms ease;
  }

  .mobile-drawer-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px max(24px, env(safe-area-inset-bottom)) 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    flex: 1;
  }

  .mobile-drawer-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ui-line, #ddd4c4);
    margin-bottom: 4px;
  }

  .mobile-drawer-section-label {
    font-family: var(--font-sans, -apple-system, sans-serif);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ui-muted, #787065);
  }

  .nav-link {
    width: 100%;
    padding: 12px 14px;
    font-size: 1.15rem;
    border-radius: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    background: transparent;
    transition: background-color 150ms ease, color 150ms ease;
  }

  .nav-link:hover,
  .nav-link:active {
    background: var(--ui-surface-2, #ede5d8);
    transform: none;
  }

  .nav-item-dropdown {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-dropdown-trigger {
    width: 100%;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 10px;
  }

  .nav-dropdown-trigger:hover,
  .nav-item-dropdown.open .nav-dropdown-trigger {
    background: var(--ui-surface-2, #ede5d8);
  }

  .nav-flyout-panel {
    position: static;
    transform: none !important;
    width: 100%;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 6px 0 6px 12px;
    margin-left: 6px;
    border-left: 2px solid var(--ui-line, rgba(184, 124, 36, 0.2));
    border-radius: 0;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
  }

  .nav-flyout-panel::before,
  .nav-flyout-panel::after {
    display: none !important;
  }

  .nav-item-dropdown.open .nav-flyout-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .flyout-two-up {
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }

  .flyout-card-tile {
    padding: 12px 14px;
    border-radius: 10px;
    gap: 4px;
  }

  .flyout-tile-title {
    font-size: 1.02rem;
  }

  .flyout-tile-desc {
    font-size: 0.78rem;
  }

  .mobile-drawer-footer {
    display: block;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--ui-line, #ddd4c4);
  }

  .mobile-drawer-footer .btn-primary {
    display: flex;
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
  }
}

@media (max-width: 540px) {
  .nav-links {
    width: 100vw;
    border-left: none;
  }
}

@media (max-width: 768px) {
  .header-theme-swatches.nav-swatches-desktop {
    display: none;
  }

  .nav-container {
    height: 66px;
    padding: 0 16px;
  }

  .brand-logo-icon {
    width: clamp(130px, 36vw, 175px);
  }
}

@media (max-width: 600px) {
  .btn-primary.nav-donate-btn {
    display: none;
  }
}

/* Background scroll lock */
html.mobile-nav-lock,
body.mobile-nav-lock,
html.modal-scroll-lock,
body.modal-scroll-lock {
  overflow: hidden !important;
  height: 100% !important;
  overscroll-behavior: none !important;
  touch-action: none;
}

/* ============================================================
   KO-FI SUPPORT MINISTRY MODAL DIALOG
   ============================================================ */
.support-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(20, 20, 22, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease-out;
}

.support-modal-backdrop[hidden] {
  display: none;
}

.support-modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.support-modal-window {
  position: relative;
  width: 100%;
  max-width: 490px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  background: var(--ui-surface, #fbf8f2);
  border: 1px solid var(--ui-line, rgba(184, 124, 36, 0.2));
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 24px 60px -8px rgba(0, 0, 0, 0.28), 0 8px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(12px);
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.support-modal-backdrop.is-visible .support-modal-window {
  transform: scale(1) translateY(0);
}

.support-modal-header {
  padding: 24px 24px 16px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ui-line, rgba(184, 124, 36, 0.14));
  background: var(--ui-surface, #fbf8f2);
  position: relative;
}

.support-modal-head-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.support-modal-title {
  font-family: var(--font-serif, 'EB Garamond', Georgia, serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ui-ink, #1f2126);
  margin: 0;
  line-height: 1.2;
}

.support-modal-desc {
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.88rem;
  color: var(--ui-muted, #787065);
  line-height: 1.45;
  margin: 4px 0 0 0;
}

.support-modal-close {
  background: var(--ui-surface-2, #ede5d8);
  border: 1px solid var(--ui-line, #ddd4c4);
  color: var(--ui-ink, #1f2126);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: transform 140ms ease, background-color 140ms ease;
  outline: none;
}

.support-modal-close:hover {
  background: var(--ui-surface, #fbf8f2);
  transform: rotate(90deg);
  border-color: var(--ui-accent, #ab7425);
}

.support-modal-body {
  position: relative;
  width: 100%;
  height: 600px;
  max-height: 60vh;
  max-height: 60dvh;
  background: var(--ui-surface-2, #f3ede2);
  display: flex;
  flex-direction: column;
}

.support-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  display: block;
}

.support-iframe-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--ui-surface-2, #ede5d8);
  color: var(--ui-muted, #787065);
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.82rem;
  z-index: 2;
  transition: opacity 250ms ease, visibility 250ms ease;
}

.support-iframe-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.support-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--ui-line, rgba(184, 124, 36, 0.2));
  border-top-color: var(--ui-accent, #ab7425);
  border-radius: 50%;
  animation: supportSpin 700ms linear infinite;
}

@keyframes supportSpin {
  to { transform: rotate(360deg); }
}

.support-modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--ui-line, rgba(184, 124, 36, 0.14));
  background: var(--ui-surface, #fbf8f2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.support-footer-secure {
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.76rem;
  color: var(--ui-muted, #787065);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.support-external-link {
  font-family: var(--font-sans, -apple-system, sans-serif);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ui-accent-strong, #8c5d1c);
  text-decoration: none;
  transition: opacity 140ms ease;
}

.support-external-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

@media (max-width: 520px) {
  .support-modal-window {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 16px;
  }
  .support-modal-header {
    padding: 18px 18px 14px 18px;
  }
  .support-modal-body {
    height: 500px;
    max-height: 56vh;
    max-height: 56dvh;
  }
}