/*
 * amaranth studio stylesheets
 *
 * files, linked in this order from index.html and fetched in parallel
 *   foundation.css  layer order, fonts, reset, tokens, base elements, primitives, utilities
 *   header.css      .header, .ticker
 *   hero.css        .hero, .glyph
 *   works.css       .works, .tag, .work
 *   services.css    .services
 *   about.css       .about
 *   clients.css     .clients
 *   footer.css      .footer
 *   panel.css       .panel, the sidebar every sub page opens in; .section, .stats, the blocks pages are made of
 *   footprint.css   .footprint, the content of /footprint
 *   intro.css       first-visit choreography, reduced motion
 *
 * cascade layers: a later layer wins regardless of selector specificity
 *   reset → tokens → base → components → utilities → intro → motion
 *
 * isolation: every component is an @scope rooted at its block class. a component
 * may place a child component's root (the scope ends at `.child > *`), never style
 * its insides.
 *
 * naming
 *   .block   .block-part   .block--variant   .is-state (set by script)   .u-utility
 *   component custom properties and keyframes are prefixed with the block name.
 *   global tokens are unprefixed and live in the tokens layer.
 *
 * breakpoints are literal because media queries can't read custom properties
 *   < 1500px polaroids stack · < 1400px header goes side by side · < 1200px tablet · < 768px phone
 */

@layer reset, tokens, base, components, utilities, intro, motion;

@font-face {
    font-family: "Montreal";
    font-weight: 400;
    src: url("/assets/fonts/ppneuemontreal-book.woff") format("woff");
}

@font-face {
    font-family: "Montreal";
    font-weight: 500;
    src: url("/assets/fonts/ppneuemontreal-medium.woff") format("woff");
}

@font-face {
    font-family: "Montreal";
    font-weight: 700;
    src: url("/assets/fonts/ppneuemontreal-bold.woff") format("woff");
}

@layer reset {
    :where(*, *::before, *::after) {
        box-sizing: border-box;
    }

    :where(body, h1, h2, h3, h4, p, address, figure, dl, dd, ol, ul) {
        margin: 0;
    }

    :where(h1, h2, h3, h4, p, address) {
        font: inherit;
    }

    :where(ol, ul) {
        padding: 0;
        list-style: none;
    }

    [hidden] {
        display: none !important;
    }
}

@layer tokens {
    :root {
        /* colour */
        --bg: #d9d9d9;
        --fg: #2f2f2f;
        --muted: #737373;
        --line: #adadad;
        --logo-filter: brightness(0) invert(0.184);
        --tint: color-mix(in srgb, var(--fg) 12%, transparent);
        --scrim: rgb(0 0 0 / 0.2);
        --border: 1px solid var(--line);
        --shadow: 0 4px 84px rgb(0 0 0 / 0.11);

        --software: #1504ff;
        --electronics: #c8ff00;
        --arts: #7d04ff;

        /* type */
        --font: "Montreal", sans-serif;
        --text-xs: 12px;
        --text-sm: 14px;
        --text-md: 16px;
        --text-base: 18px;
        --text-lg: 22px;
        --text-xl: 28px;
        --text-2xl: 34px;

        /* layout */
        --edge: 16px; /* smallest gap between content and the viewport edge */
        --content: 820px;
        --content-width: min(var(--content), 100% - 2 * var(--edge));
        --card-pad-phone: 24px;
        --ticker-height: 43px; /* the header's text line: ticker, name and logo share it */
        --bar-height: 80px; /* top bars: the site header, and panel headers from tablet up */
        --panel-width: 520px;
        --page-push: 0px; /* room the page gives up to an open panel; panel.css sets it */

        /* hero glyph; its centre is the point the intro zooms around */
        --glyph-top: 120px;
        --glyph-height: 442px;
        --glyph-center: calc(var(--glyph-top) + var(--glyph-height) / 2);

        /* motion */
        --ease: cubic-bezier(0.7, 0, 0.2, 1);
        --t-fast: 0.2s;
        --t-base: 0.4s;
        --t-slow: 0.6s;
        --intro: 2s; /* every intro timing is a fraction of this; intro.css sets it to 0s to skip */

        @media (prefers-color-scheme: dark) {
            --bg: #1a1a1a;
            --fg: #d9d9d9;
            --muted: #8c8c8c;
            --line: #404040;
            --logo-filter: brightness(0) invert(0.851);
        }

        @media (width < 768px) {
            --bar-height: 60px;
            --glyph-top: 100px;
        }
    }
}

@layer base {
    /* the background lives here because body is a container, and a container's background doesn't fill the canvas */
    :root {
        color-scheme: light dark;
        background: var(--bg);
    }

    body {
        /* the header, about and footer query this instead of the viewport, so they follow the page when a panel narrows it */
        container: page / inline-size;
        margin-inline-end: var(--page-push);
        transition: margin-inline-end var(--t-base) var(--ease);
        color: var(--fg);
        font: 400 var(--text-base) / 1 var(--font);
        position: relative;
        overflow-x: clip;
    }

    h1,
    h2,
    h3 {
        font-weight: 700;
    }

    /* type roles by heading level: title, heading, label; small is the muted aside that can sit in any of them */
    h1,
    h2 {
        font-size: var(--text-2xl);
    }

    h3 {
        font-size: var(--text-lg);
    }

    h4 {
        font-size: var(--text-xs);
        font-weight: 500;
        text-transform: uppercase;
    }

    b {
        font-weight: 500;
    }

    small {
        font-size: var(--text-xs);
        font-weight: 400;
        text-transform: none;
        color: var(--muted);
    }

    a {
        color: inherit;
    }
}

/* primitives: tiny components used inside others */
@layer components {
    @scope (.icon) {
        :scope {
            flex: none;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.5;
            stroke-linecap: round;
        }

        .icon-fill {
            fill: currentColor;
            stroke: none;
        }
    }
}

@layer utilities {
    /* recolours a black logo to the current foreground */
    .u-ink {
        filter: var(--logo-filter);
    }

    .u-muted {
        color: var(--muted);
    }

    /* the h4 label look, for text that isn't a heading */
    .u-label {
        font-size: var(--text-xs);
        font-weight: 500;
        text-transform: uppercase;
    }
}
