/* Interactive experiments */

.ix-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 576px) {
  .ix-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.ix-card a {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--global-divider-color);
  border-radius: 10px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--global-bg-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ix-card a:hover,
.ix-card a:focus-visible {
  transform: translateY(-3px);
  border-color: var(--global-theme-color);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.ix-card svg {
  display: block;
  width: 100%;
  height: auto;
  background: #faf9f7;
}

.ix-card-body {
  padding: 0.9rem 1rem 1.1rem;
}

.ix-card-kicker {
  display: block;
  font-family: var(--cococo-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--global-theme-color);
  margin-bottom: 0.3rem;
}

.ix-card-title {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.ix-card-text {
  display: block;
  font-size: 0.9rem;
  color: var(--global-text-color-light);
  line-height: 1.45;
}

.ix-highlight {
  margin: 2.5rem 0 1rem;
  padding: 1.5rem 1.5rem 0.75rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(179, 27, 27, 0.05), rgba(179, 27, 27, 0) 60%), #fcfbfa;
  border: 1px solid var(--global-divider-color);
}

.ix-highlight h2 {
  margin-top: 0;
}

.ix-highlight > p {
  color: var(--global-text-color-light);
}

/* Demo pages */

.ix-demo {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 14px;
  background: #fcfbfa;
}

.ix-demo canvas {
  display: block;
  width: 100%;
  touch-action: manipulation;
}

.ix-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0;
}

.ix-button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--global-theme-color);
  background: var(--global-theme-color);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.ix-button.secondary {
  background: transparent;
  color: var(--global-theme-color);
}

.ix-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.ix-pad {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 120px;
  margin: 0.75rem 0;
  border-radius: 12px;
  border: 2px dashed var(--global-divider-color);
  font-family: var(--cococo-mono, monospace);
  font-size: 0.95rem;
  color: var(--global-text-color-light);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: background 0.08s ease, border-color 0.08s ease;
}

.ix-pad.active {
  border-color: var(--global-theme-color);
  color: var(--global-text-color);
}

.ix-pad.flash {
  background: rgba(179, 27, 27, 0.08);
}

.ix-status {
  font-family: var(--cococo-mono, monospace);
  font-size: 0.85rem;
  color: var(--global-text-color-light);
  min-height: 1.4em;
}

.ix-result {
  margin-top: 1rem;
  font-size: 1.05rem;
}

.ix-result strong {
  color: var(--global-theme-color);
}

.ix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--global-text-color-light);
}

.ix-legend li::before {
  content: '';
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  vertical-align: -0.1rem;
  background: var(--swatch);
}

.ix-note {
  font-size: 0.85rem;
  color: var(--global-text-color-light);
  border-left: 3px solid var(--global-divider-color);
  padding-left: 0.8rem;
  margin: 1.25rem 0;
}

.ix-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 700px) {
  .ix-split {
    grid-template-columns: 1fr;
  }
}

.ix-swatch {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: background-color 0.05s linear;
}

.ix-word {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0.25rem 0 0.75rem;
}

.ix-slider {
  width: 100%;
  margin: 1rem 0 0.25rem;
  accent-color: var(--global-theme-color);
}

@media (pointer: coarse) {
  .ix-slider {
    height: 2.5rem;
  }
}

.ix-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 0.75rem;
}

