/* kirjanpito.io: a documentation site in Fleksi's palette and system fonts (site.css's colours), with a look of its
   own: a quiet header with the K mark, a sidebar of sections on a wide screen and a collapsible table of contents on
   a phone, a reading column of about 70 characters, and tables that become labelled rows at phone width. Light, and
   dark when the visitor's system is dark. Mobile first at 390 px. */

:root {
  --paper: #fff; --sand: oklch(97.5% 0 0); --ink: oklch(21% .006 285.885); --strong: oklch(14.5% 0 0);
  --muted: oklch(46% 0 0); --accent: #2563eb; --link: #1d4ed8; --tint: color-mix(in srgb, #2563eb 7%, #fff);
  --hair: oklch(91% 0 0); --focus: #1d4ed8; --mark-bg: #18181b; --mark-k: #fff;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0a0a0a; --sand: #141414; --ink: oklch(95% 0 0); --strong: oklch(98.5% 0 0); --muted: oklch(72% 0 0);
    --accent: #4f8dff; --link: #8db4ff; --tint: #4f8dff1a; --hair: #2a2a2a; --focus: #8db4ff;
    --mark-bg: #f4f4f5; --mark-k: #0a0a0a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body.kp { overflow-wrap: break-word; margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/28px var(--sans); }
h1, h2, h3 { color: var(--strong); font-weight: 700; letter-spacing: -.015em; margin: 0 0 12px; }
h1 { font-size: 30px; line-height: 36px; }
h2 { font-size: 22px; line-height: 30px; margin-top: 36px; }
h3 { font-size: 18px; line-height: 26px; margin-top: 24px; }
p, ul, ol, table { margin: 0 0 16px; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
main:focus { outline: none; }
strong { font-weight: 600; }
.kp-skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 16px; z-index: 10; }
.kp-skip:focus { top: 12px; }
.kp-wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }

/* Header */
.kp-header { border-bottom: 1px solid var(--hair); }
.kp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-height: 60px; padding-top: 8px; padding-bottom: 8px; }
.kp-logo { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font: 700 21px/1 var(--sans);
  letter-spacing: -.02em; color: var(--strong); text-decoration: none; }
.kp-mark { width: 30px; height: 30px; flex: none; }
.kp-mark-bg { fill: var(--mark-bg); }
.kp-mark-k { fill: var(--mark-k); }
.kp-mark-rule { fill: var(--accent); }
.kp-tagline { color: var(--muted); font-size: 15px; line-height: 20px; }

/* Table of contents: collapsible on a phone, a sidebar from 960 px */
.kp-toc-phone { margin-top: 12px; }
.kp-toc-phone > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center;
  padding: 0 12px; border: 1px solid var(--hair); border-radius: 10px; background: var(--sand); }
.kp-toc-phone[open] > summary { border-radius: 10px 10px 0 0; }
.kp-toc-phone nav { border: 1px solid var(--hair); border-top: 0; border-radius: 0 0 10px 10px; padding: 8px 12px; }
.kp-toc-list, .kp-toc-list ul { list-style: none; margin: 0; padding: 0; }
.kp-toc-list > li { margin: 6px 0 10px; }
.kp-toc-part { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 0; }
.kp-toc-part:first-child { margin-top: 4px; }
.kp-toc-list summary { cursor: pointer; padding: 5px 0; font-size: 15px; line-height: 21px; }
.kp-toc-list ul { margin-top: 2px; padding-left: 12px; border-left: 1px solid var(--hair); }
.kp-toc-list a { display: block; padding: 5px 0; font-size: 15px; line-height: 21px; text-decoration: none; color: var(--ink); }
.kp-toc-list summary > a { display: inline; padding: 0; font-weight: 600; color: var(--strong); }
.kp-toc-list a:hover { text-decoration: underline; }
.kp-toc-list a[aria-current="page"] { color: var(--link); font-weight: 600; }
.kp-side { display: none; }
.kp-side-head { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }

