/*
 * Test frame styles (test-redesign): frame, rail, desktop grid, buttons, plain card, goose, dots of the five
 * test pages. Every rule sits under [data-tool="test"] (contracts.md section 1), so the file changes nothing
 * on a page without that attribute. Every value comes from tokens.css (TOKEN_SCOPE_BLOCK).
 */

/* StatusRow (test_frame.py phone): wordmark left, step label right; the «з» lighter by weight (UX-009), in
   --ink-2 because --ink-3 never colours text (KD-21) */
[data-tool="test"] .status-row {
  min-height: var(--tap-min);
  padding-top: var(--test-status-padding-top);
}

/* Every step page shows the row with its PAGE_STEP label (ruling of 17 November 2026); the step label of the
   stage header is then hidden, so the label shows once */
[data-tool="test"] .status-row {
  display: flex;
}

[data-tool="test"] .step-header > p.mono-label:first-child {
  display: none;
}

[data-tool="test"] .status-row__status {
  color: var(--ink-2);
  font-size: var(--test-status-size);
  font-weight: 600;
}

[data-tool="test"] .step-of {
  color: var(--ink-2);
  font-weight: 400;
}

/* PrimaryButton and SecondaryButton (kit.py .btn, .ghost): pills; one accent primary per screen (UX-002) */
[data-tool="test"] .button {
  border-radius: var(--radius-pill);
}

[data-tool="test"] .button--primary {
  min-height: var(--test-button-min-height);
  padding-inline: var(--test-button-padding-x);
  background: var(--tool-accent);
  color: var(--on-tool-accent);
  font-size: var(--test-button-font-size);
}

/* Inactive keeps the accent at reduced opacity (ui.md PrimaryButton inactive); still focusable (CHK021) */
[data-tool="test"] .button--primary[aria-disabled="true"] {
  background: var(--tool-accent);
  color: var(--on-tool-accent);
  opacity: var(--test-button-inactive-opacity);
}

[data-tool="test"] .button--secondary {
  min-height: var(--test-secondary-min-height);
  border: var(--test-secondary-border-width) solid var(--test-secondary-line);
  background: transparent;
  color: var(--ink);
  font-size: var(--test-secondary-font-size);
}

/* TextLink (kit.py .link): accent ink, underlined */
[data-tool="test"] .stage-exit {
  color: var(--tool-accent-ink);
  font-size: var(--test-link-font-size);
  font-weight: 600;
  text-decoration-line: underline;
  text-underline-offset: var(--test-link-underline-offset);
}

