/* CSS Variables / Design Tokens */
:root {
    --doc-section-spacing: 2rem;
    --doc-header-spacing: 1.2rem;
    --doc-text-spacing: 1rem;
}

/* Base Styles & Typography */
html {
    /* Dynamic scroll padding based on actual header state */
    scroll-padding-top: calc(var(--secondary-header-height) + var(--gap));
    scroll-behavior: smooth;
}

/* Prevent header bounce on documentation page */
.documentation-page .secondary-header {
    /* Ensure smooth transitions */
    transition: top 0.2s ease-in-out, transform 0.2s ease-in-out;
    /* Prevent flicker */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.job_id-selected {
    display: none;
}

.unit-options {
    display: none;
}

/* Stabilize gap fillers on documentation page */
.documentation-page .gap-filler_header-sticky,
.documentation-page .gap-filler_header-not-sticky {
    /* Prevent transition jank */
    transition: none;
    transform: translateZ(0);
}

/* Fix main content area to proper height and scrolling */
.documentation-page .section-container.split_100pcnt {
    position: sticky;
    top: calc(var(--secondary-header-height) + var(--gap) + 6px);
    /* Match sidebar height exactly */
    height: calc(100vh - var(--secondary-header-height) - var(--gap) - 12px);
    max-height: calc(100vh - var(--secondary-header-height) - var(--gap) - 12px);
    overflow: hidden;
    /* Container doesn't scroll, content inside does */
    /* Ensure consistent sizing */
    flex-shrink: 0;
    /* Prevent layout shifts */
    contain: layout style size;
}

/* Adjust height when header menu is visible */
.documentation-page:not(:has(.header-menu.header-hidden)) .section-container.split_100pcnt {
    height: calc(100vh - var(--header-height) - var(--secondary-header-height) - var(--gap) - 12px);
    max-height: calc(100vh - var(--header-height) - var(--secondary-header-height) - var(--gap) - 12px);
}

/* Make the main content area scrollable */
.documentation-page .section-main-page {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* Enable smooth scrolling on touch devices */
    -webkit-overflow-scrolling: touch;
    /* Prevent bounce at scroll boundaries - more restrictive */
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
    /* Ensure trackpad scrolling works */
    scroll-behavior: smooth;
    /* Prevent height changes from causing scroll issues */
    position: relative;
}

/* Ensure documentation content takes full height */
.documentation-page .documentation {
    min-height: 100%;
    padding: var(--space-24);
    /* Ensure content can be scrolled */
    display: block;
}

/* Improve touch scrolling responsiveness */
.documentation-page .section-main-page::-webkit-scrollbar {
    width: 8px;
}

.documentation-page .section-main-page::-webkit-scrollbar-track {
    background: var(--color-background-darker);
}

.documentation-page .section-main-page::-webkit-scrollbar-thumb {
    background: var(--color-background-brighter);
    border-radius: 4px;
}

.documentation-page .section-main-page::-webkit-scrollbar-thumb:hover {
    background: var(--color-foreground-darker);
}

/* Hide mobile elements on desktop by default */
.documentation section .mobile-section-header,
.mobile-group-header {
    display: none;
}

/* Ensure mobile-section-content is always visible on desktop, overriding hidden class */
@media screen and (min-width: 900px) {

    .gap-filler_390 {
        width: 360px;
    }

    .documentation section .mobile-section-content.hidden {
        display: block !important;
    }
    
    .documentation section .mobile-section-content {
        display: block !important;
    }
}

/* Handle dropdown section animations to prevent bounce - only for toggleable content */
.documentation-page .input-container {
    /* Normal display for content by default */
    transition: none;
}

.documentation-page .input-container.hidden {
    /* Use the global hidden class behavior but add scroll position preservation */
    display: none !important;
}

/* Basic overscroll prevention for documentation page */
.documentation-page .section-main-page {
    /* Prevent bounce at scroll boundaries */
    overscroll-behavior-y: contain;
}

/* Make section headers clickable and add hover effects */
.documentation-page .section-header {
    /* Make entire header clickable */
    cursor: pointer;
    /* Add smooth transition for hover effect */
    transition: background-color 0.2s ease;
}

.documentation-page .section-header:hover {
    /* Darker background on hover */
    background-color: var(--color-background-darker);
}

/* Content Container Base Styles */
.content-container {
    font-size: 0.85rem;
    margin: var(--doc-text-spacing) 0;
    padding: var(--space-12);
    background: var(--color-background);
    color: var(--color-foreground);
    font-family: var(--font-family-01);
    line-height: 1.5;
    min-width: 0;
}

/* Section Layout Base Styles */
.section-main-page {
    border-top: 1px solid var(--color-background-brighter);
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    padding: 0 var(--space-18);
}

/* Typography Base Styles */
h1 {
    font-size: 1.6rem;
    font-weight: 600;
    text-align: left;
    margin: 0 0 var(--doc-section-spacing) 0;
    padding-top: var(--doc-header-spacing);
    border-top: 6px solid var(--color-foreground);
    color: var(--color-foreground);
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: var(--doc-section-spacing) 0 var(--doc-text-spacing) 0;
    padding-bottom: 0.5rem;
    color: var(--color-foreground);
}

h3 {
    font-size: 1.2rem;
    margin: 1.5rem 0 var(--doc-text-spacing) 0;
    font-weight: 500;
    color: var(--color-foreground);
}

h4 {
    font-size: 1.1rem;
    margin: 1.5rem 0 var(--doc-text-spacing) 0;
    font-weight: 500;
    color: var(--color-foreground);
}

/* Text Elements Base Styles */
p {
    letter-spacing: 0.01rem;
    margin: var(--doc-text-spacing) 0;
    line-height: 1.6;
    font-size: 0.85rem;
}

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

/* Links Base Styles */
a {
    color: var(--color-foreground);

    transition: none;
}

a:hover {
    color: var(--color-foreground-brighter);
    border-bottom-color: var(--color-foreground-brighter);
}

/* Lists Base Styles */
.doc-list {
    list-style-type: none;
    padding: 0 var(--space-12);
    font-size: 0.84rem;
    line-height: 1.5rem;
}

.doc-list li {
    margin: 8px 0 0 15px;
    list-style: decimal-leading-zero;
}

.doc-list li a {
    color: var(--color-foreground);
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease;
    border-radius: 2px;
    padding: 2px 4px;
    display: block;
}

.doc-list li a:hover {
    color: var(--color-foreground-brighter);
    background-color: var(--color-background-darker);
}

.doc-list li a:focus {
    outline: 2px solid var(--color-accent-01);
    outline-offset: 1px;
    color: var(--color-foreground-brighter);
    background-color: var(--color-background-darker);
}

/* Active navigation highlighting */
.doc-list li.active a,
.doc-list li a.active {
    color: var(--color-foreground-brighter);
    font-weight: 600;
}

.doc-list li.active a:hover,
.doc-list li a.active:hover {
    color: var(--color-accent-01-brighter);
    background-color: var(--color-background-darker);
}

/* Keyboard navigation focus states */
.doc-list[role="listbox"]:focus {
    outline: 2px solid var(--color-accent-01);
    outline-offset: 2px;
    border-radius: 4px;
}

.doc-list a[aria-selected="true"] {
    color: var(--color-accent-01-brighter);
    background-color: var(--color-accent-01-darker);
    outline: 2px solid var(--color-accent-01);
    outline-offset: 1px;
}

/* Code Sections Base Styles */
code {
    font-family: var(--font-family-02);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    max-width: fit-content;
    background: var(--color-background-darker);
}

pre {
    background: var(--color-background-darker);
    padding: var(--doc-text-spacing) 0;
    border: 1px solid var(--color-background-brighter);
    border-radius: 4px;
    margin: var(--doc-text-spacing) 0;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
}

pre code {
    background: none;
    padding: var(--space-12);
    font-size: 0.85rem;
    line-height: 1.5;
    display: block;
    white-space: pre;
    overflow-x: auto;
    width: fit-content;
    min-width: 100%;
    padding-bottom: var(--doc-text-spacing);
}


.section-container {
    overflow: hidden;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Sticky Container Component */
.section-container--sticky {
    position: static;
    height: auto;
    overflow: visible;
}


h2.overview-title {
    font-size: 1rem;
    opacity: 0.8;
    font-weight: 200;
    font-style: italic;
    margin: 0px 0px;
    padding: 0px;
}

p.overview-text {
    font-size: 0.75rem;
    opacity: 0.8;
    line-height: 1.5rem;
    letter-spacing: 0.03rem;
    font-style: italic;
    margin: 3px 0px 30px 0px;
}

/* Color Grid Component */
.color-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--gap);
    margin: var(--space-24) 0;
    min-width: 0;
}

