/* SHTnsKit.jl Custom Documentation Styles */

/* ===== Color Palette ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #7c3aed;
    --accent-color: #06b6d4;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-light: #f8fafc;
    --bg-code: #1e293b;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --gradient-start: #2563eb;
    --gradient-end: #7c3aed;
    --card-bg: #ffffff;
    --body-bg: #ffffff;
    --hover-bg: #e0e7ff;
    --inline-code-bg: #f1f5f9;
    --inline-code-color: #1d4ed8;
}

/* ===== Global UX ===== */
html {
    scroll-behavior: smooth;
}

/* ===== Hero Section Styling ===== */
.hero-banner {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    padding: 2.5rem 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-banner::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.hero-banner h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: white;
    border-bottom: none;
    padding-bottom: 0;
}

.hero-banner p {
    font-size: 1.15rem;
    opacity: 0.92;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== Feature Cards ===== */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin: 1.75rem 0;
}

.feature-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.35rem 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.feature-card h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
}

.feature-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.feature-card .icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ===== Code Blocks ===== */
pre {
    border-radius: 8px !important;
    border: 1px solid var(--border-color) !important;
    position: relative;
}

code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace !important;
    font-size: 0.9em !important;
}

/* Inline code */
p code, li code, td code {
    background: var(--inline-code-bg) !important;
    padding: 0.15rem 0.4rem !important;
    border-radius: 4px !important;
    color: var(--inline-code-color) !important;
    font-size: 0.85em !important;
}

/* ===== Tables ===== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

thead {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border: none !important;
}

thead th a {
    color: white !important;
}

tbody tr {
    transition: background-color 0.15s;
}

tbody tr:nth-child(even) {
    background: var(--bg-light);
}

tbody tr:hover {
    background: var(--hover-bg);
}

tbody td {
    padding: 0.875rem 1rem;
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
}

/* ===== Admonitions ===== */
.admonition {
    border-radius: 8px !important;
    border-left: 4px solid !important;
    margin: 1.5rem 0 !important;
    padding: 1rem 1.25rem !important;
}

.admonition.note {
    background: #eff6ff !important;
    border-color: var(--primary-color) !important;
}

.admonition.tip {
    background: #ecfdf5 !important;
    border-color: var(--success-color) !important;
}

.admonition.warning {
    background: #fffbeb !important;
    border-color: var(--warning-color) !important;
}

.admonition.danger {
    background: #fef2f2 !important;
    border-color: var(--danger-color) !important;
}

.admonition.info {
    background: #f0f9ff !important;
    border-color: var(--accent-color) !important;
}

.admonition-title {
    font-weight: 700 !important;
    margin-bottom: 0.5rem !important;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-cpu {
    background: #dbeafe;
    color: #1e40af;
}

.badge-gpu {
    background: #d1fae5;
    color: #065f46;
}

.badge-mpi {
    background: #fae8ff;
    color: #86198f;
}

.badge-new {
    background: #fef3c7;
    color: #92400e;
}

/* ===== Performance Box ===== */
.performance-box {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.performance-box h3 {
    color: var(--accent-color);
    margin-top: 0;
}

.performance-box table {
    box-shadow: none;
}

.performance-box thead {
    background: rgba(255, 255, 255, 0.1);
}

.performance-box tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

.performance-box tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===== Quick Links Grid ===== */
.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none !important;
    color: var(--text-dark) !important;
    transition: all 0.2s;
}

.quick-link:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.quick-link .icon {
    font-size: 1.5rem;
}

.quick-link .link-text {
    display: flex;
    flex-direction: column;
}

.quick-link .link-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.quick-link .link-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.3;
}

/* ===== Section Dividers ===== */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 2.5rem 0;
}

/* ===== Sidebar Enhancements ===== */
.docs-sidebar {
    border-right: 1px solid var(--border-color);
}

.docs-sidebar .docs-logo img {
    max-width: 180px;
}

.docs-sidebar li.is-active > a {
    font-weight: 700;
    color: var(--primary-color) !important;
    border-left: 3px solid var(--primary-color);
    padding-left: calc(1rem - 3px);
}

/* ===== Headings ===== */
h1 {
    color: var(--text-dark);
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

h2 {
    color: var(--primary-dark);
    margin-top: 2.5rem;
}

h3 {
    color: var(--secondary-color);
}

/* Anchor links on hover */
h2:hover .docs-heading-anchor,
h3:hover .docs-heading-anchor {
    opacity: 1;
}

.docs-heading-anchor {
    opacity: 0;
    transition: opacity 0.15s;
}

/* ===== Copy Button for Code ===== */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--primary-dark);
}

/* ===== Figure Lightbox ===== */
.grid-pattern-figure {
    max-width: 960px;
    margin: 1.75rem auto 2rem;
    padding: 0.75rem 0.75rem 0.9rem;
    overflow: hidden;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    cursor: zoom-in;
    transition: box-shadow 0.2s;
}

.grid-pattern-figure:hover {
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.13);
}

.grid-pattern-figure picture,
.grid-pattern-figure img {
    display: block;
    width: 100%;
}

