:root {
    /* LIS Color Palette */
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #f8f9fa;
    --color-accent-cyan: #0693e3;
    --color-accent-purple: #9b51e0;
    --color-text-primary: #32373c;
    --color-text-secondary: #555555;
    --color-border: #e0e0e0;
    --color-gray-light: #abb8c3;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 2rem;
}

body {
    font-family: 'Lora', Georgia, serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
}

/* Utility Classes */
.bg-primary {
    background-color: var(--color-bg-primary);
}

.bg-secondary {
    background-color: var(--color-bg-secondary);
}

.bg-accent-cyan {
    background-color: var(--color-accent-cyan);
}

.bg-accent-purple {
    background-color: var(--color-accent-purple);
}

.border-custom {
    border-color: var(--color-border);
}

.text-accent-cyan {
    color: var(--color-accent-cyan);
}

.text-accent-purple {
    color: var(--color-accent-purple);
}

/* Heading anchor links */
.heading-anchor {
    position: relative;
}

.heading-anchor .anchor-link {
    position: absolute;
    left: -2rem;
    opacity: 0;
    color: #9ca3af;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.9em;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.heading-anchor:hover .anchor-link {
    opacity: 0.5;
}

.anchor-link:hover {
    opacity: 1 !important;
    color: #6b7280;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

.article-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.3;
    scroll-margin-top: 2rem;
}

.article-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    scroll-margin-top: 2rem;
}

.article-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.article-content p {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 1.25rem;
    color: var(--color-text-primary);
}

.article-content ul, .article-content ol {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
    list-style-position: outside;
}

.article-content ul {
    list-style-type: disc;
}

.article-content ol {
    list-style-type: decimal;
}

.article-content li {
    margin-bottom: 0.35rem;
}

.article-content a {
    color: var(--color-accent-cyan);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.article-content a:hover {
    color: var(--color-accent-purple);
}

.article-content code {
    background-color: var(--color-bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

/* KaTeX equations */
.article-content .katex {
    font-size: 1.1em;
}

.article-content .katex-display {
    margin: 1.5rem 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Video and figure captions */
.caption {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--color-text-secondary);
}

.article-content .expandable-media p,
.article-content figure p {
    font-size: 0.925rem;
    margin-bottom: 0;
    color: var(--color-text-secondary);
}

.expandable-media {
    position: relative;
}

.expandable-media img {
    display: block;
    transition: box-shadow 0.2s ease;
}

.expandable-media::after {
    content: "";
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background-color: rgba(15, 23, 42, 0.6);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H3v5'/%3E%3Cpath d='M16 3h5v5'/%3E%3Cpath d='M21 16v5h-5'/%3E%3Cpath d='M3 16v5h5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 14px;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.expandable-media:hover img {
    box-shadow: 0 0 0 3px rgba(6, 147, 227, 0.25), 0 14px 30px rgba(15, 23, 42, 0.08);
}

.expandable-media:hover::after {
    opacity: 1;
    transform: translateY(0);
}

@media (hover: none) {
    .expandable-media::after {
        opacity: 0.9;
        transform: translateY(0);
    }
}

.fullscreen-video-wrap {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}

.fullscreen-video-wrap video {
    display: block;
    width: 100%;
}

.fullscreen-video-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
    z-index: 1;
    pointer-events: none;
}

.fullscreen-video-wrap::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    width: 38px;
    height: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H3v5'/%3E%3Cpath d='M16 3h5v5'/%3E%3Cpath d='M21 16v5h-5'/%3E%3Cpath d='M3 16v5h5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 38px 38px;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 2;
}

.fullscreen-video-wrap:hover::before {
    background: rgba(0, 0, 0, 0.25);
}

.fullscreen-video-wrap:hover::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

@media (hover: none) {
    .fullscreen-video-wrap::before,
    .fullscreen-video-wrap::after {
        display: none;
    }
}

.author-link {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.author-link:hover {
    color: var(--color-accent-cyan);
    border-bottom-color: var(--color-accent-cyan);
}

.page-link {
    color: var(--color-accent-cyan);
    text-decoration: none;
    transition: color 0.2s ease;
}

.page-link:hover {
    color: var(--color-accent-purple);
}

/* Video Wrapper */
.video-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.video-wrapper video {
    display: block;
    width: 100%;
}

/* Info Box */
.info-box {
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background-color: var(--color-bg-secondary);
}

.info-box-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Table of Contents */
.page-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    max-width: calc(64rem + 200px + 2rem);
    margin: 0 auto;
    padding: 0 2rem;
}

.toc-container {
    position: sticky;
    top: 8rem;
    width: 200px;
    max-width: 200px;
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
    box-sizing: border-box;
    flex: 0 0 200px;
}

/* Page-specific TOC offsets */
.page-index .toc-container {
    top: 20rem;
}

.page-implementation .toc-container {
    top: 18rem;
}

.page-results .toc-container {
    top: 20rem;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.toc-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-nav li {
    margin-bottom: 0.5rem;
}

.toc-nav a {
    display: block;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1.4;
    padding: 0.25rem 0;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.toc-nav a:hover {
    color: var(--color-accent-cyan);
    border-left-color: var(--color-accent-cyan);
}

.toc-nav a.toc-link--active {
    border-left-color: #6b7280;
}

.toc-link-indent {
    margin-left: 1.25rem;
    padding-left: 0.75rem !important;
    font-size: 0.8125rem !important;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.main-content-wrapper {
    flex: 1 1 auto;
    min-width: 0;
}

/* Responsive design */
@media (max-width: 1200px) {
    .toc-container {
        display: none;
    }

    .page-layout {
        max-width: 64rem;
        padding: 0 0.5rem;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }

    .article-content h2 {
        font-size: 1.5rem;
    }

    .article-content h3 {
        font-size: 1.1rem;
    }

    .article-content p {
        font-size: 0.95rem;
    }

    /* Hide anchor links on mobile to prevent overflow */
    .heading-anchor .anchor-link {
        display: none;
    }
}

/* Video Player Styles */
/* Responsive play button sizing */
#play-button-circle, #overview-play-button-circle {
    width: 60px;
    height: 60px;
}

#play-button-icon, #overview-play-button-icon {
    width: 28px;
    height: 28px;
}

/* Tablet and up */
@media (min-width: 640px) {
    #play-button-circle, #overview-play-button-circle {
        width: 80px;
        height: 80px;
    }
    #play-button-icon, #overview-play-button-icon {
        width: 40px;
        height: 40px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    #play-button-circle, #overview-play-button-circle {
        width: 120px;
        height: 120px;
    }
    #play-button-icon, #overview-play-button-icon {
        width: 56px;
        height: 56px;
    }
}