.color-swatch {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
    margin-bottom: var(--space-12);
}

.color-block {
    height: var(--space-42);
    width: 100%;
    max-width: 25vw;
    border: 1px solid var(--color-foreground-darker);
    border-radius: var(--space-42);
    margin: 0px auto;
}

/* Table of Contents Component */
.toc-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-right: var(--space-12);
}

.toc-content::-webkit-scrollbar {
    display: none;
}

/* Documentation Layout */
.documentation {
    width: 100%;
    max-width: 100vw;
    overflow-x: scroll;
    /* Use clip instead of hidden for better containment */
    box-sizing: border-box;
}

/* Color Palette Visualization */
.color-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    margin: var(--space-60) 0 var(--space-24) 0;
    min-width: 0;
}

.color-swatch {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}

.color-info {
    display: flex;
    flex-direction: column;
    gap: calc(var(--gap) / 2);
    min-width: 0;
    align-items: center;
}

.color-swatch code {
    display: block;
    font-size: 0.66rem;
    background: none;
    padding: 0;
    min-width: 0;
}

.color-swatch p {
    font-size: 0.66rem;
    text-align: center;
    color: var(--color-foreground-darker);
    margin: 0;
}


/* License Specific Classes */
.content-container .definition-item {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.content-container .subclause-item {
    padding-left: 2rem;
    margin: 0.5rem 0;
}

.content-container .subclause-item::before {
    content: "•";
    margin-right: 0.5rem;
    color: var(--color-foreground-darker);
}

/* Ensure all sections maintain containment */
.documentation section {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    box-sizing: border-box;
    margin-top: var(--space-18);
}

.section-main-page {
    border-top: 1px solid var(--color-background-brighter);
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    /* Use clip instead of hidden for better containment */
    box-sizing: border-box;
}

/* Section Container Overrides */
.section-container {
    overflow: hidden;
    /* Contain all overflow by default */
    min-width: 0;
    /* Prevent flex item overflow */
    width: 100%;
    box-sizing: border-box;
}

.section-container--scrollable {
    overflow: auto;
    /* Allow scrolling when needed */
    height: auto;
}

/* Ensure code blocks can still scroll horizontally within the contained section */
.section-container pre {
    max-width: 100%;
    overflow: hidden;
    /* Hide overflow at pre level */
}

.section-container pre code {
    overflow-x: auto;
    /* Enable horizontal scrolling only for code content */
}

/* Documentation Sections */
.documentation section {
    margin-bottom: 3rem;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    box-sizing: border-box;
    margin-top: var(--space-18);
}

.documentation section:last-child {
    margin-bottom: 0;
}

/* Technical Documentation Container */
#technical-documentation {
    border-top: 1px solid var(--color-foreground);
    margin-top: 3rem;
    padding-top: 2rem;
}

