/*
 * Sovereign Playbook Engine: Elite Zenith 500 Architecture (v2.0)
 * Ground-up reconstruction. Zero-compromise UI/UX.
 */

:root {
    --za-pb-obsidian: #08090E;
    --za-pb-cyan: #22D3EE;
    --za-pb-cyan-glow: rgba(34, 211, 238, 0.4);
    --za-pb-transition: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.za-playbook-layer {
    background: var(--clr-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 96px; /* Precise NavBar offset decision */
    transition: background 0.5s ease;
}

/* ── 1. The Command Deck (Zone A: Fixed Obsidian) ── */
.za-playbook-header-wrapper {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto var(--sp-8) auto;
    padding: 0 var(--sp-8);
}

.za-playbook-header {
    background: rgba(8, 9, 14, 0.92);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(34, 211, 238, 0.15); /* Subtle cyan LED edge */
    border-radius: 24px;
    padding: var(--sp-5) var(--sp-6);
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.02);
}

.za-pb-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-6);
}

.za-pb-header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-6);
    flex: 1;
    min-width: 0;
}

.za-pb-back-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: var(--za-pb-transition);
}

.za-pb-back-btn:hover {
    background: var(--za-pb-cyan);
    color: #000;
    transform: translateX(-4px);
    box-shadow: 0 0 20px var(--za-pb-cyan-glow);
}

.za-pb-title-stack {
    min-width: 0;
}

.za-pb-title {
    font-family: var(--ff-head);
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 800;
    color: #FFFFFF !important;
    margin: 0 0 6px 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Segmented Progress Path */
.za-pb-progress-segmented {
    display: flex;
    gap: 4px;
    align-items: center;
}

.za-pb-progress-dot {
    width: 12px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.5s var(--za-pb-transition);
}

.za-pb-progress-dot.is-filled {
    background: var(--za-pb-cyan);
    box-shadow: 0 0 8px var(--za-pb-cyan-glow);
}

/* ── 2. The Main Matrix Layout ── */
.za-playbook-main {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 32px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--sp-8) var(--sp-12) var(--sp-8);
    width: 100%;
}

/* Sidebar: Zone A (Obsidian Fixed) */
.za-playbook-sidebar {
    position: sticky;
    top: 96px;
    height: calc(100vh - 140px);
    align-self: start;
}

.za-pb-nav-box {
    background: var(--za-pb-obsidian);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: var(--sp-6);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.za-pb-nav-header {
    font-size: 0.7rem;
    font-family: var(--ff-mono, monospace);
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: var(--sp-6);
}

.za-pb-step-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.za-pb-step-item {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--za-pb-transition);
    margin-bottom: 4px;
    border-left: 3px solid transparent;
}

.za-pb-step-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.za-pb-step-item.is-active {
    background: rgba(34, 211, 238, 0.08);
    border-left-color: var(--za-pb-cyan);
    box-shadow: inset 20px 0 30px -20px rgba(34, 211, 238, 0.1);
}

.za-pb-step-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ff-mono, monospace);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.is-active .za-pb-step-icon {
    background: var(--za-pb-cyan);
    color: #000;
    border-style: none;
}

.za-pb-step-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.is-active .za-pb-step-label {
    color: #fff;
}

/* ── 3. The Content Canvas (Zone B: Adaptive) ── */
.za-playbook-content {
    min-width: 0;
}

.za-pb-step-pane {
    display: none;
    opacity: 0;
}

.za-pb-step-pane.is-active {
    display: block;
    animation: pbReveal 0.4s var(--za-pb-transition) forwards;
}

@keyframes pbReveal {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.za-pb-pane-inner {
    max-width: 820px;
}

.za-pb-hero-image img {
    width: 100%;
    border-radius: 20px;
    border: 1px solid var(--clr-border);
    box-shadow: var(--shadow-lg);
    background: var(--clr-bg-alt);
}

/* Legacy callout shell — scoped so detail-shared + blog are not polluted (async load race) */
#playbook-app .za-callout-header {
    margin-bottom: 0;
}

