/* =====================================================================
   staffbite.fi stylesheet, design F "Faktaruudukko" (Fact grid)
   (PLAN v20; approved mockup and its README: docs/mallikuvat/f/)
   ---------------------------------------------------------------------
   Part 1: design tokens (from the mockup's tokens.css).
   Part 2: the components the real pages use (from mockup.css; the
   mockup-only parts, such as the AI architect, references and the
   AI-visibility page sections, are left out until their content exists,
   but their tokens stay; the news rows arrived with phase 2).

   The page is squared paper: the grid the machine reads. ONE cell size
   (--cell, 24px) drives everything:
   - the background grid starts at the document origin (0, 0);
   - frames (header, layout, footer) snap their left edge and width to
     whole cells with round(), so columns start on grid lines;
   - every line-height is a whole number of cells (body = 1 cell) and
     every vertical margin and padding is a whole number of cells, so
     every text row sits in a grid row;
   - rules and borders are the grid line itself drawn dark (box-shadow,
     no layout impact), over a snapped length.
   Colour is reserved for facts: one pastel per fact type
   (site.FactTypes: sijainti, ai, yksityisyys, lahde, rajapinta), only on
   marks, in the lens (and its touch counterpart, the reading line) and
   in the footer key that explains them. Hover, pressed, focus and the
   index are neutral.

   CSP: style-src 'self'. No inline styles anywhere; the optional scripts
   (web/static/js/theme.js, cells.js, lens.js) set styles through CSSOM.
   Contrast ratios (WCAG 2.x) are noted next to each colour that is used
   for text or UI boundaries. Targets: 4.5:1 text, 3:1 UI components.
   Light is the default; dark comes from prefers-color-scheme or from
   html[data-theme="dark"] (theme.js), see the end of the token part.
   ===================================================================== */

/* ---------- Fonts (SIL OFL 1.1, self-hosted, version in file name) ----
   Source: @fontsource-variable/atkinson-hyperlegible-next@5.3.0 and
   @fontsource-variable/atkinson-hyperlegible-mono@5.3.0, latin subset;
   licences next to the files in /static/vendor/. The URLs equal the
   <link rel="preload"> URLs in head.html (no ?v: the file name carries
   the version). The subsets contain ä, ö, å but not U+2192 (arrow), so
   arrows are inline SVG. unicode-range copied from the Fontsource CSS. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/vendor/atkinson-hyperlegible-next-5.3.0-latin-wght.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: "Atkinson Hyperlegible Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/vendor/atkinson-hyperlegible-mono-5.3.0-latin-wght.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;
}

/* =====================================================================
   Part 1: design tokens. Components read only these custom properties;
   cells.js and lens.js read --cell, --lens-alpha, --lens-grey and the
   --fact-* colours from :root.
   ===================================================================== */
:root {
  color-scheme: light dark;

  /* ---------- Colour (light) ------------------------------------------- */
  --color-paper:        #FFFFFF; /* page background */
  --color-ink:          #111111; /* text, rules, primary button: 18.9 on paper */
  --color-ink-soft:     #4D4D4D; /* secondary text: 8.5 on paper, 5.6-6.8 on every fact colour */
  --color-ui-line:      #767676; /* input borders, example tag: 4.5 on paper (UI 3:1) */
  --color-hairline:     #D9D9D6; /* row separators, decorative: 1.4 on paper */
  --color-quiet:        #E6E6E2; /* neutral hover / "here" without a fact type: ink 15.1 */
  --color-on-fact:      #111111; /* text on any fact colour, in both themes */

  /* Fact types: the highlighter set. Pastel marker tones, one per fact
     type, matching the types in JSON-LD and llms.txt. Text on them is
     always --color-on-fact. NEVER used as text colour. The type is also
     given as text (mono tag or title), so meaning never rests on colour
     alone (WCAG 1.4.1).                                        on-fact ink-soft */
  --fact-sijainti:      #FFE14D; /* sijainti ja data (E's yellow)      14.5  6.5 */
  --fact-ai:            #9EE3D3; /* AI-käsittely, mint                  12.9  5.8 */
  --fact-yksityisyys:   #FFC2D1; /* yksityisyys, rose                   12.5  5.6 */
  --fact-lahde:         #B9DAFA; /* luku ja lähde, ice blue             13.0  5.8 */
  --fact-rajapinta:     #FFC796; /* koneluettava rajapinta, apricot     12.5  5.6 */
  --fact-none:          var(--color-quiet); /* structure without a fact 15.1  6.8 */

  /* Graph paper and the index trace (neutral: no fact colour in the index). */
  --color-grid:         #ECECE9; /* 1px grid lines: 1.18 on paper, decorative */
  --color-grid-on-fill: rgb(0 0 0 / 0.07); /* grid lines over mark cells */
  --color-rail:         #B3B3AE; /* unlit trace and hollow node border: 2.1 on paper, decorative
                                    (the item's text, not the node, carries the state) */

  /* Lens (lens.js reads both): peak alpha of a lit cell, and the neutral
     the accents fade into with distance from a fact. Grey cell at full
     strength: #DADAD7, 1.40 on paper (was 1.21), ink 13.5, ink-soft 6.0.
     Pastel at 0.85 over paper: ink >= 13.2, ink-soft >= 5.9. */
  --lens-alpha:         0.85;
  --lens-grey:          #D4D4D0;

  --color-night:        #111111; /* footer background */
  --color-night-text:   #FFFFFF; /* 18.9 on night */
  --color-night-soft:   #B8B8B8; /* 9.5 on night */
  --color-night-line:   #3A3A3A; /* decorative */

  --color-focus:        var(--color-ink);        /* 3px ring: 18.9 on paper */
  --color-focus-night:  var(--color-night-text); /* 18.9 on night */

  /* ---------- The cell --------------------------------------------------- */
  --cell:      24px;  /* px: shared with cells.js and lens.js */
  --cells-2:   calc(2 * var(--cell));
  --cells-3:   calc(3 * var(--cell));
  --cells-4:   calc(4 * var(--cell));
  --cells-5:   calc(5 * var(--cell));

  /* ---------- Typography ------------------------------------------------ */
  --font-text: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --weight-regular: 400;
  --weight-mark:    600; /* marked facts: meaning not by colour alone */
  --weight-strong:  700;
  --weight-display: 800;

  /* Sizes with their line-height in whole cells. */
  --text-mono:   0.875rem;  /* 14 / 1 cell */
  --text-small:  1rem;      /* 16 / 1 cell */
  --text-body:   1.125rem;  /* 18 / 1 cell (1.33) */
  --text-lead:   1.25rem;   /* 20 / 1 cell */
  --text-h3:     1.25rem;   /* 20 / 1 cell */
  --text-brand:  1.375rem;  /* 22 / 1 cell */
  --text-menu:   1.75rem;   /* 28 / 2 cells */
  --text-row:    1.75rem;   /* 28 / 2 cells; 44 / 2 cells from 64rem */
  --text-h2:     2rem;      /* 32 / 2 cells; 44 / 2 from 40rem; 60 / 3 from 64rem */
  --text-h1:     2.75rem;   /* 44 / 2 cells; 64 / 3 from 40rem; 80-96 / 4 from 64rem */
  --text-h1-inner: 2.5rem;  /* 40 / 2 cells; 56 / 3 from 40rem; 80 / 4 from 64rem */
  --lh-row:      var(--cells-2);
  --lh-h2:       var(--cells-2);
  --lh-h1:       var(--cells-2);

  --tracking-display: -0.025em;
  --tracking-h2:      -0.02em;
  --tracking-mono:    0.02em;

  --measure: 68ch;

  /* ---------- Space ------------------------------------------------------
     Vertical space is whole cells only. Inline gaps inside one text row
     (icon to label, word groups) do not move rows and use --gap-*. */
  --gap-xs: 0.25rem;
  --gap-s:  0.5rem;
  --gap-m:  0.75rem;

  --gutter:        var(--cell);         /* 2 cells from 64rem */
  --frame-max:     calc(60 * var(--cell)); /* 1440px of content */
  --index-width:   calc(10 * var(--cell)); /* 240px */
  --column-gap:    var(--cells-2);
  --number-width:  var(--cells-2);      /* clause numbers; 3 cells from 64rem */
  --header-height: var(--cells-3);
  --section-gap:   var(--cells-3);      /* 5 cells from 64rem */
  --node:          10px;

  /* ---------- Lines ------------------------------------------------------
     Drawn with box-shadow so they never add height: "top" lines are inset
     (the grid line is the first pixel row of a cell), "bottom/right"
     lines are outside (the next grid line). */
  --rule-section: 2px;
  --rule-hair:    1px;
  --radius:       0;
  --underline:         1px;
  --underline-hover:   2px;
  --underline-current: 3px;
  --focus-width:  3px;
  --focus-offset: 2px;

  /* ---------- Motion ---------------------------------------------------- */
  --duration-hover:   120ms;
  --duration-focus:   150ms;
  --ease-out:         cubic-bezier(0.22, 1, 0.36, 1);

  /* 1. Mark cells drawn cell by cell (scroll-linked, cells.js + CSS). */
  --mark-range:       entry 30% cover 35%;
  /* 2. Index "you are here" and 3. trace: the middle of the visible area
     below the sticky header (view timelines subtract scroll-padding). */
  --scroll-pad:       calc(var(--header-height) + var(--cell));
  --here-offset:      calc(50vh - var(--scroll-pad) / 2);
  --here-range:       cover var(--here-offset) cover calc(100% - var(--here-offset));
  --node-range:       cover var(--here-offset) cover calc(var(--here-offset) + 4rem);
  /* 4. Lens (lens.js): radius 3 cells, trail 650ms, load pulse 1.05s. */
  /* 5. Page transition. */
  --duration-page:    220ms;
  --ease-page:        var(--ease-out);
}

@media (min-width: 40rem) {
  :root {
    --text-h2:       2.75rem;
    --text-h1:       4rem;
    --text-h1-inner: 3.5rem;
    --lh-h1:         var(--cells-3);
  }
}

@media (min-width: 64rem) {
  :root {
    --gutter:        var(--cells-2);
    --number-width:  var(--cells-3);
    --section-gap:   var(--cells-5);
    --text-row:      2.75rem;
    --text-h2:       3.75rem;
    --lh-h2:         var(--cells-3);
    --text-h1:       clamp(5rem, 2rem + 4.7vw, 6rem);
    --text-h1-inner: 5rem;
    --lh-h1:         var(--cells-4);
  }
}

/* ---------- Dark ---------------------------------------------------------
   Same block twice: the OS preference (unless the visitor chose light),
   and the explicit choice. Near-black paper, light grid lines at low
   opacity, slightly deeper pastels that keep dark text. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-paper:        #141413;
    --color-ink:          #EDEDEA; /* 15.7 on paper */
    --color-ink-soft:     #B4B4AF; /* 8.9 on paper, >= 4.9 on lens cells */
    --color-ui-line:      #8C8C87; /* 5.5 on paper */
    --color-hairline:     #3A3A38;
    --color-quiet:        #2B2B29; /* ink on it 12.1 */
    --fact-sijainti:      #E5C84B; /* on-fact 11.4 */
    --fact-ai:            #7FCDBB; /* 10.2 */
    --fact-yksityisyys:   #E9A3B6; /*  9.3 */
    --fact-lahde:         #94BCE8; /*  9.5 */
    --fact-rajapinta:     #E9A877; /*  9.3 */
    --color-grid:         #20201F; /* 1.13 on paper */
    --color-grid-on-fill: rgb(0 0 0 / 0.1);
    --color-rail:         #5A5A57;
    --lens-alpha:         0.25;    /* ink >= 8.7, ink-soft >= 4.9 on lit cells */
    --lens-grey:          #555552; /* grey cell #232322: 1.17 on paper (was 1.06), ink 13.4, ink-soft 7.6 */
    --color-night:        #1E1E1D;
    --color-night-text:   #EDEDEA; /* 14.2 */
    --color-night-soft:   #B4B4AF; /* 7.6 */
    --color-night-line:   #333331;
  }
}

