/* The canvas's look for the Kimen components the site draws its controls with (scripts/kimen.mjs).
   It loads after Kimen's tokens and the canvas's own stylesheets. The first part only reassigns
   component tokens; the second lays out the page's own content inside and around them. Nothing
   here reaches inside a component. */

/* ══ Component tokens ═══════════════════════════════════════════════ */
:root,
[data-ki-theme='gdd'] {
  /* ki-button: the canvas's .g-ghost and .g-pk, both outlined toggles */
  --ki-button-label-padding-inline: 0px;
  --ki-button-padding-block: 0px;
  --ki-button-outline-rest-bg: transparent;
  /* Like the canvas's buttons, they take the ink of the text around them. */
  --ki-button-outline-rest-fg: currentColor;
  --ki-button-outline-rest-border: var(--ki-outline-med-em);
  --ki-button-outline-hover-bg: var(--ki-surface-hover-overlay);
  --ki-button-outline-hover-fg: currentColor;
  --ki-button-outline-hover-border: var(--ki-outline-med-em);
  --ki-button-outline-selected-bg: var(--ki-surface-primary-med-em);
  --ki-button-outline-selected-fg: var(--ki-text-primary-on-primary);
  --ki-button-outline-selected-border: var(--ki-surface-primary-med-em);
  --ki-button-toggle-radius: var(--ki-radius-component-md);
  --ki-button-toggle-selected-radius: var(--ki-radius-component-md);

  /* ki-switch: the canvas's .l-sw */
  --ki-switch-control-width: 44px;
  --ki-switch-control-height: 26px;
  --ki-switch-track-width: 44px;
  --ki-switch-track-height: 26px;
  --ki-switch-track-radius: var(--ki-radius-round);
  --ki-switch-border-width: 1.5px;
  --ki-switch-thumb-size: 17px;
  --ki-switch-thumb-width: 17px;
  --ki-switch-thumb-inset: 3px;
  --ki-switch-thumb-radius: var(--ki-radius-round);
  --ki-switch-thumb-shadow: none;
  --ki-switch-well-bg-start: transparent;
  --ki-switch-well-bg-end: transparent;
  --ki-switch-glyph-checked: transparent;
  --ki-switch-glyph-unchecked: transparent;
  --ki-switch-gap: 14px;
  --ki-switch-label-font-size: 1.0625rem;
  --ki-switch-label-line-height: 1.55em;
  --ki-switch-unchecked-rest-track: var(--ki-surface-s0);
  --ki-switch-unchecked-rest-border: var(--ki-outline-control);
  --ki-switch-unchecked-rest-thumb: var(--ki-outline-control);
  --ki-switch-unchecked-hover-track: var(--ki-surface-s0);
  --ki-switch-unchecked-hover-border: var(--ki-outline-control);
  --ki-switch-unchecked-hover-thumb: var(--ki-outline-control);
  --ki-switch-checked-rest-track: var(--ki-surface-primary-med-em);
  --ki-switch-checked-rest-border: var(--ki-surface-primary-med-em);
  --ki-switch-checked-rest-thumb: var(--ki-text-primary-on-primary);
  --ki-switch-checked-hover-track: var(--ki-surface-primary-med-em);
  --ki-switch-checked-hover-border: var(--ki-surface-primary-med-em);
  --ki-switch-checked-hover-thumb: var(--ki-text-primary-on-primary);

  /* ki-code-block: the canvas's .d-code, which inks only the keywords */
  --ki-code-bg: var(--ki-surface-s0);
  --ki-code-border: var(--ki-outline-med-em);
  --ki-code-border-width: 1px;
  --ki-code-radius: 0px;
  --ki-code-fg: var(--ki-text-high-em);
  --ki-code-keyword: var(--ki-text-primary-high-em);
  --ki-code-keyword-weight: 500;
  --ki-code-comment: var(--ki-text-high-em);
  --ki-code-function: var(--ki-text-high-em);
  --ki-code-string: var(--ki-text-high-em);
  --ki-code-number: var(--ki-text-high-em);
  /* One inset for every side: the canvas's 16px above and below, 2px short of its 18px beside. */
  --ki-code-padding: 16px;
  --ki-code-font-size: 0.8125rem;
  --ki-code-line-height: 1.65em;
}

/* The small toggles: the canvas's .g-ghost */
.k-ghost {
  --ki-button-font-weight: 500;
  --ki-button-xs-height: 36px;
  /* Kimen counts the 1px border inside this padding; the canvas adds it to 12px. */
  --ki-button-xs-padding-inline: 13px;
  --ki-button-xs-gap: 8px;
  --ki-button-xs-radius: var(--ki-radius-component-md);
  --ki-button-xs-font-size: 0.8125rem;
  --ki-button-xs-icon-size: 1.15em;
}
/* The choice cards: the canvas's .g-pk */
.k-choice {
  --ki-button-font-weight: 400;
  --ki-button-inline-size: 100%;
  --ki-button-justify-content: start;
  --ki-button-text-align: start;
  --ki-button-md-height: 72px;
  --ki-button-md-radius: var(--ki-radius-component-md);
  /* The canvas's 14px and 18px, plus the border Kimen counts inside its padding. */
  --ki-button-md-padding-inline: 19px;
  --ki-button-padding-block: 15px;
  --ki-button-md-font-size: 1.0625rem;
  /* Unitless, as in the canvas: a card's smaller line keeps its own line height. */
  --ki-button-md-line-height: 1.55;
}
.d-gate .k-choice { --ki-button-md-height: 56px; --ki-button-md-font-size: 0.9375rem; }
/* The switch's label takes the body's normal weight; the canvas's is medium. */
.k-sw { --ki-typography-weight-body-normal: 500; }

/* ══ The page's own content, in and around the components ═══════════ */
/* The canvas's script writes "true" or "false"; "false" is off. */
.k-choice > span:not(.g-st) { display: block; }
.k-choice > span + span { margin-top: 4px; }
.k-choice > .g-st { display: flex; font-size: .8125rem; color: var(--ki-text-med-em); }
.k-choice[selected]:not([selected='false']) :is(.g-cap, .g-st) { color: var(--ki-text-secondary-on-primary); }
.d .k-choice .g-cap { font-size: .8125rem; }
.k-ghost:is(:not([selected]), [selected='false']) .when-on,
.k-ghost[selected]:not([selected='false']) .when-off,
.k-sw:is(:not([checked]), [checked='false']) .when-on,
.k-sw[checked]:not([checked='false']) .when-off { display: none; }
/* A grid, not a block: a block lays the control on a line of the page's text, 9px taller. */
.k-sw { display: grid; padding: 14px 0; border-top: 1px solid var(--ki-outline-med-em); cursor: pointer; }
.k-sw:hover { background: var(--ki-surface-hover-overlay); }
.k-sw > b { font-weight: 600; font-size: 0.9375rem; color: var(--ki-text-med-em); }
.d-prose > .k-code { max-width: 920px; }
@media (max-width: 760px) {
  /* The canvas pads the pause button itself and hides its word; here the padding is the
     button's token, and no gap waits for the hidden word. */
  ki-button.g-pause { padding: 0; --ki-button-xs-padding-inline: 11px; --ki-button-xs-gap: 0px; }
}