.grid-pattern-figure img {
    height: auto;
    border-radius: 9px;
}

.grid-pattern-figure figcaption {
    max-width: 74ch;
    margin: 0.75rem auto 0;
    padding: 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: center;
}

.figure-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s;
    padding: 2rem;
}

.figure-lightbox.active {
    opacity: 1;
}

.figure-lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ===== Content Width Comfort ===== */
.content {
    max-width: 52rem;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .hero-banner {
        padding: 1.5rem 1rem;
    }

    .hero-banner h1 {
        font-size: 1.75rem;
    }

    table {
        font-size: 0.875rem;
    }

    thead th, tbody td {
        padding: 0.5rem;
    }

    .quick-links {
        grid-template-columns: 1fr;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .hero-banner {
        background: #f3f4f6;
        color: black;
    }

    .feature-card {
        break-inside: avoid;
    }

    .back-to-top {
        display: none;
    }
}

/* ===== Animation for Interactive Elements ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.feature-card, .admonition {
    animation: fadeIn 0.3s ease-out;
}

/* ===== Tooltip Styles ===== */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--text-dark);
    color: white;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ============================================================
   DARK MODE — Documenter.jl theme toggle
   ============================================================ */
html.theme--documenter-dark {
    --primary-color: #60a5fa;
    --primary-dark: #93bbfc;
    --secondary-color: #a78bfa;
    --accent-color: #22d3ee;
    --success-color: #34d399;
    --warning-color: #fbbf24;
    --danger-color: #f87171;
    --bg-light: #1e293b;
    --bg-code: #0f172a;
    --text-dark: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --gradient-start: #1e40af;
    --gradient-end: #6d28d9;
    --card-bg: #1e293b;
    --body-bg: #0f172a;
    --hover-bg: #1e3a5f;
    --inline-code-bg: #1e293b;
    --inline-code-color: #93bbfc;
}

html.theme--documenter-dark .hero-banner {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
}

html.theme--documenter-dark .feature-card {
    background: var(--card-bg);
    border-color: var(--border-color);
}

html.theme--documenter-dark .feature-card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

html.theme--documenter-dark .feature-card p {
    color: var(--text-muted);
}

html.theme--documenter-dark thead {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #0f172a;
}

html.theme--documenter-dark thead th {
    color: #0f172a;
}

html.theme--documenter-dark thead th a {
    color: #0f172a !important;
}

html.theme--documenter-dark tbody tr:hover {
    background: var(--hover-bg);
}

html.theme--documenter-dark .admonition.note {
    background: #172554 !important;
}

html.theme--documenter-dark .admonition.tip {
    background: #052e16 !important;
}

html.theme--documenter-dark .admonition.warning {
    background: #422006 !important;
}

html.theme--documenter-dark .admonition.danger {
    background: #450a0a !important;
}

html.theme--documenter-dark .admonition.info {
    background: #083344 !important;
}

html.theme--documenter-dark .admonition-title {
    color: var(--text-dark) !important;
}

html.theme--documenter-dark .badge-cpu {
    background: #1e3a5f;
    color: #93c5fd;
}

html.theme--documenter-dark .badge-gpu {
    background: #064e3b;
    color: #6ee7b7;
}

html.theme--documenter-dark .badge-mpi {
    background: #4a1d6a;
    color: #d8b4fe;
}

html.theme--documenter-dark .badge-new {
    background: #451a03;
    color: #fcd34d;
}

html.theme--documenter-dark .quick-link {
    background: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-dark) !important;
}

html.theme--documenter-dark .quick-link:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.15);
}

html.theme--documenter-dark .quick-link .link-desc {
    color: var(--text-muted);
}

html.theme--documenter-dark .grid-pattern-figure {
    background: #1e293b;
    border-color: #475569;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

html.theme--documenter-dark .grid-pattern-figure:hover {
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

html.theme--documenter-dark .grid-pattern-figure figcaption {
    color: #cbd5e1;
}

html.theme--documenter-dark hr {
    background: linear-gradient(90deg, transparent, #475569, transparent);
}

html.theme--documenter-dark .docs-sidebar {
    border-right-color: var(--border-color);
}

html.theme--documenter-dark .docs-sidebar li.is-active > a {
    color: var(--primary-color) !important;
    border-left-color: var(--primary-color);
}

html.theme--documenter-dark [data-tooltip]::after {
    background: #f1f5f9;
    color: #0f172a;
}

html.theme--documenter-dark .back-to-top {
    background: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

html.theme--documenter-dark .back-to-top:hover {
    background: #60a5fa;
}

html.theme--documenter-dark pre {
    border-color: var(--border-color) !important;
}

html.theme--documenter-dark .figure-lightbox {
    background: rgba(0, 0, 0, 0.92);
}

@media (max-width: 700px) {
    .grid-pattern-figure {
        margin-right: -0.35rem;
        margin-left: -0.35rem;
        padding: 0.4rem 0.4rem 0.7rem;
        border-radius: 10px;
    }

    .grid-pattern-figure figcaption {
        font-size: 0.82rem;
    }
}