/* The page */
.kp-layout { padding-top: 16px; padding-bottom: 32px; }
.kp-layout > main { min-width: 0; }
.kp-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 0 6px; margin: 0 0 12px; padding: 0; font-size: 15px; color: var(--muted); }
.kp-crumbs li + li::before { content: "›"; margin-right: 6px; }
.kp-crumbs a { color: var(--muted); }
.kp-article { max-width: 720px; }
.kp-meta { color: var(--muted); font-size: 15px; line-height: 22px; }
.kp-prose ul, .kp-prose ol { padding-left: 22px; }
.kp-prose li { margin-bottom: 6px; }
.kp-prose blockquote { margin: 0 0 16px; padding: 10px 16px; background: var(--sand); border-left: 3px solid var(--hair); }
.kp-prose hr { border: 0; border-top: 1px solid var(--hair); margin: 28px 0; }
.kp-prose code { font-size: .9em; background: var(--sand); padding: 1px 4px; border-radius: 4px; }
.box { border-radius: 10px; padding: 16px 18px; margin: 20px 0; }
.box > :last-child { margin-bottom: 0; }
.box-note { background: var(--tint); border-left: 4px solid var(--accent); }
.box-cta { background: var(--sand); border-left: 4px solid var(--hair); }
.box-title { font-weight: 700; font-size: 17px; margin-bottom: 6px; color: var(--strong); }

/* Tables: a scrolling table on a wide screen; at phone width each row becomes a block of labelled lines */
.table-wrap { margin-bottom: 16px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 16px; line-height: 24px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--hair); }
thead th { font-weight: 600; border-bottom: 2px solid var(--ink); }
@media (max-width: 639px) {
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap table, .table-wrap tbody { display: block; width: 100%; }
  .table-wrap tr { display: block; border: 1px solid var(--hair); border-radius: 10px; padding: 6px 12px; margin-bottom: 10px; }
  .table-wrap td { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 10px; padding: 6px 0; border: 0;
    overflow-wrap: anywhere; }
  .table-wrap td + td { border-top: 1px solid var(--hair); }
  .table-wrap td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 14px; line-height: 21px;
    hyphens: auto; }
  .table-wrap td:empty { display: none; }
  .kp-crumbs li[aria-current] { display: none; }
}
@media (min-width: 640px) { .table-wrap { overflow-x: auto; } }

/* After the content: Fleksi's quiet line, the sources, related pages, previous and next */
.kp-fleksi { margin: 28px 0 0; padding: 12px 16px; border: 1px solid var(--hair); border-radius: 10px; color: var(--muted);
  font-size: 15px; line-height: 22px; }