:root[data-theme="dark"] {
  --color-paper:        #141413;
  --color-ink:          #EDEDEA;
  --color-ink-soft:     #B4B4AF;
  --color-ui-line:      #8C8C87;
  --color-hairline:     #3A3A38;
  --color-quiet:        #2B2B29;
  --fact-sijainti:      #E5C84B;
  --fact-ai:            #7FCDBB;
  --fact-yksityisyys:   #E9A3B6;
  --fact-lahde:         #94BCE8;
  --fact-rajapinta:     #E9A877;
  --color-grid:         #20201F;
  --color-grid-on-fill: rgb(0 0 0 / 0.1);
  --color-rail:         #5A5A57;
  --lens-alpha:         0.25;
  --lens-grey:          #555552;
  --color-night:        #1E1E1D;
  --color-night-text:   #EDEDEA;
  --color-night-soft:   #B4B4AF;
  --color-night-line:   #333331;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* =====================================================================
   Part 2: components. Every vertical size is whole cells; lines are
   box-shadows on grid lines. data-fact="<type>" sets --fact.
   Scripts (all optional): theme.js (dark toggle), cells.js (marks as
   whole cells), lens.js (cursor lens). Without them the page is whole
   and the CSS mark background is used.
   ===================================================================== */

/* ---------- Base ------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--scroll-pad);
}

/* The graph paper starts at the document origin: x = 0 is the left edge
   of the page and y = 0 its top. Hard-stop gradients only draw lines. */
body {
  /* Header, layout, footer: the footer stays at the bottom of short
     pages (scripts are display: none and take no row). */
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--color-paper);
  background-image:
    linear-gradient(to right, var(--color-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: 0 0;
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--cell);
  font-variant-numeric: tabular-nums;
  timeline-scope: --s1, --s2, --s3, --s4, --s5, --s6, --s7, --s8, --s9, --s10;
}

h1, h2, h3, p, ol, ul, dl, dd, figure, blockquote {
  margin: 0;
}

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

/* Long Finnish compounds ("ohjelmistokehitystä") must never push the page
   sideways at 320px: hyphenate where the browser can, break otherwise. */
h1, h2, h3 {
  text-wrap: balance;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

p, dd, li {
  text-wrap: pretty;
}

img, svg {
  display: block;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline);
  text-underline-offset: 0.2em;
  transition: background-color var(--duration-hover) var(--ease-out),
              text-decoration-thickness var(--duration-hover) var(--ease-out);
}

a:hover {
  background-color: var(--color-quiet);
  text-decoration-thickness: var(--underline-hover);
}

a[aria-current="page"] {
  text-decoration-thickness: var(--underline-current);
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.nowrap {
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: var(--gap-s);
  left: var(--gap-s);
  z-index: 100;
  padding: 0 var(--cell);
  background-color: var(--color-ink);
  color: var(--color-paper);
  font-weight: var(--weight-strong);
  line-height: var(--cells-2);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

.arrow {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-inline-start: 0.25em;
  vertical-align: -0.08em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
}

/* "(suomeksi)" after a link to a page that exists only in Finnish. */
.lang-marker {
  color: var(--color-ink-soft);
  font-size: 0.875em;
  font-weight: var(--weight-regular);
}

/* ---------- Fact types ------------------------------------------------
   One attribute drives every fact colour: the mark, the lens, the touch
   reading line and the footer key. The index is neutral. The Go
   templates emit data-fact only with a type from site.FactTypes (tests),
   and cells.js and lens.js read the same attribute. */
[data-fact] { --fact: var(--fact-none); --on-fact: var(--color-ink); }
[data-fact="sijainti"] { --fact: var(--fact-sijainti); --on-fact: var(--color-on-fact); }
[data-fact="ai"] { --fact: var(--fact-ai); --on-fact: var(--color-on-fact); }
[data-fact="yksityisyys"] { --fact: var(--fact-yksityisyys); --on-fact: var(--color-on-fact); }
[data-fact="lahde"] { --fact: var(--fact-lahde); --on-fact: var(--color-on-fact); }
[data-fact="rajapinta"] { --fact: var(--fact-rajapinta); --on-fact: var(--color-on-fact); }

.swatch {
  display: inline-block;
  flex: none;
  width: 0.75rem;
  height: 0.75rem;
  border: 1.5px solid var(--color-ink);
  background-color: var(--fact, var(--color-paper));
  vertical-align: -0.05em;
}

/* ---------- Mark: verified facts only ---------------------------------
   At most one per paragraph and three per section, weight 600, Mark /
   MarkText in forced colours. The type is also given as text (title, or
   the mono tag on the EU-first rows), so meaning never rests on colour
   alone. Without JS the colour is a CSS background (drawn in left to
   right). With cells.js the colour moves to whole cells behind the text
   (.cellmark) and this background is cleared. */
mark {
  --fact: var(--fact-sijainti);
  margin-inline: -0.1em;
  padding-inline: 0.1em;
  background-color: transparent;
  background-image: linear-gradient(var(--fact), var(--fact));
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: var(--color-on-fact);
  font-weight: var(--weight-mark);
  -webkit-box-decoration-break: slice;
  box-decoration-break: slice;
}

h1 mark,
h2 mark,
h3 mark {
  font-weight: inherit;
}

/* The cells replace the bleed, so the rect starts where the text does.
   Marks inside a scrolling table (.table-wrap) are not given cells
   (cells.js): a cell box outside the scroller would not scroll with the
   table and could widen the page, so they keep this CSS background. */
html.js-cells .layout mark:not(.table-wrap mark) {
  margin-inline: 0;
  padding-inline: 0;
  background-image: none;
}

/* One box per mark line (cells.js sets left, top, width, height,
   background-position and --n through CSSOM): one grid row per line
   vertically, the marked glyphs plus a clamped pad horizontally. The page
   grid shows through. */
.cellmark {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  background-color: var(--fact);
  background-image:
    linear-gradient(to right, var(--color-grid-on-fill) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid-on-fill) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

/* ---------- Mono labels ---------------------------------------------- */
.label {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-soft);
}

/* ---------- Buttons and arrow links ----------------------------------
   Whole cells: 2 cells high, width from a w-N class (N cells). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--w, 6) * var(--cell));
  height: var(--cells-2);
  padding: 0;
  border: var(--rule-section) solid var(--color-ink);
  border-radius: var(--radius);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  line-height: var(--cell);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-hover) var(--ease-out),
              color var(--duration-hover) var(--ease-out);
}

.btn:hover {
  background-color: var(--color-quiet);
}

/* A button whose label is set by content (the hero CTA): as wide as the
   label plus one cell each side, rounded up to whole cells where
   calc-size() exists, never wider than its column; a label that does not
   fit wraps to a 3-cell button (2 + 10 + 24n + 10 + 2 px). */
.btn-fit {
  width: auto;
  max-width: round(down, 100%, var(--cell));
  height: auto;
  min-height: var(--cells-2);
  padding: calc(var(--cell) / 2 - var(--rule-section)) calc(var(--cell) - var(--rule-section));
  text-align: center;
  white-space: normal;
}

@supports (width: calc-size(fit-content, size)) {
  .btn-fit {
    width: calc-size(fit-content, round(up, size, var(--cell)));
  }
}

.w-4 { --w: 4; }
.w-5 { --w: 5; }
.w-6 { --w: 6; }
.w-7 { --w: 7; }

.btn-primary,
.btn-cta {
  background-color: var(--color-ink);
  color: var(--color-paper);
}

.btn-primary:hover,
.btn-cta:hover {
  background-color: var(--color-paper);
  color: var(--color-ink);
}

.btn:active,
.btn-primary:active,
.btn-cta:active {
  background-color: var(--color-quiet);
  color: var(--color-ink);
}

/* On the contact page the header button is the current page. */
.btn[aria-current="page"] {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-hover);
  text-underline-offset: 0.2em;
}

.arrow-link {
  font-weight: var(--weight-strong);
}

/* ---------- Frames: header, layout and footer share the snapping ----
   Width rounded down to whole cells, left edge rounded down to whole
   cells, so the content edge is a grid line at every viewport width.
   The header has no inner wrapper (its direct children are brand,
   toggle, nav and CTA), so it snaps its content box with padding and
   keeps a full-width background; 100% in padding is the same containing
   block width as in the layout's width. */
.layout,
.site-footer__inner {
  --frame: round(down, min(100% - 2 * var(--gutter), var(--frame-max)), var(--cell));
  width: var(--frame);
  margin-inline-start: round(down, (100% - var(--frame)) / 2, var(--cell));
}

/* ---------- Header (3 cells; the line below is the grid line) ------- */
.site-header {
  --frame: round(down, min(100% - 2 * var(--gutter), var(--frame-max)), var(--cell));
  --frame-start: round(down, (100% - var(--frame)) / 2, var(--cell));
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: var(--gap-s);
  height: var(--header-height);
  padding-inline: var(--frame-start) calc(100% - var(--frame-start) - var(--frame));
  background-color: var(--color-paper);
  box-shadow: 0 1px 0 var(--color-hairline);
  view-transition-name: site-header;
}

.brand {
  justify-self: start;
  min-width: 0;
  font-size: var(--text-brand);
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.site-header .btn-cta {
  --w: 5;
}

.nav-toggle,
.nav-close {
  width: calc(var(--w, 3) * var(--cell));
  height: var(--cells-2);
  padding: 0;
  border: var(--rule-section) solid var(--color-ink);
  border-radius: var(--radius);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-hover) var(--ease-out);
}

.nav-toggle:hover,
.nav-close:hover,
.nav-toggle:active,
.nav-close:active {
  background-color: var(--color-quiet);
}

/* Narrow screens: the nav is a full-screen popover. The browser hides it
   while closed and closes it on Esc and outside clicks; no JavaScript. */
.site-nav:popover-open {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0 var(--gutter) var(--cells-2);
  border: 0;
  background-color: var(--color-paper);
  color: var(--color-ink);
  overflow-y: auto;
}

.site-nav::backdrop {
  background-color: transparent;
}

.site-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  box-shadow: inset 0 calc(-1 * var(--rule-section)) 0 var(--color-ink);
}

.nav-main a {
  display: block;
  padding-block: var(--cell);
  box-shadow: inset 0 -1px 0 var(--color-hairline);
  font-size: var(--text-menu);
  font-weight: var(--weight-strong);
  line-height: var(--cells-2);
  text-decoration: none;
}

.nav-main a[aria-current="page"] {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-current);
}

.nav-secondary {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--cell);
  margin-top: auto;
  padding-top: var(--cells-2);
}

.nav-secondary a {
  display: inline-block;
  line-height: var(--cells-2);
  white-space: nowrap;
}

