/* ============================================
   FormSavvy Documentation Styles
   Extends marketing site styles with doc-specific components
   DARK THEME - Matches marketing site design
   ============================================ */

/* ============================================
   Documentation-Specific Variables
   Inherits from marketing site styles.css
   ============================================ */
:root {
    /* Documentation layout */
    --docs-sidebar-width: 280px;
    --docs-navbar-height: 72px;

    /* Override any light theme variables */
    --color-doc-bg: #0a0e1a;
    --color-sidebar-bg: rgba(19, 24, 41, 0.95);
    --color-code-bg: rgba(30, 35, 55, 0.6);
    --color-code-border: rgba(255, 255, 255, 0.1);
}

/* ============================================
   Documentation Index Hero Section
   ============================================ */
.docs-hero {
    background: linear-gradient(135deg, #0a0e1a 0%, #131829 50%, #1a1f35 100%);
    padding: calc(var(--docs-navbar-height) + var(--spacing-4xl)) var(--spacing-2xl) var(--spacing-4xl);
    margin-left: var(--docs-sidebar-width);
    position: relative;
    overflow: hidden;
}

.docs-hero-spacing {
    margin-left: var(--docs-sidebar-width);
}

/* The page links under a docs hero: a row of pills, the current page filled. */
.docs-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xl);
}

.docs-nav-link {
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.docs-nav-link:hover {
    border-color: #5b4fb8;
    color: var(--color-text-primary);
}

.docs-nav-link.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #ffffff;
}

.docs-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(30, 91, 168, 0.1) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, 30px); }
}

.docs-hero-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    position: relative;
    z-index: 1;
}

.version-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(170, 40, 185, 0.2);
    border: 1px solid rgba(170, 40, 185, 0.4);
    border-radius: var(--radius-full);
    color: #AA28B9;
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}

.docs-hero-title {
    font-size: var(--font-size-6xl);
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.1;
}

.docs-hero-subtitle {
    font-size: var(--font-size-xl);
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--spacing-3xl);
}

/* Search Bar in Hero */
.docs-search-wrapper {
    display: flex;
    justify-content: center;
}

.docs-search-container {
    position: relative;
    max-width: 600px;
    width: 100%;
}

.docs-search-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-md) calc(var(--spacing-2xl) + var(--spacing-lg));
    background: rgba(30, 35, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
}

.docs-search-input:focus {
    outline: none;
    border-color: #1e5ba8;
    box-shadow: 0 0 0 3px rgba(30, 91, 168, 0.1);
}

.docs-search-input::placeholder {
    color: var(--color-text-muted);
}

.docs-search-icon {
    position: absolute;
    left: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
}

.docs-search-shortcut {
    position: absolute;
    right: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-family: var(--font-family);
}

/* ============================================
   Documentation Cards Section (Index Page)
   ============================================ */
.docs-cards-section {
    padding: var(--spacing-4xl) var(--spacing-2xl);
    background: var(--color-bg-primary);
}

.doc-card-arrow {
    color: #9ecbfa;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    transition: transform var(--transition-base);
    margin-top: var(--spacing-md);
}

.doc-card:hover .doc-card-arrow {
    transform: translateX(8px);
}

/* ============================================
   Popular Topics Section
   ============================================ */
.docs-popular-section {
    padding: var(--spacing-4xl) var(--spacing-2xl);
    background: var(--color-bg-secondary);
}

.docs-section-title {
    font-size: var(--font-size-4xl);
    font-weight: 800;
    color: var(--color-text-primary);
    text-align: center;
    margin-bottom: var(--spacing-3xl);
}

.docs-popular-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: var(--spacing-lg);
    max-width: 1280px;
    margin: 0 auto;
}

.popular-link {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: rgba(30, 35, 55, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    text-decoration: none;
    transition: all var(--transition-base);
}

.popular-link:hover {
    background: rgba(30, 35, 55, 0.6);
    border-color: #1e5ba8;
    transform: translateX(4px);
}

.popular-icon {
    font-size: var(--font-size-2xl);
    flex-shrink: 0;
}

/* ============================================
   Community Section
   ============================================ */
.docs-community-section {
    padding: var(--spacing-4xl) var(--spacing-2xl);
    background: var(--color-bg-primary);
}

.docs-community-card {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--spacing-3xl);
    background: rgba(30, 35, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-2xl);
    text-align: center;
}

