/* Cascade order for every page: later layers win, whatever the selector specificity.
   tokens → base → layout → components → pages. Rules outside a layer are not used. */
@layer tokens, base, layout, components, pages;

/* Readex Pro (SIL Open Font License, wwwroot/lib/readex-pro/LICENSE), served from this site: one variable file per
   script, so a page loads only the scripts it shows. Files from @fontsource-variable/readex-pro 5.3.0, checked
   against the npm registry's SHA-512 (decision D20.02). */
@font-face {
    font-family: 'Readex Pro';
    font-style: normal;
    font-display: swap;
    font-weight: 160 700;
    src: url('../lib/readex-pro/readex-pro-arabic-wght-normal.woff2') format('woff2');
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E,
                   U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
    font-family: 'Readex Pro';
    font-style: normal;
    font-display: swap;
    font-weight: 160 700;
    src: url('../lib/readex-pro/readex-pro-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
                   U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
                   U+A720-A7FF;
}
@font-face {
    font-family: 'Readex Pro';
    font-style: normal;
    font-display: swap;
    font-weight: 160 700;
    src: url('../lib/readex-pro/readex-pro-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                   U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Design tokens: the only place colours, radii and sizes are defined. The 2026 design (decisions/20-design.md):
   warm neutrals, one blue accent, thin lines instead of shadows, Readex Pro. The names are the ones every page
   already uses, so only the values changed. */
@layer tokens {
    :root {
        color-scheme: light;

        --font-sans: 'Readex Pro', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;

        --primary:       #2450D6;
        --primary-dark:  #1D43B8;
        --primary-glow:  rgba(36, 80, 214, .16);
        --accent-soft:   #EAF0FD;
        /* Text and icons on a --primary fill (buttons, the current page number). A client theme with a light brand
           colour sets it dark (decision D21.03). */
        --on-primary:    #FFFFFF;
        /* The brand colour as text: links, the current tab, an outline button (D20.18). The brand colour itself when it
           reads at 4.5:1; dark mode needs a lighter one, because --primary must also carry white button text. */
        --primary-text:  var(--primary);
        --error:         #B42318;
        /* Status colours for text, marks and lines (D20.17): a done step, points earned, points used, a warning note. */
        --success:       #177A3C;
        --danger:        #B42318;
        --warning:       #B45309;
        /* A filled danger button (delete, refund) and its text (D20.18). */
        --danger-solid:  #B42318;
        --on-danger:     #FFFFFF;

        /* Tones: the accent of a card, badge or chart series. -ink is its text/icon colour. */
        --tone-blue:   #2450D6;  --tone-blue-ink:   #1D43B8;
        --tone-amber:  #F59E0B;  --tone-amber-ink:  #A44A08;
        --tone-green:  #10B981;  --tone-green-ink:  #047857;
        --tone-violet: #8B5CF6;  --tone-violet-ink: #7C3AED;
        --tone-pink:   #EC4899;  --tone-pink-ink:   #BE185D;
        --tone-teal:   #14B8A6;  --tone-teal-ink:   #0F766E;
        --tone-red:    #EF4444;  --tone-red-ink:    #B91C1C;
        /* How much of a tone tints its soft background. */
        --tone-soft: 10%;

        /* Surfaces and text */
        --page-bg:        #F7F6F3;
        --surface:        #FFFFFF;
        --surface-sunken: #F2F1ED;
        --border:         #E7E4DD;
        --border-strong:  #D4CFC5;
        --divider:        #EFEDE8;
        --hover:          #F3F2EE;
        --text:           #1C1B19;
        --text-sub:       #6B675F;
        --text-muted:     #736E67;
        --ring-track:     #E7E4DD;
        --grid-line:      rgba(28, 27, 25, .06);

        --radius-xs:   4px;
        --radius-sm:   6px;
        --radius-md:   10px;
        --radius-lg:   12px;
        --radius-pill: 999px;
        --hairline:    1px;

        --shadow-card-hover: 0 6px 20px rgba(28, 27, 25, .06);
        --shadow-header:     none;

        /* Shell */
        --header-height:     60px;
        --sidebar-width:     256px;
        --sidebar-width-min: 68px;
        --content-gutter:    28px;
        /* The inside edge of every card (D20.24): its title, body, footer, table's first and last columns, and the
           counts, notes and tabs between them all start on this line. 16px on phones (see below). */
        --card-pad:          1.25rem;

        /* Left menu */
        --menu-link:          #57534C;
        --menu-hover-bg:      #F3F2EE;
        --menu-hover:         #1C1B19;
        --menu-active-bg:     #EAF0FD;
        --menu-active:        #1D43B8;
        --menu-active-shadow: transparent;
        --menu-icon:          #85807A;
        --menu-heading:       #85807A;
        --menu-bullet:        #D4CFC5;
        --menu-arrow:         #A29E96;
        --menu-separator:     #EFEDE8;

        /* Sidebar toggle */
        --toggle-from: #F59E0B;
        --toggle-to:   #FB923C;
        --toggle-ring: rgba(245, 158, 11, .22);
        --toggle-glow: rgba(245, 158, 11, .40);

        /* Forms */
        --input-bg:       #FFFFFF;
        --input-border:   #D4CFC5;
        --warning-bg:     #FFFBEB;
        --warning-border: #FCD34D;
        --warning-text:   #92400E;
        --danger-bg:      rgba(239, 68, 68, .08);
        --danger-border:  rgba(239, 68, 68, .25);
        --backdrop:       rgba(17, 24, 39, .45);

        --ease: cubic-bezier(.4, 0, .2, 1);
    }

    @media (max-width: 599.98px) {
        :root { --card-pad: 16px; }
    }

    :root[data-theme="dark"] {
        color-scheme: dark;

        /* A lighter blue, so links and the accent stay readable on the dark surfaces. */
        --primary:      #4169E1;
        --primary-dark: #3459CC;
        --primary-glow: rgba(125, 155, 255, .20);
        --accent-soft:  rgba(125, 155, 255, .13);
        --primary-text: #7B9AF2;
        --error:        #F08A7E;
        --success:      #5CC98A;
        --danger:       #F08A7E;
        --warning:      #E7A443;
        --danger-solid: #DC2626;
        --tone-soft:    15%;

        --tone-blue:       #4169E1;
        --tone-blue-ink:   #9AB2FF;
        --tone-amber-ink:  #FBBF24;
        --tone-green-ink:  #34D399;
        --tone-violet-ink: #A78BFA;
        --tone-pink-ink:   #F472B6;
        --tone-teal-ink:   #2DD4BF;
        --tone-red-ink:    #F87171;

        --page-bg:        #121211;
        --surface:        #1B1B1A;
        --surface-sunken: #171716;
        --border:         #2A2927;
        --border-strong:  #3D3B38;
        --divider:        #252422;
        --hover:          #222220;
        --text:           #ECEBE7;
        --text-sub:       #A29E96;
        --text-muted:     #8A867E;
        --ring-track:     #2A2927;
        --grid-line:      rgba(255, 255, 255, .06);

        --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, .3);

        --menu-link:          #A29E96;
        --menu-hover-bg:      #222220;
        --menu-hover:         #ECEBE7;
        --menu-active-bg:     rgba(125, 155, 255, .13);
        --menu-active:        #A6BBFF;
        --menu-active-shadow: transparent;
        --menu-icon:          #8A867E;
        --menu-heading:       #77736C;
        --menu-bullet:        #3D3B38;
        --menu-arrow:         #77736C;
        --menu-separator:     #2A2927;

        --toggle-ring: rgba(245, 158, 11, .18);
        --toggle-glow: rgba(245, 158, 11, .28);

        --input-bg:       #171716;
        --input-border:   #3D3B38;
        --warning-bg:     #2D2413;
        --warning-border: #92400E;
        --warning-text:   #FCD34D;
        --danger-bg:      rgba(248, 113, 113, .10);
        --danger-border:  rgba(248, 113, 113, .30);
        --backdrop:       rgba(0, 0, 0, .6);
    }
}
