/*
 * flexagon.org — on top of Bootstrap 5.3.
 *
 * Colors are Bootstrap's own variables, set once for the light theme and once
 * for the dark one; components read them, so they follow the theme toggle.
 */

:root,
[data-bs-theme="light"] {
    --fx-brand: #4f3fd6;
    --fx-brand-rgb: 79, 63, 214;
    --fx-brand-strong: #3a2bb0;
    --fx-accent: #0ea5c6;
    --fx-surface: #ffffff;
    --fx-surface-alt: #f6f6fb;
    --fx-border: #e4e4ef;
    --fx-code-bg: #f7f7fb;
    --fx-heading: #14122b;
    --fx-muted: #5d5b74;
    --fx-footer-bg: #14122b;
    --fx-footer-text: #b9b7cf;

    --bs-primary: var(--fx-brand);
    --bs-primary-rgb: var(--fx-brand-rgb);
    --bs-link-color: var(--fx-brand);
    --bs-link-color-rgb: var(--fx-brand-rgb);
    --bs-link-hover-color: var(--fx-brand-strong);
    --bs-body-bg: var(--fx-surface);
    --bs-border-color: var(--fx-border);
    --bs-emphasis-color: var(--fx-heading);
    --bs-secondary-color: var(--fx-muted);
}

[data-bs-theme="dark"] {
    --fx-brand: #8f80ff;
    --fx-brand-rgb: 143, 128, 255;
    --fx-brand-strong: #b0a6ff;
    --fx-accent: #38c8e6;
    --fx-surface: #0f0e1c;
    --fx-surface-alt: #16152a;
    --fx-border: #2a2944;
    --fx-code-bg: #1a1930;
    --fx-heading: #f2f1fb;
    --fx-muted: #a4a2bd;
    --fx-footer-bg: #0a0914;
    --fx-footer-text: #9e9cb8;

    --bs-primary: var(--fx-brand);
    --bs-primary-rgb: var(--fx-brand-rgb);
    --bs-link-color: var(--fx-brand);
    --bs-link-color-rgb: var(--fx-brand-rgb);
    --bs-link-hover-color: var(--fx-brand-strong);
    --bs-body-bg: var(--fx-surface);
    --bs-body-color: #d9d8ea;
    --bs-border-color: var(--fx-border);
    --bs-emphasis-color: var(--fx-heading);
    --bs-secondary-color: var(--fx-muted);
}

/* Type ---------------------------------------------------------------- */

body {
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-family: var(--bs-body-font-family);
    background: var(--bs-body-bg);
    -webkit-font-smoothing: antialiased;
}
:lang(ko) body, body:lang(ko) {
    font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
    word-break: keep-all;
}
:lang(ja) body, body:lang(ja) {
    font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
    line-break: strict;
}