.docs-community-text {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-2xl);
    line-height: 1.7;
}

.docs-community-links {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.community-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    background: rgba(30, 91, 168, 0.1);
    border: 1px solid rgba(30, 91, 168, 0.3);
    border-radius: var(--radius-lg);
    color: var(--color-text-primary);
    text-decoration: none;
    transition: all var(--transition-base);
}

.community-link:hover {
    background: #1e5ba8;
    border-color: #1e5ba8;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(30, 91, 168, 0.3);
}

/* ============================================
   Documentation Layout (Sidebar + Content)
   ============================================ */
body.docs-page {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
}

.docs-layout {
    display: flex;
    min-height: calc(100vh - var(--docs-navbar-height));
    /*padding-top: var(--docs-navbar-height);*/
}

/* ============================================
   Sidebar Navigation
   ============================================ */
.docs-sidebar {
    position: fixed;
    top: var(--docs-navbar-height);
    left: 0;
    width: var(--docs-sidebar-width);
    height: calc(100vh - var(--docs-navbar-height));
    background: var(--color-sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    z-index: 100;
    padding: var(--spacing-lg) 0 var(--spacing-4xl) 0;
}

.docs-sidebar::-webkit-scrollbar {
    width: 6px;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: rgba(30, 91, 168, 0.3);
    border-radius: var(--radius-sm);
}

.docs-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(30, 91, 168, 0.5);
}

.docs-sidebar nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs-sidebar nav > ul > li {
    margin-bottom: 0;
    position: relative;
}

/* Parent section links with collapsible children */
.docs-sidebar nav > ul > li {
    position: relative;
}

.docs-sidebar nav > ul > li > a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-xl);
    padding-right: calc(var(--spacing-xl) + 30px);
    color: var(--color-text-primary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 600;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    position: relative;
}

.docs-sidebar nav > ul > li > a:hover {
    background: rgba(30, 91, 168, 0.15);
    border-left-color: rgba(30, 91, 168, 0.5);
}

.docs-sidebar nav > ul > li > a.active {
    color: #9ecbfa;
    background: rgba(30, 91, 168, 0.2);
    border-left-color: #1e5ba8;
}

/* Collapse toggle button */
.nav-section-toggle {
    position: absolute;
    right: var(--spacing-md);
    top: var(--spacing-xs);
    background: rgba(30, 91, 168, 0.2);
    border: 1px solid rgba(30, 91, 168, 0.3);
    border-radius: var(--radius-sm);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: #9ecbfa;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    z-index: 10;
}

.nav-section-toggle:hover {
    background: rgba(30, 91, 168, 0.4);
    border-color: #1e5ba8;
    transform: scale(1.1);
}

.collapsed .nav-section-toggle {
    transform: rotate(-90deg);
}

.collapsed .nav-section-toggle:hover {
    transform: rotate(-90deg) scale(1.1);
}

/* Nested/child links */
.docs-sidebar nav ul ul {
    padding-left: 0;
    margin-left: var(--spacing-xl);
    border-left: 2px solid rgba(255, 255, 255, 0.05);
    max-height: 5000px;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.collapsed > ul {
    max-height: 0 !important;
    overflow: hidden !important;
}

.docs-sidebar nav ul ul li {
    margin-bottom: 0;
    position: static;
}

.docs-sidebar nav ul ul a {
    display: block;
    font-size: var(--font-size-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    padding-left: var(--spacing-lg);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    position: relative;
}

.docs-sidebar nav ul ul a:hover {
    color: var(--color-text-primary);
    background: rgba(30, 91, 168, 0.1);
    border-left-color: rgba(30, 91, 168, 0.5);
}

.docs-sidebar nav ul ul a.active {
    color: #9ecbfa;
    background: rgba(30, 91, 168, 0.15);
    border-left-color: #1e5ba8;
    font-weight: 500;
}

/* Third-level nested links (H4 items under H3) */
/* These should always be visible (no individual collapse for H3 sections) */
.docs-sidebar nav ul ul ul {
    margin-left: var(--spacing-lg);
    margin-top: var(--spacing-xs);
    padding-left: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    max-height: none !important;
    overflow: inherit;
    display: block;
}

.docs-sidebar nav ul ul ul a {
    font-size: calc(var(--font-size-sm) - 1px);
    padding: var(--spacing-xs) var(--spacing-sm);
    padding-left: var(--spacing-md);
    /* 5.5:1 on the sidebar: the muted colour at 0.9 opacity read 3.85:1,
       under the 4.5:1 small text needs. Still dimmer than the level above. */
    color: #8390a5;
}

.docs-sidebar nav ul ul ul a:hover {
    color: var(--color-text-secondary);
    opacity: 1;
}

.docs-sidebar nav ul ul ul a.active {
    color: #9ecbfa;
    opacity: 1;
}

/* Section divider */
.docs-sidebar-section-title {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-xl);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: var(--spacing-lg);
}

.docs-sidebar-section-title:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: var(--spacing-md);
}

