/* Custom styles for DC Civil Rules Site */

:root {
    --primary-color: #004080;
    --secondary-color: #0066cc;
    --accent-color: #ff6b6b;
    --text-dark: #2c3e50;
    --text-light: #5a6c7d;
    --bg-light: #f8f9fa;
    --border-color: #dee2e6;
    --indent-1: 1.5rem;
    --indent-2: 3rem;
    --indent-3: 4.5rem;
    --indent-4: 6rem;
    --transition-speed: 0.2s;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.12);
}

/* Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    font-size: 17px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

h1 {
    font-weight: 700;
    letter-spacing: -0.03em;
}

h2 {
    font-weight: 650;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Navigation */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    transition: opacity var(--transition-speed);
}

.navbar-brand:hover {
    opacity: 0.85;
}

/* Focus states for accessibility */
a:focus,
button:focus,
.list-group-item-action:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Rule Content Styling */
.rule-container {
    max-width: 900px;
    margin: 0 auto;
}

.rule-header {
    background-color: var(--bg-light);
    padding-top: .1rem !important;
    padding-right: 1rem !important;
    padding-left: 1rem !important;
    padding-bottom: 1rem !important;
    margin-bottom: 2rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.rule-title {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.rule-subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Rule Section Styling */
.rule-section {
    margin-bottom: 2.5rem;
    padding-left: 0;
}

.rule-section-title {
    font-size: 1.3rem;
    font-weight: 650;
    color: var(--primary-color);
    margin-top: 0rem;
    margin-bottom: 1.25rem;
    letter-spacing: -0.01em;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* Hierarchical Numbering Styles with Visual Connectors */
.rule-level-1 {
    margin-left: 0.75rem;  /* Indent from main section */
    margin-bottom: 1rem;
    padding-left: 20px;    /* Space for connector line */
    position: relative;
}

/* Vertical line for level 1 */
.rule-level-1::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: -1rem;
    width: 2px;
    background-color: #2c5aa0;  /* Darker blue than level-2 */
}

/* Horizontal connector for level 1 */
.rule-level-1::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 15px;
    height: 2px;
    background-color: #2c5aa0;
}

/* Hide line for last child */
.rule-level-1:last-child::before {
    bottom: 0.5rem;
}

.rule-level-1-header {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

.rule-level-2 {
    margin-left: calc(var(--indent-1) + 0.75rem);  /* Adjusted for level-1 indent */
    margin-bottom: 0.75rem;
    position: relative;
    padding-left: 20px;
}

/* Vertical line for level 2 */
.rule-level-2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: -0.75rem;
    width: 2px;
    background-color: #4a90e2;
}

/* Horizontal connector for level 2 */
.rule-level-2::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 15px;
    height: 2px;
    background-color: #4a90e2;
}

/* Hide line for last child */
.rule-level-2:last-child::before {
    bottom: 0.5rem;
}

.rule-level-3 {
    margin-left: calc(var(--indent-2) + 0.75rem);  /* Adjusted for level-1 indent */
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 20px;
}

/* Vertical line for level 3 */
.rule-level-3::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: -0.5rem;
    width: 2px;
    background-color: #7ab8e8;
}

/* Horizontal connector for level 3 */
.rule-level-3::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 15px;
    height: 2px;
    background-color: #7ab8e8;
}

.rule-level-3:last-child::before {
    bottom: 0.5rem;
}

.rule-level-4 {
    margin-left: calc(var(--indent-3) + 0.75rem);  /* Adjusted for level-1 indent */
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 20px;
}

/* Vertical line for level 4 */
.rule-level-4::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: -0.5rem;
    width: 2px;
    background-color: #a8d0e8;
}

/* Horizontal connector for level 4 */
.rule-level-4::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5rem;
    width: 15px;
    height: 2px;
    background-color: #a8d0e8;
}

.rule-level-4:last-child::before {
    bottom: 0.5rem;
}

.rule-level-5 {
    margin-left: calc(var(--indent-4) + 0.75rem);  /* Adjusted for level-1 indent */
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 20px;
}

/* Container for maintaining line continuity */
.rule-subsection-group {
    position: relative;
}

/* Inline Rule Numbers */
.rule-number {
    font-weight: 650;
    color: var(--primary-color);
    margin-right: 0.35rem;
    display: inline-block;
}

/* Rule Text Content */
.rule-text {
    line-height: 1.5;
    text-align: left;
}

.rule-text p {
    margin-bottom: 0.75rem;
}

/* Navigation Breadcrumb for Rules */
.rule-nav {
    background-color: var(--bg-light);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 3px solid var(--secondary-color);
    box-shadow: var(--shadow-sm);
}

.rule-nav-item {
    display: inline-block;
    margin-right: 1rem;
}

.rule-nav-item a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.rule-nav-item a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Table of Contents for Individual Rules */
.rule-toc {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding-top: 0rem !important;
    padding-right: 1rem !important;
    padding-left: 1rem !important;
    padding-bottom: .1rem !important;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.rule-toc-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.rule-toc-list {
    list-style: none;
    padding-left: 0;
    line-height: 1.4;
}

.rule-toc-item {
    margin-bottom: 0.25rem;
}

.rule-toc-item a {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--transition-speed);
    display: inline-block;
}

