/*
 * The website's design tokens («Heft»), the only file with raw values
 * (tools/check-css.py skips it). Colours shared with the app carry the app's
 * values (crates/lesson-planner/static/css/tokens.css); the rest belongs to
 * the website's school material: register tabs, sticky notes, tape, a paper
 * clip, handwriting and large ink numerals. The theme follows the system
 * (prefers-color-scheme) unless the header button chose one (theme.js).
 * Check the colours with tools/contrast.py website/tokens.css.
 */
@layer reset, base, layout, components, pages, utilities;

/* ---------- Fonts (SIL OFL 1.1, built by tools/build-fonts.py) ---------- */
@font-face {
    font-family: "Figtree";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/fonts/figtree.woff2") format("woff2");
}
@font-face {
    font-family: "Literata";
    font-style: normal;
    font-weight: 500 700;
    font-display: swap;
    src: url("/fonts/literata.woff2") format("woff2");
}
/* Margin notes only: short, large, never body text. */
@font-face {
    font-family: "Caveat";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("/fonts/caveat.woff2") format("woff2");
}

/* ---------- Theme-independent tokens ---------- */
:root {
    /* Figtree for text, Literata for headings, numerals and the wordmark,
     * Caveat for the few handwritten notes. */
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: "Literata", Georgia, "Times New Roman", serif;
    --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;

    --root-size: 1rem;

    /* Type scale, ratio about 1.2 around the 1rem body text; the website
     * pushes the top: hero, section titles, ink numerals. */
    --text-2xs: 0.6875rem;  /* the app replicas' smallest captions */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-md: 1.125rem;    /* lead paragraphs */
    --text-lg: 1.2rem;
    --text-xl: 1.44rem;
    --text-2xl: 1.728rem;
    --text-h2: clamp(1.875rem, 1.2rem + 2vw, 3rem);
    --text-h3: clamp(var(--text-lg), 1.05rem + 0.35vw, 1.375rem);
    --text-hero: clamp(2.625rem, 1.3rem + 4.8vw, 5.25rem);
    --text-price: clamp(2.75rem, 1.8rem + 3vw, 4.5rem);
    /* Ink numerals: the times in «Ihr Arbeitstag». */
    --text-numeral: clamp(2.75rem, 2rem + 2.6vw, 4.25rem);
    /* Caveat runs small: about 1.4 times Figtree for the same x-height. */
    --text-hand: 1.5rem;
    --text-hand-lg: clamp(1.625rem, 1.3rem + 0.9vw, 2.125rem);

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --leading-none: 1;
    --leading-tight: 1.1;
    --leading-snug: 1.3;
    --leading-normal: 1.6;

    --tracking-tight: -0.02em;
    --tracking-caps: 0.06em;

    /* Spacing: the app's 4px scale, plus two steps for the section rhythm. */
    --space-0: 0.125rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 2rem;
    --space-8: 3rem;
    --space-9: 4rem;
    --space-10: 6rem;
    --section-pad: clamp(var(--space-8), 2rem + 4vw, var(--space-10));

    --border-width: 1px;
    --border-thick: 3px;
    --focus-width: 2px;
    --focus-offset: 2px;
    --margin-width: 2px;   /* the red margin line */

    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.75rem;   /* device frames */
    --radius-phone: 1.75rem;
    --radius-pill: 999px;
    /* A highlighter stroke: uneven ends, like a felt tip pressed on paper. */
    --radius-marker: 0.15em 0.3em 0.2em 0.35em;
    /* A register tab: rounded on top, flush with its sheet below. */
    --radius-tab: 0.5rem 0.5rem 0 0;
    /* A sticky note curls a little at the lower right corner. */
    --radius-note: 0.125rem 0.125rem 0.75rem 0.125rem;

    --control-text: var(--text-sm);
    --control-pad-y: 0.6rem;
    --control-pad-x: 0.9rem;
    --control-h: calc(var(--control-text) * 1.25 + var(--control-pad-y) * 2 + var(--border-width) * 2);
    /* Links and buttons a finger hits: 44px under pointer: coarse. */
    --target-min: 1.5rem;

    --tint-faint: 5%;
    --tint-hover: 8%;
    --tint-selected: 14%;
    --tint-strong: 20%;
    --tint-edge: 40%;

    /* Motion: only under prefers-reduced-motion: no-preference (the end of
     * style.css). Feedback within 120-200 ms; the strokes drawn once are
     * slower, like a pen. */
    --duration-fast: 0.12s;    /* a press, a colour */
    --duration-normal: 0.2s;   /* a lift, an underline, a highlighter on hover */
    --duration-open: 0.32s;    /* an answer opening or closing */
    --duration-ring: 0.5s;     /* the ink ring closing around «Jetzt» */
    --duration-draw: 0.7s;     /* a highlighter stroke drawn once */
    --delay-claim: 0.15s;      /* the claim's stroke, once the page shows */
    --delay-now: 0.8s;         /* then «Jetzt» in the replica */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    /* A pen stroke: gathers speed, slows down at the end of the word. */
    --ease-pen: cubic-bezier(0.55, 0.05, 0.25, 1);
    --lift: -2px;              /* a button or tab rises under the pointer */
    --press: 1px;              /* and is pressed into the paper */
    --nudge: 0.1875rem;        /* an arrow moves on */
    --slide: -0.375rem;        /* an answer slides down into place */
    --ring-from: 0.5rem;       /* the ring starts this far out */
    /* A section title's stroke is drawn while the title enters the screen. */
    --draw-range: entry 0% cover 35%;

    --z-raised: 1;
    --z-sticky: 20;
    --z-skip: 100;

    /* Widths. */
    --measure: 68ch;
    --page-max: 76rem;
    --gutter: clamp(var(--space-5), 0.5rem + 3vw, var(--space-7));
    --hero-text-max: 52rem;
    --journal-min: 44rem;
    --journal-period: 6.75rem;
    --underline-offset: 0.18em;
    --underline-hover: 2px;  /* a text link's underline under the pointer */
    --note-width: 17rem;

    /* Icons and pictures. */
    --icon-size: 1.125rem;
    --tick-size: 1.75rem;
    --mark-size: 1.75rem;
    --photo-ratio: 3 / 2;
    --band-ratio: 3 / 1;
    --photo-wide: 2 / 1;
    --photo-mat: 0.5rem;     /* the white border of a printed photo */

    /* Exercise-book ruling (hero, index cards) and 5 mm squares (Lehrplan). */
    --rule-gap: 2rem;
    --grid-cell: 5mm;

    /* Highlighter stroke: across the x-height and a little below, a little
     * wider than the word; a question's hover stroke the same by day. */
    --marker-top: 42%;
    --marker-bottom: 94%;
    --marker-pad: 0.12em;
    --marker-hover-top: 42%;
    --marker-hover-bottom: 94%;

    /* Register tabs: each register's tab one step further right, like a
     * binder's dividers. */
    --tab-min: 7.5rem;
    --tab-step: 8rem;
    --tab-rule: 2px;

    /* Tape, a paper clip, and how far notes and photos are turned. */
    --tape-w: 5.5rem;
    --tape-h: 1.5rem;
    /* Torn ends: a strip of tape is never cut straight. */
    --tape-shape: polygon(2% 0, 98% 6%, 100% 30%, 97% 55%, 100% 80%, 97% 100%, 3% 94%, 0 70%, 3% 45%, 0 20%);
    --clip-w: 1.25rem;
    --clip-h: 4rem;
    --tilt-note: -2deg;
    --tilt-note-alt: 1.5deg;
    --tilt-photo: -1.2deg;
    --tilt-photo-alt: 1deg;
    --tilt-tape: -5deg;
    --tilt-tape-alt: 4deg;

    /* App replicas: sidebar, time column, side panel, phone. */
    --replica-nav: 9.5rem;
    --replica-time: 2.75rem;
    --replica-side: 12rem;
    --phone-width: 16rem;
    --bezel: 0.5rem;

    /* An anchor jump stops so that the section's tab shows; from 40rem the
     * sticky header is added on top. */
    --scroll-offset: 3rem;
}

