/* ==========================================================================
   Atomic Storage — Quickstart Documentation Stylesheet
   ========================================================================== */

/* Fonts ------------------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&display=swap");
@import url("https://cdn.jsdelivr.net/npm/@fontsource-variable/lilex/index.min.css");

/* Design Tokens ----------------------------------------------------------- */
:root {
    /* Colors */
    --color-bg: #f8fafc;
    --color-surface: #0a0923;
    --color-text: #0f172a;
    --color-text-secondary: #475569;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-code-bg: #1e293b;
    --color-code-text: #e2e8f0;
    --color-border: #e2e8f0;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;
    --color-primary-bg: #eff6ff;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-links: #fe0173;

    /* Typography */
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
    --font-mono:
        "Lilex Variable", "Lilex", ui-monospace, "SFMono-Regular",
        "Cascadia Code", "Fira Code", monospace;

    /* Sizing */
    --container-max: 900px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:
        0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg:
        0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);

    /* Spacing scale */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;
    --sp-20: 80px;
}

/* Reset & Base ------------------------------------------------------------ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
svg {
    display: block;
    max-width: 100%;
}

/* Container --------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--sp-6);
}

/* Typography -------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    margin-top: var(--sp-6);
    margin-bottom: var(--sp-6);
}

h3 {
    font-size: 1.175rem;
    margin-top: var(--sp-2);
    margin-bottom: var(--sp-4);
    color: var(--color-links);
}

h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-top: var(--sp-8);
    margin-bottom: var(--sp-3);
}

p {
    margin-bottom: var(--sp-4);
    color: var(--color-text-secondary);
}

strong {
    font-weight: 600;
    color: var(--color-text);
}

/* Links ------------------------------------------------------------------- */
a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

a:hover,
a:focus-visible {
    color: var(--color-primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Nav Bar ----------------------------------------------------------------- */
.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.nav-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-bar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-bar__brand:hover {
    color: var(--color-text);
    text-decoration: none;
}

.nav-bar__brand svg,
.nav-bar__brand img {
    height: 40px;
}

.nav-bar__tag {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-primary);
    background: var(--color-primary-bg);
    padding: 2px 8px;
    border-radius: 999px;
}

.nav-bar__links {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    list-style: none;
}

.nav-bar__links a {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-links);
}

.nav-bar__links a:hover {
    color: var(--color-links);
    text-decoration: underline;
}

/* Hero -------------------------------------------------------------------- */
.hero {
    padding: var(--sp-10) 0 var(--sp-6);
    text-align: center;
}

.hero__title {
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: var(--sp-5);
    color: var(--color-text);
}

.hero__subtitle {
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--color-text-secondary);
    max-width: 620px;
    margin-inline: auto;
    line-height: 1.65;
}

.hero__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    margin-top: var(--sp-8);
}

.hero__actions .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-6);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.hero-card-label {
    color: var(--color-links);
}

.hero__actions .btn--primary {
    background: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

.hero__actions .btn--primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    text-decoration: none;
    color: #ffffff;
}

.hero__actions .btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.hero__actions .btn--secondary:hover {
    background: var(--color-bg);
    border-color: #cbd5e1;
    text-decoration: none;
}

/* Steps ------------------------------------------------------------------- */
.steps {
    display: flex;
    flex-direction: column;
    counter-reset: step-counter;
    padding-bottom: var(--sp-12);
    width: 90%;
    max-width: var(--container-max);
    margin-inline: auto;
}

.steps__item {
    counter-increment: step-counter;
    position: relative;
    padding-left: var(--sp-16);
    padding-bottom: var(--sp-12);
    align-content: center;
}

/* Vertical connector line */
.steps__item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 19px;
    top: 44px;
    bottom: 0;
    width: 2px;
    background: var(--color-border);
}

/* Step number circle */
.steps__item::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.steps__title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--sp-3);
    padding-top: var(--sp-2);
}

.steps__body p {
    margin-bottom: var(--sp-3);
}

