/* refine.css: refinements to "The tools, shown".
   Each block is headed with the recommendation it makes (R1 to R28 in the visual assessment).
   To drop a recommendation, delete its block. Nothing here changes a word or a figure.
   Loaded after site.css and refine-scale.css. R17 and R19 (text sizes) are in refine-scale.css. */

.rf-nb {
  white-space: nowrap;
}

/* ============================================================== PASS 1: FINISH */

/* R1: the closing credits. The two columns stack at phone and tablet widths. */
@media (max-width: 1180px) {
  .oa-foot__grid {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 22px;
  }
}

/* R2: the phone's top bar. All four pages fit across; past the opening, the report's bar is one slim row
   and the pages are listed at the top of the Parts sheet. */
.rf-pages {
  display: none;
}

@media (max-width: 760px) {
  .oa-bar__in {
    row-gap: 0;
    padding: 8px 14px 2px;
  }

  .oa-bar__nav {
    justify-content: space-between;
    gap: 0;
    margin: 0;
  }

  .oa-bar__link {
    padding: 6px 3px;
    font-size: 13px;
  }

  .oa-bar__link[aria-current="page"]::after {
    left: 3px;
    right: 3px;
    bottom: 6px;
  }

  .page-home .oa-bar--solid .oa-bar__nav {
    display: none;
  }

  .page-home .oa-bar--solid .oa-bar__in {
    padding-bottom: 10px;
  }

  .rf-pages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--oa-line);
  }

  .rf-pages__link {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--oa-line-2);
    border-radius: 10px;
    background: transparent;
    color: var(--oa-text);
    font: 600 14px/1.2 var(--oa-sans);
    text-align: left;
    cursor: pointer;
  }

  .rf-pages__link[aria-current="page"] {
    border-color: var(--oa-red);
    box-shadow: inset 3px 0 0 var(--oa-red);
    color: #FFFFFF;
  }

  .rf-pages__link:focus-visible {
    outline: 2px solid #FFFFFF;
    outline-offset: 2px;
  }
}

@media (max-width: 379px) {
  .oa-bar__link {
    font-size: 12px;
  }
}