@media (min-width: 40rem) {
    :root { --scroll-offset: 7.5rem; }
}
@media (max-width: 39.99rem) {
    :root {
        --control-text: var(--text-base);
        --tab-min: 6rem;
        --tab-step: 4.75rem;
        --tape-w: 4rem;
    }
}
@media (pointer: coarse) {
    :root { --target-min: 2.75rem; }
}

/* ---------- Colours: light ---------- */
:root {
    color-scheme: light;

    /* Shared with the app. */
    --bg: #f7f5ef;
    --surface: #fffefb;
    --nav-bg: #eeeae0;
    --surface-sunken: #faf8f3;
    --border: #e3dccc;
    --border-strong: #998f7b;
    --text: #2f2c26;
    --text-heading: #1c2a4a;
    --text-muted: #585244;
    --text-quiet: #454b5d;
    --primary: #24489a;
    --primary-hover: #1a3878;
    --primary-fill: #24489a;
    --primary-fill-hover: #1a3878;
    --on-primary: #ffffff;
    --focus-ring: #24489a;
    --secondary-fill: #ebe6da;
    --on-secondary: var(--text);
    --accent: #d0574e;
    --accent-text: #a5332c;
    --ok: #2e6b4c;
    --danger: #b3342b;
    --danger-text: #a52b22;
    --danger-fill-hover: #962820;
    --on-danger: #ffffff;
    /* Three highlighters: yellow now or key, green done, orange attention.
     * They are also the register colours. */
    --marker-yellow: #fbe169;
    --marker-green: #b9e3a0;
    --marker-orange: #fbbf8a;
    --on-marker: #1c2a4a;
    --nav-current-bg: var(--marker-yellow);
    --nav-current-text: var(--on-marker);
    --nav-current-edge: var(--primary);
    --now-bg: color-mix(in srgb, var(--marker-yellow) 45%, var(--surface));
    --now-text: var(--on-marker);
    --now-edge: #d9b02a;
    --margin-line: rgb(208 87 78 / 0.5);
    --mark-bg: var(--marker-yellow);
    --mark-text: #1b1914;
    --selection: rgb(251 225 105 / 0.6);
    --shadow-card: 0 1px 1px rgb(70 58 30 / 0.06), 0 2px 8px -2px rgb(70 58 30 / 0.08);
    --subject-1: #3d6bb3;
    --subject-2: #c2453b;
    --subject-3: #21827a;
    --subject-4: #9a7612;
    --subject-5: #8156ad;
    --subject-6: #4f8735;
    --subject-7: #be4c83;
    --subject-8: #8a5d3b;

    /* The website's own. Marked words keep their colour by day. */
    --hl-text: currentColor;
    --shadow-lift: 0 6px 12px -6px rgb(28 42 74 / 0.45);
    --note-bg: #fff1a6;
    --note-text: #2b2718;
    --note-shadow: 0 1px 1px rgb(70 58 30 / 0.12), 0 12px 14px -10px rgb(70 58 30 / 0.4);
    --photo-frame: #ffffff;
    --photo-shadow: 0 1px 2px rgb(70 58 30 / 0.14), 0 10px 22px -14px rgb(70 58 30 / 0.45);
    --photo-filter: none;
    --tape: rgb(236 226 196 / 0.82);
    --clip-metal: #8b929e;
    --pencil: #5c584f;      /* the handwritten «Vorher» lines */
    --rule-line: rgb(36 72 154 / 0.11);
    --grid-line: rgb(36 72 154 / 0.07);
    --card-rule: rgb(36 72 154 / 0.14);
    --device-frame: #d8d1c1;
    --device-base: #c9c1ae;
}