/* Narrow headers stay on one row (brand, toggle, CTA) without wrapping.
   The header is a size container and its content box is the snapped
   frame, so the steps follow the frame in whole cells (a desktop
   scrollbar makes a 360px window a 345px page):
   - frame of 11-12 cells (about 312-359px): a smaller brand and button
     text and a 4-cell CTA; the CTA text stays visible;
   - frame of 10 cells or less (below about 312px): the toggle narrows to
     a 2-cell menu icon; its text stays its accessible name. */
.site-header {
  container: site-header / inline-size;
}

@container site-header (width < 312px) {
  .site-header > * {
    margin-inline-end: calc(var(--gap-xs) - var(--gap-s));
  }

  .site-header > .btn-cta {
    --w: 4;
    margin-inline-end: 0;
  }

  .brand {
    font-size: var(--text-lead);
  }

  .site-header > .btn-cta,
  .nav-toggle {
    font-size: var(--text-mono);
  }
}

@container site-header (width < 264px) {
  .nav-toggle {
    --w: 2;
    position: relative;
    font-size: 0;
  }

  .nav-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    width: 1rem;
    height: 2px;
    margin: auto;
    background-color: var(--color-ink);
    box-shadow: 0 -5px 0 var(--color-ink), 0 5px 0 var(--color-ink);
  }
}

/* Browsers without popover support never hide [popover]: show the nav as
   a plain row below the brand and CTA, and drop the toggle and the close
   button. */
@supports not selector(:popover-open) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    min-height: var(--header-height);
  }

  .nav-toggle,
  .site-nav__head {
    display: none;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    padding-bottom: var(--cell);
  }

  .nav-main {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--cell);
  }

  .nav-main a {
    padding: 0;
    box-shadow: none;
    font-size: var(--text-small);
    line-height: var(--cells-2);
  }

  .nav-secondary {
    padding-top: 0;
  }
}

/* ---------- Page layout ---------------------------------------------- */
/* Stacking context, so the lens canvas and the mark cells (z-index -1)
   paint above the body's grid and below the text. */
.layout {
  position: relative;
  z-index: 0;
}

.lens {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.index {
  display: none;
}

/* Mobile contents, 2 cells summary; lines on the grid. */
.toc {
  margin-top: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

.toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--cells-2);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  cursor: pointer;
  list-style: none;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc ol {
  padding-bottom: var(--cell);
}

.toc a,
.index a {
  display: flex;
  align-items: center;
  gap: var(--gap-m);
  padding: 0 var(--gap-s);
  margin-inline: calc(-1 * var(--gap-s));
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  text-decoration: none;
}

/* Mobile contents: each link is a 2-cell row (touch target); a long
   label wraps on one-cell lines, its node stays on the first line. */
.toc a {
  align-items: flex-start;
  padding-block: calc(var(--cell) / 2);
  line-height: var(--cell);
}

.toc a:hover,
.index a:hover {
  background-color: transparent;
  text-decoration-line: underline;
}

.index__num {
  color: var(--num, var(--color-ink-soft));
}

/* Mobile contents: the same hollow square as an unlit index node. */
.toc a::before {
  content: "";
  flex: none;
  width: var(--node);
  height: var(--node);
  margin-top: calc((var(--cell) - var(--node)) / 2);
  border: 2px solid var(--color-rail);
  background-color: var(--color-paper);
}

.toggle-icon {
  position: relative;
  flex: none;
  width: 0.875rem;
  height: 0.875rem;
}

.toggle-icon::before,
.toggle-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
}

.toggle-icon::before {
  height: 0;
  border-top: var(--rule-section) solid currentColor;
}

.toggle-icon::after {
  width: 0;
  border-left: var(--rule-section) solid currentColor;
}

details[open] > summary .toggle-icon::after {
  display: none;
}

/* ---------- Hero ------------------------------------------------------ */
.hero {
  padding-block: var(--cells-2) var(--section-gap);
}

.hero h1 {
  max-width: min(100%, max(14ch, min-content)); /* a long word keeps its comma */
  font-size: var(--text-h1);
  font-weight: var(--weight-display);
  line-height: var(--lh-h1);
  letter-spacing: var(--tracking-display);
}

/* Inner pages (content pages, news, posts, 404): a smaller h1. */
.hero.intro[id] h1 {
  max-width: min(100%, max(18ch, min-content));
  font-size: var(--text-h1-inner);
}

.hero .lead {
  max-width: 44ch;
  margin-top: var(--cell);
  font-size: var(--text-lead);
}

/* The updated date ("Päivitetty" / "Updated"), visible on every content
   page. */
.updated {
  margin-top: var(--cell);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-soft);
}

/* Front page: the mono line above the h1 (home.eyebrow). */
.hero .eyebrow {
  margin-bottom: var(--cell);
}

/* Content pages: the intro text before the first h2. */
.hero__prose {
  margin-top: var(--cell);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cell);
  margin-top: var(--cells-2);
}

/* Next to a 2-cell button the link's line box is 2 cells too. */
.hero__actions .arrow-link {
  line-height: var(--cells-2);
}

/* Breadcrumbs (articles only, phase 2). */
.breadcrumbs {
  margin-top: var(--cells-2);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--gap-s);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.breadcrumbs li + li::before {
  content: "/";
  margin-inline-end: var(--gap-s);
  color: var(--color-ink-soft);
}

/* ---------- Sections: numbered like clauses --------------------------
   The 2px rule is the section's top grid line drawn bold, as long as
   the section (a whole number of cells wide). The clause counter follows
   the section's index number (tl-N), so "2.1" belongs to section 02 even
   when the hero is section 01. */
main {
  counter-reset: sec;
}

.tl-1 { counter-set: sec 1; }
.tl-2 { counter-set: sec 2; }
.tl-3 { counter-set: sec 3; }
.tl-4 { counter-set: sec 4; }
.tl-5 { counter-set: sec 5; }
.tl-6 { counter-set: sec 6; }
.tl-7 { counter-set: sec 7; }
.tl-8 { counter-set: sec 8; }
.tl-9 { counter-set: sec 9; }
.tl-10 { counter-set: sec 10; }

.section {
  padding-top: var(--cell);
  padding-bottom: var(--section-gap);
  box-shadow: inset 0 var(--rule-section) 0 var(--color-ink);
}

.section__head {
  margin-bottom: var(--cells-2);
}

.section__num {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.section__head h2 {
  max-width: 22ch;
  font-size: var(--text-h2);
  font-weight: var(--weight-display);
  line-height: var(--lh-h2);
  letter-spacing: var(--tracking-h2);
}

.section-lead {
  max-width: var(--measure);
  margin-bottom: var(--cell);
}

.section-foot {
  max-width: var(--measure);
  margin-top: var(--cells-2);
}

/* Sub-clauses "1.1", "1.2": rows of whole cells, the separator is the
   row's top grid line, the last row also draws the next one. */
.clauses {
  counter-reset: clause;
}

.clauses > li {
  counter-increment: clause;
  display: grid;
  grid-template-columns: var(--cells-2) minmax(0, 1fr);
  padding-block: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.clauses > li:last-child {
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

.clauses > li::before {
  content: counter(sec) "." counter(clause);
  grid-row: 1 / span 4;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-soft);
}

.clauses > * > * {
  grid-column: 2;
}

/* ---------- Prose: Markdown bodies (content/pages) --------------------
   Rendered by internal/content (goldmark, no raw HTML). One cell between
   blocks (as the mockup's .prose), two before a sub-heading, every line
   1 cell. Text keeps the measure; tables take the whole column and
   scroll inside .table-wrap. Marks use the mark rules above. */
.prose {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
  overflow-wrap: break-word; /* a long compound never widens the page */
}

.prose > :not(.table-wrap, pre) {
  max-width: var(--measure);
}

/* h3 20px, h4 body size; both bold on one-cell lines (h3 already
   hyphenates and wraps like h1/h2, see Base). */
.prose h3,
.prose h4 {
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
  line-height: var(--cell);
}

.prose h4 {
  margin: 0;
  font-size: var(--text-body);
  text-wrap: balance;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

.prose > :is(h3, h4):not(:first-child) {
  margin-top: var(--cell);
}

.prose ul,
.prose ol {
  padding-inline-start: var(--cell);
}

.prose ul {
  list-style: square;
}

.prose ol {
  padding-inline-start: var(--cells-2);
  list-style: decimal;
}

.prose li::marker {
  color: var(--color-ink-soft);
}

.prose ol > li::marker {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
}

/* Loose list items and nested lists: one cell between their blocks. */
.prose li > * + * {
  margin-top: var(--cell);
}

.prose li > :is(ul, ol) {
  margin-top: 0;
}

.prose blockquote {
  display: grid;
  gap: var(--cell);
  padding-inline-start: var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
}

.prose a {
  overflow-wrap: anywhere;
}

.prose code {
  padding-inline: 0.2em;
  background-color: var(--color-quiet);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  overflow-wrap: anywhere;
}

.prose pre {
  margin: 0;
  padding: var(--cell);
  overflow-x: auto;
  contain: inline-size;
  background-color: var(--color-quiet);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  line-height: var(--cell);
}

.prose pre code {
  padding: 0;
  background: none;
  overflow-wrap: normal;
}

/* Tables (e.g. the six-column dependency map on the EU-first page).
   The wrapper is a focusable, labelled region (internal/content) that
   scrolls sideways; inline-size containment keeps the table's width out
   of the page's min-content, so the page itself never scrolls sideways
   at 320 or 390px. position: relative clips the visually hidden type
   text (.vh) of a mark in a far column. The 1px padding holds the last
   row's bottom line without a vertical scrollbar. Rows are whole cells:
   half a cell above and below one-cell lines. */
.table-wrap {
  position: relative;
  contain: inline-size;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 1px;
  margin-bottom: -1px;
}

.table-wrap:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.prose table {
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-small);
  line-height: var(--cell);
}

.prose th,
.prose td {
  min-width: calc(4 * var(--cell));
  padding: calc(var(--cell) / 2) var(--cell) calc(var(--cell) / 2) 0;
  text-align: start;
  vertical-align: top;
}

.prose th:last-child,
.prose td:last-child {
  padding-inline-end: 0;
}

.prose th {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-soft);
}

.prose td {
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

/* The header rule is the first body row's top grid line drawn bold. */
.prose tbody tr:first-child td {
  box-shadow: inset 0 var(--rule-section) 0 var(--color-ink);
}

.prose tbody tr:last-child td {
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

.prose tbody tr:only-child td {
  box-shadow: inset 0 var(--rule-section) 0 var(--color-ink), 0 1px 0 var(--color-hairline);
}

/* ---------- FAQ (frontmatter faq; same text as the FAQPage JSON-LD) ---
   Rows like the mobile contents: the separator is the row's top grid
   line, the summary is 2 cells for one line, plus one per extra line. */
.faq {
  max-width: var(--measure);
  box-shadow: 0 1px 0 var(--color-hairline);
}

.faq details {
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.faq summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--cell);
  padding-block: calc(var(--cell) / 2);
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary:hover {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-hover);
  text-underline-offset: 0.2em;
}

/* The plus/minus sits in the middle of the first line. */
.faq summary .toggle-icon {
  margin-top: calc((var(--cell) - 0.875rem) / 2);
}

.faq details p {
  padding-bottom: var(--cell);
}

/* ---------- EU-first facts ------------------------------------------- */
.fact__claim {
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.fact__detail {
  color: var(--color-ink-soft);
}

/* The type as the machine labels it, in text (the colour is on the mark). */
.fact__type {
  display: block;
}

/* ---------- Roles ----------------------------------------------------- */
.role-cards > li {
  position: relative;
  grid-template-columns: var(--cells-2) minmax(0, 1fr) var(--cell);
}

.role__audience {
  grid-row: 1;
}

.role-cards .role__title,
.role-cards .role__text {
  grid-column: 2 / -1;
}

.role__title {
  justify-self: start;
  font-size: var(--text-row);
  font-weight: var(--weight-strong);
  line-height: var(--lh-row);
  letter-spacing: -0.015em;
}

.role__title a {
  text-decoration: none;
}

.role__title .lang-marker {
  font-size: var(--text-small);
  letter-spacing: 0;
}

/* The whole row is the link's target. */
.role__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.role__title a:focus-visible {
  outline: none;
}

.role-cards > li:has(a:focus-visible) {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.role-cards > li:has(a:focus-visible) .role__title a {
  background-color: var(--color-quiet);
}

.role__text {
  max-width: 52ch;
  color: var(--color-ink-soft);
}

.role__arrow {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  width: var(--cell);
  height: var(--cell);
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 2;
  stroke-linecap: square;
}

/* ---------- News: list, cards, filters, pagination, post meta -------
   Phase 2 (PLAN v23). Neutral throughout: colour stays on fact marks.
   Rows are whole cells like the clauses; every control and stand-alone
   link is 2 cells (48px) tall (WCAG 2.5.5). The list works without JS;
   htmx swaps div#news-list and marks the clicked element htmx-request. */

/* The Atom feed link under the hero lead: a 2-cell line box. */
.news-feed {
  margin-top: var(--cell);
}

.news-feed a {
  display: inline-block;
  line-height: var(--cells-2);
}

/* Filter form: fields 1 cell label + 2 cell select, side by side when
   they fit, the button on the same bottom line. */
.news-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--cell);
}

.news-filter__field {
  display: grid;
  width: min(100%, calc(10 * var(--cell)));
}

.news-filter__field label {
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
}

/* The native arrow stays (no images: CSP and forced colours). The border
   is the grid lines around the field: inside on top and left, outside on
   bottom and right, as the mockup's fields. */
.news-filter select {
  width: 100%;
  height: var(--cells-2);
  padding: 0 var(--gap-m);
  border: 0;
  border-radius: var(--radius);
  box-shadow: inset 1px 1px 0 var(--color-ui-line), 1px 1px 0 var(--color-ui-line);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font: inherit;
  line-height: var(--cell);
  cursor: pointer;
  transition: box-shadow var(--duration-focus) var(--ease-out);
}

.news-filter select:hover {
  box-shadow: inset 1px 1px 0 var(--color-ink), 1px 1px 0 var(--color-ink);
}

.news-filter__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--cell);
}