/* Inline Code ------------------------------------------------------------- */
code {
    font-family: var(--font-mono);
    font-size: 0.855em;
    font-weight: 400;
    background: #f1f5f9;
    color: #0f172a;
    padding: 0.15em 0.45em;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    word-break: break-word;
}

/* Code Blocks ------------------------------------------------------------- */
.code-block {
    position: relative;
}

.code-block pre {
    margin: var(--sp-4) 0 var(--sp-6);
}

.copy-btn {
    position: absolute;
    top: calc(var(--sp-4) + 8px);
    right: 10px;
    z-index: 2;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--color-code-text);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.copy-btn.copied {
    color: var(--color-success);
    border-color: var(--color-success);
    background: rgba(22, 163, 74, 0.12);
}

pre {
    margin: var(--sp-4) 0 var(--sp-6);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

pre > code {
    display: block;
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: var(--sp-5) var(--sp-6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    font-size: 0.84rem;
    line-height: 1.75;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    tab-size: 2;
    word-break: normal;
    white-space: pre;
}

/* Optional line-number gutter feel */
pre > code .line-number {
    display: inline-block;
    width: 2ch;
    margin-right: var(--sp-4);
    color: #64748b;
    user-select: none;
}

/* Syntax tokens (basic set — can extend per highlighter) */
pre > code .token-comment {
    color: #64748b;
    font-style: italic;
}
pre > code .token-keyword {
    color: #c084fc;
}
pre > code .token-string {
    color: #86efac;
}
pre > code .token-function {
    color: #7dd3fc;
}
pre > code .token-number {
    color: #fbbf24;
}
pre > code .token-punct {
    color: #94a3b8;
}

/* Card -------------------------------------------------------------------- */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card__header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-primary-bg);
    color: var(--color-primary);
    flex-shrink: 0;
}

.card__title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Grid of cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-6);
    margin-top: var(--sp-6);
    margin-bottom: var(--sp-8);
}

/* Badge ------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.7;
}

.badge--primary {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.badge--success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge--warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge--neutral {
    background: #f1f5f9;
    color: var(--color-text-secondary);
}

/* Method badges (REST verbs) */
.badge--get {
    background: #dbeafe;
    color: #1d4ed8;
}
.badge--post {
    background: #d1fae5;
    color: #047857;
}
.badge--put {
    background: #fef3c7;
    color: #92400e;
}
.badge--delete {
    background: #fee2e2;
    color: #b91c1c;
}

/* Tables (shared base) ---------------------------------------------------- */
.endpoint-table,
.config-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--sp-4) 0 var(--sp-8);
    font-size: 0.88rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.endpoint-table thead,
.config-table thead {
    background: #f8fafc;
}

.endpoint-table th,
.config-table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 2px solid var(--color-border);
}

.endpoint-table td,
.config-table td {
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    color: var(--color-text);
}

.endpoint-table tbody tr:last-child td,
.config-table tbody tr:last-child td {
    border-bottom: none;
}

.endpoint-table tbody tr:hover,
.config-table tbody tr:hover {
    background: #f8fafc;
}

/* Endpoint-specific: method + path columns */
.endpoint-table td:nth-child(1) {
    white-space: nowrap;
    font-weight: 600;
}

.endpoint-table td:nth-child(2) code {
    font-size: 0.82em;
    background: var(--color-code-bg);
    color: var(--color-code-text);
    padding: 0.2em 0.55em;
    border: none;
}

/* Config-specific: key column monospaced */
.config-table td:first-child {
    font-family: var(--font-mono);
    font-size: 0.83em;
    color: var(--color-primary);
    white-space: nowrap;
}

.config-table td:nth-child(2) {
    color: var(--color-text-secondary);
}

.config-table td:last-child code {
    font-size: 0.82em;
}

/* Callout / Tip ----------------------------------------------------------- */
.callout {
    display: flex;
    gap: var(--sp-4);
    padding: var(--sp-5) var(--sp-6);
    border-radius: var(--radius-md);
    margin: var(--sp-5) 0;
    border-left: 3px solid;
    font-size: 0.92rem;
}