/* ============================================
   Main Content Area
   ============================================ */
.docs-main {
    margin-left: var(--docs-sidebar-width);
    padding: var(--spacing-4xl);
    width: calc(100% - var(--docs-sidebar-width));
    min-width: 0;
}

.docs-content {
    background: rgba(30, 35, 55, 0.6);
    backdrop-filter: blur(10px);
    padding: var(--spacing-4xl);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    min-width: 0;
    overflow-wrap: break-word;
}

.docs-content h1 {
    font-size: var(--font-size-5xl);
    font-weight: 800;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.2;
}

.docs-content h2 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-top: var(--spacing-3xl);
    margin-bottom: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.docs-content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.docs-content h3 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-top: var(--spacing-2xl);
    margin-bottom: var(--spacing-md);
}

.docs-content h4 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-sm);
}

.docs-content p {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--spacing-lg);
}

.docs-content ul,
.docs-content ol {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--spacing-lg);
    padding-left: var(--spacing-xl);
}

/* styles.css sets a global `ul { list-style: none }` for the marketing nav,
   and the docs pages load it first. Without this, every list in the
   documentation renders as unmarked text that just floats. */
.docs-content ul {
    list-style: disc outside;
}

.docs-content ol {
    list-style: decimal outside;
}

.docs-content ul ul {
    list-style: circle outside;
}

.docs-content li {
    margin-bottom: var(--spacing-sm);
}

.docs-content li::marker {
    color: var(--color-primary-magenta);
}

.docs-content ol li::marker {
    color: var(--color-text-muted);
    font-weight: 600;
}

/* Lists that are deliberately unmarked: the recipe steps draw their own
   numbers, and a nested list inside a callout reads better without them. */
.docs-content .recipe-steps,
.docs-content .recipe-chooser ul {
    list-style: none;
    padding-left: 0;
}

/* Inline code is the most-used token on these pages, and #1e5ba8 on its own
   tint measured 2.59:1 against the page ground: dark blue on near-black.
   Light enough to read, still blue enough to read as code. 10.29:1. */
.docs-content code {
    background: rgba(30, 91, 168, 0.18);
    padding: 0.2em 0.4em;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: #9ecbfa;
    font-family: 'Monaco', 'Courier New', monospace;
    border: 1px solid rgba(30, 91, 168, 0.35);
}

.docs-content a {
    color: #9ecbfa;
    /* Underlined, not colour alone: a link in running text must be
       recognisable without seeing colour (WCAG 1.4.1, axe link-in-text-block). */
    text-decoration: underline;
    text-decoration-color: rgba(158, 203, 250, 0.45);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: text-decoration-color var(--transition-fast);
}

.docs-content a:hover,
.docs-content a:focus-visible {
    text-decoration-color: #9ecbfa;
}

.docs-content a.btn,
.docs-content a.plugin-download-btn {
    text-decoration: none;
}

/* ============================================
   Code Blocks
   ============================================ */
.code-block {
    position: relative;
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    overflow: hidden;
}

.code-block pre {
    padding: 1.5rem !important;
    margin: 0;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.7;
}

.code-block pre code {
    background: none !important;
    padding: 0 !important;
    color: var(--color-text-primary);
    border-radius: 0;
    border: none !important;
    display: block;
    word-wrap: normal;
    white-space: pre;
    font-size: 0.875rem !important;
}

