/* design.b1t.app: the brand manual. Sidebar plus a long reading column. */

body {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100dvh;
}

.skip {
  position: absolute;
  left: var(--s4);
  top: -3rem;
  z-index: 10;
  padding: var(--s2) var(--s3);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r2);
  text-decoration: none;
  font-weight: 600;
}

.skip:focus {
  top: var(--s4);
}

/* Sidebar */
.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: var(--s6) var(--s5);
  border-right: var(--border-w) solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s6);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  text-decoration: none;
}

.mark {
  color: var(--fg);
}

.wordmark {
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: var(--track-tight);
  line-height: 1;
}

.wordmark .one {
  color: var(--accent-text);
}

.brand-sub {
  color: var(--fg-2);
  font-size: var(--fs-sm);
  margin-left: var(--s1);
  padding-left: var(--s2);
  border-left: var(--border-w) solid var(--border-strong);
  line-height: 1;
}

.toc {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.toc a {
  display: block;
  padding: var(--s2) var(--s3);
  border-radius: var(--r2);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition:
    background var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}

.toc a:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.toc a[aria-current="true"] {
  color: var(--fg);
  background: var(--surface);
  box-shadow: inset 2px 0 0 var(--accent);
}

.theme {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--fs-sm);
  color: var(--fg-2);
  margin-top: auto;
  cursor: pointer;
}

.version {
  font-size: var(--fs-xs);
  color: var(--fg-3);
}

/* Document column */
.doc {
  padding: var(--s8) var(--gutter) var(--s9);
  max-width: 60rem;
  width: 100%;
}

.sec {
  padding-block: var(--s8);
  border-top: var(--border-w) solid var(--border);
  scroll-margin-top: var(--s6);
}

.sec:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.sec h2 {
  margin-bottom: var(--s4);
}

.sec h3 {
  margin-top: var(--s8);
  margin-bottom: var(--s4);
}

.sec h3 + p {
  margin-top: calc(-1 * var(--s2));
  margin-bottom: var(--s4);
  color: var(--fg-2);
}

.intro {
  font-size: var(--fs-lg);
  color: var(--fg-2);
  margin-bottom: var(--s6);
}

.note {
  margin-top: var(--s4);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

.hero-block {
  display: grid;
  gap: var(--s5);
  margin-bottom: var(--s8);
}

.hero-mark {
  color: var(--fg);
}

.lede {
  font-size: var(--fs-xl);
  color: var(--fg-2);
  line-height: var(--lh-normal);
}

.principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s6);
  padding-top: var(--s6);
  border-top: var(--border-w) solid var(--border);
}

.principles h3 {
  margin: 0 0 var(--s2);
  font-size: var(--fs-lg);
}

.principles p {
  color: var(--fg-2);
  font-size: var(--fs-sm);
}

/* Specimens */
.row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s4);
}

.row-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s4);
}

.spec {
  margin: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--s5);
  min-height: 14rem;
  padding: var(--s6);
  border-radius: var(--r3);
  border: var(--border-w) solid var(--border);
  position: relative;
}

.spec.dark {
  background: var(--void);
  color: var(--paper);
  border-color: var(--line);
}

.spec.light {
  background: var(--paper);
  color: var(--void);
  border-color: var(--sand);
}

.spec.signal {
  background: var(--signal);
  color: var(--void);
  border-color: var(--signal);
}

.spec figcaption {
  font-size: var(--fs-xs);
  color: inherit;
  opacity: 0.7;
  text-align: center;
  max-width: 28ch;
  text-wrap: balance;
}

.spec.construct {
  min-height: 18rem;
}

.misuse .spec {
  min-height: 10rem;
  padding: var(--s5);
  gap: var(--s4);
}

.misuse .spec::after {
  /* A struck line, drawn, not a glyph */
  content: "";
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  width: 14px;
  height: 14px;
  background:
    linear-gradient(45deg, transparent 45%, var(--err) 45%, var(--err) 55%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, var(--err) 45%, var(--err) 55%, transparent 55%);
}

.type-spec {
  min-height: 12rem;
}

.specimen-display {
  font-size: 6rem;
  font-weight: 700;
  letter-spacing: var(--track-tight);
  line-height: 1;
}

.specimen-display.mono {
  font-weight: 500;
  font-size: 5rem;
}

/* Swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--s4);
}

.swatch {
  display: grid;
  gap: 2px;
  font-size: var(--fs-sm);
}

.swatch .chip {
  height: 4rem;
  border-radius: var(--r2);
  border: var(--border-w) solid var(--border);
  margin-bottom: var(--s2);
}

.swatch b {
  font-weight: 600;
}

.swatch code {
  color: var(--fg-2);
  font-size: var(--fs-xs);
}

.swatch small {
  color: var(--fg-3);
  font-size: var(--fs-xs);
}

.proportion {
  display: flex;
  height: 2rem;
  gap: 2px;
  margin-top: var(--s4);
}

.proportion span {
  border-radius: var(--r1);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th,
td {
  text-align: left;
  padding: var(--s3) var(--s3);
  border-bottom: var(--border-w) solid var(--border);
  vertical-align: top;
}

th {
  font-weight: 500;
  color: var(--fg-2);
  font-size: var(--fs-xs);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.contrast .pair {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}

.contrast .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: var(--border-w) solid var(--border-strong);
}

.voice-table td:first-child {
  color: var(--fg-2);
  text-decoration: line-through;
  text-decoration-color: var(--err);
}

/* Type scale */
.scale {
  display: grid;
  gap: var(--s5);
}