h1, h2, h3, h4, .h1, .h2, .h3 {
    color: var(--fx-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
}

code, pre, kbd {
    font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

.btn-primary {
    --bs-btn-bg: var(--fx-brand);
    --bs-btn-border-color: var(--fx-brand);
    --bs-btn-hover-bg: var(--fx-brand-strong);
    --bs-btn-hover-border-color: var(--fx-brand-strong);
    --bs-btn-active-bg: var(--fx-brand-strong);
    --bs-btn-active-border-color: var(--fx-brand-strong);
    --bs-btn-disabled-bg: var(--fx-brand);
    --bs-btn-disabled-border-color: var(--fx-brand);
}
[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #0f0e1c;
    --bs-btn-hover-color: #0f0e1c;
    --bs-btn-active-color: #0f0e1c;
}
.text-bg-primary {
    background-color: var(--fx-brand) !important;
}
[data-bs-theme="dark"] .text-bg-primary {
    color: #0f0e1c !important;
}
.btn-link {
    font-weight: 600;
    text-decoration: none;
}

.skip-link {
    position: absolute;
    z-index: 2000;
    top: .5rem;
    left: .5rem;
    padding: .5rem 1rem;
    background: var(--fx-brand);
    color: #fff;
    border-radius: .5rem;
}

/* Header -------------------------------------------------------------- */

.site-header {
    background: color-mix(in srgb, var(--fx-surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--fx-border);
}
.site-header .navbar {
    min-height: 4rem;
}
.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    color: var(--fx-heading);
}
.site-header .nav-link {
    font-weight: 500;
    color: var(--fx-muted);
}
.site-header .nav-link:hover,
.site-header .nav-link:focus-visible {
    color: var(--fx-heading);
}
.theme-toggle {
    background: none;
    border: 0;
}
.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline; }

/* Home ---------------------------------------------------------------- */

.hero {
    position: relative;
    overflow: hidden;
    padding: 5rem 0 4.5rem;
}
.hero-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(40rem 24rem at 85% 10%, rgba(var(--fx-brand-rgb), .18), transparent 70%),
        radial-gradient(30rem 20rem at 0% 100%, rgba(14, 165, 198, .14), transparent 70%);
    pointer-events: none;
}
.release-pill {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .75rem .3rem .35rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--fx-border);
    border-radius: 2rem;
    background: var(--fx-surface);
    color: var(--fx-muted);
    font-size: .875rem;
    text-decoration: none;
}
.release-pill:hover {
    border-color: var(--fx-brand);
    color: var(--fx-heading);
}
.hero-title {
    font-size: clamp(2.4rem, 5vw, 3.75rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.035em;
    margin-bottom: 1.25rem;
}
:lang(ko) .hero-title, :lang(ja) .hero-title {
    line-height: 1.22;
    letter-spacing: -0.02em;
}
.text-gradient {
    background: linear-gradient(90deg, var(--fx-brand), var(--fx-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-lead {
    font-size: 1.2rem;
    color: var(--fx-muted);
    max-width: 36rem;
    margin-bottom: 2rem;
}
.install-command {
    display: flex;
    align-items: center;
    gap: .75rem;
    max-width: 32rem;
    padding: .65rem .65rem .65rem 1rem;
    border: 1px solid var(--fx-border);
    border-radius: .75rem;
    background: var(--fx-code-bg);
}
.install-command .prompt {
    color: var(--fx-brand);
    font-family: ui-monospace, Menlo, monospace;
    user-select: none;
}
.install-command code {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    color: var(--fx-heading);
    font-size: .9rem;
}
.btn-copy {
    color: var(--fx-muted);
    border: 0;
}
.btn-copy:hover { color: var(--fx-brand); }
.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
    margin: 1.25rem 0 0;
    color: var(--fx-muted);
    font-size: .9rem;
}
.hero-meta i { color: var(--fx-brand); margin-right: .2rem; }

.code-window {
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-code-bg);
    overflow: hidden;
}
.code-window-bar {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--fx-border);
    background: color-mix(in srgb, var(--fx-code-bg) 70%, var(--fx-border));
}
.code-window-bar .dot {
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
    background: var(--fx-border);
}
.code-window-bar .dot:nth-child(1) { background: #ff5f57; }
.code-window-bar .dot:nth-child(2) { background: #febc2e; }
.code-window-bar .dot:nth-child(3) { background: #28c840; }
.code-window-title {
    margin-left: .75rem;
    font-family: ui-monospace, Menlo, monospace;
    font-size: .8rem;
    color: var(--fx-muted);
}
.code-window pre {
    margin: 0;
    padding: 1.25rem 1.5rem;
    font-size: .875rem;
    line-height: 1.65;
    max-height: 30rem;
}
.code-window pre code.hljs,
.step pre code.hljs {
    padding: 0;
    background: transparent;
}
.code-tabs .nav-tabs {
    gap: .25rem;
    padding: .5rem .75rem 0;
    border-bottom: 1px solid var(--fx-border);
}
.code-tabs .nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--fx-muted);
    font-weight: 600;
    font-size: .9rem;
}
.code-tabs .nav-tabs .nav-link.active {
    color: var(--fx-heading);
    border-bottom-color: var(--fx-brand);
}
.code-file {
    padding: .6rem 1.5rem 0;
    font-family: ui-monospace, Menlo, monospace;
    font-size: .8rem;
    color: var(--fx-muted);
}

.stats-strip {
    padding: 2.5rem 0;
    border-top: 1px solid var(--fx-border);
    border-bottom: 1px solid var(--fx-border);
    background: var(--fx-surface-alt);
}
.stats-strip dt {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--fx-heading);
    line-height: 1.1;
}
.stats-strip dt small {
    font-size: 1.1rem;
    font-weight: 700;
    margin-left: .15rem;
    color: var(--fx-brand);
}
.stats-strip dd {
    margin: .25rem 0 0;
    color: var(--fx-muted);
}

.section {
    padding: 5.5rem 0;
}
.section-alt {
    background: var(--fx-surface-alt);
    border-top: 1px solid var(--fx-border);
    border-bottom: 1px solid var(--fx-border);
}
.section-heading {
    max-width: 46rem;
    margin: 0 auto 3.5rem;
}
.section-heading h2,
.section-title {
    font-size: clamp(1.8rem, 3.2vw, 2.5rem);
    margin-bottom: 1rem;
}
.section-heading .lead {
    color: var(--fx-muted);
}
.eyebrow {
    margin-bottom: .75rem;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--fx-brand);
}

