/* Ticket Templates editor (docs/TEMPLATES-SPEC.md). Only what ticket-maker.css lacks: that file supplies the
 * tokens, buttons, inputs, download menu, Sign Up sheet and scenes. Scoped under #tg-ticket-maker / .tm-sheet. */

/* ---------- renderer (§3): w×h pt at K=4 px/pt, CSS-scaled to its frame by JS ---------- */
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-frame { position: relative; width: 100%; overflow: hidden; }
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-ticket {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  transform-origin: 0 0;
  background: center / 100% 100% no-repeat; /* no colour: art may have alpha (notches, lanyard slot); PNG keeps it */
}
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-slot {
  position: absolute;
  box-sizing: border-box;        /* JS sets padding-top to centre 1-line slots */
  margin: 0;
  padding: 0;
  overflow: hidden;              /* at the fit floor the text clips, no ellipsis */
  white-space: pre;
  transform-origin: 0 0;
  font-style: normal;
  font-kerning: normal;
  text-decoration: none;
}
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-slot.tm-tt-wrap { white-space: pre-line; overflow-wrap: break-word; }
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-brand { position: absolute; display: block; height: auto; max-width: none; }
#tg-ticket-maker .tm-tt-export-host { position: fixed; top: 0; left: -100000px; pointer-events: none; }
/* a neutral tile of fixed height that contains any shape, centred (grid cards, strip thumbs). JS sets --tm-ar = w / h */
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-tile {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  container-type: size;
  background: var(--tm-bg3);
}
:is(#tg-ticket-maker, .tm-sheet) .tm-tt-tile > .tm-tt-frame { width: min(100%, 100cqh * var(--tm-ar, 2)); }

/* ---------- category grid (§7.4): 4 columns; the data puts 8 landscape tiles in rows 1–2 and the 4 portrait tiles in
 * row 3. Tiles take their shape's aspect, so landscape rows are short and the portrait row is tall; every tile in a
 * row has the same column width and aspect, so a row shares one height. 2 columns on tablet; on mobile landscape
 * tiles span the row and portrait tiles go 2-up. ---------- */
#tg-ticket-maker .tm-tt-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
#tg-ticket-maker .tm-tt-grid > li { margin: 0; min-width: 0; }
#tg-ticket-maker .tm-tt-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  font: inherit;
  color: var(--tm-t1);
  text-align: left;
}
#tg-ticket-maker .tm-tt-card .tm-tt-tile {
  position: relative;
  aspect-ratio: 2 / 1;
  padding: 16px;
  border-radius: 12px;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out, background-color 200ms ease-out;
}
#tg-ticket-maker .tm-tt-grid > li:not([data-shape="landscape"]) .tm-tt-tile { aspect-ratio: 3 / 4; padding: 20px; }
/* drop-shadow, not box-shadow: it follows the art's alpha (notched or slotted tickets) */
#tg-ticket-maker .tm-tt-card .tm-tt-frame { border-radius: 8px; filter: drop-shadow(0 1px 2px rgb(10 13 18 / 0.1)); }
#tg-ticket-maker .tm-tt-pill {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--tm-solid);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--tm-sh-lg);
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 150ms ease-out;
  pointer-events: none;
}
#tg-ticket-maker .tm-tt-card:is(:hover, :focus-visible) .tm-tt-tile { background: var(--tm-b2); box-shadow: var(--tm-sh-lg); transform: translateY(-4px); }
#tg-ticket-maker .tm-tt-card:is(:hover, :focus-visible) .tm-tt-pill { opacity: 1; }
#tg-ticket-maker .tm-tt-card:focus-visible { outline: none; }
#tg-ticket-maker .tm-tt-card:focus-visible .tm-tt-tile { outline: 2px solid var(--tm-bb); outline-offset: 2px; } /* the ring lifts with the tile */
@media (prefers-reduced-motion: reduce) {
  #tg-ticket-maker .tm-tt-card .tm-tt-tile, #tg-ticket-maker .tm-tt-pill { transition: none; }
  #tg-ticket-maker .tm-tt-card:is(:hover, :focus-visible) .tm-tt-tile { transform: none; }
}
@media (max-width: 1023px) {
  #tg-ticket-maker .tm-tt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  #tg-ticket-maker .tm-tt-grid { gap: 16px; }
  #tg-ticket-maker .tm-tt-grid > li[data-shape="landscape"] { grid-column: 1 / -1; }
  #tg-ticket-maker .tm-tt-grid > li:not([data-shape="landscape"]) .tm-tt-tile { padding: 12px; }
}

