/* ==========================================================================
   OutSail.pro Tutorials & Knowledge Hub Stylesheet
   Modern, blog-style reading layout with responsive image containers
   ========================================================================== */

:root {
    --tut-primary: #029ee1;
    --tut-primary-hover: #0178b0;
    --tut-dark: #0b1f2a;
    --tut-slate: #3b5b6b;
    --tut-muted: #64748b;
    --tut-border: rgba(2, 158, 225, 0.16);
    --tut-bg-light: #f6fbff;
    --tut-card-bg: #ffffff;
    --tut-radius: 12px;
    --tut-shadow-sm: 0 2px 8px rgba(11, 31, 42, 0.05);
    --tut-shadow-md: 0 8px 24px rgba(11, 31, 42, 0.08);
    --tut-shadow-lg: 0 16px 36px rgba(11, 31, 42, 0.12);
}

/* Base Container & Spacing */
.tutorials-page {
    background-color: var(--tut-bg-light);
    color: var(--tut-dark);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

.tutorials-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ==========================================================================
   Hero & Header Section (Light OutSail Theme)
   ========================================================================== */
.tutorials-hero {
    background:
        radial-gradient(circle at 18% 18%, rgba(2, 158, 225, 0.12), transparent 40%),
        radial-gradient(circle at 78% 10%, rgba(36, 182, 240, 0.09), transparent 38%),
        radial-gradient(circle at 70% 85%, rgba(1, 120, 176, 0.06), transparent 46%),
        #f6fbff;
    color: var(--tut-dark);
    padding: 3.5rem 1.5rem 2.5rem;
    text-align: center;
    position: relative;
    border-bottom: 1px solid rgba(2, 158, 225, 0.14);
}

.tutorials-hero-inner {
    max-width: 780px;
    margin: 0 auto;
}

.tutorials-hero h1 {
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
    color: var(--tut-dark);
    line-height: 1.25;
}

.tutorials-hero p {
    font-size: 1.15rem;
    color: var(--tut-slate);
    line-height: 1.6;
    margin-bottom: 1.75rem;
}

/* Language Selector Dropdown */
.lang-selector-dropdown {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(2, 158, 225, 0.22);
    box-shadow: 0 2px 10px rgba(11, 31, 42, 0.06);
    border-radius: 30px;
    padding: 4px;
    gap: 3px;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--tut-slate);
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: var(--tut-dark);
    background: rgba(2, 158, 225, 0.08);
}

.lang-btn.active {
    background: var(--tut-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(2, 158, 225, 0.35);
}

/* ==========================================================================
   Tutorials Catalog Grid (index.html)
   ========================================================================== */
.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
    margin-top: 2.5rem;
}

.tutorial-card {
    background: var(--tut-card-bg);
    border: 1px solid var(--tut-border);
    border-radius: var(--tut-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--tut-shadow-sm);
}

.tutorial-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--tut-shadow-md);
    border-color: rgba(2, 158, 225, 0.4);
}

.tutorial-card-img-wrapper {
    position: relative;
    width: 100%;
    height: 205px;
    background: #f0f7fb;
    overflow: hidden;
}

.tutorial-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.tutorial-card:hover .tutorial-card-img {
    transform: scale(1.03);
}

.tutorial-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.tutorial-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--tut-muted);
    margin-bottom: 0.75rem;
}

.tutorial-category-pill {
    background: rgba(2, 158, 225, 0.12);
    color: var(--tut-primary-hover);
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 6px;
}

.tutorial-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 0.75rem;
    color: var(--tut-dark);
}

.tutorial-card-desc {
    font-size: 0.95rem;
    color: var(--tut-slate);
    line-height: 1.55;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.tutorial-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--tut-border);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tut-primary);
}

/* ==========================================================================
   Single Tutorial Layout (post.html)
   Two-column on desktop: Sticky ToC (left) + Article Content (right)
   ========================================================================== */
.post-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3.5rem;
    align-items: start;
    margin-top: 2rem;
}

/* Sticky Sidebar (Table of Contents) */
.toc-sidebar {
    position: sticky;
    top: 2rem;
    background: var(--tut-card-bg);
    border: 1px solid var(--tut-border);
    border-radius: var(--tut-radius);
    padding: 1.5rem;
    box-shadow: var(--tut-shadow-sm);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tut-muted);
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: 0.5rem;
}

