/**
 * ndocs Article Shared Styles
 * 全記事で共通のCSS。記事固有スタイルは各HTMLの<style>に記述。
 *
 * Modern CSS:
 *   - CSS Nesting (Baseline 2023, 90.7%)
 *   - color-mix() (Baseline 2023, 91.8%)
 *   - text-wrap: balance/pretty
 *   - View Transitions API
 *   - scrollbar-width/scrollbar-color
 *
 * コンポーネント一覧:
 *  1. Custom Properties
 *  2. View Transitions
 *  3. Reset & Base
 *  4. Sidebar
 *  5. Main Layout
 *  6. Hero
 *  7. Section Card (.card--blue/purple/green/amber/cyan)
 *  8. Step Badge (.step-num--{color})
 *  9. Note Panel (.note--blue/amber/green)
 * 10. Comparison Grid (.vs-col--blue/purple/red/green + aliases)
 * 11. Flow List (.auto-list)
 * 12. Code Block (pre, .hl-*)
 * 13. Table (.def-table)
 * 14. Grid (.grid3)
 * 15. Footer
 * 16. Aside Thought (.aside-thought)
 * 17. CTA Button (.cta-tool)
 * 18. Lead Text (.lead-text)
 * 19. Divider (.divider)
 * 20. Responsive (@media max-width: 1024px)
 */

/* Rule: minimum font-size = 0.75rem (12px) */

/* ===== 1. Custom Properties ===== */
:root {
    --brand: #3e5e9b;
    --accent: #7c3aed;
    --pink: #ff20ca;
    --card-blue: #3b82f6;
    --card-purple: #7c3aed;
    --card-green: #10b981;
    --card-amber: #f59e0b;
    --card-cyan: #06b6d4;
    --card-red: #dc2626;
    --text-dark: #0f172a;
    --text-body: #1e293b;
    --text-muted: #475569;
    --text-light: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --surface: #f8fafc;
}

/* ===== 2. View Transitions ===== */
@view-transition { navigation: auto; }

::view-transition-old(root) {
    animation: 0.6s ease both vt-fade-out;
}
::view-transition-new(root) {
    animation: 0.4s ease both vt-fade-slide-in;
}
@keyframes vt-fade-out {
    to { opacity: 0; transform: translateY(-20px); }
}
@keyframes vt-fade-slide-in {
    from { opacity: 0; transform: translateY(20px); }
}
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) { animation: none; }
}

/* ===== 3. Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Screen-reader only utility */
.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;
}
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 17px;
    font-size-adjust: 0.5;
    line-height: 1.85;
    color: #b8c4d4;
    word-break: auto-phrase;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--brand) 40%, transparent) transparent;
    background:
        radial-gradient(ellipse 80% 60% at 8% 92%, color-mix(in srgb, var(--brand) 20%, transparent) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 88% 8%, color-mix(in srgb, var(--pink) 10%, transparent) 0%, transparent 55%),
        #1a2040;
    background-attachment: fixed;

    &::before {
        content: '';
        position: fixed;
        inset: 0;
        z-index: 0;
        background-image:
            linear-gradient(color-mix(in srgb, var(--brand) 12%, transparent) 1px, transparent 1px),
            linear-gradient(90deg, color-mix(in srgb, var(--brand) 12%, transparent) 1px, transparent 1px);
        background-size: 40px 40px;
        pointer-events: none;
    }
}