.ix-chain span {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.ix-metrics {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-family: var(--cococo-mono, monospace);
  font-size: 0.9rem;
}

.ix-metrics b {
  font-size: 1.3rem;
  color: var(--global-text-color);
}

.ix-tabs {
  display: inline-flex;
  border: 1px solid var(--global-divider-color);
  border-radius: 999px;
  overflow: hidden;
}

.ix-tabs button {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.35rem 0.9rem;
  border: 0;
  background: transparent;
  color: var(--global-text-color);
  cursor: pointer;
}

.ix-tabs button[aria-pressed='true'] {
  background: var(--global-theme-color);
  color: #fff;
}

input[type='range'].ix-scrub {
  flex: 1 1 200px;
  accent-color: var(--global-theme-color);
}

/* Living contours behind the home page title */

body.home .post-header {
  position: relative;
  isolation: isolate;
}

.ix-contours {
  position: absolute;
  top: -2rem;
  left: 0;
  width: 100%;
  height: calc(100% + 3rem);
  z-index: -1;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 50% 50%, #000 40%, transparent 100%);
  mask-image: radial-gradient(ellipse 70% 80% at 50% 50%, #000 40%, transparent 100%);
}

.ix-demo ol.chain {
  list-style: none;
  padding-left: 0;
}

.ix-demo ol.chain span {
  display: inline-block;
  min-width: 7.5em;
}

.ix-tabs.wrap {
  flex-wrap: wrap;
  border-radius: 12px;
}

.ix-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.ix-palette li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.ix-palette span {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* Step-by-step experiments */

.ix-steps section {
  padding: 0.25rem 0 1.25rem;
  border-bottom: 1px solid var(--global-divider-color);
  margin-bottom: 1.25rem;
}

.ix-steps section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.ix-steps h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  margin: 0.5rem 0 0.6rem;
}

.ix-num {
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  flex: none;
  border-radius: 50%;
  background: var(--global-theme-color);
  color: #fff;
  font-family: var(--cococo-mono, monospace);
  font-size: 0.85rem;
  font-weight: 600;
}

.ix-steps section[hidden] {
  display: none;
}

.ix-steps section:not([hidden]) {
  animation: ix-rise 0.45s ease both;
}

@keyframes ix-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ix-steps section:not([hidden]) {
    animation: none;
  }
}

.ix-instruction {
  margin: 0.5rem 0 0.9rem;
  padding: 0.9rem 1.1rem;
  border: 0;
  border-left: 4px solid var(--global-theme-color);
  border-radius: 0 10px 10px 0;
  background: #fff;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--global-text-color);
}

.ix-kicker,
.cs-kicker {
  font-family: var(--cococo-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--global-theme-color);
  margin: 0 0 0.35rem;
}

.ix-caption {
  font-size: 0.88rem;
  color: var(--global-text-color-light);
  align-self: center;
}

.ix-dial-row {
  margin-top: 1rem;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
}

.ix-dial-row canvas {
  max-width: 320px;
}

.ix-scale,
.ix-choice {
  border: 0;
  padding: 0;
  margin: 0.75rem 0;
}

.ix-scale legend,
.ix-choice legend {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.ix-scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.ix-scale .end {
  font-size: 0.82rem;
  color: var(--global-text-color-light);
}

.ix-scale label {
  margin: 0;
  cursor: pointer;
}

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

.ix-scale label span {
  display: inline-grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  border: 1px solid var(--global-divider-color);
  background: #fff;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ix-scale input:focus-visible + span {
  outline: 2px solid var(--global-theme-color);
  outline-offset: 2px;
}

.ix-scale input:checked + span {
  background: var(--global-theme-color);
  border-color: var(--global-theme-color);
  color: #fff;
}

.ix-scale:disabled {
  opacity: 0.4;
}

.ix-choice label {
  display: block;
  margin: 0.35rem 0;
}

.ix-bars {
  display: grid;
  gap: 0.45rem;
  margin: 0.75rem 0;
}

.ix-bars .bar {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr) 6rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.ix-bars .track {
  height: 0.7rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.ix-bars .track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #b31b1b;
  transform-origin: left;
  animation: ix-grow 0.8s ease both;
}

.ix-bars .expert .track span {
  background: #222;
}

.ix-bars .you .track span {
  background: #2f6fd6;
}

@keyframes ix-grow {
  from {
    transform: scaleX(0);
  }
}

.ix-bars small {
  color: var(--global-text-color-light);
}

@media (max-width: 576px) {
  .ix-bars .bar {
    grid-template-columns: 1fr 4.5rem;
  }

  .ix-bars .track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  /* Keep 1-7 on one row, with the end labels beneath their ends */
  .ix-scale {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    justify-items: center;
    gap: 0.4rem 0.2rem;
  }

  .ix-scale .end {
    grid-row: 2;
    grid-column: 1 / span 4;
    justify-self: start;
  }

  .ix-scale .end:last-child {
    grid-column: 4 / span 4;
    justify-self: end;
  }

  /* The fixed back-to-top button covers the controls on small screens */
  body:has(.ix-demo) #back-to-top {
    display: none;
  }
}

/* Citizen-science consent and status */

.cs-panel {
  margin: 1.25rem 0;
}

.cs-line {
  font-size: 0.88rem;
  color: var(--global-text-color-light);
  border-left: 3px solid var(--global-divider-color);
  padding-left: 0.8rem;
}

.cs-badge {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--global-divider-color);
  font-family: var(--cococo-mono, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--global-text-color);
  background: #fff;
}

.cs-badge.on {
  border-color: #2e7d4f;
  color: #2e7d4f;
}

.cs-consent,
.cs-about {
  padding: 1.25rem 1.4rem;
  border-radius: 14px;
  border: 1px solid var(--global-divider-color);
  background: linear-gradient(135deg, rgba(179, 27, 27, 0.05), rgba(179, 27, 27, 0) 55%), #fff;
}