/* ---------- Colours: dark ---------- */
/* The system's dark setting, unless the header button chose light
 * (theme.js marks the <html> element) ... */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #10141d;
        --surface: #181d29;
        --nav-bg: #0c0f16;
        --surface-sunken: #1d2230;
        --border: #2a3142;
        --border-strong: #646e87;
        --text: #d4d7de;
        --text-heading: #eef1f6;
        --text-muted: #a8afc0;
        --text-quiet: #a9b0bf;
        --primary: #93b6f2;
        --primary-hover: #b6cef7;
        --primary-fill: #8fb2f0;
        --primary-fill-hover: #b0c9f5;
        --on-primary: #0d1220;
        --focus-ring: #93b6f2;
        --secondary-fill: #262c3b;
        --accent: #e0786f;
        --accent-text: #f19a91;
        --ok: #72c09b;
        --danger: #e5776c;
        --danger-text: #f2968c;
        --danger-fill-hover: #ee8e83;
        --on-danger: #170d0c;
        --marker-yellow: #d6bb4a;
        --marker-green: #7fbf8f;
        --marker-orange: #d9925d;
        --on-marker: #14151a;
        --nav-current-bg: color-mix(in srgb, var(--marker-yellow) var(--tint-strong), var(--nav-bg));
        --nav-current-text: var(--marker-yellow);
        --nav-current-edge: var(--marker-yellow);
        --now-bg: var(--nav-current-bg);
        --now-text: var(--marker-yellow);
        --now-edge: var(--marker-yellow);
        --margin-line: rgb(224 120 111 / 0.45);
        --mark-text: var(--on-marker);
        --selection: rgb(147 182 242 / 0.22);
        --shadow-card: 0 1px 2px rgb(4 6 10 / 0.5);
        --subject-1: #7ea6e8;
        --subject-2: #ec8a80;
        --subject-3: #57c0b4;
        --subject-4: #d9b14c;
        --subject-5: #b89be6;
        --subject-6: #8fc26e;
        --subject-7: #ec8fbd;
        --subject-8: #c99a76;

        /* At night the stroke covers the whole line, so the marked words
         * take the marker's ink; a question's hover stroke stays under the
         * baseline, so its light text keeps its colour. */
        --hl-text: var(--on-marker);
        --marker-top: 12%;
        --marker-bottom: 97%;
        --marker-hover-top: 80%;
        --marker-hover-bottom: 100%;
        --shadow-lift: 0 6px 12px -6px rgb(0 0 0 / 0.75);
        --note-bg: #e9d77a;
        --note-text: #2b2718;   /* a sticky note stays paper at night */
        --note-shadow: 0 1px 1px rgb(0 0 0 / 0.35), 0 12px 16px -10px rgb(0 0 0 / 0.7);
        --photo-frame: #262d3c;
        --photo-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 22px -14px rgb(0 0 0 / 0.8);
        /* Photos a little quieter at night. */
        --photo-filter: brightness(0.85) saturate(0.9);
        --tape: rgb(214 204 172 / 0.3);
        --clip-metal: #a3abbb;
        --pencil: #b3b7c0;
        --rule-line: rgb(147 182 242 / 0.08);
        --grid-line: rgb(147 182 242 / 0.06);
        --card-rule: rgb(147 182 242 / 0.12);
        --device-frame: #2a3142;
        --device-base: #353d51;
    }
}