.news-filter__clear {
  display: inline-block;
  font-size: var(--text-small);
  line-height: var(--cells-2);
}

.news-list__status {
  margin-top: var(--cells-2);
}

/* While htmx loads the next view the old list fades a little. */
.news-list:has(.htmx-request) .post-list {
  opacity: 0.6;
  transition: opacity var(--duration-focus) var(--ease-out);
}

.news-list:has(.htmx-request) {
  cursor: progress;
}

.news-list__empty {
  margin-top: var(--cell);
  padding-block: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

/* Post rows: the separator is the row's top grid line, the last row also
   draws the next one (as .clauses). */
.news-list .post-list {
  margin-top: var(--cell);
}

.post-list > li {
  padding-block: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.post-list > li:last-child {
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

/* The whole card is the title link's target (as the role rows); the tag
   links sit above it. */
.post-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.post-card__title {
  justify-self: start;
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.post-card__title a {
  text-decoration: none;
}

.post-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.post-card:hover .post-card__title a {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-hover);
}

/* Focus rings the whole card where :has() exists; elsewhere the link's
   own ring stays. */
@supports selector(:has(a)) {
  .post-card__title a:focus-visible {
    outline: none;
  }

  .post-card:has(.post-card__title a:focus-visible) {
    outline: var(--focus-width) solid var(--color-focus);
    outline-offset: var(--focus-offset);
  }

  .post-card:has(.post-card__title a:focus-visible) .post-card__title a {
    background-color: var(--color-quiet);
    text-decoration-line: underline;
  }
}

.post-card__desc {
  max-width: 60ch;
  color: var(--color-ink-soft);
}

.post-card .tag-list {
  position: relative;
  z-index: 1;
}

/* Tag links: mono, 2 cells tall and at least 2 cells wide; the text
   starts at the column's grid line. */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--gap-m);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-width: var(--cells-2);
  height: var(--cells-2);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

/* Pagination: squares of 2 x 2 cells on the grid lines (inside on top
   and left, outside on bottom and right), the steps as wide as their
   label rounded up to whole cells where calc-size() exists. */
.pagination {
  margin-top: var(--cells-2);
}

.pagination ul {
  display: flex;
  flex-wrap: wrap;
  row-gap: var(--cell);
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--cells-2);
  height: var(--cells-2);
  font-weight: var(--weight-strong);
}

.pagination__num {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  text-decoration-line: none;
  box-shadow: inset 1px 1px 0 var(--color-ui-line), 1px 1px 0 var(--color-ui-line);
}

.pagination__num[aria-current="page"],
.pagination__num[aria-current="page"]:hover {
  background-color: var(--color-ink);
  color: var(--color-paper);
  text-decoration-line: underline;
}

.pagination__step a {
  padding-inline: var(--gap-m);
  font-size: var(--text-small);
}

@supports (width: calc-size(fit-content, size)) {
  .pagination__step a {
    width: calc-size(fit-content, round(up, size, var(--cell)));
  }
}

.arrow--back {
  margin-inline: 0 0.25em;
}

/* Post page: meta line and tags under the lead. */
.post-meta {
  margin-top: var(--cell);
}

/* ---------- 404: the services ---------------------------------------- */
.service-list a {
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

/* ---------- Contact --------------------------------------------------- */
.contact {
  display: grid;
  gap: var(--cells-2);
}

.contact__email > div + div {
  margin-top: var(--cell);
}

.contact__email dt {
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
  color: var(--color-ink-soft);
}

.contact__email dd {
  font-size: var(--text-lead);
  font-weight: var(--weight-strong);
  overflow-wrap: anywhere;
}

.contact__book,
.contact__form,
.contact__ask,
.contact__privacy {
  margin-top: var(--cell);
}

.contact__privacy {
  max-width: 40ch;
}

/* "Aloita suunnittelu heti": the AI architect first, the same on every
   page (Karo 22.11.2026). */
.contact__start-text {
  max-width: 48ch;
  margin-top: var(--cell);
}

/* The link to the form next to the email and the link to the AI
   architect: 2-cell line boxes (touch). */
.contact__form a,
.contact__ask a {
  display: inline-block;
  line-height: var(--cells-2);
}

/* ---------- Contact form (phase 3, partials/contact-form.html) --------
   Neutral like the news filters: colour stays on fact marks, so an error
   is told by words, weight and a bold rule, never by colour alone. Fields
   are a 1-cell label (plus a 1-cell error line) over a 2-cell input; the
   border is the grid lines around the field, inside on top and left,
   outside on bottom and right; an invalid field draws them 2px. Notices
   and the error summary are boxes framed by the grid lines drawn bold.
   Every value is a whole number of cells, so the rows stay on the grid in
   both themes (the tokens switch) and at 320px (no fixed widths). */
.contact-form {
  width: min(100%, calc(28 * var(--cell)));
}

.contact-form__intro {
  max-width: var(--measure);
  margin-bottom: var(--cell);
}

.form {
  display: grid;
  gap: var(--cell);
}

.field {
  display: grid;
  min-width: 0;
}

.field label {
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
}

.field__marker {
  color: var(--color-ink-soft);
  font-weight: var(--weight-regular);
}

.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  height: var(--cells-2);
  margin: 0;
  padding: 0 var(--gap-m);
  border: 0;
  border-radius: var(--radius);
  box-shadow: inset 1px 1px 0 var(--color-ui-line), 1px 1px 0 var(--color-ui-line);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font: inherit;
  line-height: var(--cell);
  transition: box-shadow var(--duration-focus) var(--ease-out);
}

/* 8 rows of text plus half a cell above and below: 9 cells. */
.field textarea {
  height: auto;
  min-height: calc(9 * var(--cell));
  padding-block: calc(var(--cell) / 2);
  resize: vertical;
}

.field input:hover,
.field textarea:hover {
  box-shadow: inset 1px 1px 0 var(--color-ink), 1px 1px 0 var(--color-ink);
}

/* An invalid field: a bold rule on the left of the whole field (label,
   error and input) and a 2px frame on the input. */
.field--error {
  padding-left: var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
}

.field--error input,
.field--error textarea,
.field--error input:hover,
.field--error textarea:hover {
  box-shadow: inset 2px 2px 0 var(--color-ink), 2px 2px 0 var(--color-ink);
}

.field__error {
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
  overflow-wrap: break-word;
}

/* The honeypot: off screen for people, still in the form for bots. Not
   display: none, which some bots detect; aria-hidden and tabindex="-1"
   keep it out of assistive technology and the tab order. */
.hp {
  position: absolute;
  left: -100vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form__actions {
  margin-top: var(--cell);
}

.form__privacy {
  max-width: var(--measure);
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

/* While htmx sends the form, the form fades a little (the button is
   disabled by hx-disable). */
.form.htmx-request {
  opacity: 0.6;
  cursor: progress;
  transition: opacity var(--duration-focus) var(--ease-out);
}

/* The error summary and the notices: framed boxes, the frame on the grid
   lines (2px, inside), one cell of padding. */
.form-errors,
.form-notice {
  max-width: var(--measure);
  margin-bottom: var(--cells-2);
  padding: var(--cell);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.form-notice--sent {
  margin-bottom: 0;
}

.form-errors__heading,
.form-notice__heading {
  margin-bottom: var(--cell);
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.form-errors ul {
  display: grid;
  gap: var(--gap-s);
}

.form-errors a {
  font-weight: var(--weight-strong);
}

.form-notice p + p {
  margin-top: var(--cell);
}

.form-notice a {
  overflow-wrap: anywhere;
}

.form-notice__action a {
  display: inline-block;
  line-height: var(--cells-2);
}

/* ---------- AI architect chat (phase 4a, partials/chat.html) ---------
   The transcript of the mockup's architect example: one row per message,
   the separator is the row's top grid line, the speaker a mono label.
   The only colour is the "ai" fact colour of the "Tekoäly" label on the
   architect's messages and its streaming preview (the word says it too,
   so meaning never rests on colour). Cards and the closed notice are
   boxes framed by the grid lines drawn bold, like the form notices.
   Every vertical value is whole cells; horizontally the cards keep a
   16px gutter on narrow screens, so 320px fits without sideways scroll.
   No animation: an answer appears whole (chat.js scrolls with
   behavior auto under prefers-reduced-motion). */
.chat {
  width: min(100%, calc(40 * var(--cell)));
}

/* The hidden attribute wins over every display value below (chat.js
   shows #chat-closed, #chat-actions and the Enter hint by toggling it). */
.chat [hidden] {
  display: none !important;
}

.chat > .form-notice,
.chat > .chat-fallback {
  margin-bottom: var(--cells-2);
}

/* The chat window (Karo, 22.11.2026): a frame drawn like the cards. The
   conversation scrolls inside #chat-scroll and the input stays at the
   window's bottom edge, like in other chat apps. Before the first message
   the window is as tall as its content (the AI notice, the opener and
   the starters stay visible and the input is close to the heading); once
   the visitor has written, it has a fixed height: whole cells, at most
   the viewport below the sticky header and at most 32 cells. The 2px
   padding keeps the scrollbar inside the frame. */
.chat-window {
  --chat-height: clamp(calc(16 * var(--cell)), round(down, 100svh - var(--header-height) - var(--cells-2), var(--cell)), calc(32 * var(--cell)));
  display: flex;
  flex-direction: column;
  padding: var(--rule-section);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.chat-window:has(.chat-msg--visitor) {
  height: var(--chat-height);
}

.chat-scroll {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding-inline: var(--gap-m);
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* The conversation sits at the bottom, next to the input, until it fills
   the window. An auto margin (not justify-content: flex-end) keeps the
   top reachable by scrolling. */
.chat-scroll > :first-child {
  margin-top: auto;
}

.chat-after {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cells-2);
  margin-top: var(--cells-2);
}

.chat-log {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.chat-log > li {
  min-width: 0;
  padding-block: var(--cell);
}

.chat-log > li + li {
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.chat-msg__body {
  overflow-wrap: break-word;
}

.chat-msg__body > :not(.table-wrap, pre) {
  max-width: var(--measure);
}

/* "Tekoäly": a one-cell mono tag in the AI fact colour. */
.chat-ai-label,
.chat-stream::before {
  display: inline-block;
  padding-inline: var(--gap-s);
  background-color: var(--fact-ai);
  color: var(--color-on-fact);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-mark);
  letter-spacing: var(--tracking-mono);
  line-height: var(--cell);
}

/* The visitor's own text: a quiet box on the right, as in other chat
   apps; plain, newlines kept, a long word wraps. */
.chat-msg--visitor {
  display: flex;
  justify-content: flex-end;
}

.chat-msg--visitor .chat-msg__text {
  max-width: min(85%, var(--measure));
  padding: calc(var(--cell) / 2) var(--gap-m);
  border-radius: var(--radius);
  background-color: var(--color-quiet);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg--notice p {
  max-width: var(--measure);
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.chat-msg--streaming .chat-msg__body,
.chat-msg--failed .chat-msg__body {
  color: var(--color-ink-soft);
}

/* The sentence-by-sentence preview (aria-hidden, outside the log): the
   label comes from data-label; empty, it takes no room. */
.chat-stream {
  padding-block: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline);
  color: var(--color-ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-stream::before {
  content: attr(data-label);
  display: block;
  width: fit-content;
  color: var(--color-on-fact);
}

.chat-stream:empty {
  display: none;
}

/* One cell is always kept for the status (between the conversation and
   the input), so the window does not jump; a status that wraps on a
   narrow screen takes its rows from the conversation, not the input. */
.chat-status,
.chat-input {
  flex-shrink: 0;
}

.chat-status {
  min-height: var(--cell);
  padding-inline: var(--gap-m);
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.chat-refusal,
.chat-fallback {
  display: grid;
  gap: var(--cell);
}

.chat-refusal {
  padding-block: var(--cell);
}

.chat-refusal > .form-notice,
.chat-fallback > .form-notice {
  margin-bottom: 0;
}

/* The input row at the bottom of the window. */
.chat-input {
  padding: calc(var(--cell) / 2) var(--gap-m) var(--gap-m);
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

/* Starters: compact buttons that wrap, the last thing above the input. */
.chat-starters {
  padding-block: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.chat-starters ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-s);
}

.chat-starter {
  display: block;
  width: auto;
  min-height: var(--cells-2);
  margin: 0;
  padding: calc(var(--cell) / 2) var(--gap-m);
  border: 0;
  border-radius: var(--radius);
  box-shadow: inset 1px 1px 0 var(--color-ui-line), 1px 1px 0 var(--color-ui-line);
  background-color: var(--color-paper);
  color: var(--color-ink);
  font: inherit;
  font-size: var(--text-small);
  line-height: var(--cell);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-hover) var(--ease-out);
}

.chat-starter:hover {
  background-color: var(--color-quiet);
}

/* The textarea and the send button side by side, the hint under both. */
.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--gap-s);
}

.chat-form__actions {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.chat-form__hint {
  grid-column: 1 / -1;
}

/* 2 rows of text plus half a cell above and below: 3 cells. It grows
   with the text up to 10 cells where field-sizing is supported. */
.chat-form .field textarea {
  min-height: calc(3 * var(--cell));
  max-height: calc(10 * var(--cell));
  field-sizing: content;
}

.field__hint {
  max-width: var(--measure);
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.chat-closed {
  display: grid;
  gap: var(--cell);
  max-width: var(--measure);
  padding: var(--cell);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cell);
}

/* The always-visible "Jätä yhteystiedot": a row like the FAQ, the card
   opens under it without its own frame. */
.chat-contact {
  box-shadow: inset 0 1px 0 var(--color-hairline), 0 1px 0 var(--color-hairline);
}

.chat-contact[open] {
  padding-bottom: var(--cell);
}

.chat-contact > summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--cell);
  padding-block: calc(var(--cell) / 2);
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
  cursor: pointer;
  list-style: none;
}

.chat-contact > summary::-webkit-details-marker {
  display: none;
}

.chat-contact > summary:hover {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-hover);
  text-underline-offset: 0.2em;
}

.chat-contact > summary .toggle-icon {
  margin-top: calc((var(--cell) - 0.875rem) / 2);
}

.chat-contact[open] > summary {
  margin-bottom: var(--cell);
}

.chat-contact > .form-notice {
  margin-bottom: var(--cell);
}

/* The contact card. */
.chat-card {
  padding: var(--cell) calc(var(--cell) * 2 / 3);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.chat-contact .chat-card {
  padding: 0;
  box-shadow: none;
}

.chat-card__heading {
  margin-bottom: var(--cell);
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.chat-card__text {
  max-width: var(--measure);
  margin-bottom: var(--cell);
}

/* Inside the framed card a notice is a bold rule on its left, not a
   second frame. */
.chat-card .form-notice,
.chat-card .form-errors {
  margin-bottom: var(--cell);
  padding: 0 0 0 var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
}

.chat-card .form-notice--sent {
  margin-bottom: 0;
}

.chat-card .form-notice__heading,
.chat-card .form-errors__heading {
  font-size: var(--text-body);
}

/* 5 rows of text plus half a cell above and below: 6 cells. */
.chat-card .field textarea {
  min-height: calc(6 * var(--cell));
}

.chat-reply {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

/* The legend floats so it is an ordinary block inside the fieldset and
   takes the invalid field's padding like a label does. */
.chat-reply legend {
  float: left;
  width: 100%;
  padding: 0;
  font-size: var(--text-small);
  font-weight: var(--weight-strong);
}

.chat-reply legend + * {
  clear: left;
}

.chat-reply.field--error {
  padding-left: var(--cell);
}

.chat-choice {
  display: flex;
  align-items: center;
  gap: var(--gap-s);
  min-height: var(--cell);
}

.chat-choice input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--color-ink);
}

.chat-choice label {
  cursor: pointer;
}

.chat-card__person {
  font-size: var(--text-small);
}

@media (pointer: coarse) {
  .chat-choice {
    min-height: var(--cells-2);
  }
}

@media (min-width: 40rem) {
  .chat-scroll,
  .chat-status {
    padding-inline: var(--cell);
  }

  .chat-input {
    padding-inline: var(--cell);
  }

  .chat-card {
    padding: var(--cell);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-starter,
  .chat .form.htmx-request {
    transition: none;
  }
}

/* Forced colours drop box-shadow lines and backgrounds: borders instead. */
@media (forced-colors: active) {
  .chat-ai-label,
  .chat-stream::before {
    border: 1px solid CanvasText;
  }

  .chat-log > li + li,
  .chat-stream,
  .chat-starters,
  .chat-contact,
  .chat-input {
    border-top: 1px solid CanvasText;
  }

  .chat-window {
    border: var(--rule-section) solid CanvasText;
  }

  .chat-msg--visitor .chat-msg__text {
    border: 1px solid CanvasText;
  }

  .chat-card,
  .chat-closed {
    border: var(--rule-section) solid CanvasText;
  }

  .chat-contact .chat-card {
    border: 0;
  }

  .chat-starter {
    border: 1px solid ButtonText;
  }
}

/* ---------- AI architect: solution sketch and suggestions -------------
   Phase 4b (partials/sketch.html, ai-architect-sketch.html). The sketch
   card is a box framed by the grid lines drawn bold, like the contact
   card; its fields are a description list: the label a mono line, the
   value under it, one cell between fields. The share page uses the same
   fields under its hero. Suggestions are link rows with the kind as a
   mono tag and the reason in secondary text. Only the "Tekoäly" tag has
   colour (the word says it too). */
.sketch-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
  padding: var(--cell) calc(var(--cell) * 2 / 3);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.sketch-card__kicker,
.sketch-page__kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-s);
}

.sketch-page__kicker {
  margin-bottom: var(--cell);
}

.sketch-card__title {
  max-width: var(--measure);
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

/* "Ei tarjous eikä sitoumus": a bold rule on its left, like a notice. */
.sketch-notice {
  max-width: var(--measure);
  padding-left: var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
  font-size: var(--text-small);
}

.sketch-page__notice {
  margin-top: var(--cell);
}

.sketch-created {
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.sketch-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
  overflow-wrap: break-word; /* a long compound never widens the card */
}

.sketch-field dt {
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.sketch-field dd {
  max-width: var(--measure);
}

.sketch-steps {
  display: grid;
  gap: var(--cell);
  padding-inline-start: var(--cells-2);
  list-style: decimal;
}

.sketch-steps > li::marker {
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
}

.sketch-steps__title {
  font-weight: var(--weight-strong);
}

.sketch-list {
  padding-inline-start: var(--cell);
  list-style: square;
}

.sketch-list > li::marker {
  color: var(--color-ink-soft);
}

.sketch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cell);
}

.sketch-copy__status {
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

/* "Pyydä Staffbitea kommentoimaan": a row like the details contact card,
   the card opens under it without a second frame. */
.sketch-comment {
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.sketch-comment > summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--cell);
  padding-top: var(--cell);
  font-weight: var(--weight-strong);
  cursor: pointer;
  list-style: none;
}

.sketch-comment > summary::-webkit-details-marker {
  display: none;
}

.sketch-comment > summary:hover {
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline-hover);
  text-underline-offset: 0.2em;
}

.sketch-comment > summary .toggle-icon {
  margin-top: calc((var(--cell) - 0.875rem) / 2);
}

.sketch-comment[open] > summary {
  margin-bottom: var(--cell);
}

.sketch-comment .chat-card {
  padding: 0;
  box-shadow: none;
}

/* The sketch was made after the session's lead: a short notice in the
   comment row's place. */
.sketch-comment-note {
  padding-top: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-hairline);
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

/* Suggestions. */
.suggest {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
}

.suggest__heading {
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.suggest__list {
  display: grid;
  box-shadow: 0 1px 0 var(--color-hairline);
}

.suggest__item {
  max-width: var(--measure);
  padding-block: calc(var(--cell) / 2);
  box-shadow: inset 0 1px 0 var(--color-hairline);
  overflow-wrap: break-word;
}

.suggest__title {
  font-weight: var(--weight-strong);
}

.suggest__why {
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

/* ---------- AI architect: EU readiness assessment and profile ---------
   Phase 4c (partials/assess.html, the contact card in partials/chat.html).
   The assessment is framed like the sketch card, its fields are the same
   description list (mono label, value under it). The fixed disclaimer is
   the first thing under the heading: body size, bold, with the notice's
   bold rule on its left. The AI Act hint is bold, and for a possibly
   high-risk or prohibited use case it carries the same rule, so the
   warning does not depend on colour. The profile on the contact card is
   a quiet read-only list between hairlines, never a form field. */
.assess {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
  padding: var(--cell) calc(var(--cell) * 2 / 3);
  box-shadow: inset 0 0 0 var(--rule-section) var(--color-ink);
}

.assess__kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-s);
}

.assess__heading {
  font-size: var(--text-h3);
  font-weight: var(--weight-strong);
}

.assess__disclaimer,
.assess__review {
  max-width: var(--measure);
  padding-left: var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
  font-weight: var(--weight-strong);
}

.assess__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cell);
  overflow-wrap: break-word; /* a long compound never widens the card */
}

.assess__field dt {
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.assess__field dd {
  max-width: var(--measure);
}

.assess__list {
  padding-inline-start: var(--cell);
  list-style: square;
}

.assess__list > li::marker {
  color: var(--color-ink-soft);
}

.assess__country {
  color: var(--color-ink-soft);
}

/* Data kinds: mono tags in a wrapping row, framed by a hairline. */
.assess__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-s);
  padding-top: calc(var(--cell) / 6);
}

.assess__tags > li {
  padding: 0 var(--gap-s);
  box-shadow: inset 0 0 0 1px var(--color-ink);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

.assess__hint {
  font-weight: var(--weight-strong);
}

.assess__hint--possibly_high_risk,
.assess__hint--possibly_prohibited {
  padding-left: var(--cell);
  box-shadow: inset var(--rule-section) 0 0 var(--color-ink);
}

.assess__links {
  display: grid;
  box-shadow: 0 1px 0 var(--color-hairline);
}

.assess__links > li {
  padding-block: calc(var(--cell) / 4);
  box-shadow: inset 0 1px 0 var(--color-hairline);
  font-weight: var(--weight-strong);
}

/* "Mitä ymmärsin tarpeestasi" on the contact card. */
.chat-profile {
  display: grid;
  gap: calc(var(--cell) / 2);
  max-width: var(--measure);
  margin-bottom: var(--cell);
}

.chat-profile__heading {
  font-size: var(--text-body);
  font-weight: var(--weight-strong);
}

.chat-profile__note {
  color: var(--color-ink-soft);
  font-size: var(--text-small);
}

.chat-profile__list {
  display: grid;
  box-shadow: 0 1px 0 var(--color-hairline);
  overflow-wrap: break-word;
}

.chat-profile__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding-block: calc(var(--cell) / 4);
  box-shadow: inset 0 1px 0 var(--color-hairline);
}

.chat-profile__item dt {
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

@media (min-width: 40rem) {
  .assess {
    padding: var(--cell);
  }

  .chat-profile__item {
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: var(--cell);
    align-items: baseline;
  }
}

@media (forced-colors: active) {
  .assess {
    border: var(--rule-section) solid CanvasText;
  }

  .assess__disclaimer,
  .assess__review,
  .assess__hint--possibly_high_risk,
  .assess__hint--possibly_prohibited {
    border-left: var(--rule-section) solid CanvasText;
  }

  .assess__tags > li {
    border: 1px solid CanvasText;
  }

  .assess__links > li,
  .chat-profile__item {
    border-top: 1px solid CanvasText;
  }
}

/* The share page: the hero, then the fields as one section, then the
   links on. The hidden print button stays hidden against .btn. */
.sketch-page [hidden] {
  display: none !important;
}

.sketch-page__print {
  margin-top: var(--cells-2);
}

/* Without JavaScript the print button stays hidden: no empty row. */
.sketch-page__print:has(> [hidden]) {
  display: none;
}

.sketch-page__body .sketch-fields {
  gap: var(--cells-2);
}

.sketch-page__body .sketch-field dd {
  font-size: var(--text-lead);
}

.sketch-page__links {
  display: grid;
  gap: var(--cell);
  padding-bottom: var(--section-gap);
}

@media (min-width: 40rem) {
  .sketch-card {
    padding: var(--cell);
  }
}

@media (forced-colors: active) {
  .sketch-card {
    border: var(--rule-section) solid CanvasText;
  }

  .sketch-notice {
    border-left: var(--rule-section) solid CanvasText;
  }

  .sketch-comment,
  .sketch-comment-note,
  .suggest__item {
    border-top: 1px solid CanvasText;
  }
}

/* ---------- Footer: the dark surface ---------------------------------- */
.site-footer {
  position: relative;
  z-index: 1;
  background-color: var(--color-night);
  color: var(--color-night-text);
  font-size: var(--text-small);
}

.site-footer__inner {
  padding-block: var(--cells-3) var(--cells-2);
}

.site-footer__grid {
  display: grid;
  gap: var(--cells-2);
}

.site-footer__brand {
  font-size: var(--text-brand);
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
}

.site-footer h2 {
  margin-bottom: var(--cell);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-mono);
  color: var(--color-night-soft);
}

.site-footer ul {
  display: grid;
}

.site-footer address {
  display: grid;
  justify-items: start;
  font-style: normal;
  overflow-wrap: anywhere;
}

.site-footer a:hover {
  background-color: var(--color-night-text);
  color: var(--color-night);
}

.site-footer :focus-visible {
  outline-color: var(--color-focus-night);
}

.site-footer .lang-marker {
  color: inherit;
}

/* Colour key: each fact type with its swatch, name and what it covers. */
.key {
  margin-top: var(--cells-2);
  padding-top: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-night-line);
}

.site-footer .key-list {
  gap: var(--cell) var(--cells-2);
}

.key-list li {
  display: grid;
  grid-template-columns: var(--cell) minmax(0, 1fr);
  align-content: start;
  align-items: start;
}

.key .swatch {
  width: 1rem;
  height: 1rem;
  margin-top: 0.25rem;
  border-color: var(--color-night-text);
}

.key .swatch--none {
  background-color: var(--fact-none);
}

.key__name {
  font-weight: var(--weight-strong);
}

.key__desc {
  grid-column: 2;
  color: var(--color-night-soft);
}

.key__note {
  max-width: 60ch;
  margin-top: var(--cell);
  color: var(--color-night-soft);
}

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--cell);
  margin-top: var(--cells-2);
  padding-top: var(--cell);
  box-shadow: inset 0 1px 0 var(--color-night-line);
  color: var(--color-night-soft);
}

