/* The ticket designer's pages (packs/ticketing/app/views/ticketing/office/designer/, Ticketing::Office::DesignerController) and the conversation on their
   left (TicketingDesignerTalkComponent), after the prototype David Shettler approved on 14 Nov 2026: the brief, then the conversation, in a column on the
   left; the tickets on the right, under a bar of switches, on a dotted field like a designer's table. On a phone the column comes first and the tickets
   after it, in the document's own order.

   The switches change only how the tickets are shown, so the page reads them with :has() and needs no script: Printed size lays the tickets in one column
   at their stock's length (the board then scrolls sideways inside itself), Show the stock lays each design over its stock's stub and window, and Long title
   and name swaps in each design drawn with the long made-up values.

   Tokens only and logical properties only, both enforced (test/styles/tokens_test.rb, test/styles/components_test.rb), so it reads on the light shell
   and the console, in light and in dark, and mirrors in a right-to-left language. Nothing pinned to an edge, no height in vh, and everything that holds
   words may shrink and wrap, so a language 40% longer never widens the page (WCAG 1.4.10). */

.ticketing-designer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
  min-inline-size: 0;
}

@media (min-width: 64rem) {
  .ticketing-designer {
    grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
  }
}

.ticketing-designer__side {
  display: grid;
  gap: var(--space-4);
  align-content: start;
  min-inline-size: 0;
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}

.ticketing-designer__ask {
  display: grid;
  gap: var(--space-1);
}

.ticketing-designer__question {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.ticketing-designer__lede,
.ticketing-designer__note,
.ticketing-designer__help {
  margin: 0;
  color: var(--fg2);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.ticketing-designer__links {
  display: grid;
  gap: var(--space-2);
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ticketing-designer__legend {
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.ticketing-designer__optional {
  color: var(--fg2);
  font-weight: 400;
}

/* A show typed on the brief is used only when "For" is that choice, so its fields are hidden while another is chosen. A browser that does not read :has()
   drops the rule and shows them, and their legend says when they are used. */
#ticketing-designer-brief:has(#brief-purpose option[value="show"]:not(:checked)) .ticketing-designer__show {
  display: none;
}

/* The office's earlier briefs, under the form: each a link to its canvas, with when it was asked and how it ended. */
.ticketing-designer__earlier {
  display: grid;
  gap: var(--space-2);
  padding-block-start: var(--space-4);
  border-block-start: 1px solid var(--rule);
}

.ticketing-designer__earlier-title {
  margin: 0;
  font-size: var(--text-md);
}

.ticketing-designer__earlier-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticketing-designer__earlier-item {
  display: grid;
  gap: var(--space-1);
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.ticketing-designer__earlier-meta {
  color: var(--fg2);
  font-size: var(--text-sm);
}

.ticketing-designer__talk,
.ticketing-designer__compose {
  display: grid;
  gap: var(--space-3);
  min-inline-size: 0;
}

.ticketing-designer__compose:not(:empty) {
  padding-block-start: var(--space-3);
  border-block-start: 1px solid var(--rule);
}

/* The right side: the bar of switches, then the board on its dotted field. */
.ticketing-designer__canvas {
  display: grid;
  min-inline-size: 0;
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}

.ticketing-designer__tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  min-inline-size: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-raised);
  border-block-end: 1px solid var(--rule);
}

.ticketing-designer__tools .field {
  margin: 0;
}

/* Print a test ticket and Publish sit at the end of the bar; open, either one's form takes a row of its own under the switches. */
.ticketing-designer__publish {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
  margin-inline-start: auto;
  min-inline-size: 0;
}

.ticketing-designer__publish > .ticketing-designer__note {
  max-inline-size: 22rem;
}

.ticketing-designer__publish:has(details[open]) {
  flex-basis: 100%;
  flex-direction: column;
  align-items: flex-end;
}

.ticketing-designer__publish details[open] {
  inline-size: 100%;
  max-inline-size: 30rem;
}

.ticketing-designer__board {
  min-inline-size: 0;
  padding: var(--space-5);
  overflow-x: auto;
  background-color: var(--surface-sunken);
  background-image: radial-gradient(var(--rule-strong) 1px, transparent 1px);
  background-size: 20px 20px;
}

.ticketing-designer__board:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* Four are two by two, as the prototype lays them out, once two tiles of 16rem fit side by side (a laptop's board beside the console's menu), and one
   column below that and on a phone. A column is never narrower than half the board, so there are never three and one. */
.ticketing-designer__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, max(16rem, calc((100% - var(--space-5)) / 2))), 1fr));
  gap: var(--space-5);
  min-inline-size: 0;
}

