/* ===== Custom Properties (Pico.css overrides) ===== */
:root {
    --pico-primary: #2563eb;
    --pico-primary-hover: #1d4ed8;
    --pico-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --color-navy: #1a2332;
    --color-accent: #2563eb;
    --color-beginner: #059669;
    --color-intermediate: #d97706;
    --color-advanced: #dc2626;
    --color-pilot-bg: #eff6ff;
    --color-pilot-border: #2563eb;
    --color-surface: #f8fafc;
    --color-card: #ffffff;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-code-bg: #f1f5f9;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Source Code Pro', 'Consolas', monospace;
    --max-width: 1200px;
}

[data-theme="dark"] {
    --pico-color: #e2e8f0;
    --pico-background-color: #0f172a;
    --color-navy: #e2e8f0;
    --color-surface: #0f172a;
    --color-card: #1e293b;
    --color-muted: #94a3b8;
    --color-border: #334155;
    --color-code-bg: #152032;
    --color-pilot-bg: #1e293b;
}

/* ===== Base ===== */
body {
    font-family: var(--pico-font-family);
    background: var(--color-surface);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section-padded {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

/* ===== Skip Link ===== */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--color-accent);
    color: #fff;
}

.skip-link:focus {
    top: 0;
}

/* ===== Header / Navigation ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(8px);
}

.site-header nav {
    padding: 0.75rem 1.5rem;
    max-width: var(--max-width);
    margin: 0 auto;
}

.site-header nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.site-header nav ul li a {
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.2s;
    color: inherit;
}

.site-header nav ul li a:hover,
.site-header nav ul li a.active {
    background: var(--color-pilot-bg);
}

.site-header nav ul li a.active {
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: calc(0.5rem - 2px);
}

[data-theme="dark"] .site-header nav ul li a:hover,
[data-theme="dark"] .site-header nav ul li a.active {
    background: rgba(255, 255, 255, 0.08);
}

.nav-brand {
    font-size: 1.1rem !important;
    font-family: var(--font-heading);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    color: var(--color-muted);
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: var(--color-pilot-bg);
}

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 5rem 1.5rem 4rem;
    background: linear-gradient(135deg, var(--color-navy) 0%, #2563eb 100%);
    color: #ffffff !important;
    --pico-color: #ffffff;
    --pico-h1-color: #ffffff;
    --pico-h2-color: #ffffff;
    --pico-h3-color: #ffffff;
    box-shadow: 0 8px 32px rgba(26, 35, 50, 0.18);
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.hero p,
.hero h1,
.hero h2,
.hero h3 {
    color: #ffffff !important;
}

.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    font-weight: 600;
}

.hero-meta {
    font-size: 1rem;
    opacity: 0.85;
    margin-bottom: 0.5rem;
}

.hero-context {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 2rem;
}

.hero-email {
    color: rgba(255, 255, 255, 0.85) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-actions a[role="button"] {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-block;
}

.hero-actions a[role="button"]:not(.outline) {
    background: #ffffff;
    color: #1a2332 !important;
}

.hero-actions a[role="button"]:not(.outline):hover {
    background: #e2e8f0;
}

.hero-actions a[role="button"].outline {
    background: transparent;
    border: 2px solid #ffffff;
    color: #ffffff !important;
}

.hero-actions a[role="button"].outline:hover {
    background: rgba(255,255,255,0.1);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2em 0.7em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.5;
}

.badge--beginner { background: var(--color-beginner); color: #fff; }
.badge--intermediate { background: var(--color-intermediate); color: #fff; }
.badge--advanced { background: var(--color-advanced); color: #fff; }

/* ===== Difficulty Legend ===== */
.difficulty-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.difficulty-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-muted);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-muted);
}

.filter-btn {
    padding: 0.4em 1em;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-card);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    color: inherit;
}

.filter-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.filter-btn.active {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

/* ===== Ranking Grid ===== */
.ranking-grid {
    display: grid;
    gap: 1rem;
}

.ranking-card {
    display: flex;
    gap: 1.25rem;
    padding: 1.5rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    align-items: flex-start;
}

.ranking-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.ranking-card.hidden {
    display: none;
}

.rank {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-accent);
    min-width: 2.5rem;
    flex-shrink: 0;
    line-height: 1;
    padding-top: 0.2rem;
}

.ranking-card-content h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    line-height: 1.3;
}

.ranking-card-content .badge {
    margin-bottom: 0.5rem;
}

.ranking-card-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-muted);
    line-height: 1.5;
}

/* ===== Methodology Grid ===== */
.methodology-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.methodology-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
}

.methodology-weight {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
}

.methodology-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.methodology-card p {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin: 0;
}

/* ===== Download Section ===== */
.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.download-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.download-card svg {
    color: var(--color-accent);
}

.download-card h3 {
    font-size: 1rem;
    margin: 0;
}

.download-card p {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0;
}

/* ===== Prompt Card ===== */
.prompt-card {
    position: relative;
    background: var(--color-code-bg);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-accent);
    border-radius: 0 0.5rem 0.5rem 0;
    margin: 1.5rem 0;
    overflow: hidden;
}

.prompt-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.prompt-card__header h4 {
    margin: 0;
    font-size: 0.95rem;
}