.site-footer .machine-links,
.site-footer__prefs {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--cell);
}

/* Theme toggle (theme.js unhides it; without JS the OS setting applies). */
.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-night-text);
  font: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--underline);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.theme-toggle[aria-pressed="true"] {
  text-decoration-thickness: var(--underline-current);
}

.theme-toggle:hover {
  background-color: var(--color-night-text);
  color: var(--color-night);
}

.theme-toggle[hidden] {
  display: none;
}

/* Narrow screens: every footer link and the toggle are 2 cells tall
   (48px, WCAG 2.5.5); wider screens keep 1-cell lines. */
@media (max-width: 47.99rem) {
  .site-footer a,
  .theme-toggle {
    display: inline-block;
    line-height: var(--cells-2);
  }

  .site-footer h2 {
    margin-bottom: 0;
  }
}

/* =====================================================================
   Wider screens. Columns that do not end at the frame edge are rounded
   to whole cells, so the next column starts on a grid line too.
   ===================================================================== */
@media (min-width: 40rem) {
  .post-card {
    grid-template-columns: calc(8 * var(--cell)) minmax(0, 1fr);
  }

  .post-card > * {
    grid-column: 2;
  }

  .post-card .post-card__meta {
    grid-column: 1;
    grid-row: 1 / span 3;
    padding-right: var(--cell);
  }

  .post-card__type,
  .post-card time {
    display: block;
  }

  .post-card__sep {
    display: none;
  }

  .site-footer__grid {
    grid-template-columns: repeat(3, round(down, (100% - 4 * var(--cell)) / 3, var(--cell)));
  }

  .site-footer__brand {
    grid-column: 1 / -1;
  }

  .site-footer .key-list {
    grid-template-columns: repeat(2, round(down, (100% - var(--cells-2)) / 2, var(--cell)));
  }
}

