/* =============================================
   Article Page Styles
   Extends ../style.css variables & base styles
   ============================================= */

/* (Article navigation now uses global .nav from ../style.css) */

/* Language toggle in article nav - reuses .settings-btn from style.css */

/* =============================================
   2. Article Header
   ============================================= */





/* =============================================
   3. Article Body
   ============================================= */
.article-body {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 var(--space-lg) var(--space-3xl);
}

.article-body h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-3xl);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--primary);
    scroll-margin-top: calc(var(--nav-height) + var(--space-lg));
}

.article-body h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    padding-left: var(--space-md);
    border-left: 3px solid var(--primary);
}

.article-body h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.article-body p {
    margin-bottom: var(--space-lg);
    line-height: 1.9;
    color: var(--text-primary);
}

.article-body strong {
    color: var(--primary);
    font-weight: 600;
}

.article-body ul,
.article-body ol {
    margin-bottom: var(--space-lg);
    padding-left: 0;
    list-style: none;
}

.article-body li {
    padding-left: var(--space-lg);
    position: relative;
    margin-bottom: var(--space-sm);
    line-height: 1.8;
}

.article-body ul > li::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 11px;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

.article-body ol {
    counter-reset: article-ol;
}

.article-body ol > li::before {
    counter-increment: article-ol;
    content: counter(article-ol);
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    background: var(--primary);
    color: var(--background);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-body ol > li {
    padding-left: calc(var(--space-xl) + 4px);
}

/* =============================================
   4. Info Boxes (article context)
   ============================================= */
.article-note {
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.article-note__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--space-sm);
}

.article-note p {
    margin-bottom: var(--space-sm);
    font-size: 14px;
}

.article-note p:last-child {
    margin-bottom: 0;
}

/* Honest box - for limitations */
.article-honest {
    background: rgba(154, 154, 154, 0.08);
    border: 1px solid rgba(154, 154, 154, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.article-honest__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.article-honest p {
    margin-bottom: var(--space-sm);
    font-size: 14px;
    color: var(--text-secondary);
}

.article-honest p:last-child {
    margin-bottom: 0;
}

/* =============================================
   5. Cycle Diagram
   ============================================= */
.cycle-diagram {
    /* Wide layout: steps in a single row, arrows in the gap.
       Below the breakpoint the layout flips to column with ↓ arrows. */
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 32px;
    margin: var(--space-xl) 0;
    padding: var(--space-xl);
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--surface-light);
}

.cycle-step {
    position: relative;
    background: var(--surface-light);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    text-align: center;
    /* Let steps shrink to fit the row, never overflow. */
    flex: 1 1 0;
    min-width: 0;
}

.cycle-step__label {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.cycle-step__desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* The explicit .cycle-arrow <div> elements would wrap independently of
   their steps on narrow viewports, leaving an orphan "→" at the end of
   the prior row. Hide them; draw arrows as pseudo-elements on each
   non-last step, positioned in the gap. */
.cycle-arrow { display: none; }

.cycle-step:not(:last-child)::after {
    content: "→";
    position: absolute;
    top: 50%;
    right: -22px; /* gap is 32px; arrow sits centered in it */
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 18px;
    pointer-events: none;
    line-height: 1;
}

/* Narrow viewports: stack vertically, flip arrows to ↓.
   Breakpoint at 600px (not 768) so tablet-portrait keeps the more
   meaningful horizontal "cycle" visual; below 600 the steps would be
   too cramped (4 × ~100px min + 3 × 32px gap + padding ≈ 560 px).
   Hard rule 5 invariant maintained: direction flip + arrow flip live
   inside the SAME media query so 601-768 stays row + → without dead
   zones. The unrelated 768 article body block has no cycle-diagram
   rules, so there is no shadowing. */
@media (max-width: 600px) {
    .cycle-diagram {
        flex-direction: column;
        align-items: stretch;
        gap: 28px;
        padding: var(--space-lg);
    }
    .cycle-step { flex: 0 0 auto; }
    .cycle-step:not(:last-child)::after {
        content: "↓";
        top: auto;
        bottom: -22px;
        right: 50%;
        transform: translateX(50%);
    }
}

/* =============================================
   6. Click Density Table
   ============================================= */
.density-list {
    margin-bottom: var(--space-lg);
}

.density-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    border: 1px solid var(--surface-light);
}

.density-item__name {
    font-weight: 700;
    color: var(--primary);
    min-width: 140px;
    font-size: 14px;
}

.density-item__desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* =============================================
   7. Mid-Article CTA (subtle)
   ============================================= */
/* Top-of-article CTA. Inserted between <header> and <main class="article-body">
   on every guide so the read → try-the-app handoff happens before the user
   commits to reading the whole article. */
.article-top-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    max-width: 720px;
    margin: var(--space-lg) auto 0;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(212, 175, 55, 0.05));
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: var(--radius-lg);
}
.article-top-cta__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 2px;
}
.article-top-cta__sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}
.article-top-cta__button {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--primary);
    color: var(--background) !important;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.15s ease;
}
.article-top-cta__button:hover {
    transform: translateY(-1px);
}
@media (max-width: 600px) {
    .article-top-cta {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}

.article-cta-subtle {
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    text-align: center;
}

.article-cta-subtle__text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.article-cta-subtle__button {
    display: inline-block;
    background: transparent;
    color: var(--primary);
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.article-cta-subtle__button:hover {
    background: var(--primary);
    color: var(--background);
}

/* =============================================
   8. Final CTA (prominent)
   ============================================= */
.article-cta {
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border: 1px solid var(--primary);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    text-align: center;
    max-width: 760px;
    margin: 0 auto var(--space-3xl);
}

.article-cta__title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.article-cta__text {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-size: 15px;
    line-height: 1.8;
}

.article-cta__button {
    display: inline-block;
    background: var(--primary);
    color: var(--background);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s ease;
}

.article-cta__button:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
}

/* =============================================
   9. Related Content
   ============================================= */
.article-related {
    max-width: 760px;
    margin: 0 auto var(--space-2xl);
    padding: 0 var(--space-lg);
}

.article-related__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--space-md);
}

