/* ============================================================================================================== */
/*               GOOGLE FONTS                                                                                     */
/* ============================================================================================================== */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;600;800&display=swap');

/* ============================================================================================================== */
/*               CSS VARIABLES                                                                                    */
/* ============================================================================================================== */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-document: 'EB Garamond', Garamond, 'Hoefler Text', 'Times New Roman', serif;

  /* LIGHT MODE (Granite) */
  --color-granite-white: #EBE9EE;                     /* Light Mode Background and Surfaces */
  --color-forged-iron: #3A314A;                       /* Light Mode Main Body Text and Headings */
  --color-quartz-bright: #FFFFFF;                     /* Light Mode Neumorphic Upper-Left Highlight */
  --color-granite-shadow: #D1CDDA;                    /* Light Mode Neumorphic Bottom-Right Shadow */
  --color-civic-purple: #6A1B9A;                      /* Primary Accent for Light Mode*/
  --color-treasury-gold: #C5A059;                     /* Secondary Accent for Light Mode*/
  --font-main: var(--font-ui);
  
  /* MAPPING FUNCTIONAL VARIABLES FOR LIGHT MODE */
  --color-bg: var(--color-granite-white);
  --color-text: var(--color-forged-iron);
  --color-highlight: var(--color-quartz-bright);
  --color-shadow: var(--color-granite-shadow);
  --color-accent: var(--color-civic-purple);

  /* INDEPENDENT ACCENTS */
  --color-liberty-red: #BA3242;
  --color-republic-blue: #2A4B7C;
  --color-stars-white: #FFFFFF; 
}

/* ============================================================================================================== */
/*              THEME OVERRIDES                                                                                   */
/* ============================================================================================================== */
[data-theme="dark"] {
  --color-deep-slate: #25212B;                        /* Dark Mode Background and Surfaces */
  --color-granite-white: #EBE9EE;                     /* Dark Mode Main Body Text and Headings */
  --color-slate-glare: #342F3D;                       /* Dark Mode Neumorphic Upper-Left Highlight */
  --color-slate-shadow: #141118;                      /* Dark Mode Neumorphic Bottom-Right Shadow */
  --color-lantern-violet: #B388FF;                    /* Primary Accent for Dark Mode */
  --color-minted-gold: #D4B371;                       /* Secondary Accent for Dark Mode */
  
  /* MAPPING FUNCTIONAL VARIABLES FOR DARK MODE */
  --color-bg: var(--color-deep-slate);
  --color-text: var(--color-granite-white);
  --color-highlight: var(--color-slate-glare);
  --color-shadow: var(--color-slate-shadow);
  --color-accent: var(--color-lantern-violet);
}

[data-theme="1776"] {
  --color-warm-parchment: #F4EFE6;                    /* 1776 Mode Flat Background */
  --color-iron-gall-ink: #2B2620;                     /* 1776 Mode Main Body Text and Headings */
  --color-archive-dust: #D8CBB6;                      /* 1776 Mode Section Dividers and Borders */
  --color-shadow: transparent;                        /* No Shadows for Flat Effect */
  --color-majestic-purple: #4A148C;                   /* Primary Accent for 1776 Mode */
  --color-colonial-bronze: #A8823A;                   /* Secondary Accent for 1776 Mode */
  --font-main: var(--font-document);
  
  /* MAPPING FUNCTIONAL VARIABLES FOR 1776 MODE */
  --color-bg: var(--color-warm-parchment);
  --color-text: var(--color-iron-gall-ink);
  --color-highlight: var(--color-archive-dust);
  /* Note: Shadow remains transparent for the flat effect */
  --color-accent: var(--color-majestic-purple);
}

[data-theme="contrast"] {
  --color-bg: #FFFFFF;                                /* Background for High Contrast */
  --color-text: #000000;                              /* Text for Easy Visibility */
  --color-highlight: #000000;                         /* Borders for High Contrast */
  --color-shadow: transparent;                        /* No Shadows for High Contrast */
  --color-accent: #0000EE;                            /* Standard Web Blue for Easy Visibility */
  --font-main: var(--font-ui);
}

/* ============================================================================================================== */
/*               BASE STYLES                                                                                      */
/* ============================================================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ========================================= */
/*           NEUMORPHIC UTILITIES            */
/* ========================================= */
.neu-card {
  background-color: var(--color-bg);
  border-radius: 20px;
  box-shadow: 10px 10px 20px var(--color-shadow), 
              -10px -10px 20px var(--color-highlight);
  padding: 2.5rem;
  border: 1px solid transparent; 
}