h1, h2, h3, h4 { color: #e4e9f0; font-weight: 700; text-wrap: balance; }
p { margin-bottom: 1.2em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
strong { color: #edf1f7; font-weight: 600; }
ul, ol { padding-left: 1.5em; }
li { margin-bottom: 0.5em; }

a {
    color: #60a5fa;
    text-decoration: none;

    &:hover { text-decoration: underline; }
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    background: var(--border-light);
    color: #1e40af;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-weight: 500;
}

/* ===== 4. Sidebar ===== */
.sidebar {
    flex-shrink: 0;
    width: 240px;
    position: sticky; top: 0;
    height: 100vh;
    background: #1e2748; color: #a0aec0;
    overflow-y: auto;
    padding: 1.5rem 0;
    border-left: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
    box-shadow: -4px 0 16px rgba(0,0,0,0.3);
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--brand) 30%, transparent) transparent;

    & a {
        display: flex; align-items: center;
        padding: 0.5rem 1.25rem;
        font-size: 0.8rem; color: #94a3b8;
        text-decoration: none;
        transition: all 0.15s;
        border-left: 3px solid transparent;
        line-height: 1.4;

        &:hover {
            background: color-mix(in srgb, var(--brand) 10%, transparent); color: #b8c4d4;
            text-decoration: none;
        }
        &.active {
            background: color-mix(in srgb, var(--accent) 12%, transparent); color: #a78bfa;
            border-left-color: var(--accent); font-weight: 600;

            & .nav-num {
                background: color-mix(in srgb, var(--accent) 25%, transparent); color: #a78bfa;
            }
        }
    }
}

.sidebar-group {
    font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--text-light); padding: 0.85rem 1.25rem 0.35rem;
}

.nav-num {
    min-width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    margin-right: 0.6rem;
    background: color-mix(in srgb, var(--brand) 20%, transparent); color: #7a8a9e;
    flex-shrink: 0;
}

/* ===== 5. Main Layout ===== */
.body-wrap { display: flex; position: relative; z-index: 1; }
.main-wrap { flex: 1; min-width: 0; }
.main-content { padding: 3rem 3.5rem; }

/* ===== 6. Hero (OG-template style) ===== */
.hero {
    position: relative;
    overflow: hidden;
    padding: 0.6rem 3.5rem 2.5rem;
}

.hero__bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 900px 550px at 5% 90%, color-mix(in srgb, var(--brand) 75%, transparent) 0%, transparent 65%),
        radial-gradient(ellipse 600px 400px at 90% 15%, color-mix(in srgb, var(--pink) 35%, transparent) 0%, transparent 70%),
        linear-gradient(160deg, #1a2540 0%, #1e2d4a 40%, #1a2438 100%);
}

.hero__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(color-mix(in srgb, var(--brand) 25%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--brand) 25%, transparent) 1px, transparent 1px);
    background-size: 40px 40px;
}

.hero__inner {
    position: relative;
    z-index: 1;
}

.hero__brand {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 0.75rem;
}

.hero__brand-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.2rem;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.03em;
    view-transition-name: ndocs-logo;
}

.hero__brand-sub {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    opacity: 0.55;
    letter-spacing: 0.08em;
    view-transition-name: ndocs-sub;
    text-transform: uppercase;
}

.hero__card {
    background: #fff;
    border-radius: 64px 0 64px 0;
    padding: 2.5rem 3rem;

    & h1 {
        font-size: clamp(1.5rem, 3.5vw, 2.2rem);
        font-weight: 900;
        line-height: 1.5;
        color: #1a1a2e;
        margin-bottom: 1rem;
        view-transition-name: article-title;
    }
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.hero__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem; font-weight: 600;
    background: var(--border-light); color: #334155;
    padding: 0.35rem 0.85rem; border-radius: 99px;
    border: 1px solid #cbd5e1;

    &::before {
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.7rem;
        color: var(--text-light);
    }
    &:first-child::before { content: '\f073'; }
    &:last-child::before  { content: '\f1ad'; }
}

/* ===== 7. Section Cards ===== */
.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    scroll-margin-top: 2rem;
    color: var(--text-body);

    & strong { color: var(--text-dark); }
    & a { color: #2563eb; }
    & li { color: #334155; }

    & h2 {
        font-size: 1.35rem; line-height: 1.35;
        margin-bottom: 1rem;
        display: flex; align-items: center;
        color: var(--text-dark);
    }
    & h3 {
        font-size: 1.05rem; line-height: 1.4;
        margin-bottom: 1rem; margin-top: 2rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--border);
        color: var(--text-dark);

        &:first-child { margin-top: 0; }
    }
}