.ticketing-designer__tiles[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
  max-inline-size: 65rem;
  margin-inline: auto;
}

.ticketing-designer__check {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* The switches. Printed size: one column, each ticket as long as its stock (the strip of the board scrolls). */
.ticketing-designer:has(#ticketing-designer-printed:checked) .ticketing-designer__tiles {
  grid-template-columns: minmax(0, max-content);
}

/* The tile is as wide as its ticket, and its words wrap to that. */
.ticketing-designer:has(#ticketing-designer-printed:checked) .ticketing-designer-tile {
  inline-size: min-content;
  max-inline-size: none;
}

.ticketing-designer:has(#ticketing-designer-printed:checked) .ticketing-designer-ticket {
  inline-size: var(--ticketing-designer-ticket-printed);
  max-inline-size: none;
}

/* Show the stock: off takes the stub and the window away, and the picture is the printer's black on white alone. */
.ticketing-designer:has(#ticketing-designer-stock:not(:checked)) .ticketing-designer-ticket__stock {
  display: none;
}

/* Long title and name: the long picture instead of the usual one. */
.ticketing-designer:has(#ticketing-designer-long:checked) .ticketing-designer-ticket__picture--normal {
  display: none;
}

.ticketing-designer:has(#ticketing-designer-long:checked) .ticketing-designer-ticket__picture--long {
  display: block;
}

/* The conversation (TicketingDesignerTalkComponent): the person's words on the end side, the designer's on the start side, each in a bubble; a run's
   steps as a list, each with a mark that says it in a shape as well as by its words. */
.ticketing-designer-talk {
  min-inline-size: 0;
}

.ticketing-designer-talk__thread {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticketing-designer-talk__said {
  display: grid;
  gap: var(--space-1);
  max-inline-size: 92%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.ticketing-designer-talk__said[data-from="you"] {
  justify-self: end;
  background: var(--accent-soft);
  color: var(--fg1);
  border-end-end-radius: var(--radius-sm);
}

.ticketing-designer-talk__said[data-from="designer"] {
  justify-self: start;
  background: var(--surface-sunken);
  color: var(--fg1);
  border-end-start-radius: var(--radius-sm);
}

.ticketing-designer-talk__words {
  margin: 0;
  white-space: pre-line;
}

.ticketing-designer-talk__meta {
  margin: 0;
  color: var(--accent-text);
  font-size: var(--text-xs);
}

.ticketing-designer-talk__step-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ticketing-designer-talk__step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-inline-size: 0;
  color: var(--fg1);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.ticketing-designer-talk__step[data-state="waiting"] {
  color: var(--fg2);
}

.ticketing-designer-talk__mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  inline-size: 1rem;
  block-size: 1.25rem;
}

.ticketing-designer-talk__mark svg {
  inline-size: 1rem;
  block-size: 1rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ticketing-designer-talk__step[data-state="done"] .ticketing-designer-talk__mark {
  color: var(--tone-good-fg);
}

.ticketing-designer-talk__step[data-state="failed"] .ticketing-designer-talk__mark {
  color: var(--tone-bad-fg);
}

.ticketing-designer-talk__dot {
  inline-size: 0.375rem;
  block-size: 0.375rem;
  border-radius: 50%;
  background: var(--fg3);
}

.ticketing-designer-talk__spinner {
  inline-size: 0.75rem;
  block-size: 0.75rem;
  border: 2px solid var(--accent-line);
  border-block-start-color: var(--accent);
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  .ticketing-designer-talk__spinner {
    animation: ticketing-designer-turn 0.8s linear infinite;
  }
}

@keyframes ticketing-designer-turn {
  to {
    transform: rotate(360deg);
  }
}