.za-callout-content p:first-child { margin-top: 0; }
.za-callout-content p:last-child { margin-bottom: 0; }

/* Elite Editorial Typography */
.za-p-rich {
    color: var(--clr-text);
    line-height: 1.8;
    font-size: 1.1rem;
}

.za-p-rich h2 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--clr-heading);
    margin: 3.5rem 0 1.5rem 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.za-p-rich h3 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--clr-heading);
    margin: 2.5rem 0 1.25rem 0;
}

.za-p-rich p {
    margin-bottom: 1.8rem;
}

.za-p-rich ul, .za-p-rich ol {
    margin-bottom: 2rem;
    padding-left: 1.5rem;
}

.za-p-rich li {
    margin-bottom: 0.8rem;
}

/* Blockquotes: Sovereign Pull-Quote style */
.za-p-rich blockquote {
    border-left: 4px solid var(--za-pb-cyan);
    background: rgba(34, 211, 238, 0.05); /* Same tint for light/dark */
    padding: 2rem;
    margin: 3rem 0;
    border-radius: 0 16px 16px 0;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--clr-heading);
}

/* Tables: Elite Technical styling */
.za-p-rich table {
    width: 100%;
    border-collapse: collapse;
    margin: 3rem 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--clr-border);
    font-size: 0.95rem;
}

.za-p-rich th {
    background: var(--za-pb-obsidian);
    color: #fff;
    text-align: left;
    padding: 16px 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.za-p-rich td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--clr-border);
}

.za-p-rich tr:last-child td {
    border-bottom: none;
}

.za-p-rich tr:hover td {
    background: rgba(34, 211, 238, 0.04);
}

/* Code Tokens & Blocks */
.za-p-rich code:not(pre code) {
    background: rgba(34, 211, 238, 0.1);
    color: var(--za-pb-cyan);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--ff-mono, monospace);
    font-size: 0.9em;
}

/* Tech-Badge Code Headers */
.code-block-wrapper {
    margin: 2.5rem 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--clr-border);
    background: #0D0E11; /* Constant dark for code */
}

.code-header {
    background: #1A1B20;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.code-lang {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #FFFFFF !important;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.1em;
}

/* Styled Inline Tech SVG Badges */
.tech-badge-icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    display: inline-block;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.1));
}

.za-p-rich .md-image {
    margin: 1.5rem 0;
    text-align: center;
}

.za-p-rich pre {
    margin: 0;
    padding: 20px;
    overflow-x: auto;
    font-family: var(--ff-mono, monospace);
    font-size: 0.9rem;
    line-height: 1.6;
    color: #E4E4E7;
}

/* ══════════════════════════════════════════════════════════
   WORLD CLASS EXECUTION MATRIX — INDUSTRIAL ZENITH DESIGN
   ══════════════════════════════════════════════════════════ */

/* ── 4a. CLEAN UP: hide raw [ ] artifacts from old parser ── */
.za-p-rich ul li {
    list-style: none;
    position: relative;
    padding-left: 1.5rem;
}
.za-p-rich ul {
    padding-left: 0;
}
.za-p-rich ul li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--za-pb-cyan);
    font-weight: 900;
}
/* Hide raw [ ] bracket text that bleeds from old server code */
.za-p-rich ul li:has(input[type="checkbox"]) {
    padding-left: 2.2rem;
}
.za-p-rich ul li:has(input[type="checkbox"])::before {
    display: none;
}