.card--blue   { border-left: 4px solid var(--card-blue); }
.card--purple { border-left: 4px solid var(--card-purple); }
.card--green  { border-left: 4px solid var(--card-green); }
.card--amber  { border-left: 4px solid var(--card-amber); }
.card--cyan   { border-left: 4px solid var(--card-cyan); }

/* ===== 8. Step Badge ===== */
.step-num {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; border-radius: 50%;
    color: #fff;
    font-size: 0.8rem; font-weight: 700;
    margin-right: 0.75rem; flex-shrink: 0;
}
.step-num--blue   { background: var(--card-blue); }
.step-num--purple { background: var(--card-purple); }
.step-num--green  { background: var(--card-green); }
.step-num--amber  { background: var(--card-amber); }
.step-num--cyan   { background: var(--card-cyan); }

/* ===== 9. Note Panel ===== */
.note {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.7;

    &::before {
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 1rem;
        flex-shrink: 0;
    }
    & strong { color: inherit; }
}

.note--blue {
    background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
    &::before { content: '\f05a'; color: var(--card-blue); }
}
.note--amber {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    &::before { content: '\f071'; color: var(--card-amber); }
}
.note--green {
    background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
    &::before { content: '\f058'; color: var(--card-green); }
}

/* ===== 10. Comparison Grid ===== */
.vs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 2rem 0;
}

.vs-col {
    padding: 1.5rem 1.75rem;
    border-radius: 12px;
}

.vs-col__title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid;
}

.vs-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0;
    font-size: 0.9rem;
    line-height: 1.5;

    & + & { border-top: 1px solid rgba(0,0,0,0.05); }
}

.vs-icon {
    flex-shrink: 0;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    margin-top: 0.1rem;
}