.pillar {
    height: 100%;
    padding: 2rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-surface);
}
.pillar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin-bottom: 1.25rem;
    border-radius: .75rem;
    background: rgba(var(--fx-brand-rgb), .1);
    color: var(--fx-brand);
    font-size: 1.4rem;
}
.pillar h3 { font-size: 1.2rem; }
.pillar p { color: var(--fx-muted); margin-bottom: 0; }

.check-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}
.check-list li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 1.1rem;
    color: var(--fx-muted);
}
.check-list li::before {
    content: "\F26E";
    font-family: "bootstrap-icons";
    position: absolute;
    left: 0;
    top: -.05rem;
    color: var(--fx-brand);
    font-size: 1.2rem;
}
.check-list strong {
    color: var(--fx-heading);
}

.compare-card {
    padding: 1.5rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-surface);
}
.compare-table {
    --bs-table-bg: transparent;
    caption-side: bottom;
}
.compare-table caption {
    padding-bottom: 0;
    font-size: .85rem;
}
.compare-table th,
.compare-table td {
    padding: .85rem .5rem;
}
.compare-table thead th {
    font-size: .85rem;
    color: var(--fx-muted);
    font-weight: 600;
}
.compare-table tbody th {
    font-weight: 500;
}
.fx-value {
    font-weight: 800;
    color: var(--fx-brand) !important;
}