.cs-consent h3 {
  margin-top: 0;
}

.cs-check {
  display: block;
  margin: 0.4rem 0;
  font-weight: 500;
}

.cs-about fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 0.8rem;
}

.cs-about legend {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.cs-about fieldset label {
  display: inline-block;
  margin: 0 0.9rem 0.25rem 0;
  font-size: 0.9rem;
}

.cs-link {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 0.5rem;
  color: var(--global-theme-color);
  text-decoration: underline;
  font: inherit;
  cursor: pointer;
}

.ix-vocab {
  margin-bottom: 1.25rem;
  padding: 1rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--global-divider-color);
  background: #fff;
}

.ix-swatch.small {
  max-width: 220px;
  margin-bottom: 0.75rem;
}

/* "Try it yourself" callouts on project pages */

p.ix-try {
  position: relative;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem 1rem 3.4rem;
  border-radius: 12px;
  border: 1px solid var(--global-divider-color);
  background: linear-gradient(110deg, rgba(179, 27, 27, 0.07), rgba(179, 27, 27, 0) 60%), #fcfbfa;
}

p.ix-try::before {
  content: '';
  position: absolute;
  left: 1.1rem;
  top: 1.15rem;
  width: 1.4rem;
  height: 1.25rem;
  background: var(--global-theme-color);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

p.ix-try strong:first-child {
  display: block;
  font-family: var(--cococo-mono, monospace);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--global-theme-color);
}

/* Section headings on experiment pages */

.ix-demo ~ h3,
.post-content > h3 {
  position: relative;
  padding-bottom: 0.35rem;
}

.ix-demo ~ h3::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.5rem;
  height: 2px;
  background: var(--global-theme-color);
}

/* Sources strip under an experiment's title */
.ix-sources { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 1.75rem; }
.ix-source {
  display: inline-flex; flex-direction: column; gap: 0.1rem;
  padding: 0.45rem 0.85rem 0.5rem; border-radius: 10px;
  border: 1px solid var(--global-divider-color); background: #fcfbfa;
  text-decoration: none !important; color: var(--global-text-color);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.ix-source:hover { border-color: var(--global-theme-color); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(179, 27, 27, 0.08); }
.ix-source-kind { font-family: var(--cococo-mono, monospace); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--global-theme-color); }
.ix-source-name { font-size: 0.86rem; line-height: 1.2; }

/* "Where this comes from": the original study, then related work */
.ix-refs { margin: 0.5rem 0 1.5rem; }
.ix-ref-origin {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.9rem 1.1rem 1rem; border-radius: 12px;
  border: 1px solid var(--global-divider-color); border-left: 3px solid var(--global-theme-color);
  background: #fcfbfa; text-decoration: none !important; color: var(--global-text-color);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.ix-ref-origin:hover { border-color: var(--global-theme-color); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(179, 27, 27, 0.08); }
.ix-ref-title { font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.ix-ref-origin:hover .ix-ref-title { color: var(--global-theme-color); }
.ix-ref-meta { display: block; font-size: 0.84rem; color: var(--global-text-color-light); }
.ix-ref-meta strong { font-weight: 600; }
.ix-ref-note { display: block; font-size: 0.88rem; line-height: 1.45; }
.ix-ref-head {
  margin: 1.25rem 0 0.5rem; font-family: var(--cococo-mono, monospace); font-size: 0.7rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--global-text-color-light);
}
.ix-ref-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.ix-ref-list li { padding-left: 0.85rem; border-left: 1px solid var(--global-divider-color); }
.ix-ref-list a { font-weight: 600; }

/* Integrity helpers: invisible to people, present in the page */
.cs-canary,
.cs-hp {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.cs-toast {
  position: fixed;
  right: 1rem;
  bottom: 3.5rem;
  z-index: 1050;
  max-width: 360px;
  padding: 1rem 1.1rem 0.6rem;
  border-radius: 14px;
  border: 1px solid var(--global-divider-color);
  background: #fff;
  box-shadow: 0 14px 40px rgba(30, 20, 20, 0.16);
  font-size: 0.92rem;
  animation: ix-rise 0.4s ease both;
}

.cs-toast p {
  margin-bottom: 0.5rem;
}

.ix-cons-chart { touch-action: pan-y; }
.ix-demo[data-ix="consonance"] .ix-cons-cursor { min-height: 1.4em; margin: 0.25rem 0 0.5rem; }
