/* ==========================================================================
   dr.eamer.dev API docs: shared standard developer-documentation stylesheet
   Stripe / GitHub-style reference layout: sticky left sidebar, single content
   column, method badges, monospace code, parameter tables. Light, neutral.
   ========================================================================== */

:root {
    /* Neutral surface palette */
    --bg:            #ffffff;
    --bg-secondary:  #f7f8fa;   /* cards, sidebar, table headers */
    --bg-tertiary:   #eef0f3;   /* code chips, param rows */
    --code-bg:       #f6f8fa;

    /* Ink */
    --text:          #1f2933;   /* dark slate body */
    --text-muted:    #52606d;
    --text-subtle:   #7b8794;

    /* Borders */
    --border:        #d7dce2;
    --border-subtle: #e7eaee;

    /* Accent (saturn signal family for cohesion) */
    --accent:        #2F5D8F;   /* links / active nav */
    --accent-hover:  #234a73;
    --accent-subtle: #e8eef5;   /* active nav background */
    --hot:           #CE3526;   /* sparing emphasis */

    /* Status */
    --success:       #1a7f37;
    --warning:       #9a6700;
    --danger:        #CE3526;

    /* HTTP method badge colors (conventional) */
    --badge-get:     #1a7f37;   /* green */
    --badge-post:    #2F5D8F;   /* blue */
    --badge-put:     #9a6700;   /* amber */
    --badge-delete:  #CE3526;   /* red */
    --badge-patch:   #6f42c1;   /* purple */

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'IBM Plex Mono', Menlo, Monaco, 'Courier New', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ---- Skip link (WCAG 2.4.1) ------------------------------------------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    background: var(--accent);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 6px 0;
    font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---- Links ------------------------------------------------------------ */
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Visible focus outline everywhere (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.endpoint-header:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---- Header ----------------------------------------------------------- */
header.site-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-nav {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.header-nav a {
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.4rem 0.25rem;
    min-height: 44px;            /* touch target */
    display: inline-flex;
    align-items: center;
}
.header-nav a:hover { color: var(--accent); text-decoration: none; }

.api-badge {
    background: var(--accent-subtle);
    color: var(--accent);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

/* ---- Layout: sticky sidebar + content column -------------------------- */
.container {
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 256px minmax(0, 1fr);
    gap: 3rem;
    padding: 2.5rem 2rem;
    align-items: start;
}

/* Single-column pages (access, getting-started, reference) center content */
.container.single {
    grid-template-columns: minmax(0, 820px);
    justify-content: center;
}

/* ---- Sidebar ---------------------------------------------------------- */
.sidebar {
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.sidebar nav h3,
.sidebar h3 {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 1.25rem 0 0.5rem;
    padding: 0 0.5rem;
}
.sidebar nav > h3:first-child,
.sidebar h3:first-child { margin-top: 0; }

.sidebar ul { list-style: none; }
.sidebar li { margin: 0; }

.sidebar a {
    display: block;
    padding: 0.4rem 0.65rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-radius: 5px;
    border-left: 2px solid transparent;
    line-height: 1.35;
}
.sidebar a:hover {
    background: var(--bg-secondary);
    color: var(--accent);
    text-decoration: none;
}
.sidebar a.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
}

/* ---- Main content ----------------------------------------------------- */
main { min-width: 0; }

section { margin-bottom: 3.5rem; scroll-margin-top: 84px; }

h2 {
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
}

h4 { font-size: 1.02rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }

p { color: var(--text-muted); margin-bottom: 1rem; line-height: 1.7; }

ul, ol { color: var(--text-muted); margin: 0 0 1rem 1.25rem; }

/* Inline code */
:not(pre) > code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-tertiary);
    color: var(--text);
    padding: 0.12em 0.4em;
    border-radius: 4px;
}

/* ---- Hero (getting-started / access) ---------------------------------- */
.hero { margin-bottom: 3rem; }
.hero h2 {
    font-size: 2rem;
    border: none;
    padding: 0;
    margin-bottom: 0.75rem;
}
.hero p { font-size: 1.05rem; max-width: 70ch; }
.hero-links { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.hero-links a {
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.hero-links a:hover { background: var(--bg-secondary); text-decoration: none; }

/* ---- Auth method + rate-limit callouts -------------------------------- */
.auth-methods {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}
.auth-methods h4 { font-size: 0.95rem; margin: 0 0 0.75rem; }
.auth-methods h4:not(:first-child) { margin-top: 1.25rem; }

.auth-method {
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    padding: 0.85rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}
.auth-method code { color: var(--success); background: none; padding: 0; }

.rate-limit {
    background: var(--accent-subtle);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.rate-limit-icon { font-size: 1.4rem; line-height: 1; }
.rate-limit-text { flex: 1; }
.rate-limit-text strong { color: var(--text); display: block; margin-bottom: 0.15rem; }

/* ---- Endpoint blocks -------------------------------------------------- */
.endpoint {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.endpoint:hover { border-color: var(--text-subtle); }

.endpoint-header {
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
    background: var(--bg-secondary);
    min-height: 44px;
}
.endpoint-header:hover { background: var(--bg-tertiary); }

.method-badge {
    padding: 0.28rem 0.6rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    flex-shrink: 0;
    font-family: var(--font-mono);
}
.method-get    { background: var(--badge-get); }
.method-post   { background: var(--badge-post); }
.method-put    { background: var(--badge-put); }
.method-delete { background: var(--badge-delete); }
.method-patch  { background: var(--badge-patch); }

.endpoint-path {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
    word-break: break-all;
}
.endpoint-toggle {
    color: var(--text-subtle);
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.endpoint.expanded .endpoint-toggle { transform: rotate(180deg); }

.endpoint-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.endpoint.expanded .endpoint-body { max-height: 4000px; }
.endpoint-content { padding: 1.5rem; border-top: 1px solid var(--border-subtle); }
.endpoint-description { color: var(--text-muted); margin-bottom: 1.25rem; }

/* ---- Parameters ------------------------------------------------------- */
.params { margin-bottom: 1.25rem; }
.params h5 {
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.param {
    background: var(--bg-secondary);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem;
    align-items: start;
}
.param-name {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 600;
}
.param-type { color: var(--text-subtle); font-size: 0.72rem; margin-left: 0.4rem; }
.param-desc { font-size: 0.85rem; color: var(--text-muted); }
.param-desc code { font-size: 0.85em; }

/* ---- Parameter / status tables --------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}
th, td {
    padding: 0.6rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}
th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
}
td { color: var(--text); }
td code { color: var(--accent); }
.params-table { /* alias used in some sections */ }

/* ---- Code examples + tabs --------------------------------------------- */
.code-examples { margin-top: 1.25rem; }
.code-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}
.code-tab {
    padding: 0.55rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: var(--font-sans);
    border-bottom: 2px solid transparent;
    position: relative;
    top: 1px;
    min-height: 40px;
}
.code-tab:hover { color: var(--text); }
.code-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.code-block-container { position: relative; }
.code-block { display: none; }
.code-block.active { display: block; }

pre {
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.1rem 1.25rem !important;
    overflow-x: auto;
    margin: 0.75rem 0 !important;
    position: relative;
}
pre code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text);
    background: none;
    padding: 0;
}
code { font-family: var(--font-mono); }

.inline-code {
    background: var(--bg-tertiary);
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--text);
    font-family: var(--font-mono);
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    z-index: 10;
    min-height: 32px;
}
.copy-btn:hover { background: var(--bg-secondary); color: var(--text); border-color: var(--accent); }
.copy-btn.copied { background: var(--success); color: #fff; border-color: var(--success); }

/* ---- Response example ------------------------------------------------- */
.response-example { margin-top: 1rem; }
.response-example h6 {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-subtle);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---- Provider grid + source tags -------------------------------------- */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
    margin: 1.5rem 0;
}
.provider-tag {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-align: center;
    font-size: 0.84rem;
    color: var(--text-muted);
}
.provider-tag:hover { border-color: var(--accent); color: var(--text); }

.source-category { margin-bottom: 1.5rem; }
.source-category h4 {
    font-size: 0.78rem;
    color: var(--text-subtle);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.source-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.source-tag {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.84rem;
    color: var(--text);
    font-family: var(--font-mono);
}

/* ---- Mermaid container ------------------------------------------------ */
.mermaid-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
    overflow-x: auto;
}

/* ---- Info cards (getting-started) ------------------------------------- */
.info-card {
    background: var(--accent-subtle);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}
.info-card.warning { background: #fdf6e3; border-left-color: var(--warning); }
.info-card.success { background: #eaf6ec; border-left-color: var(--success); }
.info-card h5 { font-size: 0.98rem; margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.5rem; }
.info-card p { margin: 0; font-size: 0.92rem; }

/* ---- Steps (getting-started) ------------------------------------------ */
.steps { display: flex; flex-direction: column; gap: 1.5rem; }
.step {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.75rem 1.5rem 1.5rem;
    position: relative;
}
.step-number {
    position: absolute;
    top: -14px;
    left: 18px;
    background: var(--accent);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}
.step h4 { margin-top: 0; font-size: 1.15rem; }

/* ---- SDK grid (getting-started) --------------------------------------- */
.sdk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}
.sdk-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}
.sdk-card:hover { border-color: var(--accent); }
.sdk-card h5 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.sdk-card p { font-size: 0.9rem; margin-bottom: 1rem; }

/* ---- Method badge inline (getting-started headings) ------------------- */
h4 .method-badge { margin-right: 0.5rem; vertical-align: middle; }

/* ---- Pricing plans (access) ------------------------------------------- */
.plans {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}
.plan-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
}
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-badge {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    border-radius: 10px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.plan-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
}
.plan-price { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.2rem; }
.plan-price span { font-size: 0.95rem; font-weight: 400; color: var(--text-subtle); }
.plan-limit {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.plan-features { list-style: none; flex: 1; margin: 0 0 1.25rem 0; }
.plan-features li {
    font-size: 0.88rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.plan-features li::before { content: '\2713'; color: var(--success); font-weight: 700; flex-shrink: 0; }
.plan-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.7rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    min-height: 44px;
}
.plan-cta:hover { text-decoration: none; opacity: 0.9; }
.plan-cta.primary { background: var(--accent); color: #fff; }
.plan-cta.secondary { background: var(--bg-tertiary); color: var(--text); border: 1px solid var(--border); }
.plan-cta.contact { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* ---- Forms (access / getting-started) --------------------------------- */
.free-section, .key-request {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    margin-bottom: 2.5rem;
}
.free-section h3, .key-request h4 { margin-top: 0; }
.free-section p { font-size: 0.94rem; margin-bottom: 1.25rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.25rem; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    padding: 0.6rem 0.85rem;
    font-family: inherit;
    min-height: 44px;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-subtle); }
.form-group textarea { resize: vertical; min-height: 90px; }
.form-group small { color: var(--text-subtle); font-size: 0.82rem; }
.form-full { grid-column: 1 / -1; }

.submit-btn, .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    cursor: pointer;
    min-height: 44px;
}
.submit-btn:hover, .btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.form-note { font-size: 0.8rem; color: var(--text-subtle); margin-top: 0.75rem; }

.success-msg {
    display: none;
    background: #eaf6ec;
    border: 1px solid var(--success);
    border-radius: 6px;
    padding: 1rem 1.5rem;
    color: var(--success);
    margin-top: 1rem;
    font-size: 0.95rem;
}

/* ---- FAQ (access) ----------------------------------------------------- */
.faq { margin-bottom: 2.5rem; }
.faq h3 { margin-bottom: 1.25rem; }
.faq-item { border-bottom: 1px solid var(--border-subtle); padding: 1rem 0; }
.faq-item h4 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.faq-item p { font-size: 0.9rem; margin: 0; }

/* ---- Footer ----------------------------------------------------------- */
footer.site-footer {
    margin-top: 3rem;
    padding: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}
footer.site-footer a { color: var(--accent); }

/* ---- Responsive: sidebar stacks under ~900px -------------------------- */
@media (max-width: 900px) {
    .container { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.5rem 1rem; }
    .sidebar {
        position: static;
        order: -1;
        max-height: none;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 1rem;
        background: var(--bg-secondary);
    }
    .container.single { grid-template-columns: 1fr; }
    .param { grid-template-columns: 1fr; gap: 0.25rem; }
    .form-row { grid-template-columns: 1fr; }
    .header-content { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
    header.site-header { padding: 0.85rem 1rem; }
    .header-content h1 { font-size: 1.05rem; }
    h2 { font-size: 1.45rem; }
    .plans { grid-template-columns: 1fr; }
    .provider-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ---- Reduced motion (WCAG 2.3.3 / respects user pref) ----------------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
