/* Rob Gill brand styles.
   Published at https://rob-gill.co.uk/brand.css
   This site loads the same file. Subdomains can load it too.
   Layout and components stay in src/styles/global.css.
   How to use it: BRAND.md. */

/* Tiny Mono. Weights 300, 400 and 600. Licence text: /fonts/tiny/OFL.txt.
   Latin plus the punctuation, arrows and letters the site actually uses.
   Emoji in old posts fall back to the system font.
   font-display: swap, with a metric-matched local monospace, so text stays
   visible while the face arrives. size-adjust matches Tiny's 0.6em advance
   to ui-monospace in Chrome (60px vs 60.2px at 100px). */
@font-face {
  font-family: "Tiny Fallback";
  src: local("Menlo"), local("Consolas"), local("Liberation Mono"), local("DejaVu Sans Mono"), local("Courier New");
  size-adjust: 99.66%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Tiny";
  font-weight: 300;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/tiny/Tiny-Light.woff2") format("woff2");
}
@font-face {
  font-family: "Tiny";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/tiny/Tiny-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Tiny";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/fonts/tiny/Tiny-SemiBold.woff2") format("woff2");
}

/* Themes. Names live in src/lib/theme.ts. Add one there, then a [data-theme="…"]
   block here. Light is the unset default. The boot script sets data-theme from
   the system until the caret is clicked; after that the saved choice wins.
   A subdomain sets the same attribute. See BRAND.md. */

:root,
[data-theme="light"] {
  /* Colour: pure neutrals only. Light mode. */
  color-scheme:    light;
  --bg:            #fff;      /* page background */
  --text:          #000;      /* primary text, hover state for links */
  --grey-1:        #2e2e2e;   /* list titles, 13.6:1 */
  --grey-2:        #5e5e5e;   /* body copy, resting links, 6.5:1 */
  --grey-3:        #6e6e6e;   /* labels, companies, years, 5.1:1 */
  --grey-4:        #757575;   /* quiet marks, index numbers, 4.6:1 */
  --grey-5:        #e8e8e8;   /* quiet fills: code, scrollbar, grab */

  /* Rules. Hairlines are a little of the ink, so they follow any background. */
  --rule-colour:   color-mix(in srgb, var(--text) 12%, transparent);
  --sheet-border:  color-mix(in srgb, var(--text) 14%, transparent);
  --rule-weight:   1px;
  --accent:        #F8D201; /* highlighter marker */
  /* Visited marker: yellow at 20%. Provius stays solid yellow. */
  --hl-seen:       0.20;
  --hl-seen-mix:   20%;
  --star:          var(--text); /* favourite mark: ink on light and yellow */
  --hl:            var(--accent);
  --plate-y:       #F8D201; /* process yellow, inside the CMYK portrait effects */
  --underline:     var(--accent);

  /* Sheets */
  --canvas-alt:    #f2f2f2;   /* internal /components lab canvas */
  --sheet-bg:      #fff;
  /* Book pages stay paper-white. Light and yellow rules use the theme ink. */
  --book-page:     #ffffff;
  --book-ink:      var(--text);
  --sheet-shadow:  0 1px 1px rgb(0 0 0 / .02), 0 4px 8px -2px rgb(0 0 0 / .03),
                   0 16px 32px -8px rgb(0 0 0 / .06), 0 40px 80px -24px rgb(0 0 0 / .08);
  --scrim:         rgb(255 255 255 / .66);

  /* Type: Tiny Mono. Desktop body 14px, small 12px, titles 20px.
     Mobile (max-width 799px) puts body and titles back to 15px / 1.8.
     The mobile header name is 18px. */
  --font:          "Tiny", "Tiny Fallback", ui-monospace, monospace;
  --w-light:       300;
  --w-regular:     400;
  --w-bold:        600;
  --fs-body:       14px;
  --fs-small:      12px;    /* sheet spines, mobile footer, place/RSS */
  --fs-title:      20px;    /* sheet titles */
  --lh:            1.8;
  --lh-small:      1.8;
  --caps-tracking: .06em;

  /* Spacing. Page sizes that multiply this step live with the layout. */
  --unit:          8px;
}


