/* ============================================================
   Tutorial Builder – Viewer Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
    --text:       #1e293b;
    --text-muted: #64748b;
    --border:     #e2e8f0;
    --bg:         #f8fafc;
    --surface:    #ffffff;
    --accent:     #6366f1;
    --radius:     8px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ─── Draft banner ─────────────────────────────────────────────────────────── */
.draft-banner {
    background: #451a03;
    color: #fcd34d;
    padding: .65rem 1.5rem;
    font-size: .85rem;
    font-weight: 600;
}
.draft-banner a { color: #fbbf24; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.viewer-layout { min-height: 100vh; }

/* ─── Tutorial Header ──────────────────────────────────────────────────────── */
.tutorial-header {
    background: var(--accent);
    color: #fff;
    padding: 3rem 1.5rem 3.5rem;
}
.tutorial-header-inner { max-width: 760px; margin: 0 auto; }
.tutorial-header h1 { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 800; margin-bottom: .5rem; line-height: 1.25; }
.tutorial-desc { font-size: 1.05rem; opacity: .88; margin-bottom: .75rem; }
.tutorial-meta { display: flex; gap: 1rem; font-size: .85rem; opacity: .75; }
.tutorial-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .85rem; }
.tutorial-tag { font-size: .75rem; font-weight: 600; text-decoration: none; background: rgba(255,255,255,.18); border-radius: 999px; padding: .15rem .65rem; transition: background .15s; }
.tutorial-tag:hover { background: rgba(255,255,255,.32); }

/* ─── Body ─────────────────────────────────────────────────────────────────── */
.tutorial-body { background: var(--bg); }
.tutorial-content {
    max-width: 760px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* ─── Step Heading ─────────────────────────────────────────────────────────── */
.step-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2.5rem 0 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--border);
}
.step-heading:first-child { margin-top: 0; }
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    font-size: .9rem;
    font-weight: 800;
    border-radius: 50%;
    flex-shrink: 0;
}
.step-heading h2 { font-size: 1.3rem; font-weight: 700; color: var(--text); }

/* ─── Text Block ───────────────────────────────────────────────────────────── */
.text-block { margin-bottom: 1.5rem; }
.text-block p          { margin-bottom: .75em; }
.text-block p:last-child { margin-bottom: 0; }
.text-block strong     { font-weight: 700; }
.text-block em         { font-style: italic; }
.text-block u          { text-decoration: underline; }
.text-block s          { text-decoration: line-through; }
.text-block a          { color: var(--accent); text-decoration: underline; }
.text-block a:hover    { opacity: .8; }
.text-block ul, .text-block ol { padding-left: 1.5rem; margin-bottom: .75em; }
.text-block li         { margin-bottom: .3em; }
.text-block h2         { font-size: 1.25rem; font-weight: 700; margin: 1.25em 0 .5em; }
.text-block h3         { font-size: 1.05rem; font-weight: 700; margin: 1em 0 .4em; }
.text-block blockquote {
    border-left: 4px solid var(--accent);
    padding: .5rem 1rem;
    margin: .75rem 0;
    background: #f0f4ff;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: #3730a3;
}
.text-block code {
    background: #e2e8f0;
    padding: .1em .4em;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: .88em;
}
.text-block pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: .75em 0;
}
.text-block pre code { background: none; padding: 0; color: inherit; font-size: .9em; }