.toc-item.level-3 {
    padding-left: 1rem;
}

.toc-link {
    display: block;
    font-size: 0.9rem;
    color: var(--tut-slate);
    text-decoration: none;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.toc-link:hover {
    color: var(--tut-primary);
    background: #f0f9ff;
}

.toc-link.active {
    color: var(--tut-primary-hover);
    background: #e0f2fe;
    font-weight: 600;
}

/* Article Main Content */
.post-content-wrapper {
    min-width: 0; /* Prevents overflow in grid */
}

/* Fallback Notice Banner */
.fallback-banner {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.925rem;
    color: #92400e;
}

.post-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--tut-border);
}

.post-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--tut-muted);
    margin-bottom: 1rem;
}

.post-breadcrumbs a {
    color: inherit;
    text-decoration: none;
}

.post-breadcrumbs a:hover {
    color: var(--tut-primary);
}

.post-title {
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--tut-dark);
    line-height: 1.25;
    margin-bottom: 1rem;
}

.post-subtitle {
    font-size: 1.15rem;
    color: var(--tut-slate);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    font-weight: 400;
}

.post-meta-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--tut-muted);
}

/* ==========================================================================
   Typography & Markdown Elements
   ========================================================================== */
.post-body {
    font-size: 1.05rem;
    line-height: 1.75;
    color: #1e293b;
}

.post-body h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 3rem;
    margin-bottom: 1rem;
    color: var(--tut-dark);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.post-body h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--tut-dark);
}

.post-body p {
    margin-bottom: 1.35rem;
}

.post-body ul, .post-body ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.post-body li {
    margin-bottom: 0.5rem;
}

.post-body blockquote {
    background: #f8fafc;
    border-left: 4px solid var(--tut-primary);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
    color: var(--tut-slate);
}

.post-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #0f172a;
}

.post-body pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.post-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.95rem;
}

.post-body th, .post-body td {
    padding: 10px 14px;
    border: 1px solid var(--tut-border);
    text-align: left;
}

.post-body th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--tut-dark);
}

/* ==========================================================================
   Screenshot Framing Containers (Responsive Image System)
   ========================================================================== */
.tutorial-figure {
    margin: 2.25rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tutorial-img-card {
    background: #ffffff;
    border: 1px solid var(--tut-border);
    border-radius: var(--tut-radius);
    overflow: hidden;
    box-shadow: var(--tut-shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.tutorial-img-card:hover {
    box-shadow: var(--tut-shadow-md);
}

.tutorial-img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
}

/* Specific Sizes */
.tutorial-figure.img-wide .tutorial-img-card {
    max-width: 100%;
}

.tutorial-figure.img-modal .tutorial-img-card {
    max-width: 580px;
    background: #f8fafc;
    padding: 8px;
    border: 1px solid #cbd5e1;
}

.tutorial-figure.img-menu .tutorial-img-card {
    max-width: 380px;
    background: #f8fafc;
    padding: 6px;
    border: 1px solid #cbd5e1;
}

.tutorial-img-caption {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--tut-muted);
    text-align: center;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   Series Navigator (Bottom Prev / Next Cards)
   ========================================================================== */
.series-navigator {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--tut-border);
}

.series-nav-card {
    background: #ffffff;
    border: 1px solid var(--tut-border);
    border-radius: var(--tut-radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.series-nav-card:hover {
    border-color: var(--tut-primary);
    box-shadow: var(--tut-shadow-sm);
    transform: translateY(-2px);
}

.series-nav-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tut-muted);
    margin-bottom: 0.5rem;
}

.series-nav-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tut-dark);
}

.series-nav-card.next {
    text-align: right;
    margin-left: auto;
    width: 100%;
}

/* Bottom Call to Action (CTA) */
.tutorial-cta-banner {
    margin-top: 3.5rem;
    background: linear-gradient(135deg, #0178b0 0%, #003a52 100%);
    color: #ffffff;
    padding: 2.75rem 2rem;
    border-radius: var(--tut-radius);
    text-align: center;
    box-shadow: var(--tut-shadow-md);
}

.tutorial-cta-banner h3 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #ffffff;
}

