/* ==========================================================================
   FRAMEFLOW — Global CSS: fonts, design tokens, reset, cookie banner
   Direction "Kadr" (brief pkt 21, etap 2): warm black, paper white, one
   accent (#FFAE00) used only on CTAs and the active menu link.
   ========================================================================== */

/* --- Fonts: self-hosted (no request to Google before cookie consent).
   Archivo is one variable file per subset with both axes: weight 100–900
   and width 62–125%, so condensed headings and normal body text come from
   the same download. latin-ext carries the Polish letters.
   Licences: fonts/OFL-Archivo.txt, fonts/OFL-IBMPlexMono.txt --- */
@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-display: swap;
    src: url("../fonts/archivo-latin.de2f1fe81758.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;
}
@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-display: swap;
    src: url("../fonts/archivo-latin-ext.589f7bc0fac4.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-400-latin.79936b18df9f.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;
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-400-latin-ext.8450d5944de2.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-500-latin.b1c8a895f5fd.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;
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-500-latin-ext.fa8d8838b94a.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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Design tokens. Contrast on --bg (WCAG): --text 16.6:1, --body 11.1:1,
   --quiet 6.4:1, --field-line 3.5:1 (UI component), dark text on
   --accent 10.5:1. Light text on --accent fails (~1.6:1): never use it. --- */
:root {
    /* Native widgets (select popup, scrollbars, autofill) render dark. */
    color-scheme: dark;

    --bg:          #0F0C0A;
    --frame:       #1A1612;  /* no-cover chapter frame, image placeholders */
    --text:        #F3ECE0;
    --body:        #CBC2B4;  /* paragraphs */
    --quiet:       #9C9384;  /* meta lines, tags, numbers */
    --line:        #2F2924;  /* dividers (decorative) */
    --field-line:  #6F665A;  /* form field boundaries, needs 3:1 */
    --accent:      #FFAE00;  /* CTA + active menu link only */
    --rec:         #E5432C;  /* HUD recording dot only (ruch.js), never text */
    --on-accent:   #0F0C0A;

    /* Every project cover on the dark page: edges pulled down and the
       whole photo a touch dimmer, so bright shots (screenshots, sky,
       a hall from a drone) don't glow against --bg. */
    --cover-edge:  inset 0 0 110px 12px rgba(14, 11, 8, 0.6);
    --cover-dim:   brightness(0.92);

    --font-main:   'Archivo', system-ui, sans-serif;
    --font-mono:   'IBM Plex Mono', ui-monospace, monospace;

    /* Condensed width for headings (Archivo wdth axis) */
    --condensed:   64%;
}

@media (max-width: 820px) {
    :root {
        --cover-edge: inset 0 0 56px 6px rgba(14, 11, 8, 0.6);
    }
}

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

html, body {
    width: 100%;
    min-height: 100%;
    font-family: var(--font-main);
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

/* --- Wagtail Admin Bar Tweak --- */
.wagtail-userbar {
    z-index: 99999 !important;
}

/* --- Cookie Consent Banner ---
   Compact, in the bottom-right corner, so it never covers the hero
   headline (bottom-left). Phones: a low bar along the bottom edge.
   Both buttons are the same size: refusing must be as easy as accepting. */
.cookie-banner[hidden] {
    display: none;
}

.cookie-banner {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10000;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    width: min(400px, calc(100% - 32px));
    padding: 14px 16px 16px;
    background: var(--bg);
    border: 1px solid var(--field-line);
}

.cookie-banner__text {
    flex: 1 1 100%;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--body);
}

.cookie-banner__text a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-banner__btn {
    flex: 1 1 0;
    padding: 8px 14px;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

@media (max-width: 600px) {
    .cookie-banner {
        right: 0;
        bottom: 0;
        width: 100%;
        gap: 8px 10px;
        padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
        border-width: 1px 0 0;
    }

    .cookie-banner__text {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    .cookie-banner__btn {
        padding: 7px 12px;
    }
}

/* "Odrzucam" — quieter than accept, but a real, equally clickable choice
   (GDPR requires refusing to be as easy as accepting). */
.cookie-banner__btn--decline {
    background: transparent;
    color: var(--text);
    border-color: var(--field-line);
}

.cookie-banner__btn--decline:hover {
    border-color: var(--text);
}

.cookie-banner :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Category switches, opened with "Ustawienia" (panel stage B, fflow.js).
   Native checkboxes in the accent; "Niezbędne" is shown but locked. */
.cookie-banner__prefs {
    flex: 1 1 100%;
    display: grid;
    gap: 10px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--line);
}

.cookie-banner__prefs[hidden] {
    display: none;
}

.cookie-pref {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    align-items: baseline;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
}

.cookie-pref input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    align-self: center;
}

.cookie-pref--locked {
    cursor: default;
}

.cookie-pref__name {
    font-weight: 600;
}

.cookie-pref__note {
    grid-column: 2;
    font-size: 0.75rem;
    color: var(--quiet);
}

.cookie-banner__btn--save {
    justify-self: start;
    margin-top: 4px;
    flex: none;
}

/* "Ustawienia": a quiet text button under the two equal choices */
.cookie-banner__more {
    flex: 1 1 100%;
    padding: 2px 0;
    font-size: 0.8125rem;
    color: var(--body);
    text-align: left;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cookie-banner__more:hover {
    color: var(--text);
}

/* ── Film grain (Ustawienia → Wygląd strony, base.html) ──────────────────
   One 128 px noise tile (tools/grain/make_grain.py) on a fixed layer over
   everything, moved in steps at 10 frames a second: only a transform on its
   own layer, no canvas, no script, no blend mode. It never takes clicks.
   Static with reduced motion, absent in print (and so in the offer PDF). */
.film-grain {
    position: fixed;
    inset: 0;
    z-index: 10002;          /* over the banner and the modal (10000/10001) */
    overflow: hidden;
    pointer-events: none;
    opacity: 0.05;
}
.film-grain--srednie {
    opacity: 0.09;
}
.film-grain::before {
    content: "";
    position: absolute;
    inset: -128px;
    background: url("../images/grain.da9a1e732cef.png") repeat;
    background-size: 128px 128px;
    will-change: transform;
    animation: film-grain 1s steps(1, end) infinite;
}
@keyframes film-grain {
    0%   { transform: translate3d(0, 0, 0); }
    10%  { transform: translate3d(-41px, 23px, 0); }
    20%  { transform: translate3d(57px, -64px, 0); }
    30%  { transform: translate3d(-90px, -18px, 0); }
    40%  { transform: translate3d(12px, 77px, 0); }
    50%  { transform: translate3d(-63px, 101px, 0); }
    60%  { transform: translate3d(84px, 39px, 0); }
    70%  { transform: translate3d(-5px, -97px, 0); }
    80%  { transform: translate3d(101px, -33px, 0); }
    90%  { transform: translate3d(-110px, 66px, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .film-grain::before {
        animation: none;
    }
}
@media print {
    .film-grain {
        display: none;
    }
}