/* The column ends above the home indicator (IMPL-023, ux.md Touch Targets): the footer actions keep the safe area */
[data-tool="test"] main.test-column {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Script focus targets (COR-7): a heading or region focused by script (tabindex="-1", unreachable with Tab) shows
   no frame, as the boards draw none; every interactive control keeps the site's ring */
[data-tool="test"] :is(h1, h2, h3, p, section, div)[tabindex="-1"]:focus {
  outline: none;
}

/* PlainCard (kit.py .panel.plain), a slot: it owns its ground, radius, padding and hairline only, so a passage,
   a transcript and a problem note share one frame; the reading passage, the transcript and the stage notice
   line take it without a markup change */
[data-tool="test"] .card--plain,
[data-tool="test"] .reading-passage,
[data-tool="test"] .audio-player,
[data-tool="test"] .stage-notice__line {
  padding: var(--test-panel-padding);
  border: var(--test-plain-border-width) solid var(--test-plain-line);
  border-radius: var(--test-panel-radius);
  background: var(--test-plain-bg);
}

/* StageNotice and the offline item line (IMPL-020, ux.md Error Presentation): the built line on PlainCard with the
   alert icon, never a pastel; the item line keeps its own icon from the stage-one template */
[data-tool="test"] .item-form > .form-message:not([hidden]) {
  padding: var(--test-panel-padding);
  border: var(--test-plain-border-width) solid var(--test-plain-line);
  border-radius: var(--test-panel-radius);
  background: var(--test-plain-bg);
  color: var(--ink);
}

[data-tool="test"] .stage-notice__line,
[data-tool="test"] .choice-card--unavailable .choice-card__note:not([hidden]) {
  display: flex;
  align-items: flex-start;
  gap: var(--test-notice-icon-gap);
}

[data-tool="test"] .stage-notice__line::before,
[data-tool="test"] .choice-card--unavailable .choice-card__note::before {
  content: "";
  flex: none;
  width: var(--test-notice-icon-size);
  height: var(--test-notice-icon-size);
  margin-top: var(--test-notice-icon-offset);
  background: var(--test-notice-icon-ink);
  -webkit-mask: var(--test-icon-alert) center / contain no-repeat;
  mask: var(--test-icon-alert) center / contain no-repeat;
}

/* TestRail (test_frame.py _rail): the four steps on desktop only; done a tick on the soft accent, current its
   number on the accent with the label in --ink and heavier, upcoming its number on --line (UX-004: the tick,
   the weight and aria-current carry the state with the colour) */
[data-tool="test"] .test-rail {
  display: none;
}

[data-tool="test"] .test-rail__list {
  display: flex;
  flex-direction: column;
  gap: var(--test-rail-item-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

[data-tool="test"] .test-rail__item {
  display: flex;
  align-items: center;
  gap: var(--test-rail-mark-gap);
  color: var(--test-rail-ink);
  font-size: var(--test-rail-size);
  font-weight: 500;
}

[data-tool="test"] .test-rail__item[aria-current="step"] {
  color: var(--test-rail-current-ink);
  font-weight: 600;
}

[data-tool="test"] .test-rail__mark {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--test-rail-mark-size);
  height: var(--test-rail-mark-size);
  border-radius: 50%;
  background: var(--test-rail-mark-bg);
  color: var(--test-rail-mark-ink);
  font-family: var(--font-display);
  font-size: var(--test-rail-number-size);
  font-weight: 800;
}

[data-tool="test"] .test-rail__tick,
[data-tool="test"] .test-rail__item--done .test-rail__number {
  display: none;
}

[data-tool="test"] .test-rail__item--done .test-rail__tick {
  display: block;
}

[data-tool="test"] .test-rail__item--done .test-rail__mark {
  background: var(--test-rail-done-bg);
  color: var(--test-rail-done-ink);
}

[data-tool="test"] .test-rail__item[aria-current="step"] .test-rail__mark {
  background: var(--test-rail-current-bg);
  color: var(--test-rail-current-mark-ink);
}

@media (min-width: 64rem) {
  [data-tool="test"] .test-rail {
    display: block;
  }
}

/* Desktop grid (test_frame.py desk; KD-14): the header row full width over the layout of TEST_LAYOUT_MAX_PX; the
   rail and the main column in one cell, the main column after the rail on a step page; the step label of the
   status row sits in the header row on a step page (the nav is hidden there), in the flow on the result */
@media (min-width: 64rem) {
  [data-tool="test"] body {
    position: relative;
    display: grid;
    grid-template-columns:
      minmax(var(--test-layout-padding-x), 1fr) minmax(0, var(--test-layout-inner))
      minmax(var(--test-layout-padding-x), 1fr);
    grid-template-rows: auto 1fr;
    align-content: start;
  }

  [data-tool="test"] body > .site-header {
    grid-column: 1 / -1;
    grid-row: 1;
    align-items: center;
    box-sizing: border-box;
    height: var(--test-header-height);
    max-width: none;
    margin: 0;
    padding: 0 max(var(--test-layout-padding-x), calc((100% - var(--test-layout-inner)) / 2));
    border-bottom: var(--hairline-width) solid var(--test-header-line);
  }

  [data-tool="test"] body > .site-header .wordmark {
    font-size: var(--test-wordmark-size);
  }

  [data-tool="test"][data-test-step] .site-nav {
    display: none;
  }

  [data-tool="test"][data-test-step] .status-row {
    position: absolute;
    top: 0;
    right: max(var(--test-layout-padding-x), calc((100% - var(--test-layout-inner)) / 2));
    height: var(--test-header-height);
    min-height: 0;
    padding: 0;
  }

  [data-tool="test"] .test-rail {
    position: sticky;
    top: 0;
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    width: var(--test-rail-width);
    padding-top: calc(var(--test-layout-padding-top) + var(--test-rail-padding-top));
  }

  [data-tool="test"] main.test-column {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    width: min(var(--test-main-width-default), 100%);
    min-height: 0;
    margin: var(--test-layout-padding-top) 0 var(--test-layout-padding-bottom);
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  /* TEST_MAIN_WIDTHS by the visible state, after the rail on a step page; a side column adds
     TEST_LAYOUT_GAP_PX and TEST_SIDE_WIDTH_PX */
  [data-tool="test"][data-test-step] main.test-column {
    width: min(var(--test-main-width-default), 100% - var(--test-rail-width) - var(--test-layout-gap));
    margin-inline-start: calc(var(--test-rail-width) + var(--test-layout-gap));
  }

  [data-tool="test"][data-test-step="1"] main.test-column {
    width: min(var(--test-main-width-gate), 100% - var(--test-rail-width) - var(--test-layout-gap));
  }

  [data-tool="test"] main.test-column:has(> #stage-question:not([hidden])) {
    width: min(var(--test-main-width-wide), 100% - var(--test-rail-width) - var(--test-layout-gap));
  }

  [data-tool="test"] main.test-column:has(> #stage-offer:not([hidden])) {
    width: min(var(--test-main-width-sample), 100% - var(--test-rail-width) - var(--test-layout-gap));
  }

  [data-tool="test"] main.test-column:has(> #stage-writing:not([hidden])),
  [data-tool="test"] main.test-column:has(> #stage-record:not([hidden])),
  [data-tool="test"] main.test-column:has(> #stage-analysis:not([hidden])) {
    width: min(calc(var(--test-main-width-sample) + var(--test-layout-gap) + var(--test-side-width)), 100% - var(--test-rail-width) - var(--test-layout-gap));
  }

  [data-tool="test"] main.test-column:has(> #result-main:not([hidden])) {
    width: min(calc(var(--test-main-width-result) + var(--test-layout-gap) + var(--test-side-width)), 100%);
  }

  [data-tool="test"] main.test-column:has(> #result-c1:not([hidden])) {
    width: min(var(--test-main-width-result), 100%);
  }

  [data-tool="test"] main.test-column:has(> #result-loading:not([hidden])) {
    width: min(var(--test-main-width-loading), 100%);
  }

  /* Buttons keep their own width on desktop, at the start of their row (footers set the end); the primary has a
     floor, so a busy label («Готую тест…») keeps the box of the idle one */
  [data-tool="test"] .test-column .button {
    display: inline-flex;
    align-self: flex-start;
    width: auto;
  }

  [data-tool="test"] .test-column .button--primary {
    min-width: var(--test-button-min-width);
  }
}

/* WaitDots (IMPL-017, kit.py .dots): WAIT_DOT_COUNT accent dots WAIT_DOT_SIZE_PX wide, WAIT_DOT_GAP_PX apart, fading
   in turn over WAIT_DOTS_CYCLE_MS (each a third of the cycle later), opacity only; the dots inherit their colour */
[data-tool="test"] .wait-dots {
  display: inline-flex;
  align-items: center;
  gap: var(--test-wait-dot-gap);
  color: var(--test-wait-dot-ink);
}

[data-tool="test"] .wait-dots__dot {
  inline-size: var(--test-wait-dot-size);
  block-size: var(--test-wait-dot-size);
  border-radius: 50%;
  background: currentColor;
  animation: wait-dot-fade var(--test-wait-dots-cycle) var(--ease-toggle) infinite;
}

[data-tool="test"] .wait-dots__dot:nth-child(2) {
  animation-delay: var(--test-wait-dot-step);
}

[data-tool="test"] .wait-dots__dot:nth-child(3) {
  animation-delay: calc(2 * var(--test-wait-dot-step));
}

@keyframes wait-dot-fade {
  0%,
  100% {
    opacity: 0.3;
  }

  33% {
    opacity: 1;
  }
}

[data-tool="test"] .wait-dots[hidden],
[data-tool="test"] .goose[hidden] {
  display: none;
}

/* GooseFigure (IMPL-018, ui.md; data-model.md Goose): a decorative picture (alt="") drawn at the height its place
   sets (GOOSE_DRAWN_HEIGHTS) and the file's own ratio, never wider than GOOSE_MAX_WIDTH; the box keeps that size
   when the file fails (goose-missing), and an empty alt draws no broken mark */
[data-tool="test"] .goose {
  display: block;
  flex: none;
  block-size: var(--test-goose-height);
  max-inline-size: calc(var(--test-goose-max-ratio) * var(--test-goose-height));
}

[data-tool="test"] .goose--checking {
  aspect-ratio: 505 / 840;
}

[data-tool="test"] .goose--lost {
  aspect-ratio: 347 / 440;
}

[data-tool="test"] .goose img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

/* Reduced motion (IMPL-019, ui.md MotionName reduced): the dots stand still at WAIT_DOT_OPACITIES and the primary
   loses its press scale; only opacity changes remain */
@media (prefers-reduced-motion: reduce) {
  [data-tool="test"] .wait-dots__dot {
    animation: none;
  }

  [data-tool="test"] .wait-dots__dot:nth-child(2) {
    opacity: var(--test-wait-dot-opacity-2);
  }

  [data-tool="test"] .wait-dots__dot:nth-child(3) {
    opacity: var(--test-wait-dot-opacity-3);
  }

  [data-tool="test"] .button:active {
    transform: none;
  }
}