.tutorial-cta-banner p {
    color: #e0f2fe;
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.tutorial-cta-btn {
    display: inline-block;
    background: #029ee1;
    color: #ffffff;
    font-weight: 700;
    padding: 10px 24px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(2, 158, 225, 0.35);
}

.tutorial-cta-btn:hover {
    background: #24b6f0;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(2, 158, 225, 0.45);
}

/* ==========================================================================
   Click-to-Zoom Lightbox Overlay
   ========================================================================== */
.tutorial-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tutorial-lightbox.active {
    display: flex;
    opacity: 1;
}

.tutorial-lightbox img {
    max-width: 95vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.96);
    transition: transform 0.25s ease;
}

.tutorial-lightbox.active img {
    transform: scale(1);
}

/* ==========================================================================
   Responsive Adaptations & Mobile Usability
   ========================================================================== */

/* Desktop Table of Contents (<details> behaves like permanent card) */
@media (min-width: 993px) {
    .toc-summary {
        list-style: none;
        cursor: default;
        pointer-events: none;
    }

    .toc-summary::-webkit-details-marker {
        display: none;
    }

    .toc-details > ul,
    .toc-details > div {
        display: block !important;
    }
}

/* Tablet & Large Mobile (<= 992px) */
@media (max-width: 992px) {
    .post-layout {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .toc-sidebar {
        position: relative;
        top: 0;
        max-height: none;
        padding: 0.85rem 1.15rem;
        background: #ffffff;
        border: 1px solid var(--tut-border);
        border-radius: var(--tut-radius);
        margin-bottom: 0.5rem;
        box-shadow: var(--tut-shadow-sm);
    }

    .toc-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        user-select: none;
        list-style: none;
        padding: 2px 0;
    }

    .toc-summary::-webkit-details-marker {
        display: none;
    }

    .toc-chevron {
        transition: transform 0.2s ease;
        color: var(--tut-muted);
        font-size: 1.1rem;
    }

    .toc-details[open] .toc-chevron {
        transform: rotate(180deg);
    }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    .tutorials-container {
        padding: 1.25rem 0.85rem 3.5rem;
    }

    .tutorials-hero {
        padding: 2.75rem 1rem 2rem;
    }

    .tutorials-hero h1 {
        font-size: 1.85rem;
    }

    .tutorials-hero p {
        font-size: 1rem;
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }

    /* Language selector wrap on mobile screens */
    .lang-selector-dropdown {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 3px;
        padding: 4px;
        border-radius: 20px;
        max-width: 100%;
    }

    .lang-btn {
        padding: 5px 9px;
        font-size: 0.8rem;
    }

    /* Article typography */
    .post-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }

    .post-title {
        font-size: 1.65rem;
        line-height: 1.3;
    }

    .post-subtitle {
        font-size: 1.05rem;
        line-height: 1.55;
    }

    .post-body {
        font-size: 1rem;
        line-height: 1.7;
    }

    .post-body h2 {
        font-size: 1.35rem;
        margin-top: 2.25rem;
    }

    .post-body h3 {
        font-size: 1.15rem;
        margin-top: 1.5rem;
    }

    /* Figures and screenshots adapt cleanly to phone widths */
    .tutorial-figure {
        margin: 1.5rem 0;
        width: 100%;
    }

    .tutorial-figure.img-modal .tutorial-img-card,
    .tutorial-figure.img-menu .tutorial-img-card {
        max-width: 100%;
    }

    .tutorial-img-card {
        border-radius: 8px;
    }

    /* Prevent overflow on tables & code */
    .post-body pre,
    .post-body table {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
    }

    /* Series navigation cards */
    .series-navigator {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 2.5rem;
        padding-top: 1.5rem;
    }

    .series-nav-card.next {
        text-align: left;
    }

    /* Catalog grid */
    .tutorial-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
        margin-top: 1.75rem;
    }

    .tutorial-card-img-wrapper {
        height: 180px;
    }

    .tutorial-card-body {
        padding: 1.15rem;
    }

    .tutorial-cta-banner {
        padding: 2rem 1.25rem;
        margin-top: 2.5rem;
    }

    .tutorial-cta-banner h3 {
        font-size: 1.4rem;
    }
}

/* Very Small Mobile (< 480px) */
@media (max-width: 480px) {
    .tutorials-hero h1 {
        font-size: 1.6rem;
    }

    .post-title {
        font-size: 1.45rem;
    }

    .post-body {
        font-size: 0.975rem;
    }
}