.article-related__link {
    display: block;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-decoration: none;
    transition: border-color 0.2s ease;
}

.article-related__link:hover {
    border-color: var(--primary);
}

.article-related__link-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.article-related__link-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* =============================================
   10. Article End Note
   ============================================= */
.article-endnote {
    max-width: 760px;
    margin: 0 auto var(--space-xl);
    padding: 0 var(--space-lg);
}

.article-endnote__text {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    border-top: 1px solid var(--surface-light);
    padding-top: var(--space-lg);
}

/* =============================================
   11. Article Footer
   ============================================= */
.article-footer {
    background: var(--surface);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    border-top: 1px solid var(--surface-light);
}

.article-footer__text {
    color: var(--text-secondary);
    font-size: 14px;
}

.article-footer__link {
    color: var(--primary);
    text-decoration: none;
}

.article-footer__link:hover {
    text-decoration: underline;
}

/* =============================================
   12. Visual Diagrams
   ============================================= */

/* Shared diagram container */
.diagram-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Beat Timeline (responsive — track shrinks with container) */
.beat-timeline {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    margin: var(--space-xl) 0;
    border: 1px solid var(--surface-light);
}

.beat-timeline__row {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    margin-bottom: var(--space-lg);
    gap: var(--space-md);
}

.beat-timeline__row:last-child {
    margin-bottom: 0;
}

.beat-timeline__label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.beat-timeline__track {
    height: 40px;
    background: var(--surface-light);
    border-radius: var(--radius-md);
    position: relative;
    min-width: 0;
}

.beat-mark {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 28px;
    border-radius: 2px;
}

.beat-mark--hit {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    top: 50%;
}