/* --- 10a. Comparison: Blue --- */
.vs-col--blue, .vs-col--human {
    background: #e8edf4;
    border: 2px solid var(--card-blue);

    & .vs-col__title { color: var(--card-blue); border-color: var(--card-blue); }
    & .vs-icon { background: #dbeafe; color: #2563eb; }
}

/* --- 10b. Comparison: Purple --- */
.vs-col--purple, .vs-col--ai {
    background: #ebe5f7;
    border: 2px solid var(--card-purple);

    & .vs-col__title { color: var(--card-purple); border-color: var(--card-purple); }
    & .vs-icon { background: #ede9fe; color: var(--card-purple); }
}

/* --- 10c. Comparison: Red --- */
.vs-col--red, .vs-col--before {
    background: #fef2f2;
    border: 2px solid #fca5a5;

    & .vs-col__title { color: var(--card-red); border-color: #fca5a5; }
    & .vs-icon { background: #fee2e2; color: var(--card-red); }
}

/* --- 10d. Comparison: Green --- */
.vs-col--green {
    background: #ecfdf5;
    border: 2px solid #6ee7b7;

    & .vs-col__title { color: #059669; border-color: #6ee7b7; }
    & .vs-icon { background: #d1fae5; color: #059669; }
}

/* --- 10e. Comparison: After (blue variant) --- */
.vs-col--after {
    background: #eff6ff;
    border: 2px solid #93c5fd;

    & .vs-col__title { color: #2563eb; border-color: #93c5fd; }
    & .vs-icon { background: #dbeafe; color: #2563eb; }
}

/* ===== 11. Flow List ===== */
.auto-list {
    display: grid;
    gap: 0.75rem;
    margin: 1.5rem 0;
    counter-reset: auto;
}

.auto-item {
    display: flex; align-items: center; gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    counter-increment: auto;

    &::before {
        content: counter(auto);
        min-width: 28px; height: 28px; border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        font-size: 0.75rem; font-weight: 700; color: #fff;
        background: var(--accent);
        flex-shrink: 0;
    }
}

.auto-item__text {
    font-size: 0.95rem;

    & strong { color: var(--text-dark); }
}

/* ===== 12. Code Block ===== */
pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.2rem 1.5rem;
    border-radius: 8px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    overflow-x: auto;
    margin: 1rem 0;
    line-height: 1.6;

    & code { background: none; padding: 0; color: inherit; font-size: inherit; }
}

.hl-cmd { color: #38bdf8; }
.hl-arg { color: #a5f3fc; }
.hl-out { color: #86efac; }
.hl-dim { color: var(--text-light); }

/* ===== 13. Table ===== */
table { border-collapse: collapse; width: 100%; }

.def-table {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;

    & th {
        background: var(--border-light); color: var(--text-muted);
        font-size: 0.75rem; font-weight: 700;
        text-transform: uppercase; letter-spacing: 0.08em;
        padding: 0.75rem 1.25rem;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }
    & td {
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
        border-bottom: 1px solid var(--border-light);
        vertical-align: top;
    }
    & tr:last-child td { border-bottom: none; }
}

/* ===== 14. Grid ===== */
.grid3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin: 1.5rem 0;
}

/* ===== 15. Footer (glassmorphism, full-width like hero) ===== */
.footer {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    padding: 2rem 2rem;
    font-size: 0.8rem;
    color: #94a3b8;
    background: color-mix(in srgb, #0a0e1a 70%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid color-mix(in srgb, var(--brand) 15%, transparent);

    & a {
        color: #94a3b8;
        text-decoration: none;
        transition: color 0.2s;

        &:hover { color: #e2e8f0; }
    }

    & .footer__sep {
        width: 1px;
        height: 0.9rem;
        background: color-mix(in srgb, var(--brand) 30%, transparent);
    }

    & .footer__social {
        display: inline-flex;
        align-items: center;

        & a {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: #94a3b8;

            &:hover { color: #e2e8f0; }
        }

        & svg {
            width: 1.1rem;
            height: 1.1rem;
        }
    }
}

/* ===== 16. Aside Thought ===== */
.aside-thought {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, transparent);
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.85;
    color: var(--text-muted);

    &::before {
        content: '\f4ad';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 1rem;
        color: var(--accent);
        flex-shrink: 0;
    }
    & strong { color: var(--text-dark); }
}

/* ===== 17. CTA Button ===== */
.cta-tool-wrap {
    text-align: center;
    margin: 2rem 0;
}

.card .cta-tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.8rem;
    border: 2px solid transparent;
    border-radius: 20px 0 20px 0;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.25s;
    letter-spacing: 0.02em;
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(135deg, var(--brand) 0%, var(--accent) 50%, #c026d3 100%) border-box;
    color: #5b4bbd;
    box-shadow:
        0 2px 6px color-mix(in srgb, var(--brand) 18%, transparent),
        0 1px 2px rgba(0,0,0,0.06);

    & i {
        font-size: 0.8rem;
        background: linear-gradient(135deg, var(--brand), var(--accent), #c026d3);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    &:hover {
        text-decoration: none;
        background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 50%, #c026d3 100%);
        color: #ffffff;
        transform: translateY(-2px);
        box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 25%, transparent);

        & i {
            background: none;
            -webkit-background-clip: unset;
            background-clip: unset;
            -webkit-text-fill-color: #ffffff;
            color: #ffffff;
        }
    }
}

/* ===== 18. Lead Text ===== */
.lead-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.5;
}
.lead-text--lg {
    font-size: 1.4rem;
}

/* ===== 19. Divider ===== */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* ===== 20. Responsive ===== */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .body-wrap { display: block; }
    .hero { padding: 0.6rem 1.25rem 2rem; }
    .hero__card {
        padding: 1.5rem 1.75rem;

        & h1 { font-size: 1.3rem; }
    }
    .hero__brand-name { font-size: 2rem; }
    .main-content { padding: 2rem 1.25rem; }
    .card { padding: 1.5rem; }
    .grid3 { grid-template-columns: 1fr; }
    .vs-grid { grid-template-columns: 1fr; }
}