.code-copy-button,
.code-copy {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(30, 91, 168, 0.2);
    border: 1px solid rgba(30, 91, 168, 0.3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* When button is inside code-header, use static positioning */
.code-header .code-copy-button,
.code-header .code-copy {
    position: static;
    top: auto;
    right: auto;
}

.code-copy-button:hover,
.code-copy:hover {
    background: #1e5ba8;
    color: white;
    border-color: #1e5ba8;
}

.code-copy-button.copied,
.code-copy.copied {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

/* ============================================
   Copy Link to Section Button
   ============================================ */
.copy-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: var(--spacing-sm);
    padding: 0;
    background: rgba(30, 91, 168, 0.15);
    border: 1px solid rgba(30, 91, 168, 0.25);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: all var(--transition-fast);
    vertical-align: middle;
    opacity: 0;
}

h2:hover .copy-link-button,
h3:hover .copy-link-button,
.copy-link-button:focus-visible {
    opacity: 1;
}

.copy-link-button:hover {
    background: rgba(30, 91, 168, 0.4);
    border-color: #1e5ba8;
    color: white;
    opacity: 1;
}

.copy-link-button.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
    opacity: 1;
}

/* ============================================
   Callout Boxes
   ============================================ */
.callout {
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin: var(--spacing-lg) 0;
    backdrop-filter: blur(10px);
}

.callout h4 {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.callout p:last-child,
.callout ul:last-child {
    margin-bottom: 0;
}

.callout.info {
    background: rgba(30, 91, 168, 0.15);
    border-color: #1e5ba8;
}

.callout.info h4 {
    color: #9ecbfa;
}

.callout.warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
}

.callout.warning h4 {
    color: #f59e0b;
}

.callout.success {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
}

.callout.success h4 {
    color: #10b981;
}

.callout.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
}

.callout.danger h4 {
    color: #ef4444;
}

/* ============================================
   Tables
   ============================================ */
.properties-table,
.params-table,
.error-codes-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-lg) 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.properties-table thead,
.params-table thead,
.error-codes-table thead {
    background: rgba(30, 91, 168, 0.2);
}

.properties-table th,
.params-table th,
.error-codes-table th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    color: var(--color-text-primary);
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    font-size: var(--font-size-sm);
}

.properties-table td,
.params-table td,
.error-codes-table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.properties-table tr:last-child td,
.params-table tr:last-child td,
.error-codes-table tr:last-child td {
    border-bottom: none;
}

.properties-table code,
.params-table code {
    background: rgba(30, 91, 168, 0.15);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    color: #9ecbfa;
}

/* ============================================
   API Endpoint Styling
   ============================================ */