/* Color Info Styles */
.color-info code {
    display: inline-block;
    text-align: center;
    line-height: 1.2;
}

.color-info code .modifier {
    display: block;
    opacity: 0.8;
    font-size: 0.9em;
    line-height: 1.8rem;
}

/* Table of Contents Styles */
.toc-content {
    max-height: calc(100vh - 200px);
    /* Leave space for header */
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
    padding-right: 20px;
    /* Add some padding to account for hidden scrollbar */
}

.toc-content::-webkit-scrollbar {
    display: none;
}

/* Toggle Functionality */
.toc-content.hidden {
    display: none;
}

.hide-show_arrow.active {
    transform: rotate(180deg);
}

/* Contents Section */
#contents.section {
    padding: 0;
}

#contents .section {
    margin-bottom: var(--gap);
}

#contents .section:last-child {
    margin-bottom: 0;
}

/* Input Container */
.input-container {
    padding: 0 12px 12px 12px;
}

.input-container.hidden {
    display: none;
}

/* Documentation List */
.doc-list {
    margin: 0;
    padding: 0;
}

.doc-list li {
    margin: 8px 0px 0px 15px;
    list-style: decimal-leading-zero;
}

/* Desktop Styles (min-width: 900px) */
@media screen and (min-width: 900px) {

    /* Content Container */
    .content-container {
        font-size: 0.9rem;
        max-width: 800px;
        padding: var(--space-18);
        margin: 2rem 0;
    }


    /* Typography */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    h4 {
        font-size: 1.11rem;
    }

    p {
        font-size: 0.9rem;
    }

    /* Code Sections */
    pre code {
        font-size: 0.9rem;
    }

    /* Color Grid */
    .color-grid {
        grid-template-columns: repeat(3, 1fr);
        margin: var(--space-60) 0 var(--space-24) 0;
    }

    .color-block {
        width: auto;
        max-width: 300px;
        margin: 0 var(--space-12);
    }

    /* Sticky Container - adjusted for documentation page */
    .documentation-page .section-container--sticky {
        position: sticky;
        top: calc(var(--secondary-header-height) + var(--gap) + 6px);
        /* Fixed height to prevent dynamic sizing issues */
        height: calc(100vh - var(--secondary-header-height) - var(--gap) - 12px);
        max-height: calc(100vh - var(--secondary-header-height) - var(--gap) - 12px);
        min-height: calc(100vh - var(--secondary-header-height) - var(--gap) - 12px);
        overflow-y: auto;
        overflow-x: hidden;
        /* Prevent bounce by using proper overflow */
        overscroll-behavior: contain;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        /* Ensure consistent sizing */
        flex-shrink: 0;
    }

    /* Adjust height when header menu is visible */
    .documentation-page:not(:has(.header-menu.header-hidden)) .section-container--sticky {
        height: calc(100vh - var(--header-height) - var(--secondary-header-height) - var(--gap) - 12px);
        max-height: calc(100vh - var(--header-height) - var(--secondary-header-height) - var(--gap) - 12px);
    }


    /* Layout */
    .split_390-100pcnt {
        flex-direction: row;
        grid-template-columns: 360px 1fr;
    }

}