.beat-mark--perfect { background: #4ADE80; }
.beat-mark--early { background: #60A5FA; }
.beat-mark--late { background: #F87171; }
.beat-mark--click { background: var(--primary); height: 32px; width: 2px; }

.beat-timeline__legend {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-md);
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-line {
    width: 12px;
    height: 2px;
    flex-shrink: 0;
}

/* Click Density Visual Grid */
.density-visual {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border: 1px solid var(--surface-light);
}

.density-row {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
}

.density-row__label {
    min-width: 120px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
}

.density-row__beats {
    display: flex;
    gap: 2px;
    flex: 1;
}

.beat-cell {
    flex: 1 1 0;
    min-width: 0;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.beat-cell--on { background: var(--primary); color: var(--background); }
.beat-cell--off { background: var(--surface-light); color: var(--text-secondary); }
.beat-cell--bar {
    flex: 0 0 3px;
    background: var(--primary);
    height: 28px;
    align-self: center;
    color: transparent;
    font-size: 0;
    border-radius: 0;
}

.density-row__difficulty {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Deviation Gauge */
.deviation-gauge {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border: 1px solid var(--surface-light);
}

.gauge-track {
    height: 12px;
    background: var(--surface-light);
    border-radius: 6px;
    position: relative;
    margin: var(--space-lg) 0 var(--space-sm);
}

.gauge-zone {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 6px;
}

.gauge-zone--pro { background: rgba(74, 222, 128, 0.3); }
.gauge-zone--mid { background: rgba(251, 191, 36, 0.2); }
.gauge-zone--beginner { background: rgba(248, 113, 113, 0.15); }

.gauge-center {
    position: absolute;
    left: 50%;
    top: -4px;
    width: 2px;
    height: 20px;
    background: var(--text-primary);
    transform: translateX(-50%);
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
}

.gauge-labels span:nth-child(2) {
    color: var(--primary);
    font-weight: 700;
}

.gauge-marker {
    position: absolute;
    top: -6px;
    width: 10px;
    height: 24px;
    border-radius: 5px;
    transform: translateX(-50%);
    border: 2px solid;
}

.gauge-marker--you {
    background: rgba(96, 165, 250, 0.3);
    border-color: #60A5FA;
}

/* Mermaid */
.mermaid-container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin: var(--space-xl) 0;
    border: 1px solid var(--surface-light);
    overflow-x: auto; /* lint-skip: Mermaid SVG is fixed-size and may exceed column width */
}

.mermaid {
    display: flex;
    justify-content: center;
}

.mermaid-lang {
    display: block !important;
}

.mermaid-lang.mermaid-hidden {
    display: none !important;
}

/* Comparison Cards */
.comparison-visual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin: var(--space-xl) 0;
}

.comparison-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--surface-light);
}

.comparison-card--good { border-color: rgba(74, 222, 128, 0.4); }
.comparison-card--bad { border-color: rgba(248, 113, 113, 0.4); }

.comparison-card__header {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: var(--space-md);
}

.comparison-card--good .comparison-card__header { color: #4ADE80; }
.comparison-card--bad .comparison-card__header { color: #F87171; }

.comparison-card__body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* =============================================
   13. Responsive
   ============================================= */
@media (max-width: 768px) {







    .article-body {
        padding: 0 var(--space-md) var(--space-2xl);
    }

    .article-body h2 {
        font-size: 19px;
        margin-top: var(--space-2xl);
    }

    .article-body h3 {
        font-size: 16px;
    }

    .article-body p,
    .article-body li {
        font-size: 15px;
    }

    /* (.cycle-diagram column-mode rules now live with the cycle-diagram
       definition further up so they stay in sync with the arrow CSS;
       previously a duplicate rule here only flipped flex-direction and
       left the 761-768px range broken.) */

    .density-item {
        flex-direction: column;
        gap: var(--space-xs);
    }

    .density-item__name {
        min-width: auto;
    }

    .article-cta {
        margin: 0 var(--space-md) var(--space-2xl);
        padding: var(--space-xl);
    }

    .article-cta__title {
        font-size: 19px;
    }

    .article-cta__button {
        display: block;
        text-align: center;
    }

    .article-related {
        padding: 0 var(--space-md);
    }

    .article-endnote {
        padding: 0 var(--space-md);
    }

    /* Diagram responsive */
    .beat-timeline {
        padding: var(--space-md);
    }

    .beat-timeline__row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .beat-timeline__label {
        min-width: auto;
        font-size: 12px;
    }

    .beat-timeline__track {
        min-width: 100%;
        width: 100%;
    }

    .beat-timeline__legend {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .density-visual {
        padding: var(--space-md);
    }

    .density-row {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .density-row__label {
        min-width: auto;
    }

    .density-row__beats {
        width: 100%;
    }

    .beat-cell {
        flex: 1;
        min-width: 28px;
        width: auto;
    }

    .deviation-gauge {
        padding: var(--space-md);
    }

    .mermaid-container {
        padding: var(--space-md);
    }

    .comparison-visual {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {

    .article-body h2 {
        font-size: 17px;
    }

    .article-body h3 {
        font-size: 15px;
    }

    .article-body p,
    .article-body li {
        font-size: 14px;
        line-height: 1.8;
    }
}
