/* ==========================================================================
   Korjin — science page. Imports the shared CTA band from ritual.css concerns;
   duplicated minimally here so science.html needs only one page stylesheet.
   ========================================================================== */

/* ---- pinned nine-steam sequence ----------------------------------------- */

.steams {
  position: relative;
}

/* Scroll distance that the pinned panel scrubs across. */
.steams__spacer {
  height: 260vh;
}

/* The pinned panel is a full-viewport slab so the sequence stays put while
   the page scrolls. It used to carry the darker sunken ground; its content is
   shorter than the viewport, so ~135px of that darker tone showed above and
   below and read as an empty section at the start and end of the pin (QA-20).
   On the page's own ground it is just breathing room. */
.steams__sticky {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  align-items: center;
}

.steams__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-8);
  align-items: center;
  width: 100%;
}

.steams__media {
  position: relative;
  aspect-ratio: 4 / 5;
  max-height: 70vh;
  overflow: hidden;
  background: var(--ground);
}

.steams__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.steams__media img.is-swapping {
  animation: steam-fade var(--dur-slow) var(--ease-out);
}

@keyframes steam-fade {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: none; }
}

.steams__media::after {
  /* gradient scrim so the cycle numeral is legible over any frame — the
     sequence runs from pale hanji to near-black, so a text-shadow alone
     can't carry it */
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to top, rgb(0 0 0 / 62%), transparent);
  pointer-events: none;
}

.steams__cycle {
  position: absolute;
  left: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 1;
  font-family: var(--font-display);
  font-size: var(--step-5);
  line-height: 1;
  color: var(--korjin-cream);
}

.steams__copy .title-lg {
  margin-block: var(--sp-3) var(--sp-4);
  min-height: 2.2em;
}

.steams__copy .prose {
  min-height: 7em;
}

.steams__track {
  position: relative;
  height: 2px;
  margin-top: var(--sp-6);
  background: var(--rule);
}

/* One tick per steam, so the bar reads as nine cycles rather than four jumps
   (QA-19). --steam-ticks is set by the script from the stages' cycle numbers;
   9 is the fallback. */
.steams__track::after {
  content: "";
  position: absolute;
  inset: -4px 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 calc(100% / var(--steam-ticks, 9) - 1px),
    var(--rule-strong) calc(100% / var(--steam-ticks, 9) - 1px) calc(100% / var(--steam-ticks, 9))
  );
  pointer-events: none;
}

.steams__fill {
  height: 100%;
  width: 0;
  background: var(--accent-surface);
  transition: width 120ms linear;
}

/* ---- compounds ---------------------------------------------------------- */

.compounds__head {
  margin-block: var(--sp-3) var(--sp-7);
}

.compounds__list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.compounds__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
}

.compounds__mult {
  font-family: var(--font-display);
  font-size: var(--step-3);
  color: var(--gold-line);
}

.compounds__track {
  height: 4px;
  margin-block: var(--sp-3);
  background: var(--band-dark-rule);
}

.compounds__fill {
  width: var(--bar, 100%);
  height: 100%;
  background: linear-gradient(90deg, var(--band-accent), var(--gold-line));
  transform-origin: left center;
}

/* Build-in on first view (QA-21). The zero state exists only once the script
   has armed the list, so without JS the bars simply show at full length.
   --cmp-delay staggers the rows (set per row by the script). */
.compounds__list.is-armed .compounds__fill {
  transform: scaleX(0);
}

.compounds__list.is-armed.is-in .compounds__fill {
  transform: scaleX(1);
  transition: transform 900ms var(--ease-out) var(--cmp-delay, 0ms);
}

.compounds__list .small {
  max-width: 68ch;
}

.compounds__note {
  margin-top: var(--sp-7);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--band-dark-rule);
  color: color-mix(in srgb, var(--band-dark-ink) 66%, transparent);
  max-width: 68ch;
}

/* ---- COA reader --------------------------------------------------------- */

.coa__head {
  margin-block: var(--sp-3) var(--sp-4);
}

.coa__lede {
  margin-bottom: var(--sp-5);
}

.coa__picker {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.coa__tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule-strong);
  color: var(--ink-muted);
  transition: background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.coa__tab[aria-pressed="true"] {
  background: var(--ground-inverse);
  border-color: var(--ground-inverse);
  color: var(--ink-inverse);
}

/* the document itself — reads like a lab report, not a marketing panel */
.coa__doc {
  border: 1px solid var(--rule-strong);
  background: var(--ground-raised);
}

.coa__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--rule);
}

.coa__meta-v {
  margin-top: var(--sp-1);
  font-size: var(--step-0);
}

.coa__pass {
  color: var(--gold-text);
}

.coa__scroll {
  overflow-x: auto;
}

.coa__table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.coa__table th,
.coa__table td {
  text-align: left;
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--rule);
  font-weight: 400;
}

.coa__table thead th {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--label-size);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.coa__table tbody th {
  color: var(--ink);
}

.coa__table td:not(:first-child) {
  white-space: nowrap;
}

.coa__status {
  font-size: var(--label-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-text);
  border: 1px solid currentcolor;
  padding: 0.125rem 0.5rem;
}

.coa__foot {
  padding: var(--sp-4) var(--sp-6) var(--sp-5);
  max-width: 72ch;
}

/* ---- shared CTA band (see ritual.css) ----------------------------------- */

.cta-band__in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

.cta-band__in .title-lg {
  margin-top: var(--sp-3);
}

.cta-band__btn {
  border-color: color-mix(in srgb, var(--band-accent-ink) 45%, transparent);
  color: var(--band-accent-ink);
}

.cta-band__btn:hover {
  border-color: var(--band-accent-ink);
  background: color-mix(in srgb, var(--band-accent-ink) 10%, transparent);
}

@media (max-width: 860px) {
  .steams__spacer {
    height: 200vh;
  }

  .steams__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-5);
  }

  .steams__media {
    max-height: 34vh;
    aspect-ratio: 16 / 10;
  }

  .steams__copy .prose,
  .steams__copy .title-lg {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .steams__media img.is-swapping {
    animation: none;
  }
}

/* Reduced motion: the steam frames swap without the fade, and the compounds
   are never armed by the script, so they render at full value. */
@media (prefers-reduced-motion: reduce) {
  .steams__media img.is-swapping {
    animation: none;
  }
}