.scale-row {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--s4);
  align-items: baseline;
  padding-bottom: var(--s4);
  border-bottom: var(--border-w) solid var(--border);
}

.scale-row code {
  color: var(--fg-2);
  font-size: var(--fs-xs);
}

.scale-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rules {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: var(--s2);
  color: var(--fg-2);
  max-width: var(--measure);
}

.rules li::marker {
  color: var(--accent-text);
}

/* Space */
.space-scale {
  display: grid;
  gap: var(--s2);
}

.space-scale div {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  align-items: center;
  gap: var(--s3);
}

.space-scale span {
  height: 1rem;
  background: var(--accent);
  border-radius: 2px;
  justify-self: start;
}

.space-scale small {
  grid-column: 2;
  color: var(--fg-3);
  font-size: var(--fs-xs);
  margin-top: -6px;
}

.space-scale code {
  color: var(--fg-2);
  font-size: var(--fs-xs);
}

.radii {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--s4);
}

.radii div {
  display: grid;
  gap: var(--s2);
  font-size: var(--fs-xs);
}

.radii span {
  height: 4rem;
  border: 2px solid var(--fg);
  border-bottom-color: var(--accent);
  border-right-color: var(--accent);
}

.radii code {
  color: var(--fg-2);
}

.radii small {
  color: var(--fg-3);
}

/* Demos */
.demo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
  padding: var(--s5);
  border: var(--border-w) dashed var(--border-strong);
  border-radius: var(--r3);
}

.demo + .demo {
  margin-top: var(--s3);
}

.demo.stack {
  display: grid;
  gap: var(--s5);
}

.demo .inline {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.durations {
  place-items: stretch;
  align-content: center;
  gap: var(--s3);
}

.durations div {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: var(--s3);
  font-size: var(--fs-sm);
  align-items: baseline;
}

.durations code {
  color: var(--accent-text);
}

.durations small {
  color: var(--fg-2);
}

.flip {
  color: var(--fg);
}

.flip-cell {
  transition:
    fill var(--dur-4) var(--ease-out),
    stroke var(--dur-4) var(--ease-out),
    filter var(--dur-4) var(--ease-out);
}

.flip.on .flip-cell {
  fill: var(--accent);
  stroke: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent));
}

/* Files */
.files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.files li {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: var(--border-w) solid var(--border);
  font-size: var(--fs-sm);
  align-items: baseline;
}

.files a {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.files small {
  color: var(--fg-2);
}

.code {
  margin: 0;
  padding: var(--s4) var(--s5);
  background: var(--surface);
  border: var(--border-w) solid var(--border);
  border-radius: var(--r3);
  overflow-x: auto;
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
}

.code code {
  font-size: inherit;
}

.doc-foot {
  display: flex;
  justify-content: space-between;
  padding-top: var(--s6);
  border-top: var(--border-w) solid var(--border);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

/* Responsive */
@media (max-width: 64rem) {
  body {
    /* minmax(0, ...) so the scrolling toc's content width cannot widen the whole page */
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    min-width: 0;
    position: sticky;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--s4);
    padding: var(--s3) var(--gutter);
    border-right: 0;
    border-bottom: var(--border-w) solid var(--border);
    background: var(--bg);
    z-index: 5;
  }

  .toc {
    display: flex;
    overflow-x: auto;
    gap: var(--s1);
    flex: 1;
    min-width: 0; /* a flex child does not shrink below its content without this, and the row would overflow */
    scrollbar-width: none;
  }

  .toc::-webkit-scrollbar {
    display: none;
  }

  .toc a {
    white-space: nowrap;
    padding: var(--s2);
  }

  .toc a[aria-current="true"] {
    box-shadow: inset 0 -2px 0 var(--accent);
  }

  .theme {
    margin-top: 0;
  }

  .theme span,
  .version,
  .brand-sub {
    display: none;
  }

  .doc {
    padding-top: var(--s6);
  }

  .sec {
    scroll-margin-top: 5rem;
  }

  .principles,
  .row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .radii {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 40rem) {
  .row-2,
  .principles,
  .row-4 {
    grid-template-columns: 1fr;
  }

  .scale-row,
  .files li {
    grid-template-columns: 1fr;
    gap: var(--s1);
  }

  .specimen-display {
    font-size: 4rem;
  }

  .radii {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