.feature-card {
    display: block;
    height: 100%;
    padding: 1.75rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.feature-card:hover {
    border-color: rgba(var(--fx-brand-rgb), .5);
    transform: translateY(-2px);
    box-shadow: 0 .75rem 2rem rgba(var(--fx-brand-rgb), .08);
}
.feature-icon {
    display: block;
    margin-bottom: 1rem;
    font-size: 1.6rem;
    color: var(--fx-brand);
}
.feature-card h3 { font-size: 1.1rem; }
.feature-card p { color: var(--fx-muted); }
.feature-more {
    font-weight: 600;
    font-size: .9rem;
    color: var(--fx-brand);
}

.step {
    height: 100%;
    padding: 1.75rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-surface);
}
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin-bottom: 1rem;
    border-radius: 50%;
    background: var(--fx-brand);
    color: #fff;
    font-weight: 700;
}
[data-bs-theme="dark"] .step-number { color: #0f0e1c; }
.step h3 { font-size: 1.15rem; }
.step pre {
    margin: 1rem 0 0;
    padding: 1rem;
    border-radius: .6rem;
    background: var(--fx-code-bg);
    border: 1px solid var(--fx-border);
    font-size: .8rem;
}

.cta-band {
    padding: 5rem 0;
    background: linear-gradient(120deg, #3a2bb0, #4f3fd6 45%, #0e8fb0);
    color: #fff;
}
.cta-band h2 {
    color: #fff;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
}
.cta-band .lead {
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, .8);
}

/* Footer -------------------------------------------------------------- */

.site-footer {
    padding: 4rem 0 2rem;
    background: var(--fx-footer-bg);
    color: var(--fx-footer-text);
}
.site-footer .brand-name { color: #fff; }
.footer-lead { max-width: 20rem; }
.footer-title {
    margin-bottom: 1rem;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #fff;
}
.footer-links li { margin-bottom: .5rem; }
.footer-links a {
    color: var(--fx-footer-text);
    text-decoration: none;
}
.footer-links a:hover { color: #fff; }
.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem 2rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
    font-size: .85rem;
}

/* Docs ---------------------------------------------------------------- */

.docs-hero {
    padding: 4.5rem 0 3rem;
    border-bottom: 1px solid var(--fx-border);
    background:
        radial-gradient(36rem 18rem at 90% 0%, rgba(var(--fx-brand-rgb), .14), transparent 70%),
        var(--fx-surface-alt);
}
.docs-hero h1 {
    font-size: clamp(2.2rem, 4vw, 3rem);
    font-weight: 800;
}
.docs-hero .lead {
    max-width: 40rem;
    margin-bottom: 1.75rem;
    color: var(--fx-muted);
}
.docs-card {
    height: 100%;
    padding: 1.75rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    background: var(--fx-surface);
}
.docs-card-icon {
    font-size: 1.4rem;
    color: var(--fx-brand);
}
.docs-card-title {
    margin: 0;
    font-size: 1.15rem;
}
.docs-card-text {
    color: var(--fx-muted);
    font-size: .95rem;
}
.docs-card-links li { margin-bottom: .35rem; }
.docs-card-links a {
    text-decoration: none;
    font-weight: 500;
}
.docs-card-links i {
    font-size: .75rem;
    margin-right: .25rem;
}

.docs-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
    padding-top: 2rem;
    padding-bottom: 4rem;
}
@media (min-width: 992px) {
    .docs-layout {
        grid-template-columns: 15rem minmax(0, 1fr);
        gap: 3rem;
    }
}
@media (min-width: 1200px) {
    .docs-layout {
        grid-template-columns: 15rem minmax(0, 1fr) 13rem;
    }
}
@media (min-width: 992px) {
    .docs-sidebar .offcanvas-lg {
        position: sticky;
        top: 5.5rem;
        max-height: calc(100vh - 6.5rem);
        overflow-y: auto;
    }
}
.docs-nav-section { margin-bottom: 1.5rem; }
.docs-nav-title {
    margin-bottom: .5rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--fx-heading);
}
.docs-nav-link {
    display: block;
    padding: .3rem .75rem;
    margin-left: -.75rem;
    border-radius: .5rem;
    color: var(--fx-muted);
    text-decoration: none;
    font-size: .925rem;
}
.docs-nav-link:hover { color: var(--fx-heading); background: var(--fx-surface-alt); }
.docs-nav-link.active {
    color: var(--fx-brand);
    background: rgba(var(--fx-brand-rgb), .09);
    font-weight: 600;
}