/* ---------- editor dialog (§4): a portal on <body> carrying .tm-sheet, so ticket-maker.css tokens and chrome apply
 * and no page stacking context (the hero's isolation) can cover it. Rules use :is(#tg-ticket-maker, .tm-sheet)
 * for the same (id-level) specificity as the ticket-maker.css rules they adjust. ---------- */
.tm-sheet.tm-tt-editor {
  position: fixed;
  inset: 0;
  z-index: 1000; /* = the Sign Up sheet, which is appended to <body> later and so paints on top */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-backdrop { position: absolute; inset: 0; background: rgba(10, 13, 18, 0.5); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel {
  position: relative;
  width: 100%;
  max-width: 1200px;
  max-height: 100%;
  padding: 0 32px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
  background: var(--tm-bg1);
  box-shadow: var(--tm-sh-lg);
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-layout {
  display: grid;
  grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
  grid-template-areas: "head head" "stage fields" "actions fields" "format fields" "strip fields";
  grid-template-rows: auto auto auto auto 1fr; /* strip sits under the actions so it is above the fold */
  column-gap: 32px;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 16px 0;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-head-text { min-width: 0; }
/* §8.3.4 helper line under the header's crumb */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-help {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  color: var(--tm-t3);
  white-space: nowrap;
  text-overflow: ellipsis;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-crumb {
  display: flex;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--tm-t3);
  white-space: nowrap;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-crumb:focus { outline: none; } /* focused programmatically on open only */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-crumb-label { overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--tm-t1); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-pos { font-variant-numeric: tabular-nums; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--tm-bg1);
  color: var(--tm-t4);
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-close:hover { background: var(--tm-bg2); color: var(--tm-t2); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-stage {
  grid-area: stage;
  position: relative; /* holds the crossfade's ghost */
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  --tm-stage-h: clamp(300px, 48vh, 440px);
  height: var(--tm-stage-h); /* one height for every shape, so switching designs never moves the actions */
  padding: 24px 16px;
  border-radius: 12px;
  border: 1px solid var(--tm-b2);
  /* light grid lines like the page hero, static; works under dark and light tickets alike (dark stages were rejected) */
  background-color: var(--tm-bg1);
  background-image: var(--tm-grid);
  background-size: 24px 24px;
  background-position: center;
}
/* the preview fits the stage: landscape by width, portrait by height (stage height minus its 2 × 24px padding) */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main {
  flex: 1;
  min-width: 0;
  max-width: calc((var(--tm-stage-h) - 48px) * var(--tm-ar));
  margin: 0 auto;
  filter: drop-shadow(0 12px 8px rgb(10 13 18 / 0.08)) drop-shadow(0 4px 3px rgb(10 13 18 / 0.03));
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-nav {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--tm-b1);
  border-radius: 50%;
  background: var(--tm-bg1);
  color: var(--tm-t2);
  box-shadow: var(--tm-sh-xs);
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-nav:hover { background: var(--tm-bg2); color: var(--tm-t1); }
/* §8.3.4 crossfade: the old preview, frozen where it was, fading out over the new one */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main.tm-tt-ghost { position: absolute; flex: none; max-width: none; margin: 0; pointer-events: none; }

/* §8.3.1 field ↔ ticket link (preview only): linked slots take the pointer; the hovered or focused field's slots get a
 * 2px dashed outline, drawn by a pseudo-element so a slot's own box keeps its radius. --tm-inv undoes the CSS scale. */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main .tm-tt-slot[data-f] { cursor: pointer; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main .tm-tt-slot.tm-tt-hl { overflow: visible; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main .tm-tt-slot.tm-tt-hl::after {
  content: "";
  position: absolute;
  inset: calc(-2px * var(--tm-inv, 1));
  border: calc(2px * var(--tm-inv, 1)) dashed var(--tm-bb);
  border-radius: calc(4px * var(--tm-inv, 1));
  pointer-events: none;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-actions { grid-area: actions; align-self: start; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-fields { grid-area: fields; display: flex; flex-direction: column; gap: 16px; min-width: 0; margin: 0; }
/* §8.3.3 groups: fieldsets as the Ticket Maker's; hidden groups take no gap, the first shown one no rule */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-group + .tm-tt-group { margin-top: 0; padding-top: 0; border-top: 0; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-group:not([hidden]) ~ .tm-tt-group:not([hidden]) { padding-top: 16px; border-top: 1px solid var(--tm-b2); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc .tm-legend { margin: 0; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc .tm-tt-group-body { padding-top: 16px; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--tm-t1);
  text-align: left;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-title { flex: none; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-sum {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 400;
  color: var(--tm-t3);
  white-space: nowrap;
  text-overflow: ellipsis;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-ic { display: grid; flex: none; margin-left: auto; color: var(--tm-t4); transition: transform 150ms ease-out; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-btn[aria-expanded="true"] .tm-tt-disc-ic { transform: rotate(180deg); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-btn:hover .tm-tt-disc-ic { color: var(--tm-t2); }
@media (prefers-reduced-motion: reduce) { :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-disc-ic { transition: none; } }
/* §8.3.4 format line under the action row */
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-format { grid-area: format; margin: 8px 0 0; font-size: 14px; line-height: 20px; color: var(--tm-t3); font-variant-numeric: tabular-nums; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor textarea.tm-input { height: auto; min-height: 76px; padding: 10px 14px; resize: vertical; font-family: inherit; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-reset { align-self: flex-start; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-strip { grid-area: strip; align-self: start; min-width: 0; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--tm-b2); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-chips { margin: 0 0 12px; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-strip-label { margin: 0 0 12px; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--tm-t2); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-strip-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb {
  display: block;
  width: 100%;
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: none;
}
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb:hover { border-color: var(--tm-b1); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb[aria-current="true"] { border-color: var(--tm-bb); }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb .tm-tt-tile { height: 88px; padding: 8px; border-radius: 4px; }
:is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb .tm-tt-frame { border-radius: 4px; }

/* mobile (§4): full-screen sheet, preview sticky at the top, strip scrolls sideways, actions sticky at the bottom */
@media (max-width: 1023px) {
  .tm-sheet.tm-tt-editor { padding: 0; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "stage" "fields" "strip" "format" "actions";
    grid-template-rows: none;
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel {
    height: 100%;
    max-height: none;
    padding: 0 16px;
    border-radius: 0;
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-head {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 64px;
    margin: 0 -16px;
    padding: 8px 8px 8px 16px;
    background: var(--tm-bg1);
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-stage {
    position: sticky;
    top: 64px;
    z-index: 2;
    gap: 8px;
    margin: 0 -16px;
    height: auto;
    padding: 12px 8px;
    border-radius: 0;
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-nav { width: 32px; height: 32px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-main { max-width: calc((45vh - 24px) * var(--tm-ar)); }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-fields { padding-top: 20px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-strip { margin-top: 24px; padding-top: 20px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-format { margin-top: 20px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-help { font-size: 13px; line-height: 18px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-strip-list {
    display: flex;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 0 16px 4px;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-thumb { flex: none; width: 168px; scroll-snap-align: start; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    gap: 8px 20px;
    margin: 24px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--tm-b2);
    background: var(--tm-bg1);
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-menu { top: auto; bottom: calc(100% + 4px); } /* opens upward from the bottom bar */
  /* one row (bar ≤ 72px): Download fills, Send / Add Secure QR Codes become 44px icon buttons; their text stays as
   * visually hidden button text (the accessible name) and as the title tooltip */
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-actions { flex-wrap: nowrap; gap: 8px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-dl { flex: 1 1 auto; min-width: 0; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-dl-main { min-width: 0; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-more { flex: none; flex-wrap: nowrap; gap: 8px; }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-link {
    position: relative;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--tm-b1);
    border-radius: 8px;
    background: var(--tm-bg1);
  }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-link:hover { background: var(--tm-bg2); }
  :is(#tg-ticket-maker, .tm-sheet).tm-tt-editor .tm-tt-panel .tm-link-text {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* ---------- Sign Up sheet: the rendered template in place of the Ticket Maker's artboard and mini ticket ---------- */
.tm-sheet .tm-tt-sheet-ticket {
  max-width: calc(240px * var(--tm-ar, 3)); /* portrait shapes: at most 240px tall, centred */
  margin-inline: auto;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: none;
  filter: drop-shadow(0 12px 8px rgb(10 13 18 / 0.08)) drop-shadow(0 4px 3px rgb(10 13 18 / 0.03));
}
.tm-sheet .tm-mt.tm-mt-tpl { /* a 220 × 88 box (the mini ticket's) that contains any shape */
  display: grid;
  place-items: center;
  container-type: size;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  -webkit-mask: none;
  mask: none;
}
:is(#tg-ticket-maker, .tm-sheet) .tm-mt-tpl > .tm-tt-frame { /* :is() for id-level specificity over the base .tm-tt-frame width */
  width: min(100%, 100cqh * var(--tm-ar, 2.5));
  border-radius: 4px;
  filter: drop-shadow(0 12px 8px rgb(10 13 18 / 0.08)) drop-shadow(0 4px 3px rgb(10 13 18 / 0.03));
}
/* the field's text is cut on this design even at the smallest size (§3): the counter line says so */
:is(#tg-ticket-maker, .tm-sheet) .tm-counter.tm-counter-warn { color: #B54708; text-align: left; }