.callout--info {
    background: var(--color-primary-bg);
    border-color: var(--color-primary);
}

.callout--success {
    background: var(--color-success-bg);
    border-color: var(--color-success);
}

.callout--warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
}

.callout__icon {
    flex-shrink: 0;
    font-size: 1.1rem;
    line-height: 1.7;
}

.callout p {
    margin: 0;
    color: var(--color-text);
}

/* Lists ------------------------------------------------------------------- */
ul,
ol {
    padding-left: var(--sp-6);
    margin-bottom: var(--sp-4);
}

li {
    margin-bottom: var(--sp-2);
    color: var(--color-text-secondary);
}

li::marker {
    color: var(--color-primary);
}

/* Divider ----------------------------------------------------------------- */
hr {
    border: none;
    height: 1px;
    background: var(--color-border);
    margin: var(--sp-12) 0;
}

/* Footer ------------------------------------------------------------------ */
.footer {
    margin-top: var(--sp-16);
    padding: var(--sp-10);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.84rem;
    color: var(--color-links);
}

.footer__links {
    display: flex;
    gap: var(--sp-4);
    list-style: none;
    color: var(--color-code-text);
}

.footer__links a {
    font-weight: 400;
    color: var(--color-links);
}

.footer__links a:hover {
    color: var(--color-links);
    text-decoration: underline;
}

.footer__copy {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

/* Utility ----------------------------------------------------------------- */
.text-center {
    text-align: center;
}
.text-mono {
    font-family: var(--font-mono);
}
.mt-0 {
    margin-top: 0;
}
.mb-0 {
    margin-bottom: 0;
}
.mt-8 {
    margin-top: var(--sp-8);
}
.mb-8 {
    margin-bottom: var(--sp-8);
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* =========================================================================
   Responsive — Mobile-first adjustments
   ========================================================================= */

@media (max-width: 768px) {
    :root {
        --container-max: 100%;
    }

    .container {
        padding-inline: var(--sp-4);
    }

    /* Nav */
    .nav-bar .container {
        height: 50px;
    }

    .nav-bar__links {
        gap: var(--sp-3);
    }

    .nav-bar__links a {
        font-size: 0.8rem;
    }

    /* Hero */
    .hero {
        padding: var(--sp-12) 0 var(--sp-10);
    }

    .hero__title {
        font-size: 1.85rem;
    }

    .hero__subtitle {
        font-size: 1rem;
    }

    .hero__actions {
        flex-direction: column;
    }

    .hero__actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* Typography */
    h1 {
        font-size: 1.75rem;
    }
    h2 {
        font-size: 1.25rem;
        margin-top: var(--sp-10);
    }
    h3 {
        font-size: 1.05rem;
    }

    /* Steps */
    .steps__item {
        padding-left: var(--sp-12);
    }

    .steps__item::before {
        width: 32px;
        height: 32px;
        font-size: 0.82rem;
    }

    .steps__item:not(:last-child)::after {
        left: 15px;
        top: 38px;
    }

    /* Code */
    pre > code {
        padding: var(--sp-4);
        font-size: 0.8rem;
    }

    /* Cards */
    .card {
        padding: var(--sp-5);
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: var(--sp-4);
    }

    /* Tables — horizontal scroll wrapper */
    .endpoint-table,
    .config-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Footer */
    .footer .container {
        flex-direction: column;
        gap: var(--sp-4);
        text-align: center;
    }

    .footer__links {
        justify-content: center;
        flex-wrap: wrap;
        gap: var(--sp-4);
    }
}

/* Tiny screens */
@media (max-width: 480px) {
    .hero__title {
        font-size: 1.55rem;
    }

    .steps__item {
        padding-left: var(--sp-10);
    }

    .steps__item::before {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .steps__item:not(:last-child)::after {
        left: 13px;
        top: 34px;
    }

    .nav-bar__tag {
        display: none;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
