/* Local minimal UI utilities (replaces Bootstrap + Font Awesome for performance) */

:root {
    color-scheme: light;
    --rw-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --rw-text: #212529;
    --rw-muted: #6c757d;
    --rw-border: #ced4da;
    --rw-bg: #ffffff;
    --rw-primary: #0d6efd;
    --rw-primary-hover: #0b5ed7;
    --rw-danger: #dc3545;
    --rw-danger-hover: #bb2d3b;
    --rw-focus: rgba(13, 110, 253, 0.25);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    font-family: var(--rw-font);
    color: var(--rw-text);
    background: var(--rw-bg);
}

a {
    color: var(--rw-primary);
}

a:hover {
    color: var(--rw-primary-hover);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.w-100 {
    width: 100% !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--rw-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    line-height: 1;
    flex: 0 0 auto;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    padding: 0.6rem 0.85rem;
    font-size: 1rem;
    line-height: 1.2;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--rw-primary);
    border-color: var(--rw-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--rw-primary-hover);
    border-color: var(--rw-primary-hover);
}

.btn-danger {
    background: var(--rw-danger);
    border-color: var(--rw-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--rw-danger-hover);
    border-color: var(--rw-danger-hover);
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--rw-text);
    background-color: #fff;
    border: 1px solid var(--rw-border);
    border-radius: 0.5rem;
}

.form-control::placeholder {
    color: var(--rw-muted);
}

.form-select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 2.25rem;
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236c757d' d='M3.2 5.5 8 10.3l4.8-4.8 1.2 1.2L8 12.7 2 6.7z'/%3E%3C/svg%3E");
}

.form-control:focus,
.form-select:focus,
.btn:focus-visible,
.form-check-input:focus-visible {
    outline: none;
    border-color: var(--rw-primary);
    box-shadow: 0 0 0 0.25rem var(--rw-focus);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check-label {
    cursor: pointer;
}

.form-check-input {
    width: 2.75rem;
    height: 1.5rem;
    border-radius: 999px;
    background: #e9ecef;
    border: 1px solid var(--rw-border);
    position: relative;
    appearance: none;
    cursor: pointer;
    flex: 0 0 auto;
}

.form-check-input::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    background: #fff;
    transform: translateY(-50%);
    transition: left 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.form-check-input:checked {
    background: var(--rw-primary);
    border-color: var(--rw-primary);
}

.form-check-input:checked::after {
    left: 1.35rem;
}

.text-primary {
    color: var(--rw-primary) !important;
}

.spinner-border {
    width: 2.2rem;
    height: 2.2rem;
    border: 0.25rem solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: #000;
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    z-index: 2000;
}

.skip-link:focus {
    left: 8px;
}

.frame-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    color: var(--rw-muted);
    background: #fff;
}

.featured-snippet-box,
.internal-link-note,
.toc,
.table-of-contents {
    border: 1px solid var(--rw-border);
    border-radius: 0.75rem;
    padding: 1rem;
    background: #fff;
}

.internal-links {
    margin-top: 2rem;
}

.internal-links-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.internal-links h3 {
    margin-bottom: 0.5rem;
}

.internal-links ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.internal-links a {
    color: #0b3d91;
    line-height: 1.5;
    display: inline-block;
    padding: 2px 0;
}

.internal-links li + li {
    margin-top: 0.25rem;
}

body.rw-dark .internal-links a {
    color: #93c5fd;
}

section article {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
}

body.rw-dark {
    background: #0b1220;
    color: #e5e7eb;
}

body.rw-dark a {
    color: #60a5fa;
}

body.rw-dark a:hover {
    color: #93c5fd;
}

body.rw-dark #sidebar {
    background: #111827 !important;
    color: #e5e7eb;
}

body.rw-dark section {
    background: #0b1220 !important;
}

body.rw-dark .wiki-counter {
    background: #1f2937 !important;
    color: #e5e7eb;
}

body.rw-dark .frame-placeholder {
    background: #0b1220;
    color: #9ca3af;
}

body.rw-dark .form-control,
body.rw-dark .form-select {
    background-color: #0f172a;
    color: #e5e7eb;
    border-color: #374151;
}

body.rw-dark .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%239ca3af' d='M3.2 5.5 8 10.3l4.8-4.8 1.2 1.2L8 12.7 2 6.7z'/%3E%3C/svg%3E");
}

body.rw-dark #loadingOverlay {
    background: rgba(0, 0, 0, 0.6) !important;
}

@media (prefers-reduced-motion: reduce) {
    .spinner-border {
        animation-duration: 1.5s;
    }

    .btn {
        transition: none;
    }
}

@media (max-width: 768px) {
    .wrapper {
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh;
    }

    #sidebar {
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
    }

    #content {
        height: 60vh;
        min-height: 380px;
    }
}