/* ── 4b. EXECUTION MATRIX: Structured checklist from PlaybookParser ── */
.za-pb-checklist {
    margin: 3rem 0;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: linear-gradient(135deg, rgba(10, 11, 18, 0.95), rgba(15, 16, 24, 0.9));
    box-shadow: 
        0 0 0 1px rgba(34, 211, 238, 0.06),
        0 40px 80px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Header bar */
.za-pb-checklist-header {
    padding: 16px 28px;
    background: rgba(34, 211, 238, 0.04);
    border-bottom: 1px solid rgba(34, 211, 238, 0.1);
    font-family: var(--ff-mono, monospace);
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    color: var(--za-pb-cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.za-pb-checklist-header::before {
    content: '▶ EXECUTION_MATRIX';
}
.za-pb-checklist-header::after {
    content: 'INTERACTIVE';
    font-size: 0.55rem;
    color: rgba(34, 211, 238, 0.5);
    border: 1px solid rgba(34, 211, 238, 0.25);
    padding: 3px 10px;
    border-radius: 100px;
    letter-spacing: 0.15em;
    animation: pulseBadge 2.5s ease-in-out infinite;
}
@keyframes pulseBadge {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; border-color: rgba(34, 211, 238, 0.6); }
}

/* Body wrapper */
.za-pb-checklist-body {
    padding: 8px 0;
}

/* Individual check item */
.za-pb-check-item {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    cursor: pointer;
    transition: background 0.25s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
}
.za-pb-check-item:last-child { border-bottom: none; }
.za-pb-check-item:hover {
    background: rgba(34, 211, 238, 0.04);
}
.za-pb-check-item:hover .za-pb-check-box {
    border-color: var(--za-pb-cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

/* The checkbox */
.za-pb-check-box {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
    position: relative;
    flex-shrink: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Checked state: cyan glow */
.za-pb-checkbox-input:checked + .za-pb-check-box {
    background: var(--za-pb-cyan);
    border-color: var(--za-pb-cyan);
    box-shadow: 
        0 0 0 4px rgba(34, 211, 238, 0.15),
        0 0 20px rgba(34, 211, 238, 0.4);
    transform: scale(1.08);
}

/* Checkmark tick */
.za-pb-check-box::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpolyline points='2,6 5,9 10,3' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s;
}
.za-pb-checkbox-input:checked + .za-pb-check-box::after {
    opacity: 1;
    transform: scale(1);
}

/* The label text */
.za-pb-check-label {
    font-size: 0.975rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.55;
    transition: color 0.3s ease, opacity 0.3s ease;
}
.za-pb-checkbox-input:checked ~ .za-pb-check-label {
    color: rgba(255, 255, 255, 0.28);
    text-decoration: line-through;
    text-decoration-color: rgba(34, 211, 238, 0.35);
}

/* SR-only helper */
.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;
}

/* ── 5. Navigation Actions ── */
.za-pb-actions {
    display: flex;
    gap: 12px;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--clr-border);
}

/* Floating Jump-to-Top */
.za-pb-jump-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--za-pb-obsidian);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
}

.za-pb-jump-top.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── 6. Mobile Responsiveness ── */
@media (max-width: 991px) {
    .za-playbook-layer { padding-top: 80px; }
    
    .za-playbook-main {
        grid-template-columns: 1fr;
        padding: 0 var(--sp-4) var(--sp-12) var(--sp-4);
    }
    
    .za-playbook-sidebar {
        position: relative;
        top: 0;
        height: auto;
        margin-bottom: 24px;
    }
    
    .za-pb-nav-box {
        padding: 16px;
        overflow-x: auto;
    }
    
    .za-pb-step-list {
        display: flex;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
        scrollbar-width: none;
    }
    
    .za-pb-step-list::-webkit-scrollbar { display: none; }
    
    .za-pb-step-item {
        flex-shrink: 0;
        margin-bottom: 0;
        padding: 8px 16px;
        border-left: none;
        border-bottom: 2px solid transparent;
    }
    
    .za-pb-step-item.is-active {
        border-left: none;
        border-bottom-color: var(--za-pb-cyan);
    }
    
    .za-pb-step-label {
        max-width: 120px;
    }
}
