/*
  The timed rounds (js/closing.js): a layer over the board once it is locked.
  A small card before and after, in the same tray and sheet as the welcome card, and between
  them a sheet the size of a board panel that holds one step at a time: a post and its
  question, or at the end the posts together.

  Tokens and patterns are the board's own (css/base.css, css/form.css). The entrances are
  played from script; this file holds the resting states.
*/
.cq {
  position: fixed; inset: 0; z-index: 65;
}
@keyframes cq-in { from { opacity: 0; } to { opacity: 1; } }
/* Its own layer, like the welcome's: nothing above it carries a filter, so the blur sees the board. */
.cq-scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  backdrop-filter: blur(26px) saturate(140%);
  animation: cq-in 280ms var(--ease-out) both;
}
.cq-stage {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.cq-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.cq-spin {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--text-2);
  animation: cq-spin 820ms linear infinite;
}
@keyframes cq-spin { to { transform: rotate(360deg); } }

/* ---------- a quiz link: the steps alone, on the board's own stage ---------- */
/* There is no board under a quiz, so nothing is dimmed or blurred: the grid stays as it is. */
.cq.is-quiz .cq-scrim { display: none; }
/* The card it opens on is the introduction's card (css/intro.css): the tray, the sheet, the
   statement and the quieter lines. Only what differs is set here. */
.cq-quiz { width: min(760px, calc(100% - 48px)); }
.cq-quiz .intro-big:focus { outline: none; }
.cq-quiz .intro-sub { margin-top: 26px; }
/* A line that wraps must still read as one statement, so the statements stand a little apart. */
.cq-quiz .intro-sub + .intro-sub { margin-top: 10px; }
.cq-quiz .intro-go { margin-top: 36px; }
/* The end of a quiz: a card with no button keeps the same air under its last line. */
.cq-shell.is-end .cq-card { padding-bottom: 50px; }
.cq-shell.is-end .cq-p:last-child { margin-bottom: 0; }
@media (max-width: 700px) {
  .cq-quiz { width: calc(100% - 24px); }
  /* Each line wraps here, so the two need more air between them to stay two. */
  .cq-quiz .intro-sub + .intro-sub { margin-top: 12px; }
  .cq-quiz .intro-go { margin-top: 30px; }
}

/* ---------- the card: before the first step, between steps, after the last ---------- */
.cq-shell {
  width: min(480px, calc(100% - 32px));
  padding: 7px;
  border-radius: 30px;
  background: var(--slot);
  box-shadow: 0 0 0 1px var(--line);
}
.cq-card {
  border-radius: 23px;
  background: var(--panel);
  box-shadow: var(--panel-shadow);
  padding: 52px 44px 34px;
  text-align: center;
}
.cq-card .gate-mark { margin-bottom: 26px; }
.cq-quiet {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.003em;
  color: var(--text-2);
}
.cq-h {
  margin: 0 0 16px;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.024em;
  text-wrap: balance;
}
.cq-h:focus { outline: none; }
.cq-p {
  margin: 0 auto 12px;
  max-width: 34ch;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-2);
  text-wrap: balance;
}
.cq-p + .cq-p { color: var(--text-3); font-size: 15.5px; }
.cq-card .btn { margin-top: 22px; }
.cq-note {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-3);
}

/* ---------- the sheet: one step ---------- */
.cq-sheet {
  position: absolute;
  inset: 24px;
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-panel);
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line-strong), var(--panel-shadow);
  overflow: hidden;
}
/* The time left: a hairline that shortens from the right. No number. */
.cq-bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  height: 60px;
  background: var(--panel);
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
  mask-image: linear-gradient(to bottom, #000 62%, transparent);
  pointer-events: none;
}
.cq-time {
  position: absolute; left: 56px; right: 56px; top: 28px;
  height: 2px;
  border-radius: 1px;
  background: var(--line);
  overflow: hidden;
}
.cq-time-fill {
  display: block; height: 100%;
  border-radius: 1px;
  background: var(--text);
  transform-origin: 0 50%;
  will-change: transform;
}
.cq-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.cq-round {
  max-width: 1320px;
  margin: 0 auto;
  padding: 84px 56px 72px;
}
.cq-title {
  margin: 0;
  max-width: 30ch;
  font-size: clamp(27px, 2.7vw, 38px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.024em;
  text-wrap: balance;
}
.cq-title:focus, .cq-round:focus { outline: none; }
.cq-fields { min-width: 0; margin: 0; padding: 0; border: 0; }

/* ---------- a post and its question ---------- */
/* Side by side. The question keeps its place while a long post is read past it. */
.cq-round.is-post {
  display: grid;
  grid-template-columns: minmax(0, 600px) minmax(0, 1fr);
  gap: 0 72px;
  align-items: start;
}
/* What the post is for: said once, quietly, above it. The post is the thing to read. */
.cq-round.is-post .cq-head { grid-column: 1 / -1; margin-bottom: 40px; }
.cq-round.is-post .cq-title {
  max-width: 40ch;
  font-size: clamp(21px, 1.9vw, 26px);
  line-height: 1.34;
  font-weight: 500;
  letter-spacing: -0.014em;
  text-wrap: pretty;
}
.cq-solo { min-width: 0; }
.cq-say { position: sticky; top: 84px; min-width: 0; max-width: 560px; }
.cq-say .f-input { font-size: 19px; }

/* ---------- a picture or a film in a post ---------- */
/* Until a file says its shape it holds the room of a wide frame. Then the frame is as wide
   as the post, or narrower where that keeps a tall file whole: no taller than the post is
   wide, or than most of a small screen (--cq-shape, width over height, is set by
   js/closing.js). A square file fills the post. */
.cq-x .x-focal { container-type: inline-size; }
.cq-media { max-width: calc(min(520px, 60vh) * var(--cq-shape, 100)); }
.cq-media { max-width: calc(min(600px, max(100cqw, 60vh)) * var(--cq-shape, 100)); }
.cq-media .x-media-file { aspect-ratio: auto 16 / 9; }
/* With the posts together a tall file stands lower, so the posts stay near one height. */
.cq-posts .cq-media { max-width: calc(min(360px, 44vh) * var(--cq-shape, 100)); }
.cq-posts .cq-media { max-width: calc(min(360px, max(100cqw, 44vh)) * var(--cq-shape, 100)); }
/* The post is not a control. Its film is. */
.cq-x video { pointer-events: auto; }
.cq-x video:focus-visible { outline: 2px solid var(--edge-hot); outline-offset: -2px; }

/* ---------- the posts together ---------- */
/* Side by side. The two choices sit on one line across them all, whatever the length of the
   posts above them. */
.cq-posts {
  display: grid;
  grid-template-columns: repeat(var(--cq-across, 3), minmax(0, 1fr));
  grid-template-rows: auto auto;
  gap: 0 32px;
  margin-top: 44px;
}
.cq-post {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  min-width: 0;
}
.cq-x { position: relative; align-self: start; min-width: 0; pointer-events: none; }
.cq-x .x { max-width: none; transition: opacity 200ms ease; }
.cq-x .x-top, .cq-x .x-meta, .cq-x .x-more { display: none; }
.cq-x .x-focal { border-bottom: 0; padding-bottom: 14px; }
/* The pick: a ring set just outside the post. */
.cq-x::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 21px;
  box-shadow: 0 0 0 1.5px var(--text);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}
