/**
 * ACM TAPS-style CSS for academic papers
 * Professional, clean, and readable design
 */

/* ========== CSS Reset & Base Styles ========== */

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

html {
    font-size: 16px;
    line-height: 1.6;
    scroll-behavior: smooth;
}

body {
    font-family: "Charter", "Georgia", "Times New Roman", serif;
    color: #1a1a1a;
    background-color: #ffffff;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
}

/* ========== Typography ========== */

h1, h2, h3, h4, h5, h6 {
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #000;
}

h1 {
    font-size: 2rem;
    margin-top: 0;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.25rem;
    margin-top: 2rem;
}

h3 {
    font-size: 1.25rem;
}

h4 {
    font-size: 1.1rem;
}

p {
    margin-bottom: 1rem;
    text-align: justify;
    hyphens: none;
}

a {
    color: #0066cc;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #004499;
    text-decoration: underline;
}

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

.smallcaps {
    font-variant: small-caps;
    letter-spacing: 0.05em;
}

/* ========== Main Container ========== */

.acm-paper {
    background: white;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========== Header Section ========== */

.paper-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 3px solid #333;
}

.paper-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.authors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem 2rem;
    margin: 1.5rem auto;
    max-width: 900px;
}

.author {
    text-align: center;
}

.author-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.author-email {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.35rem;
}

.author-affiliation {
    font-size: 0.875rem;
    color: #444;
    line-height: 1.4;
}

.author-affiliation-line {
    display: block;
}

.orcid {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    text-decoration: none;
}

.conference-info {
    margin-top: 1rem;
    font-style: italic;
    color: #555;
}

.publication-meta {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #666;
}

/* ========== Video Embed ========== */

.paper-video {
    margin: 2rem 0;
    width: 100%;
    text-align: left;
}

.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;  /* 16:9 aspect ratio */
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ========== Abstract & Keywords ========== */

.abstract {
    background: #f9f9f9;
    border-left: 4px solid #0066cc;
    padding: 1.5rem;
    margin: 2rem 0;
}

.abstract h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: none;
}

