/* Potyro's site chrome (DESIGN.md §9, §4.1, §6): what every page of potyro.com shares — the base
   rules, the logo, the buttons, the header and the footer. tokens.css (packages/design) is linked
   before this file and supplies every colour, font, size and radius. The gallery page's own rules
   are gallery.css, the documentation's docs.css; each site build joins this file in front of them
   (gallery/src/build.mjs, site/build.mjs), so a page is served one stylesheet. */

:root {
  --gutter: 16px;
  --wide: 1120px;
}
@media (min-width: 768px) {
  :root {
    --gutter: 24px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  overflow-x: hidden;
}
a {
  color: inherit;
}
:focus-visible {
  outline: var(--stroke) solid var(--focus);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--ink-soft);
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus {
  top: 0.75rem;
}
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h2 {
  font-size: var(--text-h1);
  line-height: 1.15;
}
p {
  margin: 0;
}
svg {
  display: block;
}

/* ---- The logo (§4.1): the original files, light or dark by theme; the letters of the inline
   copies follow the ink, the "y"'s stroke is rosa — or, in the closing, the hour that passes. ---- */
.wordmark img {
  display: block;
  height: 1.75rem;
  width: auto;
  min-width: 80px;
}
/* Both selectors name the wrapper and the image, so they outrank the sizing rule above. */
.wordmark .wordmark-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wordmark .wordmark-light {
    display: none;
  }
  :root:not([data-theme="light"]) .wordmark .wordmark-dark {
    display: block;
  }
}
:root[data-theme="dark"] .wordmark .wordmark-light {
  display: none;
}
:root[data-theme="dark"] .wordmark .wordmark-dark {
  display: block;
}
.mark .ink {
  fill: var(--ink-soft);
}
.mark .ink-strong {
  fill: var(--ink);
}
.mark .stroke {
  fill: var(--traco);
}

/* ---- Buttons (§6): pills, the rosa one once at the top and once at the end ---- */
.btn,
.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 1.1rem;
  border: var(--stroke) solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.btn:hover {
  background: var(--bg);
}
.btn:active,
.btn-cta:active {
  transform: scale(0.97);
}
.btn-mine {
  border-color: transparent;
  color: var(--ink-soft);
}
.btn-cta {
  min-height: 48px;
  padding: 0 var(--space-5);
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-body);
}
.btn-cta:hover {
  background: color-mix(in oklab, var(--accent) 86%, var(--ink));
}
.btn .k-icon,
.btn-cta .k-icon {
  flex: none;
}

/* ---- Header ---- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--gutter);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: var(--stroke) solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  text-decoration: none;
}
.top-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.lang select,
.theme {
  min-height: 44px;
  border: var(--stroke) solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-small);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.lang select {
  max-width: 11rem;
  padding: 0 0.9rem;
}
.theme {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
}
.lang select:hover,
.theme:hover {
  background: var(--surface);
}
.theme:active {
  transform: scale(0.97);
}
.top .btn-cta {
  display: none;
}
@media (min-width: 768px) {
  .top .btn-cta {
    display: inline-flex;
  }
}

/* ---- Footer ---- */
.foot {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6) var(--gutter) max(var(--space-6), env(safe-area-inset-bottom));
  background: var(--surface);
}
.foot > * {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
}
.privacy {
  max-width: 40rem;
  text-wrap: pretty;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}
