/* 
 * MAPS.org Policy Reader Styles
 * Aligned with MAPS Brand Guidelines (Updated 09.30.21)
 * 
 * Brand Fonts: Poppins (headlines), Lato (body)
 * Primary Color: #0f2a4a (MAPS Navy)
 * Accent Usage: <20% per brand guidelines
 */

/* Brand Fonts (Lato + Poppins) loaded via wp_enqueue_style in Assets.php */

/* Brand Color Palette - From MAPS Brand Guidelines Page 8 */
:root {
  /* Primary Colors */
  --maps-navy: #0f2a4a;           /* Primary brand color */
  --maps-blue-mid: #27527c;       /* Secondary blue */
  --maps-blue-bright: #0336c3;    /* Bright accent blue */
  
  /* Secondary/Accent Colors (use <20% per guidelines) */
  --maps-purple: #9249ff;
  --maps-cyan: #00f7ff;
  --maps-teal: #00adbd;
  --maps-green: #19cd69;
  --maps-lime: #c3ff42;
  --maps-pink: #ff5fc7;
  --maps-coral: #ff514e;
  --maps-yellow: #fdec76;
  
  /* Neutrals */
  --maps-gray-blue: #8298b7;
  --maps-gray-bg: #f8f9fa;
  --maps-gray-border: #e1e4e8;
  
  /* Semantic Aliases */
  --color-primary: var(--maps-navy);
  --color-primary-light: var(--maps-blue-mid);
  --color-accent: var(--maps-blue-bright);
  --color-highlight: var(--maps-cyan);
  --color-text: var(--maps-navy);
  
  /* Effects */
  --shadow-sm: 0 2px 8px rgba(15, 42, 74, 0.1);
  --shadow-md: 0 4px 16px rgba(15, 42, 74, 0.15);
  --shadow-lg: 0 8px 32px rgba(15, 42, 74, 0.2);
  
  /* Brand Gradients */
  --gradient-blue: linear-gradient(135deg, #0336c3 0%, #ffffff 100%);
  --gradient-tri: linear-gradient(135deg, #0336c3 0%, #9249ff 50%, #00f7ff 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(3, 54, 195, 0.05) 0%, rgba(146, 73, 255, 0.05) 50%, rgba(0, 246, 255, 0.05) 100%);
}

/* Base Typography - Lato for body copy per brand guidelines */
.pr-container {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--color-text);
  line-height: 1.6;
}

/* Headlines use Poppins Bold per brand guidelines */
h1, h2, h3, h4, h5, h6,
.pr-section__header h2,
.pr-toc__title {
  font-family: 'Poppins', sans-serif;
}

/* Main Container */
.pr-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 1024px) {
  .pr-container {
    grid-template-columns: 1fr;
    padding: 16px;
  }
}

/* ============================================
   TABLE OF CONTENTS
   ============================================ */

.pr-toc {
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease;
}

.pr-toc:hover {
  box-shadow: var(--shadow-md);
}

/* Custom Scrollbar */
.pr-toc::-webkit-scrollbar {
  width: 6px;
}

.pr-toc::-webkit-scrollbar-track {
  background: var(--maps-gray-bg);
  border-radius: 3px;
}

.pr-toc::-webkit-scrollbar-thumb {
  background: var(--color-primary-light);
  border-radius: 3px;
}

.pr-toc::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ToC Title */
.pr-toc__title {
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--maps-cyan);
}

/* ToC Lists */
.pr-toc__list,
.pr-toc__sub {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.pr-toc__sub {
  margin-top: 8px;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 2px solid var(--maps-gray-border);
}

/* ToC Links */
.pr-toc a {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--color-text);
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 400;
  position: relative;
}

.pr-toc__sec {
  font-weight: 600;
  color: var(--color-primary) !important;
  font-family: 'Poppins', sans-serif;
}

.pr-toc a:hover {
  background: var(--maps-gray-bg);
  color: var(--color-primary);
  transform: translateX(4px);
}

/* Active Link - Uses brand tri-color gradient */
.pr-toc a.active {
  background: linear-gradient(
    135deg,
    rgba(3, 54, 195, 0.08) 0%,
    rgba(146, 73, 255, 0.08) 50%,
    rgba(0, 246, 255, 0.08) 100%
  );
  color: var(--color-primary) !important;
  font-weight: 600;
  border-left: 3px solid var(--maps-blue-bright);
  padding-left: 9px;
}