.ccs-concepts {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

.ccs-concepts h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.ccs-concepts ul {
    list-style: none;
    font-size: 0.9rem;
    color: #444;
}

.ccs-concepts li:before {
    content: "• ";
    color: #0066cc;
    font-weight: bold;
    margin-right: 0.5rem;
}

.keywords {
    margin-top: 1rem;
    font-size: 0.9rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

/* ========== Action Bar (Cite & Download) ========== */

.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 1.5rem 0 2rem;
    padding: 1rem 1.25rem;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-family: "Helvetica Neue", "Arial", sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.cite-btn,
.bibtex-btn {
    background: #fff;
    color: #333;
    border: 1px solid #ccc;
}

.bibtex-btn {
    background: #f0f7ff;
    border-color: #9dc2f5;
    color: #1f4e79;
}

.cite-btn:hover,
.bibtex-btn:hover {
    background: #f0f0f0;
    border-color: #999;
}

.bibtex-btn:hover {
    background: #e2eefc;
    border-color: #6ea4ee;
    color: #1a4470;
}

.cite-btn.copied,
.bibtex-btn.copied {
    background: #e8f5e9;
    border-color: #66bb6a;
    color: #2e7d32;
}

.pdf-btn {
    background: #d6001c;
    color: #fff;
    border: 1px solid #d6001c;
}

.pdf-btn:hover {
    background: #b3001a;
    border-color: #b3001a;
    color: #fff;
    text-decoration: none;
}

.action-label {
    pointer-events: none;
}

.citation-text {
    flex-basis: 100%;
    font-size: 1rem;
    line-height: 1.55;
    color: #1a1a1a;
    margin-top: 0.25rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
}

@media (max-width: 600px) {
    .action-bar {
        padding: 0.75rem;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }
}

/* ========== Teaser Figure ========== */

.teaser-figure {
    margin: 2rem 0;
    text-align: center;
}

.teaser-figure img,
.teaser-figure object,
.teaser-figure embed {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.teaser-figure figcaption {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #444;
    text-align: left;
    padding: 0 2rem;
}

/* ========== Main Content ========== */

.content {
    /* Single-column layout by default */
    margin-top: 2rem;
}

/* Two-column layout - only when explicitly enabled */
.content.two-column {
    column-count: 2;
    column-gap: 2rem;
    column-rule: 1px solid #e0e0e0;
}

.section {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

.section h2,
.section h3,
.section h4 {
    break-after: avoid;
}

/* Prevent column breaks in certain elements */
figure,
table,
.citation-preview {
    break-inside: avoid;
}

/* ========== Figures ========== */

figure {
    margin: 1.5rem 0;
    text-align: center;
}

figure img,
figure object,
figure embed {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
}

.figure-media {
    width: 100%;
    display: block;
}

.figure-pdf {
    height: 520px;
}

.figure-pdf-frame {
    width: 100%;
    aspect-ratio: var(--pdf-w) / var(--pdf-h);
}

.figure-pdf-frame .figure-pdf {
    width: 100%;
    height: 100%;
}

.figure-media-wrapper {
    position: relative;
    display: block;
    max-width: 100%;
}

.figure-description {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-height: 50%;
    overflow: auto;
    pointer-events: none;
}

.figure-media-wrapper:hover .figure-description,
.figure-media-wrapper:focus .figure-description,
.figure-media-wrapper:focus-within .figure-description {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .figure-description {
        transition: none;
        transform: none;
    }
}

figcaption {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #444;
    text-align: left;
}

/* ========== Tables ========== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.875rem;
}

th, td {
    padding: 0.5rem;
    border: 1px solid #ddd;
    text-align: left;
}

th {
    background: #f5f5f5;
    font-weight: 600;
}

caption {
    caption-side: top;
    text-align: left;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* ========== Lists ========== */

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

li {
    margin-bottom: 0.5rem;
}

/* ========== Citations & References ========== */

.citation-group {
    white-space: nowrap;
}

.citation {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    cursor: pointer;
}

.citation:hover {
    text-decoration: underline;
    background-color: #fffacd;
}

.citation.active {
    background-color: #ffeb3b;
}

/* Citation preview tooltip */
.citation-preview {
    position: absolute;
    background: white;
    border: 1px solid #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    padding: 0.75rem;
    max-width: 350px;
    z-index: 1000;
    font-size: 0.875rem;
    line-height: 1.4;
    display: none;
}

.citation-preview.visible {
    display: block;
}

.citation-preview .preview-authors {
    font-weight: 600;
    color: #333;
}

.citation-preview .preview-title {
    margin-top: 0.25rem;
    font-style: italic;
    color: #444;
}

.citation-preview .preview-year {
    margin-top: 0.25rem;
    color: #666;
}

/* References section */
.references {
    column-span: all;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 3px solid #333;
}

.references h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

.reference-list {
    list-style: decimal;
    margin-left: 2rem;
}

.reference-list li {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: left;
}

.reference-list li.highlighted {
    background-color: #fffacd;
    padding: 0.5rem;
    margin-left: -0.5rem;
    border-radius: 4px;
}

/* ========== Math Rendering ========== */

.math {
    overflow-x: auto;
}

mjx-container {
    overflow-x: auto;
    overflow-y: hidden;
}

/* ========== Responsive Design ========== */

@media (max-width: 900px) {
    /* Ensure single column on tablets */
    .content.two-column {
        column-count: 1;
        column-rule: none;
    }

    .authors {
        grid-template-columns: repeat(2, minmax(200px, 1fr));
    }
}

@media (max-width: 600px) {
    /* Mobile adjustments */
    body {
        padding: 1rem 0.5rem;
    }

    .acm-paper {
        padding: 1rem;
    }

    .paper-title {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .teaser-figure figcaption {
        padding: 0;
    }

    p {
        text-align: left;
    }

    .authors {
        grid-template-columns: 1fr;
    }
}

/* ========== Print Styles ========== */

@media print {
    body {
        background: white;
        max-width: none;
    }

    .acm-paper {
        box-shadow: none;
    }

    .content {
        column-count: 2;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    .citation-preview {
        display: none !important;
    }
}

/* ========== Accessibility ========== */

/* Focus states for keyboard navigation */
a:focus,
.citation:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-main:focus {
    top: 0;
}
