@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap");

:root {
  --primary: #1d4ed8;
  --primary-hover: #2563eb;
  --accent: #22d3ee;
  --bg-dark: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* WCAG 2.2 AA Accessibility Overrides */
:focus-visible {
  outline: 3px solid var(--accent) !important;
  outline-offset: 3px !important;
  border-radius: 2px;
}

/* Ensure minimum tap target size of 24x24px for all interactive elements per WCAG 2.2 AA */
button, 
select, 
input[type="button"], 
input[type="submit"], 
input[type="reset"], 
input[type="checkbox"], 
input[type="radio"], 
.btn, 
.a11y-close-btn, 
.carousel-btn {
  min-height: 24px;
  min-width: 24px;
}

body {
  font-family: "Inter", sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
}

h1 {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

p {
  margin-bottom: 1rem;
  font-size: 1.125rem;
  color: var(--text-muted);
}

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

a:hover {
  text-decoration: underline;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1.5rem 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  transition: var(--transition);
}

.navbar.scrolled {
  padding: 1rem 5%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-links .nav-item {
  color: var(--text-main);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  position: relative;
}

.nav-links a.nav-item:hover,
.nav-links .dropdown:hover span {
  color: var(--accent);
  text-decoration: none;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.875rem;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(34, 211, 238, 0.4);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent);
  color: var(--bg-dark);
  text-decoration: none;
}

/* Layout Elements */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 5%;
}

header.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

/* Dynamic Shapes */
.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 1;
  opacity: 0.6;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  right: -100px;
  animation: float 10s infinite alternate;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: var(--accent);
  bottom: -50px;
  left: -100px;
  animation: float 12s infinite alternate-reverse;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(30px, 50px) scale(1.1);
  }
}

/* Sections */
section {
  padding: 6rem 0;
  position: relative;
  z-index: 2;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  padding: 2.5rem;
  transition: var(--transition);
  color: var(--text-main);
}

.glass-card:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(34, 211, 238, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.icon-wrap {
  width: 60px;
  height: 60px;
  background: rgba(34, 211, 238, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

/* Fade Elements */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity 0.8s ease-out,
    transform 0.8s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Footer */
footer {
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--glass-border);
  padding: 4rem 0 2rem;
  position: relative;
  z-index: 2;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-col h4 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: #fff;
}

.footer-col p,
.footer-col a {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--glass-border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  h1 {
    font-size: 2.5rem;
  }
  h2 {
    font-size: 2rem;
  }
  .mobile-menu-btn {
    display: block;
  }
  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    left: auto;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--glass-border);
    flex-direction: column;
    padding: 5rem 2rem 3rem;
    transition:
      right 0.4s cubic-bezier(0.16, 1, 0.3, 1),
      box-shadow 0.4s ease;
    overflow-y: auto;
    z-index: 2000;
  }
  .nav-links.active {
    right: 0;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  }

  /* Drawer Enhancements */
  .nav-close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 2001;
  }
  .nav-close-btn:hover {
    color: #fff;
  }

  .nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 6, 23, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .nav-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
  .dropdown {
    width: 100%;
  }
  .dropdown > span {
    display: block;
    width: 100%;
    padding: 10px 0;
  }
  .dropdown-content {
    position: relative;
    top: 0;
    width: 100%;
    box-shadow: none;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 10px;
  }
  .dropdown.active .dropdown-content {
    display: block;
  }
  .dropdown.active > span {
    color: var(--accent);
  }
}

/* Alert Component */
.system-alert {
  background: rgba(56, 189, 248, 0.1);
  border-left: 4px solid var(--accent);
  color: #fff;
  padding: 1rem 1.5rem;
  margin: 1rem 5% 2rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 10;
  position: relative;
}
.system-alert-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
  padding-left: 1rem;
}
.system-alert-close:hover {
  color: #fff;
}

