/* The Toolkit hub's stylesheet: Studio 2.2's own composition, then a small
   token-only layer of placement. Every file imported here is copied in from
   design/studio at build time: the Studio site's shell (site.css: tokens,
   type, fonts, Portico) and Studio's base, component and Home CSS (st-*).
   This file only places Studio's components on a page (grids, gaps, widths)
   and draws the few things Studio has no component for. Every value is a
   Studio custom property; `npm test` holds it to that. */
@layer studio.reset, studio.base, studio.layout, studio.components, studio.utilities;
@layer studio, portico, site, toolkit;
@import url("./site.css");
@import url("./studio/base.css");
@import url("./studio/components.css");
@import url("./studio/home.css");

@layer toolkit {
  .tk-mark { display: block; width: var(--spacing-icon-md); height: var(--spacing-icon-md); }
  .tk-muted { color: var(--color-on-surface-3); }
  .tk-mono { font-family: var(--type-mono-md-family); font-size: var(--type-mono-md-size); }
  .tk-measure { max-width: var(--spacing-measure); }
  .tk-lead { color: var(--color-on-surface-2); font-family: var(--type-body-lg-family); font-size: var(--type-body-lg-size); line-height: var(--type-body-lg-line-height); }
  .tk-code { margin: 0; max-width: 100%; overflow-x: auto; }
  .tk-count { color: var(--color-on-surface-3); font-family: var(--type-label-md-family); font-size: var(--type-label-md-size); font-weight: var(--type-label-md-weight); }
  .tk-ellipsis { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* site.css inherits every link's ink; Studio's linked components keep their own. */
  .site a.st-caps-link { color: var(--component-caps-link-fg); text-decoration: none; }
  .site a.site-btn-primary { color: var(--color-on-primary); text-decoration: none; }
  .site a.site-btn { text-decoration: none; }
  .site a:is(.st-kind-tile, .st-card) { color: var(--color-on-surface); text-decoration: none; }

  /* ---- Hub pages: one column at the workspace width, sections a band apart ---- */
  .tk-page { container: tk / inline-size; display: flex; flex-direction: column; gap: var(--spacing-s-9); min-width: 0; padding-block-end: var(--spacing-s-6); }
  .tk-section { display: flex; flex-direction: column; gap: var(--spacing-s-4); min-width: 0; scroll-margin-block-start: var(--spacing-scroll-offset); }
  .tk-section > .st-section-header { padding-inline: 0; }
  .tk-subsection { display: flex; flex-direction: column; gap: var(--spacing-s-3); }
  .tk-subsection + .tk-subsection { margin-block-start: var(--spacing-s-5); }
  .tk-head { padding-inline: 0; }
  .tk-hero { padding-inline: 0; }
  .tk-hero .site-actions { padding-block-start: var(--spacing-s-2); }
  .tk-provenance {
    padding-block-start: var(--spacing-s-4); border-block-start: var(--spacing-hairline) solid var(--color-outline-soft); color: var(--color-on-surface-3);
    font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); font-weight: var(--type-body-xs-weight); line-height: var(--type-body-xs-line-height); letter-spacing: var(--type-body-xs-tracking);
  }
  .site-prose .tk-provenance { margin-block-start: var(--spacing-s-8); color: var(--color-on-surface-3); }
  .tk-provenance code { font-size: inherit; }

  /* Grids: as many columns as fit a tile; three and five where the content asks. */
  .tk-grid { display: grid; gap: var(--spacing-grid-gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--spacing-template-w)), 1fr)); margin: 0; padding: 0; list-style: none; }
  @container tk (min-width: 796px) {   /* --spacing-split-at */
    .tk-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
  @container tk (max-width: 795px) {   /* below --spacing-split-at */
    .tk-grid--five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tk-grid--five .tk-tile { min-height: 0; }
  }
  @container tk (min-width: 796px) {   /* --spacing-split-at */
    .tk-grid--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
  @container tk (min-width: 1024px) {
    .tk-grid--five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  }
  .st-home-hero[data-compact] .st-hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Tiles: Studio's kind tile, holding a kicker, an address or a status. */
  .tk-tile { gap: var(--spacing-s-1); min-height: var(--spacing-tile-h); }
  .tk-tile .st-kind-tile__title { white-space: normal; overflow: visible; text-wrap: balance; }
  .tk-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .tk-tile__kicker {
    color: var(--color-on-surface-3); text-transform: var(--type-caption-xs-transform);
    font-family: var(--type-caption-xs-family); font-size: var(--type-caption-xs-size); font-weight: var(--type-caption-xs-weight); letter-spacing: var(--type-caption-xs-tracking); line-height: var(--type-caption-xs-line-height);
  }
  .tk-tile__address {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-on-surface-2); text-decoration: none;
    font-family: var(--type-mono-xs-family); font-size: var(--type-mono-xs-size); font-weight: var(--type-mono-xs-weight); letter-spacing: var(--type-mono-xs-tracking); line-height: var(--type-mono-xs-line-height);
  }
  .tk-tile > .st-status-dot { margin-block-start: auto; padding-block-start: var(--spacing-s-2); }
  .st-hero-stats__value.tk-stat-word { font-family: var(--type-label-lg-family); font-size: var(--type-label-lg-size); font-weight: var(--type-label-lg-weight); line-height: var(--type-headline-sm-line-height); letter-spacing: var(--type-label-lg-tracking); }
  .tk-well[data-tone="decision"] { background: var(--color-error-surface); color: var(--color-error); border-color: transparent; }

  /* The readiness areas: a card with a count and a thin bar. */
  .tk-area-card { display: flex; flex-direction: column; gap: var(--spacing-s-3); min-width: 0; }
  .tk-area-card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--spacing-s-3); }
  .tk-area-card__count { flex: none; color: var(--color-on-surface-3); font-family: var(--type-numeral-sm-family); font-size: var(--type-numeral-sm-size); font-weight: var(--type-numeral-sm-weight); font-feature-settings: var(--type-numeral-sm-feature); }
  .tk-area-card__count strong { color: var(--color-on-surface); font-weight: inherit; }
  .tk-area-card__meta { color: var(--color-on-surface-3); font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); line-height: var(--type-body-xs-line-height); }

  /* ---- Readiness ---- */
  .tk-filters { display: flex; flex-direction: column; gap: var(--spacing-s-3); }
  .tk-filter-bar { display: flex; align-items: center; gap: var(--spacing-s-3); }
  .tk-filter-search { flex: 1 1 auto; min-width: 0; }
  .tk-filter-menu { position: relative; flex: none; }
  .tk-filter-menu > summary { list-style: none; cursor: pointer; }
  .tk-filter-menu > summary::-webkit-details-marker { display: none; }
  .tk-filter-badge { min-width: var(--spacing-s-5); padding-inline: var(--spacing-s-1); border-radius: var(--rounded-full); background: var(--color-primary); color: var(--color-on-primary); font-feature-settings: var(--type-numeral-sm-feature); text-align: center; }
  .tk-filter-panel { position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + var(--spacing-s-2)); z-index: 10; display: flex; flex-direction: column; gap: var(--spacing-s-3); min-width: var(--spacing-search-w); max-width: calc(100vw - var(--spacing-s-8)); padding: var(--spacing-s-4); }
  .tk-filter-field { display: flex; flex-direction: column; gap: var(--spacing-s-1); }
  .tk-filter-field select { font: inherit; min-height: var(--spacing-control-h); padding-inline: var(--spacing-s-3); border: var(--spacing-hairline) solid var(--color-outline); border-radius: var(--rounded-full); background: var(--color-surface); color: var(--color-on-surface); }
  [data-filter-clear] { align-self: flex-start; }
  .tk-filter-search input { font: inherit; }
  .tk-area .st-list { gap: var(--spacing-s-2); }
  .tk-item.st-list-row { display: block; padding: 0; scroll-margin-block-start: var(--spacing-scroll-offset); }
  .tk-item__row { cursor: pointer; list-style: none; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "m v o"; }
  .tk-item__row::-webkit-details-marker { display: none; }
  .tk-item__row::marker { content: ""; }
  .tk-item .st-list-row__main { pointer-events: auto; }
  .tk-item .st-list-row__title { white-space: normal; text-wrap: pretty; }
  .tk-item .st-list-row__meta { color: var(--color-on-surface-3); font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); line-height: var(--type-body-xs-line-height); letter-spacing: var(--type-body-xs-tracking); }
  .tk-filter-search { min-height: var(--spacing-control-h); padding-inline: var(--spacing-s-4); border: var(--spacing-hairline) solid var(--color-outline); border-radius: var(--rounded-full); background: var(--color-surface); }
  .tk-item__value { flex-direction: row; align-items: center; gap: var(--spacing-s-2); min-width: 0; pointer-events: auto; }
  .tk-item__chevron { color: var(--color-on-surface-3); transition: rotate var(--motion-duration-fast) var(--motion-ease); }
  .tk-item details[open] .tk-item__chevron { rotate: 180deg; }
  .tk-item:target, .tk-item:has(details[open]) { border-color: var(--color-outline-strong); }
  .tk-item__body {
    display: grid; gap: var(--spacing-s-2); margin: 0; padding: var(--spacing-s-1) var(--spacing-s-4) var(--spacing-s-4);
    border-block-start: var(--spacing-hairline) solid var(--color-outline-soft); padding-block-start: var(--spacing-s-3);
    font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); color: var(--color-on-surface-2);
  }
  .tk-item__body > div { display: grid; grid-template-columns: var(--spacing-s-12) minmax(0, 1fr); gap: var(--spacing-s-3); }
  .tk-item__body dt { color: var(--color-on-surface-3); text-transform: var(--type-caption-xs-transform); font-family: var(--type-caption-xs-family); font-size: var(--type-caption-xs-size); letter-spacing: var(--type-caption-xs-tracking); padding-block-start: var(--spacing-s-0); }
  .tk-item__body dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
  .tk-evidence { display: flex; flex-wrap: wrap; gap: var(--spacing-s-1) var(--spacing-s-3); margin: 0; padding: 0; list-style: none; }
  @container (max-width: 555px) {   /* --spacing-row-fold-at */
    .tk-item__row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "m o" "v o"; }
    .tk-item__body > div { grid-template-columns: minmax(0, 1fr); gap: var(--spacing-s-0); }
  }

  /* ---- QA ---- */
  .tk-state { display: flex; flex-direction: column; gap: var(--spacing-s-1); }
  .tk-surface { display: flex; flex-direction: column; gap: var(--spacing-s-3); min-width: 0; }
  .tk-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-s-1); margin: 0; padding: 0; list-style: none; }
  .tk-checks { display: grid; gap: var(--spacing-s-1); margin: 0; padding-inline-start: var(--spacing-s-4); color: var(--color-on-surface-2); font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); }
  .tk-how { margin-block-start: auto; padding-block-start: var(--spacing-s-2); border-block-start: var(--spacing-hairline) solid var(--color-outline-soft); color: var(--color-on-surface-3); font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); line-height: var(--type-body-xs-line-height); }

  /* ---- Staging ---- */
  .tk-env .st-list-row__main { pointer-events: auto; }
  .tk-env .st-list-row__value { align-items: flex-end; gap: var(--spacing-s-1); min-width: 0; }
  .tk-address { color: var(--component-list-row-host-fg); text-decoration: none; }
  .tk-env-row__what { color: var(--color-on-surface-3); font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); line-height: var(--type-body-xs-line-height); }
  .tk-legend { display: flex; flex-wrap: wrap; gap: var(--spacing-s-2) var(--spacing-s-5); margin: 0; padding: 0; list-style: none; color: var(--color-on-surface-3); font-family: var(--type-body-xs-family); font-size: var(--type-body-xs-size); line-height: var(--type-body-xs-line-height); }
  .tk-legend > li { display: inline-flex; align-items: center; gap: var(--spacing-s-2); }
  .st-status-dot[data-status="pending"] { --st-status: var(--color-on-surface-4); color: var(--color-on-surface-3); }

  /* ---- Release ---- */
  .tk-checkgroups { display: grid; gap: var(--spacing-grid-gap); margin: 0; padding: 0; list-style: none; counter-reset: group; }
  .tk-checkgroup { display: flex; flex-direction: column; gap: var(--spacing-s-2); counter-increment: group; }
  .tk-checkgroup > .st-card__title::before { content: counter(group) "  "; color: var(--color-on-surface-4); }
  .tk-checklist { display: grid; margin: 0; padding: 0; list-style: none; }
  .tk-checklist > li + li { border-block-start: var(--spacing-hairline) solid var(--color-outline-soft); }
  .tk-check { align-items: flex-start; padding-block: var(--spacing-s-2); width: 100%; }
  .tk-check .st-checkbox__box { margin-block-start: var(--spacing-s-0); }
  .tk-check .st-checkbox__input { inset-block-start: var(--spacing-s-2); translate: none; }
  .tk-check__text { min-width: 0; color: var(--color-on-surface-2); overflow-wrap: anywhere; font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); }
  .tk-check:has(:checked) .tk-check__text { color: var(--color-on-surface-3); text-decoration: line-through; text-decoration-color: var(--color-outline-strong); }
  .tk-check a { position: relative; z-index: 1; }

  /* ---- Library ---- */
  .site-prose h1 .site-accent { font-family: var(--type-accent-italic-family); font-weight: var(--component-accent-word-font-weight); }
  .site-prose code.tk-file { color: var(--color-on-surface-2); background: var(--color-surface-2); padding-inline: var(--spacing-s-1); border-radius: var(--rounded-xs); }
  .site-prose :is(ul, ol) { grid-template-columns: minmax(0, 1fr); }
  .site-prose li { min-width: 0; overflow-wrap: anywhere; }
  .site-prose li.task { list-style: none; }
  .site-prose ul.tasks { padding-inline-start: var(--spacing-s-2); }
  .site-prose input[type="checkbox"] { accent-color: var(--color-primary); }
  .site-prose .tk-index, .site-prose .tk-adrs { padding: 0; gap: 0; }
  .tk-index > li { display: grid; gap: var(--spacing-s-0); padding-block: var(--spacing-s-2h); border-block-end: var(--spacing-hairline) solid var(--color-outline-soft); }
  .site-prose .tk-index__link { color: var(--color-on-surface); text-decoration: none; font-family: var(--type-label-lg-family); font-size: var(--type-label-lg-size); font-weight: var(--type-label-lg-weight); }
  .site-prose .tk-index__link:hover { text-decoration: underline; }
  .tk-index__summary { color: var(--color-on-surface-3); font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); }
  .site-prose .tk-index__more { font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); }
  .tk-adr { display: grid; grid-template-columns: var(--spacing-s-10) minmax(0, 1fr) auto; align-items: center; gap: var(--spacing-s-3); padding-block: var(--spacing-s-2); border-block-end: var(--spacing-hairline) solid var(--color-outline-soft); text-decoration: none; }
  .site-prose a.tk-adr { color: var(--color-on-surface); text-decoration: none; }
  .tk-adr:hover .tk-adr__title { text-decoration: underline; text-decoration-color: var(--color-outline-strong); }
  .tk-adr__n { color: var(--color-on-surface-3); font-family: var(--type-mono-sm-family); font-size: var(--type-mono-sm-size); font-feature-settings: var(--type-mono-sm-feature); }
  .tk-adr__title { min-width: 0; font-family: var(--type-body-md-family); font-size: var(--type-body-md-size); line-height: var(--type-body-md-line-height); }
  .tk-text { white-space: pre-wrap; }

  /* API reference. */
  .tk-method {
    display: inline-block; min-width: var(--spacing-s-10); text-align: center; padding: var(--spacing-s-0) var(--spacing-s-2);
    border-radius: var(--rounded-full); background: var(--color-surface-2); color: var(--color-on-surface-2);
    font-family: var(--type-mono-xs-family); font-size: var(--type-mono-xs-size); font-weight: var(--type-label-lg-weight); letter-spacing: var(--type-mono-xs-tracking);
  }
  .tk-method[data-method="get"] { background: var(--color-info-surface); color: var(--color-info); }
  .tk-method[data-method="post"] { background: var(--color-success-surface); color: var(--color-success); }
  .tk-method[data-method="put"], .tk-method[data-method="patch"] { background: var(--color-warning-surface); color: var(--color-warning); }
  .tk-method[data-method="delete"] { background: var(--color-error-surface); color: var(--color-error); }
  .tk-ops td:first-child { width: var(--spacing-s-10); }
  .tk-opid { color: var(--color-on-surface-3); }
  .tk-mark-lg { width: var(--spacing-icon-2xl); height: var(--spacing-icon-2xl); }
  .tk-specimen { display: inline-grid; place-items: center; padding: var(--spacing-s-6); border: var(--spacing-hairline) solid var(--color-outline); border-radius: var(--rounded-lg); background: var(--color-surface); }

  /* ---- Search ---- */
  .tk-searchbox { display: flex; }
  .tk-searchbox .st-search { flex: 1 1 auto; max-width: var(--spacing-reading); }
  .tk-results { display: grid; gap: 0; max-width: var(--spacing-reading); margin: 0; padding: 0; list-style: none; }
  .tk-results > li { display: grid; gap: var(--spacing-s-0); padding-block: var(--spacing-s-3); border-block-end: var(--spacing-hairline) solid var(--color-outline-soft); color: var(--color-on-surface-2); font-family: var(--type-body-sm-family); font-size: var(--type-body-sm-size); line-height: var(--type-body-sm-line-height); }
  .tk-results a { color: var(--color-on-surface); text-decoration: none; font-family: var(--type-label-lg-family); font-size: var(--type-label-lg-size); font-weight: var(--type-label-lg-weight); }
  .tk-results a:hover { text-decoration: underline; }
  .tk-results mark { background: var(--color-primary-soft); color: var(--color-on-primary-soft); border-radius: var(--rounded-xs); }
  .tk-result-group { color: var(--color-on-surface-3); text-transform: var(--type-caption-xs-transform); font-family: var(--type-caption-xs-family); font-size: var(--type-caption-xs-size); letter-spacing: var(--type-caption-xs-tracking); }

  @media (prefers-reduced-motion: reduce) {
    .tk-item__chevron { transition: none; }
  }
}
