/* ==========================================================================
   K02 — Color, Tokens & Presets (kit/color-and-tokens.html)
   Page-specific styles. Panels that demo a fixed theme or preset carry
   their own data-preset / data-theme attributes, so every token inside
   them resolves against that scope (see tokens.css).

   Contents
     01 Token architecture   .token-layer .token-row .code-sample
     02 Studio & Darkroom    .theme-panel .theme-row
     03 The accent           .accent-*
     04 Status               .status-note
     05 Contrast             .contrast-table
     06 Signature presets    .specimen
     07 Contrast by preset   .preset-contrast .contrast-chip
   ========================================================================== */

/* ---- 01 Token architecture ------------------------------------------- */
.token-layers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 20px;
}

.token-layer {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.token-layer__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.token-layer__name {
  font-family: var(--f-display);
  font-weight: var(--d-weight);
  font-size: 26px;
}

.token-layer__desc {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--muted);
  text-wrap: pretty;
}

.token-layer__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.token-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.token-row__chip {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--swatch);
}

.token-row__label {
  font-family: var(--f-mono);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* Dark code block (keeps the column alignment of the sample) */
.code-sample {
  margin: 20px 0 0;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--sheet-ink);
  font-family: var(--f-mono);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
}

.code-sample code {
  font: inherit;
}

/* ---- 02 Studio & Darkroom -------------------------------------------- */
.theme-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 20px;
}

.theme-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
}

.theme-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.theme-panel__name {
  font-family: var(--f-display);
  font-size: 40px;
  line-height: 1;
}

.theme-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.theme-row__chip {
  width: 48px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--swatch);
}

.theme-row__name > * {
  display: block;
}

.theme-row__role {
  font-size: 15px;
  font-weight: 500;
}

.theme-row__hex {
  font-family: var(--f-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---- 03 The accent ---------------------------------------------------- */
.accent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 40px 56px;
  align-items: start;
  margin-top: 32px;
}

.accent-copy {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.accent-copy__text {
  margin: 0;
  max-width: 34em;
  text-wrap: pretty;
}

.accent-copy__text strong {
  font-weight: 600;
}

.accent-rules {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.accent-rule {
  padding-top: 10px;
  border-top: 1px solid var(--ink);
}

.accent-rule__label {
  margin-bottom: 8px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.accent-rule__label--use   { color: var(--success); }
.accent-rule__label--never { color: var(--error); }

.accent-rule__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.accent-rule__list li {
  padding: 3px 0;
  font-size: 15px;
}

.accent-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}

.accent-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
}

.accent-panel__row {
  display: flex;
}

/* Static button sample (not interactive) */
.accent-panel__button {
  padding: 14px 22px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 600;
}

.accent-panel__link {
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 600;
}

/* Price circled with the grease pencil (data-mark, see proof.js) */
.accent-panel__price {
  align-self: flex-start;
  padding: 4px 6px;
  font-family: var(--f-display);
  font-size: 30px;
  line-height: 1;
}

/* The circle overshoots its host (124% wide); undo the global svg max-width */
.accent-panel__price .mark {
  max-width: none;
}

.accent-panel__spec {
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---- 04 Status -------------------------------------------------------- */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.status-note {
  --status: var(--info);
  --status-bg: var(--info-bg);
  --status-shape: 50%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--status);
  border-radius: var(--radius);
  background: var(--status-bg);
  color: var(--ink);
}

.status-note--success {
  --status: var(--success);
  --status-bg: var(--success-bg);
}

.status-note--warning {
  --status: var(--warning);
  --status-bg: var(--warning-bg);
  --status-shape: 0;
}

/* Error: plum, hatched ground, dashed rule — never mistaken for the accent */
.status-note--error {
  --status: var(--error);
  --status-shape: 0;
  border: 1.5px dashed var(--error);
  background: repeating-linear-gradient(135deg, var(--error-bg) 0 8px, transparent 8px 10px), var(--error-bg);
}

.status-note__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--status);
  border-radius: var(--status-shape);
  color: var(--status);
  font-family: var(--f-mono);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.status-note__title {
  color: var(--status);
  font-size: 16px;
  font-weight: 600;
}

.status-note__msg {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.5;
}

.status-note__token {
  margin-top: 8px;
}

/* ---- 05 Contrast ------------------------------------------------------ */
.contrast-intro {
  margin-bottom: 20px;
}

.contrast-table__row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1.6fr) minmax(0, 1fr) 84px 96px;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.contrast-table__row--head {
  align-items: stretch;
  border-bottom-color: var(--ink);
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* "Aa" sample: colours set per row via --fg / --bg */
.contrast-table__sample {
  padding: 9px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-display);
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.contrast-table__use {
  color: var(--muted);
}

.contrast-table__end {
  text-align: right;
}

.contrast-table__ratio {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}

.contrast-table__grade {
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 500;
}

/* ---- 06 Signature presets --------------------------------------------- */
.specimens {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}

.specimen {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--f-body);
}