.foot-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: var(--tinta);
}
.foot-links a:hover {
  color: var(--tinta);
}
.made {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: var(--text-micro);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.symbol img {
  height: 16px;
  min-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* An app's picture (build.mjs `shotPicture`): the <picture> is only a choice of files — the <img>
   inside is laid out as if it stood alone, wherever a page puts it. */
picture[data-shot-locales] {
  display: contents;
}

/* The site's text pages (the docs, the Learn-more pages, /developers): a reading column, the
   contents beside it where there is room, code in the tokens' colours, diagrams drawn at build.
   tokens.css, hours.css and chrome.css (the shared base, logo, header and footer) come before this. */

:root {
  --measure: 72ch;
  --side: 260px;
  --code-keyword: #884dd5; --code-string: #1f7e3f; --code-constant: #a05e1c; --code-function: #1e74a6; --code-type: #1f7885;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --code-keyword: #b995f7; --code-string: #37ca68; --code-constant: #f1902f; --code-function: #4db5f7; --code-type: #37bed3; }
}
:root[data-theme="dark"] { --code-keyword: #b995f7; --code-string: #37ca68; --code-constant: #f1902f; --code-function: #4db5f7; --code-type: #37bed3; }

.brand .wordmark { display: block; height: 28px; width: auto; }
.mark .ink { fill: var(--ink-soft); } .mark .ink-strong { fill: var(--ink); } .mark .stroke { fill: #e44f89; }
.made .symbol { height: 16px; width: auto; }
.site-nav { display: none; gap: var(--space-5); margin-left: var(--space-6); margin-right: auto; }
/* The header holds the logo, the pages, the language, the theme and the way in. They come in as
   there is room for them in the longest language: the pages from 900px, the way in from 1180px. */
@media (min-width: 900px) { .site-nav { display: flex; } }
.site-nav ~ .top-tools .btn-cta { display: none; }
@media (min-width: 1180px) { .site-nav ~ .top-tools .btn-cta { display: inline-flex; } }
.site-nav a { white-space: nowrap; }
.site-nav a { color: var(--ink-soft); font-weight: 600; text-decoration: none; padding: 6px 0; border-bottom: var(--stroke) solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: #e44f89; }

main { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); padding: var(--space-6) 0 var(--space-9); }
@media (min-width: 1024px) { .layout:not(.one) { grid-template-columns: var(--side) minmax(0, 1fr); gap: var(--space-8); } }
.layout.one article { width: 100%; max-width: 760px; margin: 0 auto; }
article { min-width: 0; }
article > *:not(.head):not(figure):not(.table-scroll):not(pre):not(.more):not(.toc):not(.pager) { max-width: var(--measure); }

/* ---- Side: the contents and every page — beside the text where there is room, after it on a phone ---- */
.side { order: 2; padding-top: var(--space-6); border-top: var(--stroke) solid var(--line); }
@media (min-width: 1024px) {
  .side { order: 0; position: sticky; top: calc(var(--space-6) + 56px); align-self: start; max-height: calc(100vh - 56px - var(--space-8)); overflow: auto; padding-top: 0; border-top: 0; }
}
.eyebrow { margin: 0 0 var(--space-2); font-size: var(--text-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.toc ol, .pages ol { list-style: none; margin: 0; padding: 0; }
.toc { font-size: var(--text-small); line-height: 1.45; margin-bottom: var(--space-5); }
.toc a { display: block; padding: 5px 0 5px var(--space-3); border-left: var(--stroke) solid var(--line); color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--tinta); border-left-color: var(--tinta); }
.toc li.h3 a { padding-left: var(--space-5); color: var(--muted); }
.pages { font-size: var(--text-small); }
.pages .groups > li { margin-bottom: var(--space-4); }
.pages a { display: block; padding: 4px 0; color: var(--ink-soft); text-decoration: none; }
.pages a:hover { color: var(--tinta); }
.pages a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---- Type ---- */
h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: var(--text-display); line-height: 1.1; margin: 0 0 var(--space-3); }
@media (max-width: 767px) { h1 { font-size: var(--text-h1); line-height: 1.15; } }
.lede { font-size: var(--text-h3); line-height: 1.4; color: var(--muted); margin: 0 0 var(--space-7); max-width: 44ch; text-wrap: pretty; }
h2 { font-size: var(--text-h2); line-height: 1.25; margin: var(--space-8) 0 var(--space-4); padding-top: var(--space-5); border-top: var(--stroke) solid var(--line); }
h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-h3); line-height: 1.3; margin: var(--space-7) 0 var(--space-3); text-wrap: balance; }
h2 a.anchor, h3 a.anchor { color: inherit; text-decoration: none; }
h2 a.anchor:hover::after, h3 a.anchor:hover::after { content: " #"; color: var(--tinta); }
p, ul, ol { margin: 0 0 var(--space-4); }
li { margin-bottom: var(--space-2); }
ul { padding-left: 1.25em; } ol { padding-left: 1.4em; }
a { color: var(--tinta); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: var(--stroke); }
strong { font-weight: 600; }
blockquote { margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); border-left: var(--stroke) solid var(--traco); background: var(--aguada); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
blockquote p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: var(--stroke) solid var(--line); margin: var(--space-7) 0; }
.banner { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface); color: var(--ink-soft); font-size: var(--text-small); }
.note { color: var(--muted); font-size: var(--text-small); }
.doc-list { list-style: none; padding: 0; }
.doc-list li { display: grid; gap: 2px; margin-bottom: var(--space-3); }
.doc-list a { font-weight: 600; text-decoration: none; }
.doc-list a:hover { text-decoration: underline; }
.doc-list span { color: var(--muted); font-size: var(--text-small); }