.rule-toc-item a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.rule-toc-item-sub {
    margin-left: 1.5rem;
    font-size: 0.9rem;
}

/* Comments Section */
.rule-comments {
    background-color: #fffbf0;
    border-left: 4px solid #ffc107;
    padding: 1.5rem;
    margin-top: 3rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.rule-comments-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

/* Print button styling */
.print-button {
    background-color: var(--bg-light);
    border: 2px solid var(--border-color);
    color: var(--text-dark);
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all var(--transition-speed);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.print-button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .navbar-brand {
        font-size: 1rem;
        padding-right: 0.5rem;
    }

    .rule-container {
        padding: 0 1rem;
    }

    .rule-level-2 {
        margin-left: 1rem;
    }

    .rule-level-3 {
        margin-left: 2rem;
    }

    .rule-level-4 {
        margin-left: 3rem;
    }

    .rule-level-5 {
        margin-left: 4rem;
    }

    /* Fix vertical connector line positioning for mobile */
    .rule-subsection-group::before {
        left: 1rem; /* Match the mobile margin for rule-level-2 */
    }

    /* Adjust nested subsection groups */
    .rule-level-2 .rule-subsection-group::before {
        left: 1rem; /* Relative positioning for nested groups */
    }

    .rule-level-3 .rule-subsection-group::before {
        left: 1rem;
    }

    .rule-header {
        padding: 1.5rem;
        padding-right: 0.5rem;
    }

    .rule-title {
        font-size: 1.5rem;
        word-break: break-word;
        hyphens: auto;
    }

    /* Larger touch targets on mobile */
    .list-group-item-action {
        min-height: 48px;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .rule-toc-item a {
        padding: 0.5rem 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Back to top button adjustment for mobile */
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
    }
}

/* Print Styles */
@media print {
    .navbar, .rule-nav, footer, .back-to-top, .print-button {
        display: none !important;
    }

    .rule-container {
        max-width: 100%;
        padding: 0;
    }

    .rule-section {
        page-break-inside: avoid;
    }

    .rule-level-1 {
        page-break-inside: avoid;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .rule-header {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    a {
        color: #000 !important;
        text-decoration: none;
    }

    /* Show URLs after links in print */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Don't show URLs for internal links */
    a[href^="#"]:after {
        content: "";
    }
}

/* Tooltip Styles */
.rule-tooltip {
    position: fixed;
    background-color: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rule-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.rule-tooltip.visible {
    opacity: 1;
}

/* Copy feedback state */
.rule-tooltip.copied {
    background-color: #28a745;
    transform: scale(1.05);
    transition: all 0.3s ease;
}

.rule-tooltip.copied::after {
    border-color: #28a745 transparent transparent transparent;
}

/* Hoverable rule sections - clickable for copying citation */
[data-rule-path] {
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    border-radius: 4px;
}

[data-rule-path]:hover {
    background-color: rgba(74, 144, 226, 0.08);
}

/* Utility Classes */
.highlight {
    background-color: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
}

.note {
    color: var(--text-light);
    font-style: italic;
    font-size: 0.95rem;
}

.divider {
    border-top: 2px solid var(--border-color);
    margin: 2rem 0;
}

/* Visually hidden content for SEO (screen readers can still access) */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Cards on Index Page */
.card {
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-speed);
    border: 1px solid var(--border-color);
}

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

.card-header {
    border-radius: 8px 8px 0 0 !important;
    border-bottom: 2px solid var(--border-color);
}

.card-header h5 {
    color: var(--primary-color);
    font-weight: 650;
    margin-bottom: 0;
}

.list-group-item-action {
    transition: all var(--transition-speed);
    border-left: 3px solid transparent;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.list-group-item-action:hover {
    background-color: #f0f8ff;
    border-left-color: var(--secondary-color);
}

.list-group-item.fw-bold {
    background-color: #e8f4f8;
    border-left: 3px solid var(--secondary-color);
}

/* Better spacing between card groups */
.card.mb-3 {
    margin-bottom: 1.5rem !important;
}

/* Footer Styling */
footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, #003366 100%);
    color: white;
    padding: 2rem 0;
    margin-top: 4rem;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.05);
}

footer p {
    margin-bottom: 0.5rem;
}

footer .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

footer .footer-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: color var(--transition-speed);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

footer .footer-link:hover {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

/* Alert Box Improvements */
.alert-info {
    border-left: 4px solid #0dcaf0;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    background-color: #e7f6fd;
}

.alert-info strong {
    color: var(--primary-color);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-speed), visibility var(--transition-speed), transform var(--transition-speed);
    box-shadow: var(--shadow-md);
    z-index: 999;
    font-size: 1.5rem;
    border: none;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    background-color: var(--secondary-color);
}

.back-to-top:active {
    transform: translateY(-1px);
}