@media (min-width: 64rem) {
  .layout {
    display: grid;
    grid-template-columns: var(--index-width) minmax(0, 1fr);
    column-gap: var(--column-gap);
  }

  .toc {
    display: none;
  }

  .index {
    display: block;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: calc(var(--header-height) + var(--cells-2));
    margin-top: var(--cells-2);
    view-transition-name: page-index;
  }

  /* The title's rule is the grid line below it, drawn bold. */
  .index__title {
    margin-bottom: var(--cell);
    box-shadow: 0 var(--rule-section) 0 var(--color-ink);
  }

  /* Trace on the grid line at the index's left edge. Each item is one
     cell; its node sits on the line, its segment runs to the next node. */
  .index ol {
    position: relative;
    display: grid;
  }

  .index ol::before {
    content: "";
    position: absolute;
    top: calc(var(--cell) / 2);
    bottom: calc(var(--cell) / 2);
    left: -1px;
    width: 2px;
    background-color: var(--color-rail);
  }

  /* One cell per label line: a long label (a content h2, up to 40
     characters) wraps to whole extra cells, and its node stays on the
     first line. */
  .index li {
    position: relative;
    display: flex;
    align-items: flex-start;
    min-height: var(--cell);
    padding-left: var(--cell);
  }

  .index a {
    flex: 1;
    align-items: flex-start;
    line-height: var(--cell);
  }

  .index li:not(:last-child)::before {
    content: "";
    position: absolute;
    top: calc(var(--cell) / 2);
    left: -1px;
    width: 2px;
    height: 100%;
    background-color: var(--color-ink);
    transform-origin: 50% 0;
    scale: 1 0;
  }

  .index li::after {
    content: "";
    position: absolute;
    top: calc((var(--cell) - var(--node)) / 2);
    left: calc(var(--node) / -2);
    width: var(--node);
    height: var(--node);
    border: 2px solid var(--color-rail);
    background-color: var(--color-paper);
  }

  main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .section {
    display: grid;
    grid-template-columns: var(--number-width) minmax(0, 1fr);
    align-content: start;
  }

  .section > * {
    grid-column: 2;
  }

  .section__head,
  .section > .clauses {
    grid-column: 1 / -1;
  }

  /* The number sits in the last cell row of the heading's first line,
     near its baseline, without leaving the grid. */
  .section__head {
    display: grid;
    grid-template-columns: var(--number-width) minmax(0, 1fr);
    align-items: start;
  }

  .section__num {
    grid-column: 1;
    grid-row: 1;
    margin-top: calc(var(--lh-h2) - var(--cell));
  }

  .section__head > :not(.section__num) {
    grid-column: 2;
  }

  .clauses > li {
    grid-template-columns: var(--number-width) minmax(0, 1fr);
  }

  .role-cards > li {
    grid-template-columns: var(--number-width) calc(9 * var(--cell)) minmax(0, 1fr) var(--cells-2);
  }

  .role-cards > li > * {
    grid-column: 3;
  }

  .role-cards > li::before,
  .role-cards .role__audience {
    padding-top: var(--cell);
  }

  .role-cards .role__audience {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding-right: var(--cell);
  }

  .role-cards .role__title,
  .role-cards .role__text {
    grid-column: 3;
  }

  .role-cards .role__arrow {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
    margin-top: var(--cell);
  }

  .facts > li {
    grid-template-columns: var(--number-width) round(down, 40%, var(--cell)) minmax(0, 1fr);
  }

  .fact__claim {
    padding-right: var(--cell);
  }

  .facts > li > * {
    grid-column: auto;
  }

  .contact {
    grid-template-columns: round(down, 40%, var(--cell)) minmax(0, 1fr);
    column-gap: var(--cells-2);
  }

  .site-footer__grid {
    grid-template-columns: var(--index-width) repeat(3, round(down, (100% - var(--index-width) - 3 * var(--column-gap)) / 3, var(--cell)));
    column-gap: var(--column-gap);
  }

  .site-footer__brand {
    grid-column: auto;
  }

  .site-footer__bottom,
  .key {
    margin-left: calc(var(--index-width) + var(--column-gap));
  }

  .site-footer .key-list {
    grid-template-columns: repeat(3, round(down, (100% - 2 * var(--cells-2)) / 3, var(--cell)));
  }
}

