/* ═══════════════════════════════════════════════════════════════
   Repdoc — shared design tokens & primitives
   Design system: design-system/repdoc/MASTER.md
   Loaded by every page (homepage, auth, admin), before the page CSS.
   Light is the default theme; [data-theme="dark"] overrides tokens.
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens: light (default) ─────────────────────────────────── */
:root {
    --bg-base:      #F4F7FC;
    --bg-surface:   #FFFFFF;
    --bg-muted:     #EEF4FF;
    --bg-elevated:  #FFFFFF;

    --text-primary: #12233F;
    --text-muted:   #66758C;

    --primary:       #0B57D0;
    --primary-hover: #093B9C;
    --primary-light: #EEF4FF;

    --border-color: #DFE7F2;
    --border-strong:#CFDCF0;
    --border-focus: #0B57D0;

    --success: #12A065;
    --success-bg: #EAF8F1;
    --warning: #B45309;
    --warning-bg: #FFF7E8;
    --danger:  #B42318;
    --danger-bg: #FEF5F4;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 10px 24px rgba(15, 23, 42, .10);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, .14);

    --font-sans:    'Inter', 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
    --font-heading: 'Inter', 'Noto Sans Bengali', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    --container: 1200px;
    --gutter: 20px;
    --header-h: 68px;

    --transition-fast: .15s ease;
    --transition-normal: .25s ease;
}

/* ── Tokens: dark override ───────────────────────────────────── */
[data-theme="dark"] {
    --bg-base:      #071426;
    --bg-surface:   #0B1B30;
    --bg-muted:     #102844;
    --bg-elevated:  #0E1F36;

    --text-primary: #EAF2FF;
    --text-muted:   #A8BCDA;

    --primary:       #5AA2FF;
    --primary-hover: #8BC0FF;
    --primary-light: rgba(90, 162, 255, .15);

    --border-color: #1D3557;
    --border-strong:#2A4A73;
    --border-focus: #5AA2FF;

    --success: #34D399;
    --success-bg: rgba(16, 185, 129, .18);
    --warning: #FBBF24;
    --warning-bg: rgba(245, 158, 11, .18);
    --danger:  #FB7185;
    --danger-bg: rgba(244, 63, 94, .18);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, .6);
}

/* ── Reset / base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
    /* Never let a stray wide element cause horizontal scroll. Mobile browsers
       zoom out to fit such overflow, which shrinks the painted page and leaves
       a blank strip beside it. */
    overflow-x: clip;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3 { margin: 0; font-family: var(--font-heading); line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

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

/* Outline icons: no fill, stroke follows text colour. */
.icon {
    width: 20px; height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.sprite g { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Focus visibility (both themes) ──────────────────────────── */
:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: var(--space-4); top: -60px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--space-4); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    border: 1.5px solid transparent;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast), transform var(--transition-fast);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .84rem; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Utilities ───────────────────────────────────────────────── */
/* Credit balance: tabular figures so amounts never shift width. */
.balance {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.balance-zero { color: var(--text-muted); }

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}