/* Hide video controls until hover (only for videos in video-wrapper) */
.video-wrapper video::-webkit-media-controls {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-wrapper:hover video::-webkit-media-controls {
    opacity: 1;
}

.video-wrapper video::-webkit-media-controls-enclosure {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-wrapper:hover video::-webkit-media-controls-enclosure {
    opacity: 1;
}

/* Citation and Bibliography Styles */
cite {
    font-style: normal;
}

.citation-link {
    color: var(--color-accent-purple);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.citation-link:hover {
    color: var(--color-accent-cyan);
}

.bibliography-list {
    list-style: decimal;
    padding-left: 2rem;
    margin-top: 1rem;
}

.bibliography-item {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--color-text-primary);
}

.bibliography-item a {
    color: var(--color-accent-purple);
    text-decoration: none;
    transition: color 0.2s ease;
}

.bibliography-item a:hover {
    color: var(--color-accent-cyan);
}

/* Lightbox for images */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: zoom-out;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
    background: none;
    border: none;
    line-height: 1;
}

.lightbox-close:hover {
    color: var(--color-accent-cyan);
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95%;
    max-height: 95%;
    cursor: default;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    cursor: default;
}

.lightbox-caption {
    color: #ffffff;
    text-align: center;
    padding: 12px 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 800px;
    margin-top: 12px;
}

.lightbox-caption code {
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
}

/* Bar Charts */
.bar-chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.bar-chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.bar-chart-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.bar-chart-plot {
    position: relative;
    height: 200px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    margin-left: 36px;
    overflow: visible;
}

.bar-chart-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

.bar-chart-gridline {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed var(--color-border);
}

.bar-chart-gridline span {
    position: absolute;
    right: calc(100% + 6px);
    top: -0.55em;
    font-size: 0.7rem;
    color: var(--color-text-secondary);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.bar {
    width: 5em;
    height: 0;
    border-radius: 4px 4px 0 0;
    position: relative;
    cursor: default;
    transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.bar.animated {
    height: var(--bar-height);
}

.bar--primary {
    background-color: #38bdf8;
}

.bar--secondary {
    background-color: #ff8dc8;
}

.bar::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-text-primary);
    color: #ffffff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.bar:hover::before {
    opacity: 1;
}

.bar-chart-column-title {
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

@media (max-width: 767px) {
    .bar-chart-column + .bar-chart-column {
        padding-top: 1rem;
    }

    .bar {
        width: 10em;
    }
}

@media (max-width: 475px) {
    .bar {
        width: 6em;
    }
}

/* Needs Update Highlight - for content that needs to be changed later */
.needs-update {
    background-color: #fef3c7;
    color: #92400e;
    font-weight: 600;
}