.specimen__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--muted);
}

.specimen__card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Frame follows the preset: ratio, mat (padding) and image filter */
.specimen__frame {
  aspect-ratio: var(--frame-ratio);
  padding: var(--frame-pad);
  border-radius: var(--radius);
  background: var(--surface);
}

.specimen__ph {
  display: flex;
  align-items: flex-end;
  height: 100%;
  padding: 10px;
  border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, var(--ph) 0 10px, var(--ph-stripe) 10px 11px);
  filter: var(--img-filter);
}

.specimen__ph-label {
  padding: 2px 6px;
  background: var(--ph);
  color: var(--ph-ink);
  font-family: var(--f-mono);
  font-size: 12px;
}

.specimen__title {
  font-family: var(--f-display);
  font-weight: var(--d-weight);
  text-transform: var(--d-case);
  letter-spacing: var(--d-track);
  font-size: 28px;
  line-height: 1.05;
}

.specimen__credits {
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.specimen__result {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
}

.specimen__result strong {
  font-weight: 600;
}

.specimen__link {
  color: var(--accent-text);
  font-weight: 600;
}

.specimen__chapter {
  position: relative;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.specimen__kicker {
  margin-bottom: 6px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--muted);
}

.specimen__chapter-title {
  margin-bottom: 8px;
  font-family: var(--f-display);
  font-weight: var(--d-weight);
  text-transform: var(--d-case);
  font-size: 22px;
  line-height: 1.15;
}

.specimen__text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.specimen__notes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.specimen__hand {
  display: block;
  color: var(--accent-text);
  font-family: var(--f-hand);
  font-size: 22px;
  line-height: 1;
  transform: rotate(-2deg);
}

.specimen__stamp {
  display: block;
  padding: 3px 7px;
  border: 2px solid var(--accent);
  color: var(--accent-text);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  transform: rotate(-7deg);
}

/* Token overrides of this preset */
.specimen__tokens {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.specimen__tokens > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.specimen__tokens dd {
  margin: 0;
  color: var(--ink);
}

/* ---- 07 Contrast by preset ------------------------------------------- */
.preset-contrast {
  margin-top: 28px;
}

.preset-contrast__title {
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: capitalize;
}

.preset-contrast__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 8px;
}

.contrast-chip {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
}

/* "Aa" sample: colours set per chip via --fg / --bg */
.contrast-chip__sample {
  padding: 6px 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-display);
  font-size: 18px;
  text-align: center;
}

.contrast-chip__name {
  font-size: 13px;
  line-height: 1.3;
}

.contrast-chip__hex {
  display: block;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
}

.contrast-chip__score {
  font-family: var(--f-mono);
  font-size: 12px;
  text-align: right;
}

.contrast-chip__grade {
  display: block;
  font-weight: 500;
}
