/* ==========================================================================
   Experiment pages — the write up of a single experiment

   Shared by every experiment page. Base, navigation, chain, steps, and footer
   come from styles.css; all values come from tokens.css.
   ========================================================================== */

.backlink {
  display: inline-block;
  margin-bottom: var(--space-8);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  transition: color var(--duration-fast) var(--ease);
}

.backlink:hover {
  color: var(--accent);
}

/* ==========================================================================
   Gameplay film

   A poster and a play control that behave as a link to YouTube until the page
   script swaps in an inline player, so no third party code loads unasked.
   ========================================================================== */

.film {
  margin-top: var(--space-16);
}

/* The clip is an ultrawide strip, so the frame matches it rather than
   letterboxing a 16:9 box around it. */
.film__frame {
  position: relative;
  display: block;
  aspect-ratio: 1920 / 574;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.film__poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--duration-medium) var(--ease);
}

.film__frame:hover .film__poster {
  opacity: 0.88;
}

.film__play {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: calc(var(--unit) * 5);
  height: calc(var(--unit) * 5);
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 92%, transparent);
  box-shadow: var(--shadow-lg);
  transition: transform var(--duration-fast) var(--ease),
    background-color var(--duration-fast) var(--ease);
}

/* Triangle drawn with borders so there is no extra markup or asset. */
.film__play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  translate: -50% -50%;
  border-style: solid;
  border-width: calc(var(--unit) * 0.85) 0 calc(var(--unit) * 0.85) calc(var(--unit) * 1.4);
  border-color: transparent transparent transparent var(--accent-contrast);
}

.film__frame:hover .film__play {
  transform: scale(1.06);
  background: var(--accent-hover);
}

.film__cue {
  position: absolute;
  left: 50%;
  bottom: var(--space-8);
  translate: -50% 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface-sunken) 82%, transparent);
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.film__frame iframe,
.film__frame video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.film__caption {
  max-width: 40em;
  margin: var(--space-6) auto 0;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

/* ==========================================================================
   Beats — a single line given a screen of its own
   ========================================================================== */

.beat {
  margin: var(--space-12) 0;
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-regular);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  text-align: center;
  text-wrap: balance;
}

.beat--split {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-4) var(--space-6);
}

.beat__a {
  background-image: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.beat__or {
  font-size: var(--text-lg);
  color: var(--text-tertiary);
}

.beat__b {
  color: var(--text-secondary);
}

/* ==========================================================================
   The loop diagram
   ========================================================================== */

.cycle {
  max-width: calc(var(--unit) * 34);
  margin: var(--space-16) auto 0;
}

.cycle svg {
  width: 100%;
  height: auto;
}

.cycle__ring {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1;
  stroke-dasharray: 3 7;
}

.cycle__arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 70 433;
  transform-origin: 190px 110px;
  animation: cycle-spin 6s linear infinite;
}

@keyframes cycle-spin {
  to {
    transform: rotate(360deg);
  }
}

.cycle__nodes circle {
  fill: var(--surface-base);
  stroke: var(--accent);
  stroke-width: 2;
}

.cycle__labels text {
  fill: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
}

/* ==========================================================================
   The headline result
   ========================================================================== */

.result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-12);
  align-items: center;
  margin-top: var(--space-8);
}

.result__dial {
  position: relative;
  width: calc(var(--unit) * 17);
  max-width: 100%;
  margin: 0;
}

.result__dial svg {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
}

.result__track {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 10;
}

/* r=86 gives a circumference of 540.4; 90% of it is 486.4. */
.result__value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 486.4 540.4;
}

.result__centre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* Deliberately the largest number on the page. The cap holds it to the same
   share of the dial it had at the original scale. */
.result__figure {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, calc(var(--unit) * 4.75));
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
  line-height: 1;
  background-image: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result__label {
  font-family: var(--font-display);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Callout — the distinction this experiment draws
   ========================================================================== */

/* The width of the accuracy paragraph beside the dial, so the two blocks in
   this section match. */
.callout {
  max-width: calc(100% - var(--unit) * 17 - var(--space-12));
  margin: var(--space-16) 0 0;
  padding: var(--space-8);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-base));
}

.callout__tag {
  margin-bottom: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
}

.callout__body {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.callout__body a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
}

/* ==========================================================================
   Methodology — the technical layer, collapsed by default
   ========================================================================== */

.method {
  margin-top: var(--space-12);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-base);
}

.method__summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-8);
  cursor: pointer;
  list-style: none;
}

.method__summary::-webkit-details-marker {
  display: none;
}

.method__summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.method__title {
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: var(--weight-medium);
}

.method__hint {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.method__chevron {
  width: calc(var(--unit) * 0.65);
  height: calc(var(--unit) * 0.65);
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  rotate: 45deg;
  transition: rotate var(--duration-medium) var(--ease);
}

.method[open] .method__chevron {
  rotate: 225deg;
}

.method__body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-8);
  padding: 0 var(--space-8) var(--space-8);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-8);
}

.method__item h3 {
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.method__item p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.method__item a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
}

.method__item p + p {
  margin-top: var(--space-3);
}