/* Wide screens: the nav is a static row between the brand (over the
   index column) and the CTA. Author styles override the UA rule that
   hides a closed popover. Of the lower menu group only the language
   switch stays in the row (on /en it may be the only link there); the
   other links are in the footer at this width. Eight header links (Karo
   22.11.2026) fit on one row from 80rem; below that the menu button. */
@media (min-width: 80rem) {
  .site-header {
    grid-template-columns: var(--index-width) minmax(0, 1fr) auto;
    column-gap: var(--column-gap);
  }

  .nav-toggle,
  .site-nav__head,
  .nav-secondary li:not(:has(.lang-switch)) {
    display: none;
  }

  .nav-secondary {
    margin: 0 0 0 auto;
    padding: 0;
  }

  .nav-secondary a {
    line-height: var(--cell);
    font-size: var(--text-small);
  }

  .site-nav[popover],
  .site-nav:popover-open {
    position: static;
    display: flex;
    align-items: center;
    column-gap: var(--cell);
    inset: auto;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    overflow: visible;
  }

  .nav-main {
    display: flex;
    column-gap: var(--cell);
  }

  .nav-main a {
    display: inline;
    padding: 0;
    box-shadow: none;
    font-size: var(--text-small);
    font-weight: var(--weight-regular);
    line-height: var(--cell);
    text-decoration-line: none;
    white-space: nowrap;
  }

  .nav-main a:hover {
    text-decoration-line: underline;
  }

  .nav-main a[aria-current="page"] {
    font-weight: var(--weight-strong);
    text-decoration-line: underline;
    text-decoration-thickness: var(--underline-hover);
  }
}

/* Eight header links (Etusivu, EU-first and AI-arkkitehti added, Karo
   22.11.2026) fit over the content column only from 96rem. Below that the
   brand takes only its own width and the links sit closer together. */
@media (min-width: 80rem) and (max-width: 95.999rem) {
  .site-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .site-nav[popover],
  .site-nav:popover-open,
  .nav-main {
    column-gap: var(--gap-m);
  }
}

/* =====================================================================
   Forced colours (Windows high contrast): the grid, the mark cells and
   the lens are hidden, marks use the system Mark / MarkText, and the
   box-shadow rules (dropped by the browser) come back as borders.
   ===================================================================== */
@media (forced-colors: active) {
  html mark,
  html.js-cells .layout mark {
    forced-color-adjust: none;
    background-image: none;
    background-color: Mark;
    color: MarkText;
  }

  .cellmark,
  .lens {
    display: none;
  }

  body {
    background-image: none;
  }

  .site-header {
    border-bottom: 1px solid CanvasText;
  }

  .section {
    border-top: var(--rule-section) solid CanvasText;
  }

  .clauses > li {
    border-top: 1px solid CanvasText;
  }

  .clauses > li:last-child,
  .index__title,
  .site-nav__head,
  .nav-main a {
    border-bottom: 1px solid CanvasText;
  }

  .toc {
    border-block: 1px solid CanvasText;
  }

  .faq details,
  .prose td {
    border-top: 1px solid CanvasText;
  }

  .faq,
  .prose tbody tr:last-child td {
    border-bottom: 1px solid CanvasText;
  }

  .prose blockquote {
    border-inline-start: var(--rule-section) solid CanvasText;
  }

  .key,
  .site-footer__bottom {
    border-top: 1px solid CanvasText;
  }

  .post-list > li,
  .news-list__empty {
    border-top: 1px solid CanvasText;
  }

  .post-list > li:last-child,
  .news-list__empty {
    border-bottom: 1px solid CanvasText;
  }

  .news-filter select,
  .pagination__num,
  .field input,
  .field textarea {
    border: 1px solid CanvasText;
  }

  .field--error {
    border-left: var(--rule-section) solid CanvasText;
  }

  .field--error input,
  .field--error textarea,
  .form-errors,
  .form-notice {
    border: var(--rule-section) solid CanvasText;
  }

  .pagination__num[aria-current="page"] {
    border-width: var(--focus-width);
  }

  .nav-toggle::before {
    forced-color-adjust: none;
    background-color: ButtonText;
    box-shadow: 0 -5px 0 ButtonText, 0 5px 0 ButtonText;
  }
}

/* =====================================================================
   Motion (README of the mockup, "Liike"). CSS for 1-3, 4b and 5, lens.js
   for 4. Without support, and with reduced motion, the end state shows
   at once.
   ===================================================================== */

/* 1. Marks draw in. With cells.js: cell by cell (steps of whole cells),
      left to right, as the mark scrolls into view. Without JS: the CSS
      background draws in smoothly. */
@keyframes mark-draw {
  from { background-size: 0% 100%; }
  to   { background-size: 100% 100%; }
}

@keyframes cell-draw {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* The marked text keeps the page's ink until its fill is complete, so it
   stays readable before the draw-in in the dark theme too (text on a
   fact colour is always --color-on-fact, which is near-black). */
@keyframes mark-ink {
  from { color: var(--color-ink); }
  to   { color: var(--color-on-fact); }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    html:not(.js-cells) main mark,
    html.js-cells main .table-wrap mark {
      animation: mark-draw linear both, mark-ink steps(1, jump-end) both;
      animation-timeline: view(), view();
      animation-range: var(--mark-range);
    }

    html.js-cells main mark:not(.table-wrap mark) {
      animation: mark-ink steps(1, jump-end) both;
      animation-timeline: view();
      animation-range: var(--mark-range);
    }

    .cellmark {
      animation: cell-draw steps(var(--n, 1), jump-end) both;
      animation-timeline: view();
      animation-range: var(--mark-range);
    }
  }
}

/* 2. Index "you are here": discrete, while the section crosses the
      middle. Neutral: bold on a quiet grey, number in ink. */
@keyframes here {
  from, to {
    background-color: var(--color-quiet);
    --num: var(--color-ink);
    font-weight: var(--weight-strong);
  }
}

/* 3. Index trace: the segment fills while its section is read; the node
      goes from a hollow grey square to a filled ink square as the section
      starts, and stays filled once passed. */
@keyframes trace-fill {
  from { scale: 1 0; }
  to   { scale: 1 1; }
}

@keyframes node-on {
  from {
    border-color: var(--color-rail);
    background-color: var(--color-paper);
    scale: 0.6;
  }
  to {
    border-color: var(--color-ink);
    background-color: var(--color-ink);
    scale: 1;
  }
}

.tl-1 { view-timeline-name: --s1; }
.tl-2 { view-timeline-name: --s2; }
.tl-3 { view-timeline-name: --s3; }
.tl-4 { view-timeline-name: --s4; }
.tl-5 { view-timeline-name: --s5; }
.tl-6 { view-timeline-name: --s6; }
.tl-7 { view-timeline-name: --s7; }
.tl-8 { view-timeline-name: --s8; }
.tl-9 { view-timeline-name: --s9; }
.tl-10 { view-timeline-name: --s10; }

@supports (animation-timeline: view()) and (timeline-scope: --a) {
  .index a {
    animation-name: here;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: none;
    animation-range: var(--here-range);
  }

  .index li::before {
    animation-name: trace-fill;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-range: var(--here-range);
  }

  .index li::after {
    animation-name: node-on;
    animation-duration: auto;
    animation-timing-function: var(--ease-out);
    animation-fill-mode: both;
    animation-range: var(--node-range);
  }

  .ix-1 > a, .ix-1::before, .ix-1::after { animation-timeline: --s1; }
  .ix-2 > a, .ix-2::before, .ix-2::after { animation-timeline: --s2; }
  .ix-3 > a, .ix-3::before, .ix-3::after { animation-timeline: --s3; }
  .ix-4 > a, .ix-4::before, .ix-4::after { animation-timeline: --s4; }
  .ix-5 > a, .ix-5::before, .ix-5::after { animation-timeline: --s5; }
  .ix-6 > a, .ix-6::before, .ix-6::after { animation-timeline: --s6; }
  .ix-7 > a, .ix-7::before, .ix-7::after { animation-timeline: --s7; }
  .ix-8 > a, .ix-8::before, .ix-8::after { animation-timeline: --s8; }
  .ix-9 > a, .ix-9::before, .ix-9::after { animation-timeline: --s9; }
  .ix-10 > a, .ix-10::before, .ix-10::after { animation-timeline: --s10; }
}

/* The trace follows the reader's scrolling like a scrollbar, so it stays
   with reduced motion; only the node's scale pop is dropped. */
@media (prefers-reduced-motion: reduce) {
  @keyframes node-on {
    from {
      border-color: var(--color-rail);
      background-color: var(--color-paper);
    }
    to {
      border-color: var(--color-ink);
      background-color: var(--color-ink);
    }
  }
}

/* 4b. Reading line on touch screens (no lens there). The section's top
       grid row gets ticks in its fact colour, one cell at a time, while
       the section crosses the middle of the screen. Sections without
       facts use the grey of the unlit trace. Full and static with
       reduced motion or without support. */
@media (pointer: coarse) {
  .section {
    position: relative;
    --n: 14;
  }

  .section::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: calc(var(--n) * var(--cell));
    max-width: 100%;
    height: 6px;
    background-image: linear-gradient(to right, var(--fact, var(--color-rail)) calc(100% - 2px), transparent calc(100% - 2px));
    background-size: var(--cell) 100%;
    background-repeat: repeat-x;
  }

  @supports (animation-timeline: view()) and (timeline-scope: --a) {
    @media (prefers-reduced-motion: no-preference) {
      /* The section's own timeline: view() here would track the strip. */
      .section::after {
        animation-name: read-line;
        animation-duration: auto;
        animation-timing-function: steps(var(--n), jump-end);
        animation-fill-mode: both;
        animation-range: var(--here-range);
      }

      .tl-1::after { animation-timeline: --s1; }
      .tl-2::after { animation-timeline: --s2; }
      .tl-3::after { animation-timeline: --s3; }
      .tl-4::after { animation-timeline: --s4; }
      .tl-5::after { animation-timeline: --s5; }
      .tl-6::after { animation-timeline: --s6; }
      .tl-7::after { animation-timeline: --s7; }
      .tl-8::after { animation-timeline: --s8; }
      .tl-9::after { animation-timeline: --s9; }
      .tl-10::after { animation-timeline: --s10; }
    }
  }
}