.cq-post.is-pick .cq-x::after, .cq-x.is-pick::after { opacity: 1; }
/* The weakest steps back. */
.cq-post.is-weak .cq-x .x, .cq-x.is-weak .x { opacity: 0.5; }

.cq-choose { align-self: start; margin-top: 18px; border-bottom: 1px solid var(--line); }
.cq-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 48px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  line-height: 1.3;
  color: var(--text-2);
  cursor: pointer;
  transition: color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}
.cq-opt input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cq-mark {
  position: relative;
  flex: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow 150ms ease, transform 140ms var(--ease-out);
}
.cq-mark::after {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 50%;
  background: var(--text);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 150ms ease, transform 180ms var(--ease-out);
}
.cq-opt:has(input:checked) { color: var(--text); }
.cq-opt:has(input:checked) .cq-mark { box-shadow: inset 0 0 0 1px var(--text); }
.cq-opt:has(input:checked) .cq-mark::after { opacity: 1; transform: none; }
.cq-opt:has(input:focus-visible) { outline: 2px solid var(--edge-hot); outline-offset: 2px; border-radius: 6px; }
.cq-opt:active .cq-mark { transform: scale(0.92); }
@media (hover: hover) and (pointer: fine) {
  .cq-opt:hover { color: var(--text); }
}
.cq-fields:disabled .cq-opt, .cq-fields:disabled .cq-opt input { cursor: default; }
.cq-fields:disabled .cq-opt:not(:has(input:checked)) { color: var(--text-3); }

.cq-why {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 56px;
  margin-top: 44px;
}
.cq-why .f { padding-bottom: 12px; }
.cq-why .f-input { font-size: 19px; }
.cq-fields:disabled .f-input { color: var(--text-2); }
.cq-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
  margin-top: 30px;
}
.cq-foot .f-error { margin: 0; font-size: 16px; }

/* Too narrow for three across: each post takes a row, its two choices beside it. A post
   alone has its question under it. */
@media (max-width: 1080px) {
  .cq-round.is-post { grid-template-columns: minmax(0, 600px); }
  .cq-say { position: static; margin-top: 36px; max-width: none; }
  .cq-posts { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 40px; }
  .cq-post { grid-row: auto; grid-template-rows: none; grid-template-columns: minmax(0, 560px) minmax(180px, 240px); gap: 0 36px; align-items: start; }
  .cq-choose { margin-top: 0; }
}
/* A phone: the post, then its choices under it. The sheet is the whole screen. */
@media (max-width: 700px) {
  .cq-sheet { inset: 0; border-radius: 0; box-shadow: none; }
  .cq-round { padding: 68px 20px 56px; }
  .cq-time { left: 20px; right: 20px; top: 24px; }
  .cq-bar { height: 52px; }
  .cq-posts { margin-top: 34px; gap: 34px; }
  .cq-round.is-post { grid-template-columns: minmax(0, 1fr); }
  .cq-round.is-post .cq-head { margin-bottom: 30px; }
  .cq-say { margin-top: 28px; }
  .cq-post { grid-template-columns: minmax(0, 1fr); }
  .cq-choose { margin-top: 16px; }
  .cq-why { grid-template-columns: minmax(0, 1fr); margin-top: 34px; }
  .cq-card { padding: 44px 24px 26px; }
  .cq-h { font-size: 27px; }
  /* Inside a round a post keeps its own edges (on the board it runs to the screen's). */
  .cq-x .x { margin: 0; border: 1px solid var(--x-line); border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cq-scrim { animation: none; }
  .cq-mark, .cq-mark::after { transition: opacity 150ms ease, box-shadow 150ms ease; }
  .cq-mark::after { transform: none; }
  .cq-opt:active .cq-mark { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .cq-scrim { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
