/* Talik UI components. MIT © 2026 Talat Gurbanbayov. Token custom properties only. */
@layer reset, tokens, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--topbar-height); }
  @media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
  body { margin: 0; }
  img, svg { max-inline-size: 100%; }
}

@layer components {
  /* Talik UI components. Token custom properties only; no literal colours. Logical properties throughout. */
  
  /* ---------- base ---------- */
  .tk, .tk *, .tk *::before, .tk *::after { box-sizing: border-box; }
  .tk { font-family: var(--font-sans); font-size: 18px; line-height: 1.6; color: var(--ink); background: var(--paper); }
  .tk :where(h1, h2, h3, p, ul, ol, figure, pre) { margin: 0; }
  .tk :where(h1, h2, h3) { text-wrap: balance; }
  .tk :where(p, li, figcaption) { text-wrap: pretty; }
  :where(.tk) a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color 200ms ease, color 200ms ease; }
  :where(.tk) a:hover { text-decoration-thickness: 2px; }
  :where(.tk) :focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: 0 0 0 3px var(--signal); } /* taste-skill-ignore: focus ring, legend ring or the one hard offset, not a soft shadow at rest */
  :where(.tk) a:focus-visible { outline: none; background: var(--signal); color: var(--on-signal); box-shadow: 0 3px 0 0 var(--focus); text-decoration: none; } /* taste-skill-ignore: focus ring, legend ring or the one hard offset, not a soft shadow at rest */
  .tk ::selection, .tk::selection { background: var(--signal); color: var(--on-signal); }
  .tk-hl { background: var(--hl); color: var(--on-lime); padding-inline: 0.08em; border-radius: 6px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
  .tk-key { color: var(--err-text); }
  .tk code, .tk pre { font-family: var(--font-mono); font-size: 0.9em; }
  .tk-sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  
  /* ---------- layout: the section template ---------- */
  .tk-section { padding-block: var(--space-72); background: var(--paper); }
  .tk-section[data-field="mist"] { background: var(--mist); }
  .tk-section[data-field="stone"] { background: var(--stone); }
  .tk-section[data-field="hero"] { background: var(--hero); color: var(--hero-ink); }
  .tk-section[data-field="yellow"] { background: var(--field-yellow); }
  .tk-section[data-field="violet"] { background: var(--field-violet); }
  .tk-section[data-field="hero"] .tk-legend li::before { box-shadow: 0 0 0 1.5px var(--hero-ink); } /* taste-skill-ignore: focus ring, legend ring or the one hard offset, not a soft shadow at rest */
  .tk-one, .tk-two { max-inline-size: var(--content-max); margin-inline: auto; padding-inline: var(--space-40); }
  .tk-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-72); align-items: start; container-type: inline-size; }
  .tk-stack { display: grid; gap: var(--space-16); }
  .tk-stack > p { max-inline-size: var(--measure); }
  @media (max-width: 1000px) { .tk-two { grid-template-columns: minmax(0, 1fr); gap: var(--space-32); } }
  @media (max-width: 640px) { .tk-one, .tk-two { padding-inline: var(--space-16); } .tk-section { padding-block: var(--space-48); } }
  
  /* ---------- Button ---------- */
  .tk-btn { display: inline-flex; align-items: center; justify-content: center; min-block-size: var(--target); padding-inline: var(--space-20); border: 2px solid var(--edge); border-radius: var(--radius); background: var(--violet); color: var(--on-violet); font: 500 18px/1 var(--font-sans); text-decoration: none; cursor: pointer; transition: background-color 200ms ease; }
  .tk-btn:hover { background: var(--violet-hover); }
  .tk-link { background: none; border: 0; min-block-size: var(--target); padding-inline: var(--space-2); color: inherit; font: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
  .tk-link:hover { text-decoration-thickness: 2px; }
  
  /* ---------- CopyButton + CodeBlock ---------- */
  .tk-codebox { position: relative; }
  .tk-code { display: block; background: var(--code-bg); color: var(--ink); border: 2px solid var(--edge); border-radius: var(--radius); padding-block: var(--space-16); padding-inline: var(--space-18) var(--space-56); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
  .tk-copy { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; inline-size: 36px; block-size: 36px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius-inner); background: transparent; color: var(--ink); cursor: pointer; transition: background-color 200ms ease; }
  .tk-copy:hover { background: var(--surface-2); }
  .tk-copy:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
  .tk-copy svg { inline-size: 20px; block-size: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .tk-copy .tk-i-check { display: none; }
  .tk-copy.is-done .tk-i-copy { display: none; }
  .tk-copy.is-done .tk-i-check { display: block; }
  .tk-cmd { position: relative; display: flex; align-items: center; background: var(--surface); border: 2px solid var(--edge); border-radius: var(--radius); padding-block: 6px; padding-inline: var(--space-18) var(--space-56); max-inline-size: 520px; }
  .tk-cmd code { font-size: 18px; }
  .tk-cmd .tk-copy { inset-block-start: 50%; translate: 0 -50%; }
  .tk-band .tk-copy { color: var(--on-brand-band); }
  
  /* ---------- ThemeToggle ---------- */
  .tk-theme { display: inline-flex; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .tk-theme button { min-block-size: 36px; min-inline-size: var(--target); padding-inline: var(--space-10); border: 0; border-radius: var(--radius-inner); background: none; color: var(--muted); font: 15px/1 var(--font-sans); cursor: pointer; }
  .tk-theme button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
  .tk-theme button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
  
  /* ---------- Topbar ---------- */
  .tk-topbar { position: sticky; inset-block-start: 0; z-index: var(--z-topbar); background: var(--topbar); color: var(--hero-ink); border-block-end: 1px solid var(--line); }
  .tk-topbar__in { max-inline-size: var(--content-max); margin-inline: auto; padding: var(--space-10) var(--space-40); display: flex; align-items: center; gap: var(--space-24); }
  .tk-topbar__mark { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-10); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; text-decoration: none; }
  .tk-topbar__where { margin-inline-end: auto; font-size: 15px; color: var(--hero-muted); }
  .tk-topbar__nav { display: flex; gap: 22px; font-size: 15px; }
  .tk-topbar__nav a { text-decoration: none; padding-block: var(--space-10); color: var(--hero-muted); }
  .tk-topbar__nav a:hover, .tk-topbar__nav a[aria-current] { color: var(--hero-ink); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
  .tk-topbar__nav a[aria-current] { background: var(--signal); color: var(--on-signal); text-decoration: none; border-radius: var(--radius-pill); padding-inline: var(--space-12); margin-inline: calc(var(--space-12) * -1); }
  @media (max-height: 500px) { .tk-topbar { position: static; } }
  @container (max-width: 700px) { .tk-topbar__nav { display: none; } }
  @media (max-width: 1000px) { .tk-topbar__nav { display: none; } }
  
  /* ---------- PageMap ---------- */
  .tk-pagemap { background: var(--paper); border: 2px solid var(--edge); border-radius: var(--radius); padding: var(--space-24) var(--space-28); }
  .tk-pagemap__title { font: 800 22px/1.2 var(--font-display); letter-spacing: -0.01em; }
  .tk-pagemap ol { margin-block-start: var(--space-10); padding-inline-start: 1.4em; display: grid; gap: 6px; }
  .tk-pagemap li > span { color: var(--muted); font-size: 15px; margin-inline-start: 6px; }
  .tk-legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px var(--space-18); font-size: 15px; }
  .tk-legend li { display: inline-flex; align-items: center; gap: var(--space-8); }
  .tk-legend li::before { content: ""; inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--d); flex: none; }
  .tk-g-err { --d: var(--err-mark); } .tk-g-drift { --d: var(--drift-mark); } .tk-g-usage { --d: var(--usage-mark); } .tk-g-ci { --d: var(--ci-mark); }
  
  /* ---------- Terminal ---------- */
  .tk-terminal { background: var(--term-bg); color: var(--term-ink); border-radius: var(--radius); padding-block-end: var(--space-18); box-shadow: var(--shadow-offset); } /* taste-skill-ignore: focus ring, legend ring or the one hard offset, not a soft shadow at rest */
  .tk-terminal__bar { display: flex; align-items: center; gap: 7px; padding: 12px var(--space-16); background: var(--term-bar); color: var(--term-bar-ink); border-start-start-radius: var(--radius); border-start-end-radius: var(--radius); font-size: 15px; }
  .tk-terminal__bar span { inline-size: 11px; block-size: 11px; border-radius: 50%; background: var(--term-dot); }
  .tk-terminal__bar b { font-weight: 500; margin-inline-start: var(--space-10); }
  .tk-terminal pre { padding: 14px var(--space-20) 0; font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--term-ink); }
  .tk-t-dim { color: var(--term-dim); }
  .tk-t-err { color: var(--term-err); font-weight: 700; }
  .tk-t-drift { color: var(--term-drift); font-weight: 700; }
  .tk-t-usage { color: var(--term-usage); font-weight: 700; }
  @container (max-width: 520px) { .tk-terminal .tk-t-x { display: none; } }
  
  /* ---------- DataTable + FindingTag ---------- */
  .tk-frag { background: var(--code-bg); border: 2px solid var(--edge); border-radius: var(--radius); padding: var(--space-20); container-type: inline-size; }
  .tk-table { inline-size: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
  .tk-table caption { text-align: start; color: var(--muted); padding-block-end: var(--space-10); }
  .tk-table th { text-align: start; font-weight: 500; color: var(--muted); padding: 4px 12px 8px 0; }
  .tk-table td { padding: 8px 12px 8px 0; }
  .tk-table tbody tr:nth-child(odd) td { background: var(--surface); }
  .tk-table :is(td, th):first-child { padding-inline-start: var(--space-10); }
  .tk-table .tk-num { text-align: end; }
  .tk-bad { color: var(--bad-text); font-weight: 600; }
  @container (max-width: 420px) { .tk-table { table-layout: fixed; } .tk-table :is(td, th) { overflow-wrap: anywhere; } .tk-table .tk-hide-narrow { display: none; } }
  .tk-tag { display: inline-block; padding: 2px var(--space-10); border-radius: var(--radius-pill); border: 1px solid var(--line); font-size: 15px; font-weight: 500; background: var(--surface); color: var(--ink); }
  .tk-tag--err { background: var(--err); color: var(--err-text); }
  .tk-tag--drift { background: var(--drift); color: var(--drift-text); }
  .tk-tag--usage { background: var(--usage); color: var(--usage-text); }
  .tk-tag--ci { background: var(--ci); color: var(--ci-text); }
  
  /* ---------- GroupAccordion, FAQ, shared summary ---------- */
  .tk-acc { display: grid; gap: 6px; }
  .tk details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-16); min-block-size: 56px; padding-block: var(--space-10); padding-inline: var(--space-20) 52px; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-weight: 500; transition: background-color 200ms ease; }
  .tk details > summary::-webkit-details-marker { display: none; }
  .tk details > summary::before, .tk details > summary::after { content: ""; position: absolute; inset-inline-end: 22px; inset-block-start: 50%; inline-size: 14px; block-size: 2px; margin-block-start: -1px; background: currentColor; }
  .tk details > summary::after { rotate: 90deg; }
  .tk details[open] > summary::after { rotate: 0deg; }
  .tk details > summary:hover { background: var(--surface-2); }
  .tk details > summary:focus-visible { outline-offset: -5px; }
  .tk details > summary span { color: var(--muted); font-weight: 400; font-size: 15px; }
  .tk-faq > p, .tk-faq > .tk-codebox { margin: var(--space-14) var(--space-20) var(--space-18); max-inline-size: 72ch; }
  .tk-group { border-radius: var(--radius); background: var(--surface); border-inline-start: 6px solid var(--gm); }
  .tk-group > summary { background: transparent; border-start-start-radius: 0; border-end-start-radius: 0; }
  .tk-group > summary:hover { background: var(--gf); }
  .tk-group[open] { background: var(--gf); }
  .tk-group__name { font: 800 26px/1.15 var(--font-display); letter-spacing: -0.015em; color: var(--ink) !important; }
  .tk-group__body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-16) var(--space-48); padding: var(--space-20); container-type: inline-size; }
  .tk-group__body > p { grid-column: 1 / -1; max-inline-size: var(--measure); }
  .tk-group .tk-frag, .tk-group .tk-code { background: var(--paper); }
  .tk-group .tk-table tbody tr:nth-child(odd) td { background: transparent; }
  .tk-group .tk-table tbody td:first-child { border-inline-start: 4px solid var(--gm); }
  .tk-group .tk-list b, .tk-group .tk-bad { color: var(--gt); }
  .tk-group--err { --gf: var(--err); --gt: var(--err-text); --gm: var(--err-mark); }
  .tk-group--drift { --gf: var(--drift); --gt: var(--drift-text); --gm: var(--drift-mark); }
  .tk-group--usage { --gf: var(--usage); --gt: var(--usage-text); --gm: var(--usage-mark); }
  .tk-group--ci { --gf: var(--ci); --gt: var(--ci-text); --gm: var(--ci-mark); }
  .tk-list { display: grid; gap: var(--space-10); padding: 0; list-style: none; }
  @media (max-width: 1000px) { .tk-group__body { grid-template-columns: minmax(0, 1fr); } }
  
  /* ---------- Caption / Callout ---------- */
  .tk-caption { margin-block-start: var(--space-10); font-size: 15px; line-height: 1.45; color: var(--muted); }
  .tk-callout { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-16) var(--space-20); max-inline-size: var(--measure); }
  .tk-callout b { font-weight: 600; }
  
  /* ---------- ClientPicker ---------- */
  .tk-chips { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-block-end: var(--space-18); }
  .tk-chips button { min-block-size: 40px; padding-inline: var(--space-14); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); font: 15px/1 var(--font-sans); cursor: pointer; transition: background-color 200ms ease; }
  .tk-chips button:hover { background: var(--surface-2); }
  .tk-chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
  .tk-panel { display: grid; gap: var(--space-10); }
  .tk-panel + .tk-panel { margin-block-start: var(--space-24); }
  :root.js .tk-panel:not(.is-on) { display: none; }
  :root.js .tk-panel + .tk-panel { margin-block-start: 0; }
  :root:not(.js) .tk-chips { display: none; }
  
  /* ---------- LivingPicture ---------- */
  .tk-living { position: relative; }
  .tk-living .tk-spark { display: block; inline-size: 100%; block-size: auto; }
  .tk-spark rect { fill: var(--muted); opacity: var(--opacity-chart-bar); transform-box: fill-box; transform-origin: bottom; }
  .tk-spark rect.hot { fill: var(--err-mark); opacity: 1; }
  .tk-spark line { stroke: var(--err-text); stroke-width: 1.5; stroke-dasharray: 4 4; }
  @keyframes tk-rise { from { transform: scaleY(0.04); } to { transform: none; } }
  @keyframes tk-show { from { opacity: 0; } to { opacity: 1; } }
  @media (prefers-reduced-motion: no-preference) {
    .tk-living.is-start .tk-spark rect.base { transform: scaleY(0.04); }
    .tk-living.is-start .tk-spark rect.hot, .tk-living.is-start .tk-spark line { opacity: 0; }
    .tk-living.is-start [data-step] { opacity: 0; }
    .tk-living.is-playing .tk-spark rect.base { animation: tk-rise 600ms cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(var(--i) * 40ms); }
    .tk-living.is-playing .tk-spark rect.hot { animation: tk-rise 450ms cubic-bezier(.22, 1, .36, 1) both; animation-delay: 2080ms; }
    .tk-living.is-playing .tk-spark line { animation: tk-show 450ms cubic-bezier(.22, 1, .36, 1) both; animation-delay: 2080ms; }
    .tk-living.is-playing [data-step] { animation: tk-show 450ms cubic-bezier(.22, 1, .36, 1) both; animation-delay: calc(var(--i) * 450ms); }
  }
  
  /* ---------- SupportBand (the brand band) ---------- */
  .tk-support, .tk-band { background: var(--brand-band); color: var(--on-brand-band); border-block: 2px solid var(--on-brand-band); }
  .tk-support { padding-block: var(--space-72); }
  .tk-band a:not(.tk-btn), .tk-support a:not(.tk-btn) { color: var(--on-brand-band); }
  .tk-band .tk-btn, .tk-support .tk-btn { background: var(--violet-on-band); color: var(--on-violet-on-band); border-color: var(--edge-on-lime); }
  .tk-band .tk-btn:hover, .tk-support .tk-btn:hover { background: var(--violet-hover); }
  .tk-band :focus-visible, .tk-support :focus-visible { outline-color: var(--on-brand-band); box-shadow: none; } /* taste-skill-ignore: removes a focus ring, not a shadow */
  .tk-band a:not(.tk-btn):focus-visible, .tk-support a:not(.tk-btn):focus-visible { background: none; color: var(--on-brand-band); outline: 3px solid var(--on-brand-band); outline-offset: 3px; box-shadow: none; } /* taste-skill-ignore: removes a focus ring, not a shadow */
  .tk-band .tk-cmd, .tk-support .tk-cmd { background: var(--hero); border-color: var(--on-brand-band); }
  .tk-band .tk-cmd code, .tk-support .tk-cmd code, .tk-support .tk-copy { color: var(--hero-ink); }
  .tk-support :is(h2, h4) { font: 800 56px/0.98 var(--font-display); letter-spacing: -0.03em; }
  @media (max-width: 640px) { .tk-support { padding-block: var(--space-48); } .tk-support :is(h2, h4) { font-size: 32px; } }
  
  /* ---------- Footer ---------- */
  .tk-footer { background: var(--footer); color: var(--hero-ink); padding-block: var(--space-56) var(--space-40); }
  .tk-footer .tk-one { display: grid; gap: var(--space-12); }
  .tk-footer__name { display: inline-flex; align-items: center; gap: var(--space-14); font: 800 56px/1 var(--font-display); letter-spacing: -0.03em; }
  .tk-footer__links { display: flex; flex-wrap: wrap; gap: var(--space-8) var(--space-24); }
  .tk-footer small, .tk-footer .tk-meta { font-size: 15px; color: var(--hero-muted); }
  
  /* ---------- Badge ---------- */
  .tk-badge { display: inline-block; padding: 3px var(--space-12); border-radius: var(--radius-pill); background: var(--signal); color: var(--on-signal); font: 600 15px/1.4 var(--font-sans); vertical-align: 0.1em; }
  .tk-hl-y { background: var(--signal); color: var(--on-signal); padding-inline: 0.15em; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
  
  /* ---------- BraceMark ---------- */
  .tk-mark { display: inline-block; inline-size: var(--mark-size, 64px); block-size: auto; aspect-ratio: 1; border-radius: var(--radius-mark); vertical-align: middle; }
  
  /* ---------- system modes ---------- */
  @media (forced-colors: active) {
    .tk-btn, .tk-copy, .tk-theme button, .tk-chips button, .tk details > summary, .tk-tag { border: 1px solid ButtonText; forced-color-adjust: auto; }
    .tk-theme button[aria-pressed="true"], .tk-chips button[aria-pressed="true"] { outline: 2px solid Highlight; }
    .tk-legend li::before, .tk-group { forced-color-adjust: none; }
    .tk-terminal { box-shadow: none; border: 1px solid CanvasText; } /* taste-skill-ignore: removes a focus ring, not a shadow */
  }
  @media (prefers-reduced-motion: reduce) {
    .tk *, .tk *::before, .tk *::after { transition-duration: 0ms !important; animation: none !important; }
  }
}

@layer utilities {
  .tk-sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