/* ---- Code ---- */
code, pre, kbd { font-family: var(--font-mono); font-variant-ligatures: none; }
:not(pre) > code { font-size: 0.875em; padding: 0.1em 0.4em; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); overflow-wrap: anywhere; }
a > code { color: inherit; }
pre.code { margin: 0 0 var(--space-5); padding: var(--space-4) var(--space-5); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font-size: var(--text-small); line-height: 1.6; overflow-x: auto; tab-size: 2; }
pre code { font-size: inherit; background: none; padding: 0; white-space: pre; }
.shiki .line { display: inline; }
.tk-keyword { color: var(--code-keyword); } .tk-string, .tk-string-expression { color: var(--code-string); } .tk-constant { color: var(--code-constant); }
.tk-function { color: var(--code-function); } .tk-link { color: var(--code-type); } .tk-comment { color: var(--muted); font-style: italic; } .tk-punctuation { color: var(--ink-soft); }

/* ---- Tables and diagrams ---- */
.table-scroll { overflow-x: auto; margin: 0 0 var(--space-5); border-radius: var(--radius-md); }
table { border-collapse: collapse; width: 100%; font-size: var(--text-small); line-height: 1.45; }
th, td { text-align: left; vertical-align: top; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--ink-soft); background: var(--surface); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { white-space: normal; }
figure.diagram { margin: 0 0 var(--space-5); padding: var(--space-4); background: var(--surface); border-radius: var(--radius-md); overflow-x: auto; }
figure.diagram svg { display: block; height: auto; max-width: 100%; margin: 0 auto; }
@media (max-width: 767px) { figure.diagram svg { max-width: none; } }

/* ---- Previous and next, the source ---- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin: var(--space-8) 0 var(--space-4); padding-top: var(--space-5); border-top: var(--stroke) solid var(--line); }
.pager a { display: grid; gap: 2px; text-decoration: none; color: var(--ink); font-weight: 600; }
.pager a span { font-size: var(--text-micro); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.pager .next { text-align: right; }
.source { font-size: var(--text-small); color: var(--muted); }

/* ---- The Learn-more pages: the idea's hour on the head, as on the home ---- */
article.how .head { margin: 0 calc(-1 * var(--gutter)) var(--space-7); padding: var(--space-7) var(--gutter) var(--space-7); background: var(--traco); color: #231f20; border-radius: 0 0 28px 28px; }
@media (min-width: 768px) { article.how .head { margin: var(--space-4) 0 var(--space-7); padding: var(--space-8) var(--space-7); border-radius: 28px; } }
article.how .head .eyebrow, article.how .head .lede { color: #231f20; }
article.how .head h1 { color: #231f20; }
article.how .head .lede { margin-bottom: 0; opacity: 0.85; }
.more { margin-top: var(--space-8); padding-top: var(--space-5); border-top: var(--stroke) solid var(--line); }
.more ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.more a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: var(--radius-pill); background: var(--traco); color: #231f20; font-weight: 600; text-decoration: none; }
.more a:hover { filter: brightness(0.96); }