.api-endpoint {
    margin: var(--spacing-2xl) 0;
    padding: var(--spacing-2xl);
    background: rgba(10, 14, 26, 0.6);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.http-method {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
}

.http-method.get {
    background: #10b981;
    color: white;
}

.http-method.post {
    background: #1e5ba8;
    color: white;
}

.http-method.put {
    background: #f59e0b;
    color: white;
}

.http-method.delete {
    background: #ef4444;
    color: white;
}

.endpoint-path {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: var(--font-size-lg);
    color: var(--color-text-primary);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Badge TEXT is a lightened tint of the brand colour, not the brand colour
   itself. #1e5ba8 on its own tint over #0a0e1a measures 2.49:1, well under
   the 4.5:1 WCAG AA needs, and read as unreadable dark-blue-on-black. The
   backgrounds and borders are unchanged, so the colour coding still carries.
   Measured ratios are in each rule. */
.badge.admin {
    background: rgba(30, 91, 168, 0.22);
    color: #7ab5f5;                 /* 7.66:1 */
    border: 1px solid rgba(30, 91, 168, 0.45);
}

.badge.api {
    background: rgba(170, 40, 185, 0.22);
    color: #e07bf0;                 /* 6.46:1 */
    border: 1px solid rgba(170, 40, 185, 0.45);
}

.badge.new {
    background: rgba(16, 185, 129, 0.22);
    color: #34d9a4;                 /* 7.52:1 */
    border: 1px solid rgba(16, 185, 129, 0.45);
}

.badge.deprecated {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;                 /* 7.86:1 */
    border: 1px solid rgba(245, 158, 11, 0.45);
}

/* Marks a feature that requires the Professional plan. Uses the brand
   accent so it reads as a plan marker rather than a status like
   Draft/Published/Archived. */
.badge.professional {
    background: rgba(170, 40, 185, 0.20);
    color: #e09bf0;                 /* 8.07:1, was 4.83:1 */
    border: 1px solid rgba(170, 40, 185, 0.45);
    vertical-align: middle;
    margin-left: var(--spacing-sm);
}

/* An inline note under a heading saying what Standard does get. Deliberately
   quiet: the point is to stop someone burning an afternoon on a feature that
   silently does nothing, not to advertise. */
.tier-note {
    font-size: var(--font-size-sm);
    opacity: 0.85;
    border-left: 2px solid rgba(170, 40, 185, 0.35);
    padding-left: var(--spacing-md);
    margin: var(--spacing-sm) 0 var(--spacing-lg);
}

/* ============================================
   Screenshot Placeholders
   ============================================ */
.screenshot-placeholder {
    margin: var(--spacing-2xl) 0;
    text-align: center;
}

/* A docs video, framed like a screenshot. No vignette mask: it would dim
   the captions and the player's controls. */
.docs-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1440 / 900;
    margin: var(--spacing-xl) 0;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    background: #0f1322;
}

.screenshot {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    /* A soft vignette: the edges fade slightly into the dark page, so a
       bright product screen sits in the content instead of on it. A mask,
       because an <img> cannot carry an overlay pseudo-element and an inset
       shadow paints beneath the image. */
    -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 70%, rgba(0, 0, 0, 0.82) 100%);
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 70%, rgba(0, 0, 0, 0.82) 100%);
}

img.screenshot[role="button"] {
    cursor: zoom-in;
}

img.screenshot:focus-visible {
    outline: 2px solid var(--color-primary-blue);
    outline-offset: 4px;
}

/* The full-size view: the image at its own width, up to the viewport. */
.screenshot-zoom {
    /* margin: auto restores the centering the global reset removes. */
    margin: auto;
    border: none;
    padding: 0;
    background: transparent;
    max-width: 92vw;
    max-height: 88vh;
    overflow: visible;
    cursor: zoom-out;
}

.screenshot-zoom::backdrop {
    background: rgba(5, 8, 20, 0.88);
}

.screenshot-zoom img {
    display: block;
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

/* Pinned to the viewport corner, clear of the image's own controls. */
.screenshot-zoom-close {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: #1a1f35;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

body.screenshot-zoom-open {
    overflow: hidden;
}

.screenshot-caption {
    margin-top: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-style: italic;
}

/* ============================================
   Documentation Cards (for index and next steps)
   ============================================ */
.docs-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: var(--spacing-xl);
    margin: var(--spacing-2xl) 0;
}

.doc-card {
    background: rgba(30, 35, 55, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: block;
}

.doc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1e5ba8 0%, #AA28B9 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-base);
}

.doc-card:hover::before {
    transform: scaleX(1);
}

.doc-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(30, 91, 168, 0.3);
    border-color: rgba(170, 40, 185, 0.3);
}

.doc-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #1e5ba8 0%, #AA28B9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-lg);
    color: white;
}

.doc-card-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-sm);
}

.doc-card-description {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 0;
}

/* ============================================
   Mobile Sidebar Toggle (Vertical Tab)
   ============================================ */