/* ─── Image Block ──────────────────────────────────────────────────────────── */
.image-block { margin: 1.5rem 0; }
.image-block img { border-radius: var(--radius); box-shadow: 0 2px 12px rgba(0,0,0,.1); height: auto; }
.image-block figcaption {
    margin-top: .6rem;
    font-size: .82rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* ─── Callout Block ────────────────────────────────────────────────────────── */
.callout-block {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin: 1.25rem 0;
    border: 1px solid rgba(0,0,0,.06);
}
.callout-emoji { font-size: 1.3rem; flex-shrink: 0; line-height: 1.5; }
.callout-content { flex: 1; font-size: .95rem; }
.callout-content p { margin-bottom: .4em; }
.callout-content p:last-child { margin-bottom: 0; }
.callout-content a { color: var(--accent); }
.callout-content strong { font-weight: 700; }

/* ─── Video Block ──────────────────────────────────────────────────────────── */
.video-block { margin: 1.5rem 0; }
.video-block video {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,.1);
    background: #000;
}
.video-block figcaption {
    margin-top: .6rem;
    font-size: .82rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* ─── Code Block ───────────────────────────────────────────────────────────── */
.code-block { margin: 1.25rem 0; border-radius: var(--radius); overflow: hidden; }
.code-label {
    background: #1e293b;
    color: #64748b;
    padding: .4rem 1rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-family: 'Fira Code', monospace;
}
.code-block pre {
    margin: 0;
    border-radius: 0;
    font-size: .87rem;
    line-height: 1.65;
    overflow-x: auto;
}
.code-block pre code { font-family: 'Fira Code', monospace; }

/* ─── Footer ───────────────────────────────────────────────────────────────── */
.tutorial-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}
.footer-brand { font-size: .8rem; color: #cbd5e1; }
.footer-brand a { color: inherit; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.footer-mark { height: 16px; width: auto; opacity: .85; }
.footer-brand a:hover { color: var(--accent); text-decoration: underline; }

/* ─── Password Gate ────────────────────────────────────────────────────────── */
.pw-gate { min-height: 100vh; display: grid; place-items: center; background: #0f172a; }
.pw-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%; max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0,0,0,.5);
}
.pw-icon  { font-size: 2.5rem; margin-bottom: 1rem; }
.pw-card h1 { font-size: 1.4rem; font-weight: 700; color: #f1f5f9; margin-bottom: .4rem; }
.pw-card p  { color: #94a3b8; font-size: .9rem; margin-bottom: 1.25rem; }
.pw-error {
    background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d;
    border-radius: 8px; padding: .6rem .9rem; font-size: .85rem; margin-bottom: 1rem;
}
.pw-card input[type=password] {
    width: 100%; padding: .75rem 1rem;
    background: #0f172a; border: 1px solid #334155; border-radius: 8px;
    color: #f1f5f9; font-size: 1rem; outline: none; margin-bottom: .75rem;
    transition: border-color .2s;
}
.pw-card input:focus { border-color: #6366f1; }
.pw-card button {
    width: 100%; padding: .85rem;
    background: #6366f1; color: #fff;
    border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background .2s;
}
.pw-card button:hover { background: #4f46e5; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .tutorial-header { padding: 2rem 1rem 2.5rem; }
    .tutorial-content { padding: 1.5rem 1rem 3rem; }
    .step-heading { gap: .65rem; }
    .step-num { width: 30px; height: 30px; font-size: .8rem; }
    .step-heading h2 { font-size: 1.1rem; }
    .callout-block { padding: .75rem 1rem; }
}

/* ─── Related Tutorials ────────────────────────────────────────────────────── */
.kb-back { display: inline-block; font-size: .85rem; font-weight: 600; opacity: .8; text-decoration: none; margin-bottom: .75rem; transition: opacity .15s; }
.kb-back:hover { opacity: 1; text-decoration: underline; }
.pw-back { display: inline-block; font-size: .85rem; color: #94a3b8; text-decoration: none; margin-bottom: 1rem; }
.pw-back:hover { color: #f1f5f9; }

/* ─── Was this helpful? ────────────────────────────────────────────────────── */
.helpful-wrap {
    margin-top: 3rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: center;
}
.helpful-ask { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.helpful-q { font-weight: 700; font-size: 1rem; color: var(--text); }
.helpful-btns { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.helpful-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .55rem 1.2rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-family: inherit; font-size: .9rem; font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s, transform .1s;
}
.helpful-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: #fff; }
.helpful-btn:active:not(:disabled) { transform: scale(.97); }
.helpful-btn:disabled { opacity: .6; cursor: wait; }
.helpful-icon { width: 1.15em; height: 1.15em; flex-shrink: 0; }
.helpful-result { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.helpful-thanks { font-weight: 700; color: var(--text); }
.helpful-stats { font-size: .88rem; color: var(--text-muted); }
.helpful-stats strong { color: var(--accent); font-size: 1rem; }
.helpful-change {
    margin-top: .25rem;
    background: none; border: none; padding: 0;
    font-family: inherit; font-size: .78rem; color: var(--text-muted);
    text-decoration: underline; cursor: pointer;
}
.helpful-change:hover { color: var(--accent); }
.helpful-error { margin-top: .6rem; font-size: .82rem; color: #b91c1c; }

.related-wrap { margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related-heading {
    font-size: 1.05rem; font-weight: 700; color: var(--text);
    margin-bottom: 1rem;
}
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .85rem; }
.related-card {
    display: flex; flex-direction: column; gap: .35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 1rem 1.1rem; text-decoration: none;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}
.related-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(99, 102, 241, .12);
    transform: translateY(-2px);
}
.related-card-title { font-weight: 700; font-size: .92rem; color: var(--text); line-height: 1.35; }
.related-card-desc {
    font-size: .8rem; color: var(--text-muted); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.related-card-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.related-tag { font-size: .7rem; font-weight: 600; color: var(--accent); background: rgba(99,102,241,.1); border-radius: 999px; padding: .05rem .5rem; }
.related-card-arrow { margin-top: auto; padding-top: .25rem; font-size: .82rem; font-weight: 600; color: var(--accent); }