.kp-fleksi p { margin: 0; }
/* "Kysy kirjanpito.io:lta" (D146): the header's link, the box and its answer */
.kp-ask-link { margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.kp-ask .field { display: grid; gap: 4px; margin-bottom: 12px; }
.kp-ask label { font-weight: 600; }
.kp-ask textarea { width: 100%; min-height: 96px; padding: 8px 12px; font: 400 17px/1.4 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--muted); border-radius: 10px; resize: vertical; }
.kp-ask textarea[aria-invalid="true"] { border: 2px solid #b91c1c; }
.kp-ask .btn { min-height: 48px; padding: 0 24px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font: 600 17px/1 var(--sans); cursor: pointer; }
.ask-privacy, .ask-note, .ask-page, .kp-ask .field-error { color: var(--muted); font-size: 15px; line-height: 22px; }
.kp-ask .ask-answer { margin: 16px 0 24px; padding: 12px 16px; background: var(--tint); border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; }
.kp-ask .err-icon { display: none; }
.kp-fleksi strong { color: var(--ink); }
.kp-sources { margin-top: 32px; padding-top: 4px; border-top: 1px solid var(--hair); font-size: 15px; line-height: 22px; }
.kp-sources h2, .kp-related h2 { font-size: 18px; line-height: 26px; margin-top: 16px; }
.kp-sources ol { padding-left: 22px; }
.kp-sources li { margin-bottom: 8px; overflow-wrap: anywhere; }
.kp-related ul { padding-left: 20px; }
.kp-related li { margin-bottom: 8px; }
.kp-pager { display: grid; gap: 10px; margin-top: 28px; }
.kp-pager a { display: block; padding: 12px 16px; border: 1px solid var(--hair); border-radius: 10px; text-decoration: none; line-height: 22px; }
.kp-pager a:hover { border-color: var(--accent); }
.kp-pager span { display: block; font-size: 13px; color: var(--muted); }
.kp-next { text-align: right; }
.kp-top { font-size: 15px; }

/* Section and front pages */
.kp-pages { list-style: none; padding: 0; }
.kp-pages li { padding: 12px 0; border-bottom: 1px solid var(--hair); }
.kp-pages a { font-weight: 600; font-size: 18px; line-height: 26px; }
.kp-pages p { margin: 4px 0 0; color: var(--muted); font-size: 15px; line-height: 22px; }
.kp-lead { font-size: 18px; line-height: 29px; }
.kp-front-section { padding: 4px 0 8px; border-top: 1px solid var(--hair); }
.kp-front-rest { margin-top: 8px; border-top: 1px solid var(--hair); }
.kp-part { margin-top: 24px; }
.kp-part-intro { color: var(--muted); }
.kp-steps { padding-left: 24px; }
.kp-steps > li::marker { font-weight: 600; color: var(--muted); }
.kp-front-section h3 { margin-top: 16px; }
.kp-front-section h3 a { color: var(--strong); text-decoration: none; }
.kp-front-section h3 a:hover { text-decoration: underline; }
.kp-front-section ul { padding-left: 20px; }
.kp-front-section li { margin-bottom: 6px; }

.kp-footer { background: var(--sand); border-top: 1px solid var(--hair); padding: 28px 0 36px; color: var(--muted); font-size: 15px; line-height: 23px; }
.kp-footer p { max-width: 720px; }
.kp-footer strong { color: var(--ink); }

@media (min-width: 640px) {
  :root { --gutter: 24px; }
  h1 { font-size: 34px; line-height: 40px; }
  .kp-pager { grid-template-columns: 1fr 1fr; }
  .kp-pager .kp-next:only-child { grid-column: 2; }
}
@media (min-width: 960px) {
  .kp-toc-phone { display: none; }
  .kp-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; padding-top: 28px; }
  .kp-side { display: block; position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow-y: auto;
    padding-right: 8px; }
}
@media print {
  .kp-header, .kp-footer, .kp-toc-phone, .kp-side, .kp-pager, .kp-top, .kp-skip { display: none !important; }
  body.kp { font-size: 12pt; line-height: 1.45; }
  .kp-sources a::after { content: " (" attr(href) ")"; }
}

/* Search (D146): the header's box (its own row at phone width) and the search page's results */
.kp-search { display: flex; flex: 1 1 100%; margin: 4px 0 0; }
.kp-search input, .kp-search-page input { flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 6px 12px; font: 400 16px/1.2 var(--sans);
  color: var(--ink); background: var(--paper); border: 1px solid var(--muted); border-radius: 10px 0 0 10px; }
.kp-search button, .kp-search-page .search-button { display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 44px; padding: 0 14px; border: 1px solid var(--muted); border-left: 0; border-radius: 0 10px 10px 0;
  background: var(--sand); color: var(--strong); font: 600 16px/1.2 var(--sans); cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kp-search-page label { display: block; font-weight: 600; margin-bottom: 4px; }
.search-row { display: flex; }
.search-status { color: var(--muted); font-size: 15px; margin-top: 12px; }
.search-results { list-style: none; padding: 0; }
.search-results li { padding: 12px 0; border-bottom: 1px solid var(--hair); }
.search-results a { display: block; text-decoration: none; }
.search-title { display: block; font-weight: 600; font-size: 18px; line-height: 26px; text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 3px; }
.search-heading { display: block; color: var(--ink); font-size: 15px; line-height: 22px; }
.search-results p { margin: 4px 0 0; color: var(--muted); font-size: 15px; line-height: 22px; }
@media (min-width: 640px) { .kp-search { flex: 0 1 300px; margin: 0 0 0 auto; } }