/* ... and the button's dark choice, whatever the system says. The same
 * block as above: tools/contrast.py fails when the two differ. */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #10141d;
    --surface: #181d29;
    --nav-bg: #0c0f16;
    --surface-sunken: #1d2230;
    --border: #2a3142;
    --border-strong: #646e87;
    --text: #d4d7de;
    --text-heading: #eef1f6;
    --text-muted: #a8afc0;
    --text-quiet: #a9b0bf;
    --primary: #93b6f2;
    --primary-hover: #b6cef7;
    --primary-fill: #8fb2f0;
    --primary-fill-hover: #b0c9f5;
    --on-primary: #0d1220;
    --focus-ring: #93b6f2;
    --secondary-fill: #262c3b;
    --accent: #e0786f;
    --accent-text: #f19a91;
    --ok: #72c09b;
    --danger: #e5776c;
    --danger-text: #f2968c;
    --danger-fill-hover: #ee8e83;
    --on-danger: #170d0c;
    --marker-yellow: #d6bb4a;
    --marker-green: #7fbf8f;
    --marker-orange: #d9925d;
    --on-marker: #14151a;
    --nav-current-bg: color-mix(in srgb, var(--marker-yellow) var(--tint-strong), var(--nav-bg));
    --nav-current-text: var(--marker-yellow);
    --nav-current-edge: var(--marker-yellow);
    --now-bg: var(--nav-current-bg);
    --now-text: var(--marker-yellow);
    --now-edge: var(--marker-yellow);
    --margin-line: rgb(224 120 111 / 0.45);
    --mark-text: var(--on-marker);
    --selection: rgb(147 182 242 / 0.22);
    --shadow-card: 0 1px 2px rgb(4 6 10 / 0.5);
    --subject-1: #7ea6e8;
    --subject-2: #ec8a80;
    --subject-3: #57c0b4;
    --subject-4: #d9b14c;
    --subject-5: #b89be6;
    --subject-6: #8fc26e;
    --subject-7: #ec8fbd;
    --subject-8: #c99a76;

    /* At night the stroke covers the whole line, so the marked words
     * take the marker's ink; a question's hover stroke stays under the
     * baseline, so its light text keeps its colour. */
    --hl-text: var(--on-marker);
    --marker-top: 12%;
    --marker-bottom: 97%;
    --marker-hover-top: 80%;
    --marker-hover-bottom: 100%;
    --shadow-lift: 0 6px 12px -6px rgb(0 0 0 / 0.75);
    --note-bg: #e9d77a;
    --note-text: #2b2718;   /* a sticky note stays paper at night */
    --note-shadow: 0 1px 1px rgb(0 0 0 / 0.35), 0 12px 16px -10px rgb(0 0 0 / 0.7);
    --photo-frame: #262d3c;
    --photo-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 22px -14px rgb(0 0 0 / 0.8);
    /* Photos a little quieter at night. */
    --photo-filter: brightness(0.85) saturate(0.9);
    --tape: rgb(214 204 172 / 0.3);
    --clip-metal: #a3abbb;
    --pencil: #b3b7c0;
    --rule-line: rgb(147 182 242 / 0.08);
    --grid-line: rgb(147 182 242 / 0.06);
    --card-rule: rgb(147 182 242 / 0.12);
    --device-frame: #2a3142;
    --device-base: #353d51;
}