/* Mobile Documentation Layout - FAQ Style Collapsible Sections */
@media screen and (max-width: 899px) {

    /* Keep secondary header visible on mobile documentation page */
    .documentation-page .secondary-header {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: var(--z-secondary-header);
    }

    /* Remove sticky behavior and adjust heights for mobile */
    .documentation-page .section-container.split_100pcnt {
        position: static !important;
        height: auto !important;
        max-height: none !important;
        top: auto !important;
    }

    /* Remove scroll padding since no sticky header */
    .documentation-page {
        scroll-padding-top: 0 !important;
    }

    /* Override desktop sticky/height constraints on mobile */
    .documentation-page .section-container.split_100pcnt {
        position: static !important;
        height: auto !important;
        max-height: none !important;
        top: auto !important;
        overflow: visible !important;
        flex-shrink: 1 !important;
        contain: none !important;
    }

    /* Override main layout mobile styles for documentation page */
    .documentation-page .split_390-100pcnt {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .documentation-page .split_100pcnt {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        position: static !important;
    }

    /* Remove scrollable behavior from main content area on mobile */
    .documentation-page .section-main-page {
        height: auto !important;
        overflow: visible !important;
        position: static !important;
        border: none !important;
        padding: 0 !important;
        background-color: var(--color-background-darker);
        -webkit-overflow-scrolling: auto !important;
        overscroll-behavior: auto !important;
        scroll-behavior: auto !important;
    }

    /* Remove height constraints from documentation container */
    .documentation-page .documentation {
        min-height: auto !important;
        height: auto !important;
        padding: var(--space-18) !important;
        border: 1px solid var(--color-background-brighter);
        background-color: var(--color-background);
    }

    /* Hide sidebar completely on mobile */
    .documentation-page .split_390 {
        display: none !important;
    }

    /* Make content area full width and visible */
    .documentation-page .split_100pcnt {
        width: 100% !important;
        display: block !important;
    }



    /* Convert each documentation section to collapsible card */
    .documentation-page .documentation section {
        border: 0px solid var(--color-background-brighter) !important;
        border-radius: 4px !important;
        margin-bottom: var(--gap) !important;
        overflow: hidden !important;
        display: block !important;
    }

    /* Show all documentation sections on mobile */
    .documentation-page .documentation section {
        display: block !important;
    }

    /* Mobile group headers - show on mobile only */
    .mobile-group-header {
        display: block !important;
        border-top: 1px solid var(--color-foreground);
        font-size: 1.5rem;
        font-weight: 600;
        color: var(--color-foreground);
        padding: var(--space-24) 0 var(--space-12) 0;
        margin: 60px 0px 0px 0px;
        background: var(--color-background);
        text-align: left;
    }
    
    /* First mobile group header has no top margin */
    .mobile-group-header:first-of-type {
        margin-top: 0px;
    }

    /* Show mobile section headers only on mobile - EXACT copy of .section-header */
    .documentation section .mobile-section-header {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        height: fit-content;
        padding: 0px;
        background: var(--color-background);
        border-bottom: 0px solid var(--color-background-brighter);
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    .documentation section .mobile-section-header:hover {
        background: var(--color-background-darker);
    }

    /* EXACT copy of .control-label */
    .documentation section .mobile-section-header .control-label {
        color: var(--color-foreground);
        font-size: 1rem;
        line-height: 1.5rem;
        font-weight: 200;
        text-transform: capitalize;
        opacity: 1;
    }

    /* EXACT copy of .hide-show_arrow */
    .documentation section .mobile-section-header .hide-show_arrow {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        margin: 0 0 0 18px;
        padding: 0;
        background: transparent;
        border: 0;
        cursor: pointer;
        vertical-align: middle;
        transition: none;
        transform: rotate(180deg);
    }

    .documentation section .mobile-section-header .hide-show_arrow svg {
        width: 21px;
        height: 21px;
        color: var(--color-foreground);
        transition: none;
    }

    .documentation section .mobile-section-header .hide-show_arrow:hover svg {
        color: var(--color-foreground);
    }

    /* Rotate arrow to point up when expanded */
    .documentation section .mobile-section-header .hide-show_arrow.active {
        transform: rotate(0deg);
    }

    /* Content area that gets collapsed */
    .documentation section .mobile-section-content {
        padding: 16px 0px;
        background: var(--color-background);
        transition: none;
        display: block;
    }

    /* Hidden state */
    .documentation section .mobile-section-content.hidden {
        display: none !important;
    }

 

    /* Hide h1 titles inside mobile sections since title is in header */
    .documentation section .mobile-section-content h1 {
        display: none !important;
    }

    /* Adjust content spacing for mobile cards */
    .documentation section .mobile-section-content h2 {
        margin-top: 60px;
        font-size: 1.5rem;
    }

    .documentation section .mobile-section-content p:first-child {
        margin-top: 0;
    }

    .documentation section .mobile-section-content p:last-child {
        margin-bottom: 0;
    }
}