/* Shared G27 timing-chart walkthrough and 0–8 s trial timeline strip.
   Works on both index.html (experience-home tokens) and work.html (gallery tokens),
   stays strictly CSP-clean (no inline styles), and degrades to a plain 5-step
   ordered list when JavaScript is off. */

.g27x {
  --g27-card: var(--ground-raised, var(--card, #163029));
  --g27-ink: var(--ink, #e4efe8);
  --g27-muted: var(--ink-muted, var(--muted, #9db6ac));
  --g27-rule: var(--rule, var(--line, rgba(228, 239, 232, 0.18)));
  --g27-focus: var(--focus, #f3d68a);
  --g27-sans: var(--sans, var(--display, "Source Sans 3", system-ui, sans-serif));
  --g27-mono: var(--mono, var(--data, "DM Mono", ui-monospace, monospace));
  --g27-accent: #e5aed0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 1fr);
  gap: clamp(1.25rem, 2.8vw, 2.5rem);
  align-items: start;
  min-width: 0;
  font-family: var(--g27-sans);
}

.g27x__visual,
.g27x__walk {
  min-width: 0;
}

.g27x__plate {
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #0c1715;
  color: #e6f0ea;
  box-shadow: 0 0 0 1px rgba(228, 239, 232, 0.18);
}

.g27x__plot {
  position: relative;
  background: #0b1114;
}

.g27x__plot .plate__image,
.g27x__image-link {
  display: block;
  border-radius: 0;
  background: #0b1114;
}

.g27x__plot img {
  display: block;
  width: 100%;
  height: auto;
}

/* Separate x-axis highlight layer aligned to the 1720x980 PNG plot box:
   x = 0 s -> 138 px (8.0233%), x = 8 s -> 1686 px (98.0233%, width 90.0000%)
   y = 205..853 px -> top 20.9184%, height 66.1224% */
.g27x__overlay {
  position: absolute;
  left: 8.0233%;
  width: 90%;
  top: 20.9184%;
  height: 66.1224%;
  pointer-events: none;
  z-index: 2;
}

:root:not(.js) .g27x__overlay,
.g27x:not([data-active-step]) .g27x__overlay,
.g27x[data-active-step="all"] .g27x__overlay {
  display: none;
}

.g27x__overlay-tag {
  position: absolute;
  right: 0.35rem;
  top: -1.55rem;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  background: rgba(12, 23, 21, 0.9);
  border: 1px solid rgba(229, 174, 208, 0.45);
  color: #f3d7e8;
  font: 0.68rem/1.3 var(--g27-mono);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.g27x__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease-out;
}

.g27x[data-active-step="1"] .g27x__layer--step1,
.g27x[data-active-step="2"] .g27x__layer--step2,
.g27x[data-active-step="3"] .g27x__layer--step3,
.g27x[data-active-step="4"] .g27x__layer--step4,
.g27x[data-active-step="5"] .g27x__layer--step5 {
  opacity: 1;
  visibility: visible;
}

.g27x__band {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
}

.g27x__band-label {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  padding: 0.12rem 0.38rem;
  border-radius: 3px;
  background: rgba(10, 20, 18, 0.88);
  color: #eef6f1;
  font: 600 0.68rem/1.25 var(--g27-sans);
  white-space: nowrap;
}

.g27x__band--ready {
  left: 0%;
  width: 25%;
  background: rgba(169, 196, 185, 0.11);
  border-right: 2px solid rgba(235, 245, 240, 0.85);
}

.g27x__band--imagery {
  left: 25%;
  width: 18.75%;
  background: rgba(74, 154, 244, 0.18);
  border-right: 2px dashed rgba(243, 214, 138, 0.9);
}

.g27x__band--feedback {
  left: 43.75%;
  width: 56.25%;
  background: rgba(217, 110, 62, 0.13);
}

.g27x__band--window-35 {
  left: 31.25%;
  width: 12.5%;
  background: rgba(58, 134, 224, 0.24);
  border: 1px solid rgba(114, 178, 252, 0.85);
  border-right: 3px solid #6db2ff;
}

.g27x__band--window-425 {
  left: 40.625%;
  width: 12.5%;
  background: rgba(217, 90, 43, 0.24);
  border: 1px solid rgba(245, 135, 92, 0.88);
  border-right: 3px solid #ff9468;
}

.g27x__band--overlap {
  left: 43.75%;
  width: 9.375%;
  background: repeating-linear-gradient(
    -45deg,
    rgba(243, 214, 138, 0.34),
    rgba(243, 214, 138, 0.34) 4px,
    rgba(217, 90, 43, 0.22) 4px,
    rgba(217, 90, 43, 0.22) 8px
  );
  border-left: 2px dashed #f3d68a;
}

.g27x__band--chance-zone {
  left: 0%;
  width: 37.5%;
  background: rgba(160, 182, 174, 0.08);
  border-right: 2px dashed rgba(229, 174, 208, 0.85);
}

.g27x__band--rise-zone {
  left: 37.5%;
  width: 62.5%;
  background: rgba(229, 174, 208, 0.15);
}

.g27x__band-label--bottom {
  top: auto;
  bottom: 0.35rem;
}

/* Trial timeline strip directly below the PNG, aligned to 0..8 s */
.g27x__timeline {
  padding: 0.65rem 1.9767% 0.75rem 8.0233%;
  border-top: 1px solid rgba(228, 239, 232, 0.14);
  background: #10211d;
}

.g27x__timeline-title {
  margin: 0 0 0.35rem;
  font: 0.72rem/1.3 var(--g27-mono);
  color: #a8c0b6;
  letter-spacing: 0.02em;
}

.g27x__bar {
  display: grid;
  grid-template-columns: 25fr 18.75fr 56.25fr;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(228, 239, 232, 0.22);
}

.g27x__seg {
  min-width: 0;
  padding: 0.38rem 0.45rem;
  font-size: 0.76rem;
  line-height: 1.25;
  color: #eaf3ee;
}

.g27x__seg strong {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g27x__seg span {
  display: block;
  font: 0.69rem/1.25 var(--g27-mono);
  color: #c2d6cd;
}

.g27x__seg--ready {
  background: #1d332d;
}

.g27x__seg--imagery {
  background: #1a4673;
  border-left: 2px solid #eef6f1;
}

.g27x__seg--feedback {
  background: #512f20;
  border-left: 2px dashed #f3d68a;
}

.g27x__ticks {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  margin-top: 0.3rem;
  font: 0.7rem/1.3 var(--g27-mono);
  color: #9db6ac;
}

.g27x__legend {
  display: none;
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
  gap: 0.25rem;
  font-size: 0.76rem;
  line-height: 1.35;
  color: #d3e3dc;
}

.g27x__plate-foot,
.g27x__plate figcaption.g27x__plate-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem 1rem;
  padding: 0.55rem 0.85rem 0.65rem;
  border-top: 1px solid rgba(228, 239, 232, 0.12);
  background: #0c1715;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #a8c0b6;
}

.g27x__plate-foot p,
.g27x__plate figcaption.g27x__plate-foot p {
  margin: 0;
  color: #a8c0b6;
}

.g27x__plate-foot a,
.g27x__plate figcaption.g27x__plate-foot > a {
  color: #e4efe8;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Walkthrough panel */
.g27x__walk {
  padding: 1rem 1.1rem;
  border: 1px solid var(--g27-rule);
  border-radius: 6px;
  background: var(--g27-card);
  color: var(--g27-ink);
}

.g27x__kicker {
  margin: 0 0 0.55rem;
  font: 0.76rem/1.3 var(--g27-mono);
  color: var(--g27-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.g27x__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--g27-rule);
}

:root:not(.js) .g27x__controls {
  display: none;
}

.g27x__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.g27x__pill,
.g27x__nav-btn,
.g27x__all-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.65rem;
  border: 1px solid var(--g27-rule);
  border-radius: 6px;
  background: transparent;
  color: var(--g27-ink);
  font: 600 0.88rem/1 var(--g27-mono);
  cursor: pointer;
}

.g27x__nav-btn,
.g27x__all-btn {
  font-family: var(--g27-sans);
  font-size: 0.85rem;
  padding: 0 0.75rem;
}

.g27x__pill:hover,
.g27x__nav-btn:hover,
.g27x__all-btn:hover {
  border-color: var(--g27-ink);
}

.g27x__pill[aria-current="step"],
.g27x__all-btn[aria-pressed="true"] {
  background: var(--g27-ink);
  border-color: var(--g27-ink);
  color: var(--ground, var(--paper, #0e211c));
}

.g27x__pill:focus-visible,
.g27x__nav-btn:focus-visible,
.g27x__all-btn:focus-visible {
  outline: 2px solid var(--g27-focus);
  outline-offset: 2px;
}

.g27x__nav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
  margin-top: 0.15rem;
}

.g27x__all-btn {
  margin-left: auto;
}

.g27x__steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.js .g27x[data-active-step]:not([data-active-step="all"]) .g27x__step:not(.is-active) {
  display: none;
}

.g27x__step {
  margin: 0;
  padding: 0;
}

.js .g27x[data-active-step="all"] .g27x__step + .g27x__step,
:root:not(.js) .g27x__step + .g27x__step {
  padding-top: 0.85rem;
  border-top: 1px solid var(--g27-rule);
}

.g27x__step-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.38rem;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--g27-ink);
}

.g27x__step-num {
  flex: none;
  font: 0.78rem/1 var(--g27-mono);
  color: var(--g27-muted);
}

.g27x__step p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--g27-ink);
}

.g27x__step p + p {
  margin-top: 0.5rem;
}

.g27x__step-note {
  color: var(--g27-muted) !important;
  font-size: 0.88rem !important;
}

/* Integration on work.html#g27 */
.g27 > .g27x {
  grid-column: 1 / -1;
  margin-bottom: 1.75rem;
}
.g27 > .g27-aside--row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: start;
  gap: 1.25rem 2rem;
}

@media (max-width: 980px) {
  .g27x {
    grid-template-columns: minmax(0, 1fr);
  }
  .g27 > .g27-aside--row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .g27x__overlay-tag,
  .g27x__band-label {
    display: none;
  }
  .g27x__timeline {
    padding: 0.6rem 0.7rem 0.7rem;
  }
  .g27x__seg strong {
    display: none;
  }
  .g27x__legend {
    display: grid;
  }
  .g27x__walk {
    padding: 0.85rem 0.85rem;
  }
  .g27x__all-btn {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .g27x__layer {
    transition: none;
  }
}
