/* Reusable pieces: cards, lesson blocks, filters, the search palette and toasts. */

.card {
  position: relative;
  display: block;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.card--link:hover {
  border-color: var(--accent-line);
  color: var(--text);
  transform: translateY(-2px);
}

.card--link::after {
  --c: var(--accent);
  content: '';
  position: absolute;
  inset: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  background:
    linear-gradient(var(--c), var(--c)) top left / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 1px 10px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 10px 1px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 1px 10px no-repeat;
}

.card--link:hover::after {
  opacity: 1;
}

.card h3 {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 600;
}

.card p:not(.eyebrow) {
  color: var(--mute);
  font-size: 14.5px;
}

/* Lesson typography */
.lesson__body > * + * {
  margin-top: 18px;
}

.lesson__body p,
.page p {
  font-size: 16.5px;
  line-height: 1.7;
}

.lesson__body .lead {
  color: var(--ink);
  font-size: 19.5px;
  line-height: 1.6;
}

.lesson__body h2 {
  margin-top: 40px;
  font-size: 23px;
  font-weight: 600;
  font-stretch: 105%;
}

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

.list li {
  position: relative;
  margin: 9px 0;
  padding-left: 24px;
  line-height: 1.65;
}

.list li::before {
  content: '';
  position: absolute;
  top: 0.62em;
  left: 5px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
}

.list--numbered {
  counter-reset: step;
}

.list--numbered li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  top: 0.2em;
  left: 0;
  width: auto;
  height: auto;
  background: none;
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 11px;
  transform: none;
}

.list--numbered li {
  padding-left: 28px;
}

/* Steps along a dashed route, like waypoints. */
.steps {
  margin: 24px 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 16px;
  padding-bottom: 18px;
}

.step:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 44px;
  bottom: 2px;
  left: 20px;
  border-left: 1px dashed var(--accent-line);
}

.step__n {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
}

.step__title {
  margin: 9px 0 3px;
  color: var(--accent);
  font-size: 16.5px;
  font-weight: 600;
}

.lesson__body .step__text {
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.6;
}

/* Callouts */
.callout {
  --tone: var(--accent);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--tone);
  border-radius: 12px;
  background: var(--surface);
}

.callout[data-tone='note'] {
  --tone: var(--blue);
}

.callout[data-tone='warn'] {
  --tone: var(--danger);
}

.callout[data-tone='draft'] {
  border-style: dashed;
  border-left-style: solid;
  background: var(--accent-soft);
}

.callout__label {
  margin-bottom: 6px;
  color: var(--tone);
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lesson__body .callout__text,
.page .callout__text {
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.65;
}

/* Prompts and code */
.prompt,
.code {
  margin-inline: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.prompt__head,
.code__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px 11px 14px;
  border-bottom: 1px solid var(--line);
}

.prompt__title,
.code__title {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.prompt__body,
.code__body {
  margin: 0;
  padding: 16px 18px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 4;
}

.prompt__body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code__body {
  overflow-x: auto;
  white-space: pre;
  scrollbar-width: thin;
}

.code__body code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  overflow-wrap: normal;
}

.ph {
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.tok-comment {
  color: var(--tok-comment);
  font-style: italic;
}

.tok-string {
  color: var(--tok-string);
}

.tok-number {
  color: var(--tok-number);
}

.tok-keyword {
  color: var(--tok-keyword);
}

.tok-key {
  color: var(--tok-key);
}

.code__note {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--mute);
  font-size: 14px;
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.copy:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}

.copy.is-done {
  border-color: var(--ok);
  color: var(--ok);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

th {
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--mute);
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  line-height: 1.55;
  vertical-align: top;
}

td:first-child {
  color: var(--ink);
  font-weight: 600;
}

/* Checklists */
.checklist {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.5;
  transition: border-color var(--dur) var(--ease);
}

.check:hover {
  border-color: var(--line-2);
}

.check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check__box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.5px solid var(--line-2);
  border-radius: 6px;
  color: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.check input:checked + .check__box {
  border-color: var(--accent-fill);
  background: var(--accent-fill);
  color: var(--on-accent);
}

.check input:checked ~ span:last-child {
  color: var(--mute);
}

.check input:focus-visible + .check__box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.swatch {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 13.5px;
}

.swatch__chip {
  height: 44px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.swatch code {
  width: fit-content;
  font-size: 11.5px;
}

.swatch__role {
  color: var(--mute);
  font-size: 12.5px;
}

/* Illustrations */
.art {
  margin: 0;
}

.lesson__body .art {
  margin-block: 28px;
}

.art__frame {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--art-line);
  border-radius: var(--r);
  background:
    radial-gradient(120% 90% at 75% 10%, rgba(243, 158, 33, 0.09), transparent 60%),
    var(--art-bg);
}

.art__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.art figcaption {
  margin-top: 10px;
  color: var(--mute);
  font-family: var(--f-mono);
  font-size: 12px;
}

.source {
  color: var(--blue);
  font-family: var(--f-mono);
  font-size: 11.5px !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Details */
details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform var(--dur) var(--ease);
}

details[open] summary::before {
  transform: rotate(45deg);
}

/* Filters */
.filter__bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.filter__input {
  flex: 1;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15.5px;
}

.filter__input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter__count {
  color: var(--mute);
  font-family: var(--f-mono);
  font-size: 11.5px !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}

.chip {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.chip:hover {
  border-color: var(--accent-line);
}

.chip[aria-pressed='true'] {
  border-color: transparent;
  background: var(--accent-fill);
  color: var(--on-accent);
}

.stack {
  display: grid;
  gap: 18px;
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  color: var(--mute);
  text-align: center;
}

.origin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0 4px;
  color: var(--mute);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

/* Search palette */
.palette {
  width: min(660px, calc(100vw - 32px));
  max-height: min(620px, 80vh);
  margin: 11vh auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.85);
}

.palette[open] {
  animation: rise 240ms var(--ease);
}

.palette::backdrop {
  background: rgba(1, 8, 18, 0.62);
  backdrop-filter: blur(3px);
}

.palette__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--mute);
}

.palette__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
}

.palette__list {
  max-height: 52vh;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
}

.palette__item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.palette__item[aria-selected='true'] {
  background: var(--accent-soft);
}

.palette__item .pill {
  justify-self: start;
}

.palette__text strong,
.palette__text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette__text strong {
  font-size: 14.5px;
}

.palette__text small {
  color: var(--mute);
  font-family: var(--f-mono);
  font-size: 11px;
}

.palette__empty {
  padding: 22px;
  color: var(--mute);
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast:empty {
  display: none;
}
