/* House style base: the rules every web app of Robin's shares, published with the tokens as /house-style/house.css.
   HOUSE-STYLE.md says how to use them. An app links tokens.css, then this file, then its own stylesheet:

     <link rel="stylesheet" href="https://robinmanhaeve.be/house-style/tokens.css">
     <link rel="stylesheet" href="https://robinmanhaeve.be/house-style/house.css">
     <link rel="stylesheet" href="/app.css">

   Everything below sits in the layer "house", which loses to any rule outside a layer whatever its specificity, so an
   app overrides a rule here by writing its own (a data-heavy app's body on --app-page, say) and never edits this.
   The site itself doesn't use this file: its own base is global.css. The fonts are served beside this file. */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(fonts/figtree-latin-wght-normal.woff2) format("woff2-variations");
  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: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url(fonts/figtree-latin-ext-wght-normal.woff2) format("woff2-variations");
  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: "Figtree";
  font-style: italic;
  font-weight: 300 900;
  font-display: swap;
  src: url(fonts/figtree-latin-wght-italic.woff2) format("woff2-variations");
}

/* The theme switch ("Using it in an app"): a choice sets data-theme on the root; print stays light. Outside the layer
   on purpose: tokens.css sets `:root { color-scheme: light dark }` outside any layer, which would beat these inside
   it, and the switch would do nothing. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media print { :root, :root[data-theme] { color-scheme: light; } }

/* The fades of .scroll-row (below), as lengths an animation can move. Registered outside the layer: @property is
   global anyway. */
@property --scroll-row-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --scroll-row-end { syntax: "<length>"; inherits: false; initial-value: 0px; }

@layer house {
  :root { --font-sans: "Figtree", system-ui, sans-serif; }

  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--step--1);
    line-height: 1.5;
  }

  /* Type: headings 750 with -0.01 em tracking. */
  h1, h2, h3 { font-weight: 750; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
  h1 { font-size: var(--step-2); }
  h2 { font-size: var(--step-1); }
  h3 { font-size: var(--step-0); }
  p { margin: 0 0 var(--space-3); }
  img { display: block; max-width: 100%; }

  /* Links ("Using it in an app"): the text keeps its colour, the underline is --ui, thicker under the pointer. */
  a { color: inherit; text-decoration-line: underline; text-decoration-color: var(--ui);
    text-decoration-thickness: 0.08em; text-underline-offset: 0.2em; }
  a:hover { text-decoration-thickness: 2px; }

  /* Focus: a 2 px --ui ring. */
  :focus-visible { outline: 2px solid var(--ui); outline-offset: 2px; }

  /* The label above every section and number ("In a data-heavy app"). */
  .label { font-size: var(--step--2); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--muted); }

  /* A row of controls that scrolls ("Using it in an app", "A row that scrolls"): it scrolls sideways with no
     scrollbar, and the side that has more fades into the paper over --space-6. The fades follow the scroll position
     where the browser can tell it in CSS (scroll-driven animations): none at the start on the left, none at the end
     on the right, none at all when everything fits, as a scroll timeline with nothing to scroll is inactive.
     Elsewhere the row scrolls, unfaded. scroll-padding keeps a word brought into view (by focus) clear of the fade.
     The padding, taken back by the margin, is room for the focus ring of the words at the ends (below): a box that
     scrolls cuts off what is drawn outside it. An app whose row has its own padding or width makes that room itself. */
  .scroll-row {
    overflow-x: auto;
    scrollbar-width: none;
    scroll-padding-inline: var(--space-6);
    padding-inline: 4px;
    margin-inline: -4px;
  }
  .scroll-row::-webkit-scrollbar { display: none; }
  @supports (animation-timeline: scroll()) {
    .scroll-row {
      mask-image: linear-gradient(to right, transparent, #000 var(--scroll-row-start),
        #000 calc(100% - var(--scroll-row-end)), transparent);
      animation: house-scroll-row linear both;
      animation-timeline: scroll(self inline);
    }
  }
  @keyframes house-scroll-row {
    from { --scroll-row-start: 0px; --scroll-row-end: var(--space-6); }
    10%, 90% { --scroll-row-start: var(--space-6); --scroll-row-end: var(--space-6); }
    to { --scroll-row-start: var(--space-6); --scroll-row-end: 0px; }
  }

  .muted { color: var(--muted); }
  .num { font-variant-numeric: tabular-nums; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
    white-space: nowrap; }
}

/* .link: a button that does what a link does (an undo, "Clear", "show all") and looks like one. Outside the layer on
   purpose: an app's own rule for every button (a border, no underline) would beat it there; here the class beats a
   rule for the element, and an app still adjusts it with a more specific one (".sel .link"). */
.link { color: inherit; text-decoration-line: underline; text-decoration-color: var(--ui);
  text-decoration-thickness: 0.08em; text-underline-offset: 0.2em; }
.link:hover { text-decoration-thickness: 2px; }
button.link { border: 0; padding: 0; background: none; font: inherit; font-weight: inherit; cursor: pointer; }

/* A word in a .scroll-row takes its focus ring inside its edges, since the row, which scrolls, cuts off what is drawn
   outside it (the top and the outer side of the ring of a word as tall as the bar). The padding, taken back by the
   margin, keeps the ring 2 px off the letters, as the ring is everywhere else; the row's own padding (above) makes
   room for it at the ends. Outside the layer, like .link, so that an app's own rules for its words and for every
   :focus-visible don't undo it; a word that keeps a margin of its own (an auto margin that pushes it to the end) says
   so in a more specific rule. */
.scroll-row :focus-visible { outline-offset: -2px; padding-inline: 4px; margin-inline: -4px; }