.docs-toc { display: none; }
@media (min-width: 1200px) {
    .docs-toc { display: block; }
}
.docs-toc-inner {
    position: sticky;
    top: 5.5rem;
    max-height: calc(100vh - 6.5rem);
    overflow-y: auto;
    font-size: .85rem;
}
.docs-toc-title {
    margin-bottom: .75rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.docs-toc li { margin-bottom: .4rem; }
.docs-toc .toc-level-3 { padding-left: .85rem; }
.docs-toc a {
    color: var(--fx-muted);
    text-decoration: none;
}
.docs-toc a:hover,
.docs-toc a.active { color: var(--fx-brand); }

.docs-content .breadcrumb {
    font-size: .875rem;
    margin-bottom: 1rem;
}
.docs-content .breadcrumb a { text-decoration: none; }
.docs-title {
    font-size: clamp(2rem, 3.5vw, 2.75rem);
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.markdown-body {
    font-size: 1.025rem;
    line-height: 1.75;
}
.markdown-body h2 {
    margin: 3rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--fx-border);
    font-size: 1.75rem;
}
.markdown-body > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.markdown-body h3 { margin: 2.25rem 0 .85rem; font-size: 1.3rem; }
.markdown-body h4 { margin: 1.75rem 0 .75rem; font-size: 1.1rem; }
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    scroll-margin-top: 5.5rem;
}
.markdown-body .anchor {
    margin-left: .4rem;
    color: var(--fx-border);
    text-decoration: none;
    font-weight: 400;
    opacity: 0;
    transition: opacity .1s ease;
}
.markdown-body :is(h2, h3, h4):hover .anchor,
.markdown-body .anchor:focus-visible {
    opacity: 1;
    color: var(--fx-brand);
}
.markdown-body p,
.markdown-body ul,
.markdown-body ol { margin-bottom: 1.1rem; }
.markdown-body li { margin-bottom: .35rem; }
.markdown-body a { text-underline-offset: .2em; }
.markdown-body :not(pre) > code {
    padding: .12rem .4rem;
    border-radius: .35rem;
    background: rgba(var(--fx-brand-rgb), .08);
    color: var(--fx-brand-strong);
    font-size: .875em;
    word-break: break-word;
}
[data-bs-theme="dark"] .markdown-body :not(pre) > code { color: var(--fx-brand-strong); }
.markdown-body pre {
    position: relative;
    margin: 1.25rem 0 1.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--fx-border);
    border-radius: .75rem;
    background: var(--fx-code-bg);
    font-size: .875rem;
    line-height: 1.6;
}
.markdown-body pre code.hljs {
    padding: 0;
    background: transparent;
}
.markdown-body pre .btn-copy {
    position: absolute;
    top: .4rem;
    right: .4rem;
    opacity: 0;
    background: var(--fx-surface);
}
.markdown-body pre:hover .btn-copy,
.markdown-body pre .btn-copy:focus-visible { opacity: 1; }
.markdown-body .table {
    --bs-table-bg: transparent;
    display: block;
    overflow-x: auto;
    margin: 1.25rem 0 1.75rem;
    font-size: .925rem;
}
.markdown-body .table th {
    white-space: nowrap;
    background: var(--fx-surface-alt);
}
.markdown-body .table td,
.markdown-body .table th { padding: .55rem .75rem; }
.markdown-body .callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--fx-brand);
    border-radius: 0 .75rem .75rem 0;
    background: rgba(var(--fx-brand-rgb), .06);
}
.markdown-body .callout > :last-child { margin-bottom: 0; }

.docs-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--fx-border);
}
.docs-pager-link {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--fx-border);
    border-radius: .75rem;
    text-decoration: none;
}
.docs-pager-link:hover { border-color: var(--fx-brand); }
.docs-pager-link.next {
    grid-column: 2;
    text-align: right;
}
.docs-pager-label {
    font-size: .8rem;
    color: var(--fx-muted);
}
.docs-pager-title {
    font-weight: 600;
}

/* Error --------------------------------------------------------------- */

.error-page {
    padding: 7rem 0;
}
.error-code {
    font-size: clamp(5rem, 14vw, 9rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.05em;
    background: linear-gradient(90deg, var(--fx-brand), var(--fx-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.error-page .lead {
    margin-bottom: 2rem;
    color: var(--fx-muted);
}

@media (max-width: 575.98px) {
    .hero { padding: 3rem 0; }
    .section { padding: 4rem 0; }
}

@media (prefers-reduced-motion: reduce) {
    .feature-card { transition: none; }
    .feature-card:hover { transform: none; }
}
