/* ==========================================================================
   Page · K04 Layout, Surfaces & Density
   ========================================================================== */

/* ---- ST 010 · Grid ------------------------------------------------------ */

.grid-demo {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(8px, 1.6vw, 24px);
  height: 120px;
  margin-bottom: 12px;
}

.grid-demo__col {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  background: rgba(15, 76, 154, .12);
  border-left: 1px solid var(--action);
  border-right: 1px solid var(--action);
  font: 500 11px/1 var(--f-mono);
  color: var(--ink-2);
}

.breakpoint-table-wrap {
  margin-top: 24px;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
}

.breakpoint-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font: 400 14px/1.3 var(--f-mono);
}

.breakpoint-table th {
  padding: 12px 14px;
  background: var(--surface);
  font-weight: 500;
  text-align: left;
}

.breakpoint-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

/* ---- ST 020 · Spacing scale -------------------------------------------- */

.space-scale {
  display: grid;
  gap: 8px;
}

.space-scale__row {
  display: grid;
  grid-template-columns: 72px 56px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  font: 400 13px/1 var(--f-mono);
}

.space-scale__value {
  color: var(--muted);
}

/* --size: the spacing token, drawn at 2× */
.space-scale__bar {
  width: calc(var(--size) * 2);
  max-width: 100%;
  height: 14px;
  background: var(--ink);
}

/* ---- ST 030 · Geometry -------------------------------------------------- */

.shape-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 24px;
}

.shape {
  height: 140px;
  background: var(--ink);
}

.shape--chamfer-s { clip-path: var(--chamfer-s); }
.shape--chamfer-m { clip-path: var(--chamfer-m); }
.shape--chamfer-l { clip-path: var(--chamfer-l); }

.shape--hairline {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--ink);
  border-radius: 2px;
  font: 500 12px/1 var(--f-mono);
  color: var(--ink-2);
}

.shape__token {
  margin-top: 10px;
  font: 500 13px/1.6 var(--f-mono);
}

.shape__use {
  font-size: 14px;
  color: var(--ink-2);
}

/* rail: hairline, blue progress up to --progress, carrier at the same spot */
.rail-demo {
  margin-top: 40px;
}

.rail-demo__label {
  margin-bottom: 12px;
}

.rail {
  position: relative;
  height: 40px;
}

.rail__line {
  position: absolute;
  left: 0;
  right: 0;
  top: 19px;
  height: 1px;
  background: var(--line-strong);
}

.rail__progress {
  position: absolute;
  left: 0;
  top: 18px;
  width: var(--progress);
  height: 3px;
  background: var(--action);
}

.rail__tick {
  position: absolute;
  left: var(--pos);
  top: 13px;
  width: 1px;
  height: 13px;
  background: var(--ink);
}

.rail__tick--end {
  left: auto;
  right: 0;
}

.rail__carrier {
  position: absolute;
  left: var(--progress);
  top: 7px;
  width: 20px;
  height: 26px;
  margin-left: -10px;
  background: var(--ink);
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}

/* copper lamp on the carrier */
.rail__carrier::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  width: 6px;
  height: 6px;
  background: var(--accent);
}

/* ---- ST 040 · Spec table ----------------------------------------------- */

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.table-toolbar__text {
  margin: 0;
  max-width: 56ch;
  font-size: var(--fs-small);
  color: var(--ink-2);
}

.diff-toggle {
  min-height: var(--target);
  padding: 0 16px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: 600 14px/1 var(--f-text);
  text-transform: uppercase;
  letter-spacing: .05em;
  cursor: pointer;
}

.diff-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--canvas);
}

.spec-table-wrap {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--canvas);
}

/* separate borders so the sticky cells keep their rules while scrolling */
.spec-table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font: 400 15px/1.3 var(--f-mono);
}

.spec-table th,
.spec-table td {
  vertical-align: top;
}

/* sticky header row */
.spec-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--canvas);
  font-weight: 500;
  text-align: right;
}

/* pinned corner cell */
.spec-table thead th:first-child {
  left: 0;
  z-index: 3;
  width: 240px;
  text-align: left;
}

/* pinned parameter column */
.spec-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--f-text);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.spec-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

/* "Highlight differences": .spec-table--diff provides the tint,
   rows whose values differ across sizes use it */
.spec-table--diff {
  --diff-bg: rgba(15, 76, 154, .10);
}

.spec-table__row--varies td {
  background: var(--diff-bg, transparent);
}

.spec-table__unit {
  font: 400 12px var(--f-mono);
  color: var(--muted);
}

.spec-table__note {
  margin: 10px 0 0;
  font: 400 12px/1.4 var(--f-mono);
  color: var(--muted);
}

/* ---- ST 050 · Density cards -------------------------------------------- */

.density-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
  align-items: start;
}

.density-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  background: var(--canvas);
  color: var(--ink);
  font-size: var(--fs-body);
}

.density-card__meta {
  display: flex;
  justify-content: space-between;
  font: 500 12px/1 var(--f-mono);
  color: var(--ink-2);
}

.density-card__title {
  font: 700 30px/1 var(--f-display);
  text-transform: uppercase;
}

.density-card__field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--target);
  padding: 6px 12px;
  border: 1.5px solid var(--ink);
}

.density-card__field-label {
  font: 500 var(--fs-cap)/1.3 var(--f-mono);
  color: var(--muted);
}

.density-card__field-value {
  font: 500 var(--fs-body)/1.3 var(--f-mono);
}

.density-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.density-card__note {
  font-size: var(--fs-small);
  color: var(--ink-2);
}

/* static button specimens that follow the card's density tokens */
.density-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  font: 600 var(--fs-small)/1 var(--f-text);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.density-btn--primary {
  padding: 0 20px;
  background: var(--action);
  color: var(--action-ink);
  clip-path: var(--chamfer-s);
}

.density-btn--outline {
  padding: 0 16px;
  border: 1.5px solid var(--ink);
}