[data-theme="dark"] {
  color-scheme:  dark;
  --bg:          #000;
  --text:        #fff;
  --canvas-alt:  #111;
  --grey-1:      #dcdcdc; /* list titles */
  --grey-2:      #a6a6a6; /* body. 8.1:1 on the sheet */
  --grey-3:      #a0a0a0; /* labels, years, the ink counter. 7.5:1 on the sheet */
  --grey-4:      #9a9a9a; /* quietest text: sitemap, trusted-by. 7.0:1 on the sheet */
  --grey-5:      #242424; /* fills only: code, scrollbar, grab */
  --sheet-bg:    #0b0b0b;
  --sheet-shadow:0 1px 1px rgb(0 0 0 / .4), 0 16px 32px -8px rgb(0 0 0 / .6), 0 40px 80px -24px rgb(0 0 0 / .8);
  --scrim:       rgb(0 0 0 / .62);
  --star:        #F8D201; /* yellow clears the dark sheet; ink yellow does not */
  /* Visited marker: yellow at 30%. Provius stays solid yellow. */
  --hl-seen:     0.30;
  --hl-seen-mix: 30%;
  /* Don't invert the book. Pages stay white; rules stay dark ink. */
  --book-page:   #ffffff;
  --book-ink:    #000;
}

/* Yellow. --ink is the one blue to swap. Text greys are that blue mixed toward
   white, each clearing 4.5:1 on #F8D201. The 14% mix is a fill, not text.
   The highlighter is white, on links and on the portrait. Link text on that
   stroke stays black. */
[data-theme="yellow"] {
  color-scheme:  light;
  --bg:          #F8D201;
  --ink:         #000A73;
  --text:        var(--ink);
  --grey-1:      color-mix(in srgb, var(--ink) 92%, white);
  --grey-2:      color-mix(in srgb, var(--ink) 88%, white);
  --grey-3:      color-mix(in srgb, var(--ink) 84%, white);
  --grey-4:      color-mix(in srgb, var(--ink) 82%, white);
  --grey-5:      color-mix(in srgb, var(--ink) 14%, var(--bg));
  --sheet-bg:    var(--bg);
  --sheet-shadow:0 1px 1px color-mix(in srgb, var(--ink) 4%, transparent), 0 16px 32px -8px color-mix(in srgb, var(--ink) 8%, transparent), 0 40px 80px -24px color-mix(in srgb, var(--ink) 12%, transparent);
  --scrim:       rgb(248 210 1 / .72);
  --accent:      #FFFFFF;
  --hl:          #FFFFFF;
  /* Visited marker is solid white, the same stroke as hover. */
  --hl-seen:     1;
  --hl-seen-mix: 100%;
  --plate-y:     #fff;
}

/* Theme swaps are instant. A fade made the hairlines jump ahead of the background.
   This kills colour transitions for one frame so hover fades stay, and the
   theme itself does not smear. */
html.is-theme-swap, html.is-theme-swap * {
  transition-property: none !important;
}

/* No choice yet, and no JavaScript: follow the system. Lines stay the ink mixes above. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme:  dark;
    --bg:          #000;
    --text:        #fff;
    --grey-1:      #dcdcdc;
    --grey-2:      #a6a6a6;
    --grey-3:      #a0a0a0;
    --grey-4:      #9a9a9a;
    --grey-5:      #242424;
    --sheet-bg:    #0b0b0b;
    --sheet-shadow:0 1px 1px rgb(0 0 0 / .4), 0 16px 32px -8px rgb(0 0 0 / .6), 0 40px 80px -24px rgb(0 0 0 / .8);
    --scrim:       rgb(0 0 0 / .62);
    --star:        #F8D201;
    --book-page:   #ffffff;
    --book-ink:    #000;
    --hl-seen:     0.30;
    --hl-seen-mix: 30%;
  }
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-weight: var(--w-regular); font-size: var(--fs-body); line-height: var(--lh);
  font-variant-ligatures: none; font-synthesis: none;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--text); color: var(--bg); }
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; font: inherit; }
ol, ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: var(--rule-weight) solid var(--text); outline-offset: 3px; border-radius: 1px; }

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

/* Phone width. Body and titles step up together. The site uses the same 799px. */
@media (max-width: 799px) {
  :root {
    --fs-body: 15px;
    --fs-title: 15px;
  }
}
