:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --text-color: #2c3e50;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
}

.legal-nav {
    background: var(--secondary-color);
    padding: 1rem 2rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Drupal admin bar adjustments */
body.toolbar-fixed .legal-nav {
    top: 79px !important;
}

body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open .legal-nav {
    top: 119px !important;
}

.legal-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.legal-nav a:hover,
.legal-nav a:focus {
    background-color: var(--accent-color);
    outline: 2px solid white;
}

.legal-nav a.active {
    background-color: var(--accent-color);
}

.legal-document {
    background: white;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    scroll-margin-top: 2rem;
}

/* Drupal scroll margin adjustments */
body.toolbar-fixed .legal-document {
    scroll-margin-top: 100px !important;
}

body.toolbar-fixed.toolbar-horizontal.toolbar-tray-open .legal-document {
    scroll-margin-top: 140px !important;
}

.legal-header {
    background: var(--primary-color);
    color: white;
    padding: 2rem;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

.document-meta {
    background: var(--light-bg);
    padding: 1rem;
    border-left: 4px solid var(--accent-color);
    margin-bottom: 2rem;
    border-radius: 4px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: white;
}

h2 {
    font-size: 1.8rem;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--primary-color);
}

h3 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.5rem 0;
    color: var(--secondary-color);
}

h4 {
    font-size: 1.1rem;
    margin: 1rem 0 0.5rem 0;
    color: var(--secondary-color);
}

p {
    margin-bottom: 1rem;
}

ul, ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 2rem 0;
    background: white;
}

th, td {
    border: 1px solid var(--border-color);
    padding: 0.25rem;
    text-align: left;
}

th {
    background-color: var(--light-bg);
    font-weight: 600;
}

.notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #fdcb6e;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.warning {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #e74c3c;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.back-to-top {
    display: inline-block;
    margin-top: 2rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.back-to-top:hover {
    background: var(--accent-color);
}

pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.toc-sidebar {
    position: sticky;
    top: 100px;
    background: var(--light-bg);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 2rem;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 90;
}

.toc-sidebar h4 {
    margin-top: 0;
    color: var(--primary-color);
}

.toc-sidebar ul {
    list-style: none;
    padding-left: 0;
}

.toc-sidebar li {
    margin-bottom: 0.25rem;
}

.toc-sidebar a {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.toc-sidebar a:hover {
    color: var(--accent-color);
}

a[href^="http"]:not([href*="[Your Website URL]"]) {
    position: relative;
}

a[href^="http"]:not([href*="[Your Website URL]"])::after {
    content: " ↗";
    font-size: 0.6em;
    opacity: 0.5;
    margin-left: 2px;
    display: inline-block;
    transition: opacity 0.2s ease;
}

a[href^="http"]:not([href*="[Your Website URL]"]):hover::after {
    opacity: 1;
}

@media (max-width: 480px) {
    a[href^="http"]:not([href*="[Your Website URL]"]):not(.legal-nav a)::after {
        content: " (external)";
        display: block;
        font-size: 0.5em;
        margin-left: 0;
        margin-top: 2px;
        opacity: 0.7;
    }
    
    td a[href^="http"]:not([href*="[Your Website URL]"])::after {
        content: " ↗";
        display: inline;
        font-size: 0.6em;
    }
}

.version-history {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 4px;
}

.version-history summary {
    cursor: pointer;
    font-weight: 600;
}

.version-history table {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.history-content {
    margin-top: 1rem;
}

.placeholder-notice {
  display: none !important;
}

.placeholder-row {
    background: #f8f9fa !important;
    font-style: italic;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ecf0f1;
        --secondary-color: #bdc3c7;
        --text-color: #ecf0f1;
        --light-bg: #2c3e50;
        --border-color: #34495e;
    }
    
    .legal-document {
        background: #34495e;
        color: var(--text-color);
    }
    
    th {
        background-color: #2c3e50;
    }
    
    .notice {
        background: #5d4037;
        border-color: #8d6e63;
        color: #ffccbc;
    }
    
    .version-history {
        background: #2c3e50;
    }
    
    .placeholder-row {
        background: #34495e !important;
    }
}

@media (max-width: 768px) {
    .legal-nav {
        flex-direction: column;
        gap: 0.5rem;
/*        position: relative; */
        position: sticky;
        top: 0;
        background: var(--secondary-color);
        z-index: 100;
        padding: 1rem;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }
    
    .legal-nav a {
        text-align: center;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .legal-document {
        padding: 1rem;
    }
    
    .toc-sidebar {
        position: relative;
        top: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    a[href^="http"]:not([href*="[Your Website URL]"])::after {
        transition: none;
    }
    .placeholder-row {
        animation: none;
    }
}

#external-link-notice {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: #666;
}

.attribution-section table.view-table td,
.attribution-section table.view-table th {
  padding: 4pm 8px;
}

.pager__item a {
  text-decoration: none;
  font-weight: bold;
}

/* ========================== */
/* Table of Contents Styling  */
/* ========================== */

/* Scroll-spy active link styling */
.sticky-header .toc-link.active {
  background-color: rgba(0, 123, 255, 0.2);
  color: #007bff;
  /* Keep active always visible */
  outline: none !important;
  box-shadow: none !important;
}

/* Remove default focus outline on mouse click */
.sticky-header .toc-link:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* Maintain visible outline for keyboard navigation */
.sticky-header .toc-link:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Default TOC link styling */
a.toc-link {
  outline: none;
  transition: box-shadow 0.2s, background-color 0.2s;
  text-decoration: none;
  color: inherit;
}

/* Subtle focus indicator for accessibility */
a.toc-link:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
  border-radius: 4px;
}

/* Optional hover effect */
a.toc-link:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

/* Prevent sticky header from obscuring active section */
.sticky-header .toc-link.active::after {
  content: '';           /* optional: visual cue if needed */
  display: block;
  height: 0;
}
