/* Shared chrome and bento primitives for the journal, collections and (soon) lessons.
   Needs assets/theme.css first. Class names are prefixed so they never collide with
   legacy lab CSS (.site-header, .topbar, nav, footer ...). All colours come from theme
   tokens; tiles pick a colour family with .tile-<sun|indigo|coral|mint|lilac|pink|sky>.

   Components
     .chrome-header     sticky header: round brand mark + name, pill nav, theme toggle
     .chrome-breadcrumb optional trail under the header
     .chrome-footer     quiet footer
     .chrome-container  wide centred column (--container) with responsive gutters
     .chrome-skip       skip link
     .chip-list / .chip pill tags (inherit the surrounding ink)
     .chip-button       pill filter button; aria-pressed marks the choice
     .badge             small uppercase eyebrow label
     .btn / .btn-primary  pill action link
     .tile              rounded colour block with hard ink edge; .tile-<colour>
       .tile-eyebrow .tile-state .tile-blurb .tile-go .tile-art (inline SVG art)
       a.tile is one link; for a tile holding other links use an h2/h3 link with
       .tile-stretch (covers the tile) and lift the inner links with position: relative */

.chrome-container,
.tile,
.btn {
  box-sizing: border-box;
}

.chrome-skip {
  position: absolute;
  top: -4rem;
  left: var(--space-3);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius-md);
  font: 800 var(--text-sm) / 1.4 var(--body-font);
}

.chrome-skip:focus {
  top: var(--space-2);
}

.chrome-container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header */
.chrome-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  border-bottom: 2px solid var(--tile-edge);
}

.chrome-header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-h);
}

.chrome-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  font: 800 1.15rem / 1 var(--heading-font);
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.chrome-mark {
  display: grid;
  place-items: center;
  width: 2.125rem;
  height: 2.125rem;
  color: var(--tile-sun-ink);
  background: var(--tile-sun);
  border: 2px solid var(--tile-edge);
  border-radius: 50%;
  font: 800 0.95rem / 1 var(--heading-font);
}

.chrome-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

.chrome-nav a {
  padding: var(--space-2) 0.875rem;
  color: var(--ink);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  font: 800 0.95rem / 1.2 var(--body-font);
  text-decoration: none;
}

.chrome-nav a:hover {
  background: var(--tile-chip);
  border-color: var(--tile-edge);
}

.chrome-nav a[aria-current] {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

/* Breadcrumb: <nav class="chrome-breadcrumb"><ol><li><a>…</a></li><li aria-current="page">…</li></ol></nav> */
.chrome-breadcrumb {
  padding-block: var(--space-4) 0;
  font: 700 var(--text-sm) / 1.4 var(--body-font);
}

.chrome-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.chrome-breadcrumb li + li::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--line-strong);
}

.chrome-breadcrumb a {
  color: var(--muted);
  text-underline-offset: 3px;
}

.chrome-breadcrumb a:hover {
  color: var(--ink);
}

.chrome-breadcrumb [aria-current] {
  color: var(--ink);
}

/* Footer */
.chrome-footer {
  margin-top: var(--space-7);
  padding-block: var(--space-5) var(--space-6);
  border-top: 2px solid var(--tile-edge);
  color: var(--muted);
  font: 700 var(--text-sm) / 1.5 var(--body-font);
}

.chrome-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
}

.chrome-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}

.chrome-footer a {
  color: var(--ink);
  text-underline-offset: 3px;
}

.chrome-footer a:hover {
  text-decoration-thickness: 2px;
}

/* Pill tags and filters: the border and text follow the surrounding ink. */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 4px 9px;
  color: inherit;
  border: 2px solid currentcolor;
  border-radius: var(--radius-pill);
  font: 800 0.74rem / 1 var(--body-font);
}

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--tile-edge);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font: 800 0.92rem / 1.2 var(--body-font);
}

.chip-button:hover {
  background: var(--tile-chip);
}