.neu-button {
  background-color: var(--color-bg);
  color: var(--color-accent);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.5rem;
  box-shadow: 6px 6px 12px var(--color-shadow), 
              -6px -6px 12px var(--color-highlight);
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Gives the tactile "pressed" feel on hover */
.neu-button:hover {
  box-shadow: inset 4px 4px 8px var(--color-shadow), 
              inset -4px -4px 8px var(--color-highlight);
  transform: translateY(1px);
}

/* Keeps the button pressed when clicked */
.neu-button:active {
  box-shadow: inset 6px 6px 12px var(--color-shadow), 
              inset -6px -6px 12px var(--color-highlight);
  transform: translateY(2px); 
  color: var(--color-text);
}

/* ========================================= */
/*         FLAT THEME OVERRIDES              */
/* ========================================= */
[data-theme="1776"] .neu-card,
[data-theme="1776"] .neu-button {
  box-shadow: none;
  border: 2px solid var(--color-highlight);
  border-radius: 0;
}

[data-theme="1776"] .neu-button {
  color: var(--color-text);
  background-color: transparent;
}

[data-theme="1776"] .neu-button:active {
  background-color: var(--color-highlight);
}

[data-theme="contrast"] .neu-card,
[data-theme="contrast"] .neu-button {
  box-shadow: none; 
  border: 3px solid var(--color-highlight);
  border-radius: 8px;
}

[data-theme="contrast"] .neu-button {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-weight: 800;
}

[data-theme="contrast"] .neu-button:active {
  background-color: var(--color-text);
  color: var(--color-bg);
}

/* Ensures the 1776 mode stays flat on hover */
[data-theme="1776"] .neu-button:hover {
  background-color: var(--color-highlight);
  box-shadow: none;
  transform: translateY(1px);
}

/* Ensures the contrast mode stays flat on hover */
[data-theme="contrast"] .neu-button:hover {
  background-color: var(--color-text);
  color: var(--color-bg);
  box-shadow: none;
  transform: translateY(1px);
}

/* Flattens the pill navbar for 1776 Mode */
[data-theme="1776"] nav.navbar {
  box-shadow: none;
  border: 2px solid var(--color-highlight);
  border-radius: 0;
}

/* Flattens the pill navbar for Contrast Mode */
[data-theme="contrast"] nav.navbar {
  box-shadow: none; 
  border: 3px solid var(--color-highlight);
  border-radius: 8px;
}

/* ========================================= */
/*          LAYOUT & TYPOGRAPHY              */
/* ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 20px 0 0 0; 
  background: color-mix(in srgb, var(--color-bg) 80%, transparent);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  width: 100%;
}

nav.navbar {
  display: flex;
  justify-content: space-between; 
  align-items: center;
  width: 96%; 
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 2rem;
  background-color: var(--color-bg);
  border-radius: 20px;
  box-shadow: 10px 10px 20px var(--color-shadow), 
              -10px -10px 20px var(--color-highlight);
  border: 1px solid transparent;
  position: relative; 
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text); 
  letter-spacing: 2px;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.7;
}

/* --- MOBILE NAVIGATION SETUP --- */
.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 45px;
  height: 45px;
  padding: 0; 
}

.bar {
  width: 20px;
  height: 2px;
  background-color: var(--color-text);
  transition: 0.3s;
}

/* The Animated 'X' */
.menu-toggle.is-active .bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.menu-toggle.is-active .bar:nth-child(2) {
  opacity: 0;
}
.menu-toggle.is-active .bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.nav-menu {
  display: none;
  flex-direction: column;
  gap: 2rem;
  position: absolute;
  top: calc(100% + 15px);
  left: 0;
  width: 100%;
  background-color: var(--color-bg);
  padding: 2rem;
  border-radius: 20px;
  box-shadow: 10px 10px 20px var(--color-shadow), 
              -10px -10px 20px var(--color-highlight);
  z-index: 10;
}

.nav-menu.active {
  display: flex;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  list-style: none;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.95rem;
  transition: opacity 0.2s ease;
}

.nav-links a.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-links a.modal-trigger {
  color: var(--color-accent);
  cursor: pointer;
}

/* --- DESKTOP NAVIGATION OVERRIDES --- */
@media (min-width: 1000px) {
  .menu-toggle {
    display: none;
  }

  .nav-menu {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    position: static;
    width: 100%;
    margin-left: 3rem;
    background: transparent;
    padding: 0;
    box-shadow: none;
  }

  .nav-links {
    flex-direction: row;
  }
}

main {
  width: 100%;
  max-width: 800px;
  margin: 3rem auto 0 auto; 
  padding: 0 2rem;
}

.hero {
  margin-bottom: 2.5rem;
  text-align: center;
}

.floating-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  padding: 0;
}

.badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--color-republic-blue), var(--color-liberty-red));
  color: var(--color-stars-white);
  box-shadow: 4px 4px 8px var(--color-shadow);
}

[data-theme="1776"] .badge {
  background: transparent;
  color: var(--color-liberty-red);
  border: 1px solid var(--color-liberty-red);
  box-shadow: none;
  border-radius: 0;
}

[data-theme="contrast"] .badge {
  background: var(--color-bg);
  color: var(--color-text);
  border: 3px solid var(--color-text);
  box-shadow: none;
  border-radius: 8px;
}

h1, h2 {
  color: var(--color-text);
  margin-bottom: 1.5rem;
  line-height: 1.2;
}