.prompt-card pre {
    margin: 0;
    padding: 1rem;
    background: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

.prompt-card code {
    background: transparent;
    font-family: inherit;
    font-size: inherit;
}

[data-theme="dark"] .prompt-card pre,
[data-theme="dark"] .prompt-card code {
    color: #e2e8f0;
}

/* ===== Copy Button ===== */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-muted);
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.copy-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.copy-btn--success {
    border-color: var(--color-beginner);
    color: var(--color-beginner);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* ===== Pilot Box ===== */
.pilot-box {
    background: var(--color-pilot-bg);
    border-left: 4px solid var(--color-pilot-border);
    padding: 1.5rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin: 2rem 0;
}

.pilot-box h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--color-accent);
}

.pilot-box__time {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-accent);
    margin-bottom: 0;
}

/* ===== Application Article ===== */
.app-article {
    padding: 3rem 0;
    border-bottom: 1px solid var(--color-border);
}

.app-article:last-child {
    border-bottom: none;
}

.app-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.app-header .rank {
    font-size: 2.5rem;
}

.app-header h2 {
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.app-header .badge {
    margin-top: 0.35rem;
}

/* ===== Skills Grid ===== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.skill-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
}

.skill-card h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-accent);
    margin: 0 0 0.5rem;
}

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

/* ===== Deployment Details ===== */
.deployment-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1.5rem;
    margin: 1rem 0;
}

.deployment-dl dt {
    font-weight: 600;
    font-size: 0.9rem;
}

.deployment-dl dd {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-muted);
}

/* ===== Sidebar Layout (Applications page) ===== */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.sidebar-nav {
    position: sticky;
    top: 5rem;
    height: fit-content;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding: 1rem 0;
}

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

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 0.375rem;
    color: var(--color-muted);
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--color-pilot-bg);
    color: var(--color-navy);
}

.sidebar-nav a.active {
    background: var(--color-pilot-bg);
    color: var(--color-accent);
    border-left-color: var(--color-accent);
    font-weight: 600;
}

.sidebar-nav .sidebar-badge {
    font-size: 0.65rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* ===== App Tagline ===== */
.app-tagline {
    font-size: 1.05rem;
    color: var(--color-muted);
    font-style: italic;
    margin: 0.25rem 0 1.75rem;
    line-height: 1.5;
}

/* ===== Rubric Weights List ===== */
.rubric-weights {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 1rem;
}

.rubric-weights li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    gap: 1rem;
}

.rubric-weights li:last-child {
    border-bottom: none;
}

.rubric-weights .criterion {
    flex: 1;
}

.rubric-weights .weight {
    font-weight: 700;
    color: var(--color-accent);
    white-space: nowrap;
}

/* ===== Skill Card Category Accents ===== */
.skill-card:nth-child(1) { border-top: 3px solid #2563eb; }
.skill-card:nth-child(2) { border-top: 3px solid #10b981; }
.skill-card:nth-child(3) { border-top: 3px solid #8b5cf6; }
.skill-card:nth-child(4) { border-top: 3px solid #f59e0b; }

/* ===== Risks (details/summary) ===== */
.risk-item {
    margin-bottom: 0.5rem;
}

.risk-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 0.25rem 0.5rem 0.6rem;
    border-left: 3px solid #f59e0b;
}

.risk-item p {
    padding-left: 1rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

/* ===== App Navigation (prev/next) ===== */
.app-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 2rem 0;
    margin-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.app-nav a {
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 50;
    transition: opacity 0.2s;
}

.back-to-top.visible {
    display: flex;
}

/* ===== Quick Start Cards ===== */
.quickstart-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.quickstart-card__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.quickstart-card__header .rank {
    font-size: 1.5rem;
}

.quickstart-card__header h3 {
    margin: 0;
    font-size: 1.1rem;
    flex: 1;
    min-width: 200px;
}

.quickstart-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    gap: 0.5rem;
}

.quickstart-card__footer a {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.pilot-box__submit {
    width: 100%;
    font-size: 0.875rem;
    color: var(--pico-muted-color, #6b7280);
    border-top: 1px solid var(--pico-muted-border-color, #e5e7eb);
    padding-top: 0.5rem;
    line-height: 1.5;
}

/* ===== Prompt Library ===== */
.prompt-search {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.prompt-search input[type="search"] {
    flex: 1;
    min-width: 200px;
}

.prompt-library-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.prompt-library-card.hidden {
    display: none;
}

.prompt-library-card__meta {
    padding: 1rem 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.prompt-library-card__meta .source-link {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* ===== References ===== */
.reference-list {
    list-style: none;
    padding: 0;
}

.reference-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    line-height: 1.6;
}

.reference-list li:last-child {
    border-bottom: none;
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--color-border);
    margin-top: 3rem;
    background: var(--color-code-bg);
}

.site-footer p {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0.25rem 0;
}

/* ===== Page Header (non-hero pages) ===== */
.page-header {
    padding: 2rem 0 1rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.page-header h1 {
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--color-muted);
    font-size: 1.05rem;
    margin: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-header nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .site-header nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero {
        padding: 3rem 1rem 2.5rem;
    }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-nav {
        position: static;
        max-height: none;
        border-bottom: 1px solid var(--color-border);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .app-header .rank {
        font-size: 2rem;
    }

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

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

    .deployment-dl {
        grid-template-columns: 1fr;
    }

    .app-nav {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .ranking-card {
        flex-direction: column;
        gap: 0.75rem;
    }

    .rank {
        font-size: 1.5rem;
    }
}