.pr-toc a.active::before {
  content: '▸';
  position: absolute;
  left: -8px;
  color: var(--maps-blue-bright);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   SEARCH
   ============================================ */

.pr-search {
  margin-bottom: 20px;
}

#pr-search-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--maps-gray-border);
  border-radius: 8px;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}

#pr-search-input:focus {
  outline: none;
  border-color: var(--maps-blue-bright);
  box-shadow: 0 0 0 3px rgba(3, 54, 195, 0.1);
}

#pr-search-input::placeholder {
  color: var(--maps-gray-blue);
  font-weight: 300;
}

/* Search Results */
#pr-search-results {
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#pr-search-results a {
  display: block;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--color-text);
  border-bottom: 1px solid var(--maps-gray-border);
  transition: all 0.2s ease;
}

#pr-search-results a:last-child {
  border-bottom: none;
}

#pr-search-results a:hover {
  background: var(--gradient-subtle);
  color: var(--color-primary);
  padding-left: 16px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.pr-content {
  min-width: 0;
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow-sm);
}

.pr-section {
  margin-bottom: 64px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--maps-gray-border);
}

.pr-section:last-child {
  border-bottom: none;
}

/* Section Headers */
.pr-section__header {
  margin-bottom: 24px;
}

.pr-section__header h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--color-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 8px 0;
}

/* Copy Link Button */
.pr-copylink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--maps-gray-border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  flex-shrink: 0;
  color: var(--color-text-muted, #666);
}

.pr-copylink svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor;
  display: block;
  flex-shrink: 0;
  fill: none;
}

.pr-copylink:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  transform: scale(1.1);
}

.pr-copylink:active {
  transform: scale(0.95);
}

/* ============================================
   SECTION BODY TYPOGRAPHY
   ============================================ */

.pr-section__body {
  font-family: 'Lato', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
}

/* Subheadings */
.pr-section__body h3 {
  color: var(--color-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  margin-top: 32px;
  margin-bottom: 16px;
  font-weight: 700;
}

.pr-section__body h4 {
  color: var(--color-primary-light);
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}

/* Paragraphs */
.pr-section__body p {
  margin-bottom: 16px;
}

/* Links */
.pr-section__body a {
  color: var(--maps-blue-bright);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
  font-weight: 400;
}

.pr-section__body a:hover {
  color: var(--maps-purple);
  border-bottom-color: var(--maps-purple);
}

/* Lists */
.pr-section__body ul,
.pr-section__body ol {
  margin: 16px 0;
  padding-left: 32px;
}

.pr-section__body li {
  margin-bottom: 8px;
}

.pr-section__body li::marker {
  color: var(--maps-blue-bright);
}

/* Blockquotes */
.pr-section__body blockquote {
  margin: 24px 0;
  padding: 20px 24px;
  background: linear-gradient(
    90deg,
    rgba(146, 73, 255, 0.05),
    transparent
  );
  border-left: 4px solid var(--maps-purple);
  font-style: italic;
  color: var(--color-primary);
  font-weight: 400;
  border-radius: 0 8px 8px 0;
}

/* Code */
.pr-section__body code {
  background: var(--maps-gray-bg);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--color-primary);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-weight: 400;
}

.pr-section__body pre {
  background: var(--maps-gray-bg);
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--maps-gray-border);
}

.pr-section__body pre code {
  background: none;
  padding: 0;
}

/* ============================================
   TABLES
   ============================================ */

.pr-section__body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 24px 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pr-section__body th {
  background: linear-gradient(
    135deg,
    var(--color-primary) 0%,
    var(--color-primary-light) 100%
  );
  color: white;
  padding: 14px 16px;
  text-align: left;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pr-section__body td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--maps-gray-border);
  background: white;
}

.pr-section__body tr:last-child td {
  border-bottom: none;
}

.pr-section__body tbody tr:hover {
  background: var(--gradient-subtle) !important;
}

/* Striped tables */
.pr-section__body tbody tr:nth-child(even) {
  background: var(--maps-gray-bg);
}

/* ============================================
   ENDNOTES / FOOTNOTES
   ============================================ */

.pr-endnotes {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 2px solid var(--maps-cyan);
}