/* Tabs Component */
.tabs-nav {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar {
  display: none;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.5rem 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.tab-btn:hover {
  color: #fff;
}
.tab-btn.active {
  color: var(--accent);
}
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -0.6rem;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 -2px 10px rgba(34, 211, 238, 0.5);
}
.tab-content {
  display: none;
  animation: fadeInTab 0.4s ease;
}
.tab-content.active {
  display: block;
}
@keyframes fadeInTab {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 1rem 0;
  margin-bottom: 1rem;
}
.breadcrumbs a {
  color: var(--accent);
}
.breadcrumbs span {
  opacity: 0.5;
}

/* Accordion */
.accordion {
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.accordion-header {
  width: 100%;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}
.accordion-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.accordion-icon {
  transition: transform 0.3s;
}
.accordion.active .accordion-icon {
  transform: rotate(180deg);
}
.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.accordion-content-inner {
  padding: 0 1.5rem 1.5rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Stepper */
.stepper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
}
.stepper-item {
  display: flex;
  gap: 1rem;
}
.stepper-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.2);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}
.stepper-content h4 {
  margin-bottom: 0.25rem;
  color: #fff;
  font-weight: 700;
}
.stepper-content p {
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* Blockquote */
.system-quote {
  border-left: 4px solid var(--accent);
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background: linear-gradient(
    90deg,
    rgba(34, 211, 238, 0.1) 0%,
    transparent 100%
  );
  border-radius: 0 8px 8px 0;
  font-size: 1.25rem;
  font-style: italic;
  color: #fff;
}
.system-quote footer {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
  padding: 0;
  border: none;
  background: transparent;
}

/* Forms & Inputs Component */
.form-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 2.5rem;
  margin-top: 3rem;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* Checkbox & Radio Components */
.form-check-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  color: #cbd5e1;
}
.form-check-group input {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Toggle Switch Component */
.form-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #cbd5e1;
}
.form-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.form-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.4s;
  border-radius: 26px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
.form-toggle input:checked + .toggle-slider {
  background-color: var(--accent);
}
.form-toggle input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* Spinner Component */
.spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 3px solid #fff;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: text-bottom;
  margin-right: 8px;
}
.btn .spinner {
  display: none;
}
.btn.loading .spinner {
  display: inline-block;
}
.btn.loading .btn-text {
  opacity: 0.7;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Skeleton Loader Component */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 2s infinite ease-in-out;
  border-radius: 4px;
}
@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
.skeleton-box {
  height: 100%;
  width: 100%;
  border-radius: 8px;
}
.skeleton-text {
  height: 1.25rem;
  margin-bottom: 0.75rem;
  width: 100%;
}
.skeleton-text.short {
  width: 60%;
}

/* Utility Pages */
.page-header {
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 100px;
}

/* Leaflet Map Migration Styles */
.leaflet-container {
  background-color: var(--glass-bg);
  font-family: "Inter", sans-serif;
}

.custom-polling-icon {
  background: transparent;
  border: none;
  font-size: 24px;
  text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
}

.early-voting-icon {
  filter: drop-shadow(0 0 5px #facc15);
}

.election-day-icon {
  filter: drop-shadow(0 0 5px #60a5fa);
}

/* Dropdown Menu Styles */
.dropdown {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  min-width: 180px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  z-index: 100;
  top: 100%;
  left: 0;
  overflow: hidden;
}

.dropdown-content a {
  color: #e2e8f0;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

.dropdown-content a:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--accent);
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover > span {
  color: var(--accent);
}

/* News Carousel Styles */
.carousel-wrapper {
  overflow: hidden;
  width: 100%;
  padding: 10px 0;
  border-radius: 12px;
}

.carousel-track {
  display: flex;
  gap: 2rem;
  transition: transform 0.5s ease-in-out;
}

.carousel-slide {
  min-width: 350px;
  max-width: 350px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.carousel-controls {
  display: flex;
  gap: 10px;
}

.carousel-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
  color: white;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: var(--transition);
}

.carousel-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-dark);
  transform: scale(1.1);
}

@media (max-width: 768px) {
  .carousel-slide {
    min-width: 280px;
    max-width: 280px;
  }
}

/* Precinct Directory Enhancements */
.hub-card-hover {
  transition:
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.3s ease;
}

.hub-card-hover:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--accent) !important;
  box-shadow: 0 10px 30px rgba(34, 211, 238, 0.25);
  z-index: 10;
}

.hub-card-hover:hover .card-img-zoom {
  transform: scale(1.1);
}

@keyframes staggerFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-fade-in {
  opacity: 0;
  animation: staggerFadeIn 0.6s ease-out forwards;
}

/* --- Ponytail Global Mobile Overrides --- */
@media (max-width: 768px) {
  html, body {
    max-width: 100vw !important;
    overflow-x: clip !important;
  }

  .container {
    padding: 0 1.25rem !important;
  }

  h1 { font-size: 2.2rem !important; }
  h2 { font-size: 1.8rem !important; }
  h3 { font-size: 1.5rem !important; }

  .grid-3, .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  .form-card, .glass-card {
    padding: 1.5rem !important;
  }

  .btn {
    min-height: 48px;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .hero-actions {
    flex-direction: column;
    width: 100%;
  }

  /* Nav Drawer fixes */
  .nav-links.active {
    width: 100% !important;
    max-width: 100% !important;
    padding-top: 4rem !important;
  }
  
  .dropdown-content {
    min-width: 100% !important;
  }
}

/* Fallback for fade-in animations on mobile so content is never invisible if IntersectionObserver fails */
@media (max-width: 768px) {
  .fade-in {
    opacity: 1 !important;
    transform: none !important;
  }
}
