/* ==========================================================
   GLOBAL PAGE-WIDE STYLING
   ========================================================== */

/* ------------ Main Content Wrapper ------------ */
main {
  max-width: 1100px;
  margin: 100px auto 80px;
  padding: 0 20px;
}

/* ------------ Buttons (global) ------------ */
.btn-primary {
  background: linear-gradient(135deg,
    var(--accent-gold-dark) 0%,
    var(--accent-gold) 100%
  );
  color: #072616;
  padding: 12px 22px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  box-shadow:
    0 6px 18px rgba(232,196,77,0.45),
    inset 0 -3px 6px rgba(0,0,0,0.2);
  transition: transform .15s, box-shadow .25s, filter .2s;
}

.btn-primary:hover {
  filter: brightness(1.2);
  transform: translateY(-2px);
  box-shadow:
    0 10px 22px rgba(232,196,77,0.55),
    inset 0 -3px 7px rgba(0,0,0,0.3);
}

.btn-ghost {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.20);
  color: #e6f3ff;
  padding: 12px 22px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s, box-shadow .25s, border-color .2s;
}

.btn-ghost:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow:
    0 5px 18px rgba(232,196,77,0.25),
    inset 0 0 12px rgba(232,196,77,0.14);
}

/* ------------ Back to Top Button ------------ */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: rgba(16, 24, 34, 0.9);
  border: 1px solid var(--accent-gold-soft);
  border-radius: 50%;
  color: var(--accent-gold);
  font-size: 20px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  opacity: 0;
  transform: translateY(20px);
}

.back-to-top:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  background: rgba(16, 24, 34, 1);
  border-color: var(--accent-gold);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* ------------ Back to Home Button ------------ */
.back-to-home {
  position: fixed;
  bottom: 90px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: rgba(16, 24, 34, 0.9);
  border: 1px solid var(--accent-gold-soft);
  border-radius: 50%;
  color: var(--accent-gold);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 1000;
}

.back-to-home:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}

.back-to-home:hover {
  background: rgba(16, 24, 34, 1);
  border-color: var(--accent-gold);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* ------------ Smooth Scrolling ------------ */
html {
  scroll-behavior: smooth;
}

/* ------------ Focus Styles ------------ */
*:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------- Accessibility (merged from accessibility.css) ---------------- */
/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .parallax-bg { transform: none !important; }
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent-gold);
  color: #072616;
  padding: 8px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  z-index: 10000;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 6px; }

/* Screen reader only helper */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Loading utility with accessible spinner */
.loading { position: relative; }
.loading::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid var(--accent-gold-soft);
  border-top: 2px solid var(--accent-gold);
  border-radius: 50%; animation: spin 1s linear infinite;
}
.loading[aria-label]::after { z-index: -1; }

/* Error/validation visuals */
.error { border: 2px solid #ff6b6b; background: rgba(255, 107, 107, 0.1); }
.error-message { color: #ff6b6b; font-size: 0.9em; margin-top: 4px; display:flex; align-items:center; gap:4px; }
.error-message::before { content: '⚠️'; font-size: 1em; }

/* Tooltip and modal global styles */
.tooltip { position: relative; }
.tooltip-content { position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%); background: var(--panel-strong); color: #ffffff; padding: 8px 12px; border-radius: 6px; font-size: 0.9em; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; z-index: 1000; border: 1px solid var(--accent-gold-soft); }
.tooltip:hover .tooltip-content, .tooltip:focus .tooltip-content { opacity: 1; visibility: visible; }

.modal { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.8); display:flex; align-items:center; justify-content:center; z-index:10000; }
.modal-content { background: var(--panel-strong); border-radius: var(--radius-lg); padding: 24px; max-width: 90vw; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 4px; }
.modal-close:hover, .modal-close:focus { background: rgba(255,255,255,0.1); color: var(--accent-gold); }

/* Voice control helper */
[data-voice-command] { position: relative; }
[data-voice-command]::after { content: attr(data-voice-command); position: absolute; top: -30px; left: 0; background: var(--accent-gold); color: #072616; padding: 4px 8px; border-radius: 4px; font-size: 0.8em; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.voice-commands-visible [data-voice-command]::after { opacity: 1; }

/* Keyboard navigation group styles (from accessibility.css) */
.keyboard-navigation .result-item:focus,
.keyboard-navigation .category-card:focus,
.keyboard-navigation button:focus {
  outline: 3px solid var(--accent-gold);
  outline-offset: 2px;
  background: rgba(242,197,124,0.15);
}

/* ------------ Page Transition Animations ------------ */
.fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#home-section, #article-container {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#article-container {
  opacity: 0;
  transform: translateY(20px);
}

#article-container.show {
  opacity: 1;
  transform: translateY(0);
}