.docs-sidebar-toggle {
    display: none;
    position: fixed;
    top: calc(var(--docs-navbar-height) + var(--spacing-md));
    left: 0;
    width: 26px;
    height: 48px;
    background: linear-gradient(135deg, #1e5ba8 0%, #AA28B9 100%);
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    cursor: pointer;
    z-index: 1001;
    border: none;
    border-left: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    transition: left var(--transition-base), box-shadow var(--transition-base);
}

/* Hamburger icon (three lines) */
.docs-sidebar-toggle::before,
.docs-sidebar-toggle::after {
    content: '';
    display: block;
    width: 10px;
    height: 2px;
    background: white;
    transition: all 0.3s ease;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.docs-sidebar-toggle::before {
    top: calc(50% - 5px);
}

.docs-sidebar-toggle::after {
    top: calc(50% + 3px);
}

.docs-sidebar-toggle span {
    display: block;
    width: 10px;
    height: 2px;
    background: white;
    transition: all 0.3s ease;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* X icon when open */
.docs-sidebar-toggle.open {
    left: var(--docs-sidebar-width);
}

.docs-sidebar-toggle.open::before {
    top: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

.docs-sidebar-toggle.open::after {
    top: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
}

.docs-sidebar-toggle.open span {
    opacity: 0;
}

.docs-sidebar-toggle:hover {
    box-shadow: 2px 0 15px rgba(30, 91, 168, 0.5);
}

/* ============================================
   Scroll to Top Button
   ============================================ */
.scroll-to-top {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #1e5ba8 0%, #AA28B9 100%);
    border-radius: var(--radius-full);
    box-shadow: 0 10px 30px rgba(30, 91, 168, 0.5);
    cursor: pointer;
    z-index: 999;
    border: none;
    color: white;
    font-size: var(--font-size-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
    transform: translateY(20px);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(30, 91, 168, 0.6);
}

/* ============================================
   FAQ Accordion (for FAQ page)
   ============================================ */
.faq-list {
    margin: var(--spacing-2xl) 0;
}

.faq-item {
    background: rgba(30, 35, 55, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    overflow: visible;
    transition: all var(--transition-base);
}

.faq-item:hover {
    border-color: rgba(30, 91, 168, 0.3);
    box-shadow: 0 4px 12px rgba(30, 91, 168, 0.1);
}

.faq-question {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-base);
    line-height: 1.5;
}

.faq-question:hover {
    background: rgba(30, 91, 168, 0.1);
}

.faq-question.active {
    background: rgba(30, 91, 168, 0.15);
    color: #9ecbfa;
    padding-bottom: var(--spacing-md);
}

.faq-question-text {
    flex: 1;
}

.faq-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
    margin-top: 2px;
}

.faq-question.active .faq-icon {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-answer.open {
    max-height: 5000px;
    overflow: visible;
}

.faq-answer-content {
    padding: 2rem var(--spacing-lg) var(--spacing-lg);
}

.faq-answer-content p {
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: var(--spacing-md);
}

.faq-answer-content p:last-child {
    margin-bottom: 0;
}

.faq-answer-content ul,
.faq-answer-content ol {
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-xl);
}

.faq-answer-content li {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
    line-height: 1.6;
}

.faq-answer-content .callout {
    margin: var(--spacing-lg) 0;
}

.faq-answer-content .properties-table {
    margin: var(--spacing-lg) 0;
}

.faq-answer-content .code-block {
    margin: var(--spacing-lg) 0;
}

/* ============================================
   Footer Override for Docs
   ============================================ */
.footer {
    background: var(--color-bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-left: var(--docs-sidebar-width);
}

.footer-tagline,
.footer-column a,
.footer-bottom p {
    color: var(--color-text-secondary);
}

.footer-heading {
    color: var(--color-text-primary);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    .docs-hero,
    .docs-hero-spacing {
        margin-left: 0;
    }

    .footer {
        margin-left: 0;
    }

    .docs-sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .docs-sidebar.open {
        transform: translateX(0);
    }

    .docs-main {
        margin-left: 0;
        width: 100%;
    }

    .docs-sidebar-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .docs-main {
        padding: var(--spacing-xl);
    }

    .docs-content {
        padding: var(--spacing-xl);
    }

    .docs-content h1 {
        font-size: var(--font-size-3xl);
    }

    .docs-content h2 {
        font-size: var(--font-size-2xl);
    }

    .docs-cards-grid {
        grid-template-columns: 1fr;
    }

    .properties-table,
    .params-table,
    .error-codes-table {
        display: block;
        overflow-x: auto;
    }

    .docs-hero,
    .docs-cards-section,
    .docs-popular-section,
    .docs-community-section {
        padding-left: var(--spacing-lg);
        padding-right: var(--spacing-lg);
    }

    .docs-section-title {
        font-size: var(--font-size-3xl);
    }

    .docs-community-card {
        padding: var(--spacing-xl);
    }
}

@media (max-width: 480px) {
    .docs-main {
        padding: var(--spacing-lg);
    }

    .docs-content {
        padding: var(--spacing-lg);
    }

    .docs-content h1 {
        font-size: var(--font-size-2xl);
    }

    .docs-hero,
    .docs-cards-section,
    .docs-popular-section,
    .docs-community-section {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
    }

    .docs-section-title {
        font-size: var(--font-size-2xl);
        margin-bottom: var(--spacing-xl);
    }

    .docs-community-card {
        padding: var(--spacing-lg);
    }
}

/* Media placeholders in the docs.
   Deliberately loud: an unreplaced placeholder should be obvious in review,
   not blend into the page and ship. */
.docs-media-placeholder {
    display: block;
    padding: 2rem;
    margin: 1.5rem 0;
    border: 2px dashed rgba(170, 40, 185, 0.35);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(30, 91, 168, 0.05) 0%, rgba(170, 40, 185, 0.05) 100%);
    text-align: center;
    color: var(--color-text-secondary);
}

.docs-media-placeholder span {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* ============================================
   Recipe Tabs (plugin walkthroughs)
   A tabbed walkthrough where each panel is a
   complete, self-contained build of one KIND of
   plugin. Panels are hidden with [hidden], and
   docs.js reveals the right one when an anchor
   inside a closed panel is targeted -- otherwise
   a search hit would scroll to an invisible box.
   ============================================ */
.recipe-tabs {
    margin: var(--spacing-lg) 0 var(--spacing-xl);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-secondary);
    overflow: hidden;
}

.recipe-tablist {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    background: rgba(10, 14, 26, 0.6);
    border-bottom: 1px solid var(--color-border);
    padding: 0;
    margin: 0;
}

.recipe-tab {
    flex: 1 1 auto;
    min-width: 8.5rem;
    appearance: none;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: var(--spacing-md) var(--spacing-md);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    text-align: center;
}

.recipe-tab:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.recipe-tab[aria-selected="true"] {
    color: var(--color-text-primary);
    border-bottom-color: var(--color-primary-blue);
    background: rgba(30, 91, 168, 0.12);
}

.recipe-tab:focus-visible {
    outline: 2px solid var(--color-primary-magenta);
    outline-offset: -2px;
}

.recipe-tab-kind {
    display: block;
    font-weight: 400;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

.recipe-tab[aria-selected="true"] .recipe-tab-kind {
    color: var(--color-text-secondary);
}

.recipe-panel {
    padding: var(--spacing-lg);
}

.recipe-panel[hidden] {
    display: none;
}

.recipe-panel > h4:first-child,
.recipe-panel > h3:first-child {
    margin-top: 0;
}

/* The one-line statement of what this recipe builds. */
.recipe-goal {
    border-left: 4px solid var(--color-primary-blue);
    background: rgba(30, 91, 168, 0.1);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.recipe-goal p {
    margin: 0;
}

.recipe-goal p + p {
    margin-top: var(--spacing-xs);
}

/* Numbered build steps inside a recipe panel. */
.recipe-steps {
    list-style: none;
    counter-reset: recipe-step;
    padding: 0;
    margin: 0;
}

.recipe-steps > li {
    counter-increment: recipe-step;
    position: relative;
    padding-left: 2.75rem;
    margin-bottom: var(--spacing-lg);
}

.recipe-steps > li::before {
    content: counter(recipe-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    color: var(--color-white);
    font-size: var(--font-size-sm);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recipe-steps > li > h5 {
    margin: 0.2rem 0 var(--spacing-sm);
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
}

.recipe-steps .code-block {
    margin-top: var(--spacing-sm);
}

/* "Which one do I need?" chooser above the tabs. */
.recipe-chooser {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-lg) 0;
}

.recipe-chooser td {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.recipe-chooser tr:last-child td {
    border-bottom: 0;
}

.recipe-chooser td:first-child {
    color: var(--color-text-primary);
    width: 45%;
}

.recipe-chooser a {
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .recipe-tab {
        flex: 1 1 100%;
        text-align: left;
        border-bottom: 1px solid var(--color-border);
        border-left: 3px solid transparent;
    }

    .recipe-tab[aria-selected="true"] {
        border-left-color: var(--color-primary-blue);
        border-bottom-color: var(--color-border);
    }

    .recipe-chooser td:first-child {
        width: auto;
    }
}