@media (pointer: coarse) and (min-width: 40rem) {
  .section { --n: 20; }
}

@keyframes read-line {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* 5. Page transition: the role title on the front page (h3.vt-<key>)
      becomes the h1 of the service page (h1.vt-<key>). Names come from
      classes only, one per page. */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

.vt-ai-native { view-transition-name: vt-ai-native; }
.vt-ai-visibility { view-transition-name: vt-ai-visibility; }
.vt-ai-mindset { view-transition-name: vt-ai-mindset; }
.vt-products { view-transition-name: vt-products; }

.vt-ai-native,
.vt-ai-visibility,
.vt-ai-mindset,
.vt-products {
  width: fit-content;
}

::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
  animation-duration: var(--duration-page);
  animation-timing-function: var(--ease-page);
}

::view-transition-old(vt-ai-native),
::view-transition-old(vt-ai-visibility),
::view-transition-old(vt-ai-mindset),
::view-transition-old(vt-products) {
  animation-duration: calc(var(--duration-page) / 2);
}

/* htmx 4 request indicators. htmx's own injected style element is
   disabled (includeIndicatorCSS:false) because the CSP forbids inline
   styles. */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Visually hidden, still read by assistive technology (e.g. a fact mark's
   type where no visible type tag is next to it). */
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Landing page (Prosessistudio, PLAN v42) -------------------
   partials/landing.html and the content walker with view.Page.FormAfter.
   The hero is one column on narrow screens (text, buttons, then the
   visual, so the h1 and the primary button come first on a phone) and
   text beside the visual from 64rem. Lists whose items open with bold
   text become cards ("Näin se toimii" numbered, "Mitä saatte", "Kenelle",
   "Pilotti"); plain lists stay lists. The visual's one-off animation runs
   only without prefers-reduced-motion. Vertical values are whole cells. */
.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--cells-2);
  align-items: center;
}

.landing-hero__signin {
  margin-top: var(--cell);
}

.landing-hero__signin .arrow-link {
  line-height: var(--cells-2);
}

/* The example workshop (Karo 22.11.2026): the diagram in a frame that
   scrolls sideways on narrow screens (its text keeps a readable size),
   the transcript under it. The animation: each utterance types in
   (t1-t3), then the part of the diagram it produces fades in (d1-d3). */
.landing-visual {
  max-width: calc(30 * var(--cell));
  margin: var(--cells-2) 0 0;
}

.landing-visual__caption {
  margin-bottom: var(--gap-s);
  color: var(--color-ink-soft);
}

.ps-diagram {
  overflow-x: auto;
  box-shadow: inset 0 0 0 1px var(--color-ui-line);
  background-color: var(--color-paper);
}

.ps-visual {
  display: block;
  width: 100%;
  min-width: calc(22 * var(--cell));
  height: auto;
}

.ps-visual text {
  fill: var(--color-ink);
  font-family: var(--font-text);
}

.ps-visual .v-lane__shape {
  fill: none;
  stroke: none;
}

.ps-visual .v-lane__divider {
  fill: none;
  stroke: var(--color-ui-line);
  stroke-width: 1;
}

.ps-visual .v-lane__divider--sys {
  stroke-dasharray: 6 4;
}

.ps-visual .v-lane__label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-anchor: middle;
}

.ps-visual .v-lane__label--sys {
  font-size: 10px;
}

.ps-visual .v-flow,
.ps-visual .v-gateway__mark {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ps-visual .v-assoc {
  fill: none;
  stroke: var(--color-ui-line);
  stroke-width: 1.5;
  stroke-dasharray: 2 4;
}

.ps-visual .v-start,
.ps-visual .v-end {
  fill: var(--color-paper);
  stroke: var(--color-ink);
  stroke-width: 2;
}

.ps-visual .v-end {
  stroke-width: 4;
}

/* Steps the AI drew from the talk: the "ai" fact colour. */
.ps-visual .v-task {
  fill: var(--fact-ai);
  stroke: var(--color-ink);
  stroke-width: 2;
}

.ps-visual .v-task__text {
  fill: var(--color-on-fact);
  font-size: 15px;
  font-weight: var(--weight-strong);
  text-anchor: middle;
}

.ps-visual .v-gateway {
  fill: var(--color-paper);
  stroke: var(--color-ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.ps-visual .v-gateway__text {
  font-size: 14px;
  text-anchor: end;
}

.ps-visual .v-branch {
  font-family: var(--font-mono);
  font-size: 12px;
}

.ps-visual .v-system {
  fill: var(--color-quiet);
  stroke: var(--color-ui-line);
  stroke-width: 1.5;
}

.ps-visual .v-system__text {
  font-size: 14px;
  text-anchor: middle;
}

.ps-transcript {
  display: grid;
  gap: var(--gap-s);
  margin-top: var(--cell);
  padding: 0;
  list-style-type: "\200B";
}

.ps-transcript li {
  display: grid;
  grid-template-columns: calc(4 * var(--cell)) minmax(0, 1fr);
  column-gap: var(--gap-m);
  max-width: var(--measure);
}

.ps-transcript__role {
  color: var(--color-ink-soft);
}

@media (prefers-reduced-motion: no-preference) {
  .ps-transcript .v-t1,
  .ps-transcript .v-t2,
  .ps-transcript .v-t3 {
    animation: ps-type 1200ms steps(24, end) both;
  }

  .ps-transcript .v-t1 { animation-delay: 300ms; }
  .ps-transcript .v-t2 { animation-delay: 2600ms; }
  .ps-transcript .v-t3 { animation-delay: 4900ms; animation-duration: 1600ms; }

  .ps-visual .v-d1,
  .ps-visual .v-d2,
  .ps-visual .v-d3 {
    animation: ps-fade 700ms var(--ease-out) both;
  }

  .ps-visual .v-d1 { animation-delay: 1500ms; }
  .ps-visual .v-d2 { animation-delay: 3800ms; }
  .ps-visual .v-d3 { animation-delay: 6500ms; }
}

@keyframes ps-type {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes ps-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Card lists. A zero-width list-style string, not "none", so Safari
   keeps announcing them as lists. */
.landing .prose > :is(ul, ol):has(> li > strong:first-child) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(13 * var(--cell))), 1fr));
  gap: var(--cell);
  max-width: var(--measure);
  padding: 0;
  list-style-type: "\200B";
  counter-reset: step;
}

.landing .prose > :is(ul, ol):has(> li > strong:first-child) > li {
  padding: var(--cell);
  box-shadow: inset 0 0 0 1px var(--color-ui-line);
  background-color: var(--color-paper);
}

.landing .prose > :is(ul, ol):has(> li > strong:first-child) > li > strong:first-child {
  display: block;
  margin-bottom: var(--gap-s);
}

/* "Näin se toimii": the step number above the title. */
.landing .prose > ol:has(> li > strong:first-child) > li {
  counter-increment: step;
}

.landing .prose > ol:has(> li > strong:first-child) > li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: var(--gap-s);
  color: var(--color-ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  letter-spacing: var(--tracking-mono);
}

/* The pilot form under the "Pilotti" section's text. */
.landing-form {
  max-width: var(--measure);
  margin-top: var(--cells-2);
}

/* Narrow screens: the buttons right under the h1, before the eyebrow and
   the lead, so the primary button is visible without scrolling on a
   320x568 phone. */
@media (max-width: 39.999rem) {
  .landing-hero__text {
    display: flex;
    flex-direction: column;
  }

  .landing-hero__text > * {
    order: 2;
  }

  .landing-hero__text > h1 {
    order: 0;
  }

  .landing-hero__text > .eyebrow {
    margin: var(--cell) 0 0;
  }

  .landing-hero__actions {
    order: 1;
    margin-top: var(--cell);
  }
}

@media (forced-colors: active) {
  .landing .prose > :is(ul, ol):has(> li > strong:first-child) > li {
    border: 1px solid CanvasText;
  }

  .ps-visual .v-task,
  .ps-visual .v-gateway,
  .ps-visual .v-system,
  .ps-visual .v-start,
  .ps-visual .v-end {
    fill: Canvas;
    stroke: CanvasText;
  }

  .ps-visual .v-task {
    stroke: Highlight;
    stroke-width: 3;
  }

  .ps-visual text,
  .ps-visual .v-task__text {
    fill: CanvasText;
  }

  .ps-visual .v-flow,
  .ps-visual .v-gateway__mark,
  .ps-visual .v-assoc,
  .ps-visual .v-lane__divider {
    stroke: CanvasText;
  }

  .ps-diagram {
    border: 1px solid CanvasText;
  }
}

/* ---------- Print ------------------------------------------------------
   Black on white without the graph paper (the sketch share page's
   "Tulosta", phase 4b, and any page printed from the browser). The
   header, the navigation, the index, the footer, every button and the
   card actions are left out; the content takes the whole width. The
   token block repeats the dark theme's two selectors at the same
   specificity, later in the file, so it wins in every theme. */
@media print {
  :root:not([data-theme="light"]),
  :root[data-theme] {
    color-scheme: light;
    --color-paper:        #FFFFFF;
    --color-ink:          #000000;
    --color-ink-soft:     #000000;
    --color-ui-line:      #000000;
    --color-hairline:     #000000;
    --color-quiet:        #FFFFFF;
    --color-on-fact:      #000000;
    --fact-sijainti:      #FFFFFF;
    --fact-ai:            #FFFFFF;
    --fact-yksityisyys:   #FFFFFF;
    --fact-lahde:         #FFFFFF;
    --fact-rajapinta:     #FFFFFF;
    --color-grid:         #FFFFFF;
    --color-grid-on-fill: transparent;
  }

  body {
    display: block;
    min-height: 0;
    background: #FFFFFF none;
    color: #000000;
  }

  .skip-link,
  .site-header,
  .site-nav,
  .site-footer,
  .index,
  .toc,
  .breadcrumbs,
  .lens,
  button,
  .btn,
  .chat-input,
  .chat-starters,
  .chat-status,
  .chat-stream,
  .sketch-actions,
  .sketch-comment,
  .sketch-comment-note,
  .sketch-page__print,
  .sketch-page__links {
    display: none !important;
  }

  /* The whole conversation on paper, not the window's scrolled part. */
  .chat-window,
  .chat-scroll {
    height: auto !important;
    max-height: none;
    padding: 0;
    overflow: visible;
    box-shadow: none;
  }

  .layout {
    display: block;
    width: auto;
    margin: 0;
  }

  main {
    margin: 0;
  }

  .hero {
    padding-block: 0 var(--cells-2);
  }

  /* The "Tekoäly" tag keeps its frame without the fact colour. */
  .chat-ai-label {
    border: 1px solid #000000;
  }

  .sketch-field,
  .sketch-steps > li,
  .suggest__item,
  .assess__field {
    break-inside: avoid;
  }

  a {
    color: #000000;
  }
}