.chip-button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
}

.chip-button[aria-pressed="true"]::before {
  content: "\2713";
}

.chip-count {
  font-weight: 700;
  opacity: 0.85;
}

.badge {
  font: 800 0.78rem / 1.2 var(--body-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Actions */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  color: inherit;
  background: transparent;
  border: 2px solid currentcolor;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font: 800 var(--text-sm) / 1.3 var(--body-font);
  text-decoration: none;
}

.btn:hover {
  background: var(--tile-chip);
}

.btn-primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Tiles */
.tile {
  --tb: var(--tile-sun);
  --ti: var(--tile-sun-ink);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 20px 20px 18px;
  overflow: hidden;
  color: var(--ti);
  background: var(--tb);
  border: 2px solid var(--tile-edge);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 0 var(--tile-edge);
  text-decoration: none;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s, opacity 0.3s, filter 0.3s;
}

.tile[hidden] {
  display: none;
}

.tile-sun {
  --tb: var(--tile-sun);
  --ti: var(--tile-sun-ink);
}

.tile-indigo {
  --tb: var(--tile-indigo);
  --ti: var(--tile-indigo-ink);
}

.tile-coral {
  --tb: var(--tile-coral);
  --ti: var(--tile-coral-ink);
}

.tile-mint {
  --tb: var(--tile-mint);
  --ti: var(--tile-mint-ink);
}

.tile-lilac {
  --tb: var(--tile-lilac);
  --ti: var(--tile-lilac-ink);
}

.tile-pink {
  --tb: var(--tile-pink);
  --ti: var(--tile-pink-ink);
}

.tile-sky {
  --tb: var(--tile-sky);
  --ti: var(--tile-sky-ink);
}


a.tile:hover,
a.tile:focus-visible,
.tile:has(a.tile-stretch:hover),
.tile:has(a.tile-stretch:focus-visible) {
  box-shadow: 0 9px 0 var(--tile-edge);
  transform: translateY(-5px);
}

.tile:has(a.tile-stretch:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

a.tile-stretch {
  color: inherit;
  text-decoration: none;
}

a.tile-stretch::after {
  content: "";
  position: absolute;
  inset: 0;
}

a.tile-stretch:focus-visible {
  outline: none;
}

.tile.dim {
  opacity: 0.55;
  filter: saturate(0.45);
}

.tile.dim:hover {
  opacity: 0.9;
  filter: none;
}

.tile h1,
.tile h2,
.tile h3 {
  margin: 0;
  font-family: var(--heading-font);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.02;
}

.tile h3 {
  font-size: clamp(1.45rem, 2.1vw, 1.9rem);
}

.tile-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font: 800 0.78rem / 1.2 var(--body-font);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tile-state {
  padding: 1px 8px;
  border: 2px solid currentcolor;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

.tile-state:empty {
  display: none;
}

.tile-blurb {
  max-width: 30ch;
  margin: 0;
  font: 600 0.98rem / 1.4 var(--body-font);
}

.tile-go {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  align-self: flex-start;
  margin-top: auto;
  padding-bottom: 1px;
  border-bottom: 3px solid currentcolor;
  font: 800 var(--text-base) / 1.3 var(--body-font);
}

.tile-go b {
  display: inline-block;
  transition: transform 0.2s;
}

a.tile:hover .tile-go b,
.tile:has(a.tile-stretch:hover) .tile-go b,
.tile:has(a.tile-stretch:focus-visible) .tile-go b,
a.tile:focus-visible .tile-go b {
  transform: translateX(5px);
}

.tile-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 190px;
  margin-top: auto;
}

.tile-art .s {
  fill: none;
  stroke: currentcolor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-art .f {
  fill: var(--tile-fill);
  stroke: currentcolor;
  stroke-width: 2.5;
}

.tile-art .d {
  stroke-dasharray: 5 4;
}

.tile-art .solid {
  fill: currentcolor;
}

.tile-art .arc {
  fill: none;
  stroke: currentcolor;
  stroke-width: 10;
  stroke-linecap: round;
  opacity: 0.22;
}

.tile-art text {
  fill: currentcolor;
  font: 800 13px var(--body-font);
}

.tile-art text.inv {
  fill: var(--tb);
}

/* Staircase: modules as rising steps. Items are links (homepage) or .step spans (decorative). */
.stairs {
  container-type: inline-size;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: clamp(200px, 22vw, 240px);
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.stairs li {
  flex: 1 1 0;
  height: var(--h);
  min-width: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.stairs li:nth-child(1) {
  --h: 42%;
  --step: var(--step-1);
}
.stairs li:nth-child(2) {
  --h: 53.6%;
  --step: var(--step-2);
}
.stairs li:nth-child(3) {
  --h: 65.2%;
  --step: var(--step-3);
}
.stairs li:nth-child(4) {
  --h: 76.8%;
  --step: var(--step-4);
}
.stairs li:nth-child(5) {
  --h: 88.4%;
  --step: var(--step-5);
}
.stairs li:nth-child(6) {
  --h: 100%;
  --step: var(--step-6);
}

.stairs a,
.stairs .step {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px 4px 6px 10px;
  color: var(--step-ink);
  background: var(--step);
  border: 2px solid var(--step-edge);
  border-radius: 16px 16px 4px 4px;
  text-decoration: none;
}

.stairs a:hover {
  filter: brightness(1.08);
}

.step-word {
  font: 800 0.68rem / 1.1 var(--body-font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.step-num {
  font: 800 clamp(1.5rem, 3.2vw, 2.7rem) / 1 var(--heading-font);
  letter-spacing: -0.03em;
}

.step-name {
  margin-top: auto;
  font: 800 0.74rem / 1.1 var(--body-font);
  overflow-wrap: normal;
  white-space: nowrap;
  word-break: keep-all;
}

.stairs li.is-off a {
  opacity: 0.4;
}

.stairs li.is-match a::after {
  content: "\2713 topic";
  margin-top: 2px;
  font: 800 0.66rem / 1.1 var(--body-font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Narrow staircases: drop the "Module" word and turn the short name sideways so no word breaks. */
@container (max-width: 619px) {
  .step-word {
    display: none;
  }

  .step-name {
    align-self: flex-start;
    font-size: 0.7rem;
    transform: rotate(180deg);
    writing-mode: vertical-rl;
  }
}

@media (max-width: 520px) {
  .stairs {
    gap: 5px;
  }

  .stairs a,
  .stairs .step {
    padding: 6px 2px 4px 8px;
    border-radius: 12px 12px 3px 3px;
  }

  .stairs li.is-match a::after {
    content: "\2713";
  }
}

@media (max-width: 520px) {
  .chrome-header-inner {
    flex-wrap: wrap;
    padding-block: var(--space-2);
    row-gap: var(--space-2);
  }

  /* Compact header: the name collapses to the brand mark so mark, nav and toggle share one row. */
  .chrome-brand > span:last-child {
    display: none;
  }

  .chrome-nav {
    margin-left: auto;
  }

  .chrome-nav a {
    padding: var(--space-2) 0.625rem;
    font-size: 0.85rem;
  }

  .tile {
    padding: 18px 16px 16px;
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .stairs li,
  .tile-go b {
    transition: none;
  }

  a.tile:hover,
  a.tile:focus-visible,
  .tile:has(a.tile-stretch:hover),
  .tile:has(a.tile-stretch:focus-visible) {
    transform: none;
  }

  a.tile:hover .tile-go b,
  .tile:has(a.tile-stretch:hover) .tile-go b,
  .tile:has(a.tile-stretch:focus-visible) .tile-go b,
  a.tile:focus-visible .tile-go b {
    transform: none;
  }
}