p {
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* ========================================= */
/*           HOMEPAGE & PAGES                */
/* ========================================= */
.institute-mission {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.launch-feature {
  margin-top: 2.5rem;
  text-align: center;
  border-top: 4px solid var(--color-liberty-red); 
}

.document-spacing {
  margin-top: 2.5rem;
}

/* ========================================= */
/*                SITE FOOTER                */
/* ========================================= */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 4rem 2rem 2rem 2rem;
  margin-top: 4rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  list-style: none;
  margin-bottom: 1.5rem;
}

.footer-links a {
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.footer-links a:hover {
  opacity: 1;
}

.site-footer p {
  font-size: 0.85rem;
  opacity: 0.5;
  margin: 0;
}

/* ========================================= */
/*                  MODALS                   */
/* ========================================= */
.modal-overlay {
  display: none; 
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: color-mix(in srgb, var(--color-bg) 70%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  -ms-overflow-style: none;  
  scrollbar-width: none;     
}

.modal-content::-webkit-scrollbar {
  display: none;             
}

.close-modal-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.5rem 1rem;
}

/* ========================================= */
/*           MODAL INTERIOR STYLES           */
/* ========================================= */
.modal-heading {
  margin-top: 1rem;
}

.modal-divider {
  border: none;
  height: 2px;
  background: var(--color-shadow);
  margin: 1.5rem 0;
}

.modal-topic-grid {
  display: grid;
  gap: 1.5rem;
}

.topic-link {
  text-align: center;
  text-decoration: none;
  display: block;
}

/* ========================================= */
/*       MODAL & DOCUMENT UTILITIES          */
/* ========================================= */
.modal-badge {
  margin-top: 1rem;
}

.document-heading {
  margin-bottom: 1rem;
}

.document-text {
  margin-bottom: 1.5rem;
}

.modal-actions {
  margin-top: 3rem;
  display: flex;
  justify-content: flex-end;
}

.download-link {
  text-decoration: none;
}

/* ========================================= */
/*           DECLARATION GRID LAYOUT         */
/* ========================================= */
.grievance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

.grievance-column h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--color-accent);
  margin-bottom: 1.5rem;
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
  .grievance-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

/* ========================================= */
/*           MODAL & SWITCHER LAYOUT         */
/* ========================================= */

/* 1. Make the modal wider for better desktop viewing */
.modal-content {
  max-width: 900px; /* Increased from 600px */
}

/* 2. The Switcher UI (Hidden on Desktop) */
.mobile-view-switcher {
  display: none; 
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

/* 3. The Grid Layout */
.grievance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

/* 4. Mobile Responsiveness */
@media (max-width: 768px) {
  .mobile-view-switcher {
    display: flex; /* Show the buttons only on mobile */
  }

  .grievance-grid {
    grid-template-columns: 1fr; /* Stacked by default */
  }

  /* Logic: If 'show-modern' class is added, hide the historical column */
  .view-state-modern .column-1776 {
    display: none;
  }

  /* Logic: If 'show-history' class is added, hide the modern column */
  .view-state-history .column-2026 {
    display: none;
  }
}

/* ========================================= */
/*           ANIMATED VIEW SLIDER            */
/* ========================================= */
.mobile-view-switcher {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.view-label {
  font-weight: 700;
  color: var(--color-text);
  font-size: 0.9rem;
}

.view-slider {
  width: 60px;
  height: 30px;
  background: var(--color-bg);
  border: none;
  border-radius: 15px;
  box-shadow: inset 4px 4px 8px var(--color-shadow), 
              inset -4px -4px 8px var(--color-highlight);
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
}

.slider-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: var(--color-accent);
  border-radius: 50%;
  box-shadow: 2px 2px 4px var(--color-shadow), 
              -2px -2px 4px var(--color-highlight);
  transition: transform 0.3s ease;
}

/* Logic: Move knob when active */
.view-slider.active .slider-knob {
  transform: translateX(30px);
}

/* Fade animation for text */
.grievance-column {
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  .mobile-view-switcher {
    display: flex;
  }

  /* When slider is inactive (1776 view) */
  .grievance-grid:not(.view-modern) .column-2026 {
    display: none;
  }

  /* When slider is active (2026 view) */
  .grievance-grid.view-modern .column-1776 {
    display: none;
  }
}

/* ========================================= */
/*           INLINE CONTEXT LINKS            */
/* ========================================= */
.inline-context-link {
  background: none;
  border: none;
  color: var(--color-accent);
  font-family: inherit;
  font-size: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: opacity 0.2s ease;
}

.inline-context-link:hover {
  opacity: 0.7;
}

/* Ensure Context Modal sits on top of Declaration Modal */
#contextModal {
  z-index: 2050; 
}

/* ========================================= */
/*           MODAL SOURCE BUTTONS            */
/* ========================================= */
#contextSourcesContainer {
  gap: 1rem;
  flex-wrap: wrap;
}