.pr-endnotes h2 {
  color: var(--color-primary);
  font-family: 'Poppins', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.pr-endnotes ol {
  padding-left: 24px;
}

.pr-endnotes li {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.6;
}

/* Footnote References in Text */
.pr-fn-ref {
  vertical-align: super;
  font-size: 0.75em;
  font-weight: 600;
  margin: 0 2px;
}

.pr-fn-ref a {
  color: var(--maps-blue-bright);
  text-decoration: none;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 0.2s ease;
  background: rgba(3, 54, 195, 0.05);
}

.pr-fn-ref a:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.1);
}

/* Footnote Popup Tooltip */
.pr-pop {
  position: absolute;
  z-index: 9999;
  background: var(--color-primary);
  color: white;
  max-width: 400px;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
  font-weight: 400;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pr-pop a {
  color: var(--maps-cyan);
  text-decoration: underline;
}

.pr-pop a:hover {
  color: white;
}

/* ============================================
   SEARCH HIGHLIGHT
   ============================================ */

.pr-highlight {
  background: var(--maps-yellow);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ============================================
   RESPONSIVE / MOBILE
   ============================================ */

@media (max-width: 1024px) {
  .pr-content {
    padding: 32px;
  }
}

@media (max-width: 768px) {
  .pr-toc {
    position: relative;
    top: 0;
    margin-bottom: 24px;
    max-height: none;
  }
  
  .pr-content {
    padding: 24px;
    border-radius: 8px;
  }
  
  .pr-section__header h2 {
    font-size: 24px;
    flex-wrap: wrap;
  }
  
  .pr-section__body {
    font-size: 15px;
  }
  
  .pr-section__body h3 {
    font-size: 20px;
  }
  
  .pr-section__body h4 {
    font-size: 17px;
  }
  
  .pr-section__body table {
    font-size: 14px;
  }
  
  .pr-section__body th,
  .pr-section__body td {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .pr-container {
    padding: 12px;
  }
  
  .pr-content {
    padding: 20px;
  }
  
  .pr-section__header h2 {
    font-size: 22px;
  }
  
  .pr-toc {
    padding: 16px;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .pr-toc,
  .pr-copylink,
  .pr-search {
    display: none !important;
  }
  
  .pr-container {
    display: block;
    max-width: 100%;
    padding: 0;
  }
  
  .pr-content {
    box-shadow: none;
    padding: 0;
  }
  
  .pr-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  .pr-section__header h2 {
    color: #000;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  .pr-fn-ref a:after {
    content: "";
  }
  
  .pr-section__body a {
    color: #000;
    text-decoration: underline;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
.pr-toc a:focus-visible,
.pr-copylink:focus-visible,
#pr-search-input:focus-visible,
.pr-section__body a:focus-visible {
  outline: 3px solid var(--maps-blue-bright);
  outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pr-toc a.active {
    border-left-width: 4px;
  }
  
  .pr-section__body blockquote {
    border-left-width: 5px;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Brand gradient backgrounds (use sparingly, <20%) */
.pr-gradient-tri {
  background: var(--gradient-tri);
}

.pr-gradient-subtle {
  background: var(--gradient-subtle);
}

/* Accent color utilities */
.pr-accent-purple { color: var(--maps-purple); }
.pr-accent-cyan { color: var(--maps-cyan); }
.pr-accent-teal { color: var(--maps-teal); }
.pr-accent-green { color: var(--maps-green); }

/* ============================================
   PDF DOWNLOAD BUTTON
   ============================================ */

.pr-download-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--color-primary);
  color: white !important;
  border-radius: 8px;
  text-decoration: none !important;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.pr-download-pdf:hover {
  background: var(--color-primary-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  color: white !important;
}

.pr-download-pdf svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

@media print {
  .pr-download-pdf {
    display: none !important;
  }
}

/* ============================================
   PARDOT MODAL
   ============================================ */

.pr-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

.pr-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 42, 74, 0.6);
  backdrop-filter: blur(4px);
}

.pr-modal__content {
  position: relative;
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 90vw;
  max-width: 600px;
  height: 80vh;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pr-modal__close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 1;
  background: none;
  border: none;
  font-size: 28px;
  color: var(--maps-gray-blue);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.pr-modal__close:hover {
  background: var(--maps-gray-bg);
  color: var(--color-primary);
}

.pr-modal__iframe {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 0 0 16px 16px;
}

@media (max-width: 768px) {
  .pr-modal__content {
    width: 95vw;
    height: 90vh;
    border-radius: 12px;
  }
}