.details__next {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-12);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
  .result {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
    gap: var(--space-8);
  }

  .method__body {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }

  .callout {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .film__play {
    width: calc(var(--unit) * 3.5);
    height: calc(var(--unit) * 3.5);
  }

  .film__play::before {
    border-width: calc(var(--unit) * 0.6) 0 calc(var(--unit) * 0.6) var(--unit);
  }

  .film__cue {
    bottom: var(--space-4);
    font-size: var(--text-xs);
  }

  /* The hint wraps under the title once a column beside it would be
     narrower than its longest word. */
  .method__summary {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: var(--space-2);
  }

  .method__hint {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .method__summary,
  .method__body {
    padding-inline: var(--space-6);
  }

  .callout {
    padding: var(--space-6);
  }
}

/* ==========================================================================
   Gameplay beside the loop that defines the experiment
   ========================================================================== */

.pair {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: var(--space-8);
  align-items: center;
  margin-top: var(--space-16);
}

.film--flush {
  margin-top: 0;
}

.film__frame--tall {
  aspect-ratio: 4 / 3;
}

.cycle--five {
  max-width: none;
  margin-top: 0;
}

.cycle--five .cycle__arc {
  stroke-dasharray: 86 530;
  transform-origin: 210px 150px;
}

.cycle__caption {
  max-width: 25.5em;
  margin: var(--space-6) auto 0;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

/* ==========================================================================
   Outcomes of an action
   ========================================================================== */

.outcomes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-12);
}

.outcome {
  padding: var(--space-6) var(--space-8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.outcome--good {
  border-color: var(--accent-border);
}

.outcome--bad {
  border-color: var(--border-strong);
}

.outcome__tag {
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.outcome--good .outcome__tag {
  color: var(--accent);
}

.outcome__body {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

/* ==========================================================================
   Headline numbers
   ========================================================================== */

.marks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.mark {
  padding: var(--space-8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-base);
}

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

.mark__figure {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
  line-height: 1;
  color: var(--text-primary);
}

/* The peak dodge rate is the number to remember, so only it takes the gradient. */
.mark--hero .mark__figure {
  background-image: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mark__label {
  margin-top: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.mark__body {
  margin-top: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

/* ==========================================================================
   Charts
   ========================================================================== */

.chart {
  margin-top: var(--space-16);
}

.chart svg {
  width: 100%;
  height: auto;
}

.chart__grid {
  stroke: var(--border-subtle);
  stroke-width: 1;
}

.chart__area {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
}

.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__line--muted {
  stroke: var(--text-tertiary);
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.chart__point {
  fill: var(--accent);
  stroke: var(--surface-sunken);
  stroke-width: 3;
}

.chart__point--muted {
  fill: var(--text-tertiary);
}

.chart__gap {
  stroke: var(--text-tertiary);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.chart__tick,
.chart__axis {
  fill: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart__axis {
  font-family: var(--font-display);
  font-size: 12px;
}

.chart__note {
  fill: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 13px;
}

.chart__note--hi {
  fill: var(--accent);
}

.chart__caption {
  max-width: 47em;
  margin: var(--space-6) auto 0;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  text-align: center;
}

/* ==========================================================================
   Resource comparison
   ========================================================================== */

.versus {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
  margin-top: var(--space-12);
}

.versus__name {
  margin-bottom: var(--space-6);
  font-family: var(--font-display);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.versus__row {
  display: grid;
  grid-template-columns: calc(var(--unit) * 9.5) 1fr calc(var(--unit) * 5.5);
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-4);
}

.versus__who {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.versus__bar {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-overlay);
  overflow: hidden;
}

/* The energy bar is deliberately tiny: that ratio is the point. A floor keeps
   it visible rather than rounding away to nothing. */
.versus__fill {
  display: block;
  min-width: 3px;
  height: 100%;
  border-radius: var(--radius-pill);
  background-image: var(--gradient-accent);
}

.versus__fill--alt {
  background-image: none;
  background-color: var(--text-tertiary);
}

.versus__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-primary);
  text-align: right;
}

.versus__ratio {
  margin-top: var(--space-4);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-sm);
}

.callout--scaling {
  max-width: none;
  margin-top: var(--space-12);
}

.callout__body + .callout__body {
  margin-top: var(--space-4);
}

/* The closing line of the argument, so it carries the gradient. */
.callout__punch {
  margin-top: var(--space-6);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-heading);
  background-image: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.versus__caveat {
  margin-top: var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1000px) {
  .pair,
  .versus {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-12);
  }

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

  .cycle--five {
    max-width: calc(var(--unit) * 30);
    margin-inline: auto;
  }
}

@media (max-width: 760px) {
  .outcomes {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .outcome,
  .mark {
    padding: var(--space-6);
  }

  .versus__row {
    grid-template-columns: 1fr calc(var(--unit) * 4.5);
    grid-template-areas: "who value" "bar bar";
    gap: var(--space-2) var(--space-3);
  }

  .versus__who {
    grid-area: who;
  }

  .versus__value {
    grid-area: value;
  }

  .versus__bar {
    grid-area: bar;
  }

  /* On a phone the chart is drawn at about half its design width, so the
     labels are set larger in chart units to land near caption size. */
  .chart__tick {
    font-size: 18px;
  }

  .chart__axis {
    font-size: 19px;
  }

  .chart__note {
    font-size: 21px;
  }
}