/* R2, tablets: all four pages stay in the bar. */
@media (min-width: 761px) and (max-width: 1100px) {
  .oa-bar__in {
    gap: 14px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .oa-bar__nav {
    gap: 2px;
  }

  .oa-bar__link {
    padding: 8px 7px;
  }

  .oa-bar__date {
    display: none;
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .oa-bar__link {
    padding: 8px 5px;
    font-size: 13px;
  }

  .oa-bar__intro {
    padding: 0 12px;
  }
}

/* R3: the Parts button on a phone. Smaller and quiet, so it no longer hides a line of text behind a red slab.
   The word "Parts" stays for screen readers; the icon and the part's name say it to the eye. */
@media (max-width: 760px) {
  .oa-parts.is-past .oa-parts__toggle {
    min-height: 44px;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid rgba(238, 242, 248, 0.24);
    background: rgba(7, 13, 24, 0.8);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  }

  .oa-parts__tlabel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .oa-parts__now {
    opacity: 1;
  }

  .oa-foot {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

/* R6: on a touch screen nothing lifts or lights up as if a mouse were resting on it. */
@media (hover: none) {
  .oa-card:hover {
    transform: none;
    border-color: var(--oa-line);
    box-shadow: none;
  }

  .oa-card:hover .oa-mon img {
    transform: none;
  }
}

/* R10: Part 3's list of names and prices sits two across on a phone. */
@media (max-width: 760px) {
  .oa-adds {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .oa-adds li {
    min-height: 66px;
  }
}

/* R11: on a touch screen, everything that can be pressed is at least 44 pixels tall. */
@media (hover: none), (max-width: 760px) {
  .oa-tags {
    gap: 8px;
  }

  .oa-tag,
  .oa-weblink,
  .oa-bar__link,
  .oa-bar__intro,
  .oa-parts__close,
  .oa-sheet__close,
  .oa-flip__btn {
    min-height: 44px;
  }

  .oa-tag {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .oa-parts__subitem {
    min-height: 44px;
    align-items: center;
  }
}

/* R12: headlines break where the sense breaks. (The sizes stop growing at the page's full width in refine-scale.css.) */
.oa-hero__title,
.oa-part__title,
.oa-h2,
.oa-h3,
.oa-sub,
.oa-card__name,
.oa-sheet__title,
.oa-tile__name,
.oa-rundown__title,
.oa-site__card h4 {
  text-wrap: balance;
}

/* R17 (with refine-scale.css): the notes are read, so they are set larger and lighter. */
.oa-fine {
  font-size: 14px;
  color: var(--oa-soft);
}

@media (max-width: 760px) {
  .oa-mon__step,
  .oa-card__cost span,
  .oa-card__small,
  .oa-chain__label,
  .oa-stage__facts span,
  .oa-sheet__facts dt,
  .oa-sheet__text h3,
  .oa-sheet__nav button span,
  .oa-adds__cost,
  .oa-tile__kick,
  .oa-parts__txt small,
  .oa-rundown__no,
  .oa-costs__total span {
    font-size: 13px;
  }
}

/* R18: lines of reading text stop at a comfortable length. */
.oa-fine {
  max-width: 76ch;
}

.oa-lede,
.oa-part__note {
  max-width: 34em;
}

.oa-alt p,
.oa-siteline {
  max-width: none;
}

@media (min-width: 761px) {
  .oa-alt p {
    max-width: 96ch;
  }
}

/* ============================================================== PASS 2: THE PHONE, PROPERLY */

/* R4: on a phone each tool is a compact row: a small drawing, its name, what it does and its price.
   A tap anywhere on the row opens the sheet, where the rest is read. */
@media (max-width: 760px) {
  .oa-cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .oa-card {
    flex-direction: row;
    align-items: stretch;
    border-radius: 14px;
  }

  .oa-card .oa-mon {
    flex: 0 0 116px;
    width: 116px;
    min-height: 104px;
    aspect-ratio: auto;
    border-bottom: 0;
    border-right: 1px solid var(--oa-line);
  }

  .oa-card .oa-mon__step,
  .oa-card .oa-mon__track {
    display: none;
  }

  .oa-card .oa-mon__chip {
    right: 6px;
    bottom: 6px;
  }

  .oa-card__body {
    min-width: 0;
    padding: 12px 14px 12px;
  }

  .oa-card__name {
    font-size: 24px;
  }

  .oa-card__does {
    margin-top: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--oa-soft);
  }

  .oa-card__uses,
  .oa-card__links {
    display: none;
  }

  .oa-card__cost {
    padding-top: 8px;
  }

  .oa-card__cost b {
    font-size: 24px;
  }
}

/* R8: the sheet's frame on a phone. One slim header with the close button at the right, and Previous and Next
   held along the bottom within reach of a thumb. */
@media (max-width: 760px) {
  .oa-sheet {
    height: 100dvh;
    max-height: 100dvh;
    overscroll-behavior: contain;
  }

  .oa-sheet__bar {
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 12px 8px 16px;
  }

  .oa-sheet__crumb {
    flex-wrap: nowrap;
    font-size: 0;
    letter-spacing: 0;
  }

  .oa-sheet__crumb b,
  .oa-sheet__crumb span {
    font-size: 12px;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }

  .oa-sheet__nav {
    position: sticky;
    z-index: 3;
    bottom: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--oa-line);
    background: rgba(7, 13, 24, 0.94);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .oa-sheet__nav button {
    min-height: 52px;
    padding: 8px 12px;
    gap: 4px;
    font-size: 17px;
    line-height: 1;
  }

  .oa-sheet__next {
    grid-column: 2;
  }
}

/* R14: the card grid. Every card keeps one width, and a short last row is centred:
   five sit as three and two, six as three and three, seven as four and three. */
@media (min-width: 1101px) {
  .oa-cards {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .oa-cards > .oa-card {
    grid-column: span 2;
  }

  .oa-cards > .oa-card:first-child:nth-last-child(5),
  .oa-cards > .oa-card:first-child:nth-last-child(6),
  .oa-cards > .oa-card:nth-child(4):nth-last-child(3),
  .oa-cards > .oa-card:nth-child(5):nth-last-child(3) {
    grid-column: 2 / span 2;
  }

  .oa-cards > .oa-card:nth-child(4):nth-last-child(2) {
    grid-column: 3 / span 2;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .oa-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .oa-cards > .oa-card {
    grid-column: span 2;
  }

  .oa-cards > .oa-card:last-child:nth-child(odd) {
    grid-column: 2 / span 2;
  }
}

/* R14: a card with no website link keeps the space of the link row, so every price sits on one line. */
@media (min-width: 761px) {
  .oa-card__cost:last-child {
    margin-bottom: 42px;
  }
}

/* R14: the stage cards' facts sit at the bottom, in line with their neighbours'. */
.oa-stage {
  display: flex;
  flex-direction: column;
}

.oa-stage__facts {
  margin-top: auto;
}

/* R16: every sheet is one height, with Previous and Next held in place at its foot. */
@media (min-width: 761px) {
  .oa-sheet[open] {
    display: flex;
    flex-direction: column;
    height: min(880px, calc(100vh - 32px));
  }

  .oa-sheet__grid {
    flex: 1 0 auto;
  }

  .oa-sheet__nav {
    position: sticky;
    z-index: 3;
    bottom: 0;
    padding: 14px 26px 18px;
    border-top: 1px solid var(--oa-line);
    background: rgba(7, 13, 24, 0.94);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
}

/* R16: when the sheet shows the vendor's picture, the caption says so, and the label sits clear of the vendor's logo. */
.oa-flip__tag {
  top: auto;
  left: auto;
  right: 12px;
  bottom: 12px;
}

.oa-sheet__figcap.is-flipped .rf-cap--diagram {
  display: none;
}

.oa-sheet__figcap.is-flipped ~ .oa-flip__what,
.oa-sheet__figcap.is-flipped + .oa-flip__what {
  margin-top: 6px;
}

/* R21: movement rests. A drawing plays while it is on screen and new, then holds still until pointed at.
   js/refine.js adds and removes the "rf-rest" class. */
.rf-rest *,
.rf-rest *::before,
.rf-rest *::after {
  animation-play-state: paused !important;
}

.oa-hero.rf-rest .oa-hero__media img,
.oa-hero.rf-rest .oa-hero__media video,
.oa-hero.rf-rest .oa-hero__sweep {
  animation-play-state: paused;
}

.oa-bar__mark i {
  animation-iteration-count: 8;
}

.oa-kicker::before {
  animation-iteration-count: 3;
}

/* R22: the tool cards no longer turn over on a timer (js/refine.js), so the ring that counted down is gone.
   In the sheet, the change to the vendor's picture is a quick fade, not a turn. */
.oa-mon__hold {
  display: none;
}

.oa-flip__inner,
.oa-flip.is-flipped .oa-flip__inner {
  transform: none;
  transition: none;
}

.oa-flip__front,
.oa-flip__back {
  -webkit-backface-visibility: visible;
  backface-visibility: visible;
  transition: opacity 0.3s ease;
}

.oa-flip__back {
  transform: none;
  opacity: 0;
  pointer-events: none;
}

.oa-flip.is-flipped .oa-flip__back {
  opacity: 1;
  pointer-events: auto;
}

.oa-flip.is-flipped .oa-flip__front {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .oa-flip__front,
  .oa-flip__back {
    transition: none;
  }
}

/* ============================================================== PASS 3: POLISH */

/* R20: panels and lines stand a shade clear of the page, and the second background of Parts 2 and 4 reads as a band. */
.oa {
  --oa-panel: #0E1626;
  --oa-panel-2: #131D31;
  --oa-line: rgba(238, 242, 248, 0.14);
}

.oa-part--deep {
  background: linear-gradient(180deg, #0B1424 0%, var(--oa-night) 100%);
}

/* R23: the picture labels keep every word, on dark glass with a dot in each label's colour,
   so the tool's name is the brightest thing on its card. */
.oa-chip,
.oa-chip--live,
.oa-chip--mock,
.oa-chip--vendor,
.oa-chip--studio,
.oa-chip--diagram,
.oa-chip--sample {
  border: 1px solid rgba(238, 242, 248, 0.2);
  background: rgba(5, 8, 15, 0.74);
  color: #DCE3EE;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.oa-chip::before,
.oa-chip--live::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rf-dot, #9AA6B8);
}

.oa-chip--live {
  --rf-dot: #E3262E;
}

.oa-chip--mock {
  --rf-dot: #F2B33D;
}

.oa-chip--vendor {
  --rf-dot: #4FC38A;
}

.oa-chip--studio {
  --rf-dot: #B58AF0;
}

.oa-chip--diagram,
.oa-chip--sample {
  --rf-dot: #8DB7FF;
}

/* R24: the cost bars. Steps of one blue, largest darkest, so red keeps its meaning elsewhere;
   and each name sits beside its own figure. The colours are set in the page itself, hence "important". */
.oa-costs__bar .oa-costs__seg:nth-child(1),
.oa-costs__legend .oa-costs__item:nth-child(1) .oa-costs__key {
  background: #1F56B3 !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(2),
.oa-costs__legend .oa-costs__item:nth-child(2) .oa-costs__key {
  background: #3A6FCB !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(3),
.oa-costs__legend .oa-costs__item:nth-child(3) .oa-costs__key {
  background: #5788DC !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(4),
.oa-costs__legend .oa-costs__item:nth-child(4) .oa-costs__key {
  background: #77A0E8 !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(5),
.oa-costs__legend .oa-costs__item:nth-child(5) .oa-costs__key {
  background: #98B8F0 !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(6),
.oa-costs__legend .oa-costs__item:nth-child(6) .oa-costs__key {
  background: #B9CFF6 !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(7),
.oa-costs__legend .oa-costs__item:nth-child(7) .oa-costs__key {
  background: #AEB8C8 !important;
}

.oa-costs__bar .oa-costs__seg:nth-child(8),
.oa-costs__legend .oa-costs__item:nth-child(8) .oa-costs__key {
  background: #D5DCE6 !important;
}

.oa-costs__legend {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 22px;
}

.oa-costs__item b {
  margin-left: 2px;
}

@media (max-width: 760px) {
  .oa-costs__legend {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

/* R25: the three signature pieces, small, near the top of the report. */
.rf-sig {
  border-bottom: 1px solid var(--oa-line);
  background: var(--oa-night);
}

.rf-sig__in {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 14px 18px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.rf-sig__label {
  max-width: 10ch;
  margin: 0;
  font: 600 12px/1.3 var(--oa-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oa-red-ink);
}

.rf-sig__tile {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 8px;
  border: 1px solid var(--oa-line);
  border-radius: 12px;
  background: var(--oa-panel);
  color: var(--oa-text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.25s var(--oa-ease), border-color 0.25s ease;
}

.rf-sig__tile img {
  display: block;
  width: 104px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
}

.rf-sig__name {
  display: block;
  font-family: var(--oa-cond);
  font-stretch: 68%;
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  text-transform: uppercase;
  color: #FFFFFF;
}

.rf-sig__line {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--oa-dim);
}

@media (hover: hover) {
  .rf-sig__tile:hover {
    transform: translateY(-2px);
    border-color: rgba(227, 38, 46, 0.7);
  }
}

.rf-sig__tile:focus-visible {
  outline: 3px solid #FFFFFF;
  outline-offset: 2px;
}

@media (max-width: 1180px) {
  .rf-sig__in {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rf-sig__label {
    grid-column: 1 / -1;
    max-width: none;
  }
}

@media (max-width: 760px) {
  .rf-sig__in {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .rf-sig__tile {
    grid-template-columns: 88px minmax(0, 1fr);
    min-height: 44px;
  }

  .rf-sig__tile img {
    width: 88px;
    height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rf-sig__tile {
    transition: none;
  }
}

/* R26: past the opening screen, "Play the intro" is a quiet outline. On a phone's first screen it shows once. */
.oa-bar__intro {
  border: 1px solid transparent;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.oa-bar--solid .oa-bar__intro {
  border-color: rgba(238, 242, 248, 0.3);
  background: transparent;
  box-shadow: none;
}

@media (max-width: 760px) {
  .page-home .oa-bar:not(.oa-bar--solid) .oa-bar__intro {
    display: none;
  }
}

/* R27: a key for the two outlines a tool's name can have in Part 2. */
.rf-tagkey {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 16px;
}

.rf-tagkey__item {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid rgba(238, 242, 248, 0.22);
  border-radius: 7px;
  background: rgba(238, 242, 248, 0.06);
  font: 600 12px/1.3 var(--oa-sans);
  color: var(--oa-soft);
}

.rf-tagkey__item--add {
  border-style: dashed;
}

@media (max-width: 760px) {
  .rf-tagkey {
    justify-content: flex-start;
  }

  /* R27: on a phone a box inside a box loses its outer frame, so the text has the width of the screen. */
  .oa-settle,
  .oa-chain {
    padding-left: 0;
    padding-right: 0;
    border: 0;
    border-radius: 0;
    background: none;
  }
}

/* R21: with "reduce motion" on, the chapter pictures no longer drift either. */
@media (prefers-reduced-motion: reduce) {
  .oa-cine img {
    transition: none;
  }
}
