/* share-ticket.3.css - the ticket-style Share window of the share pages (/e/<id>, /a/<source>/<id>).
   Approved design: deploy/share-ticket-design (dark and light, desktop dialog, phone bottom sheet).
   Loaded AFTER /styles.css and ONLY by a share page that offers the window. Colours are the site's tokens and nothing else
   (apps/api/test/share-ticket-assets.test.ts fails on a colour literal): the window sits in .theme-dark-scope or .theme-light-scope,
   which is how the Dark / Light switch re-colours the whole window, and the script reads the same tokens to paint the image.
   A new look is a new file name (share-ticket.4.css), never an edit of this one.
   share-ticket.3 (1.5.1, J4): the filled buttons (Copy link, Share, Save image) fill with --accent-action, the Arctic #16314A in light,
   the emerald in dark (unchanged); their press and hover keep --accent-primaryPressed. The selected segment keeps --accent-primary. */

/* ---------------------------------------------------------------- the button that opens it (page theme) */
.share-open {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-control);
  border-radius: 12px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.share-open[hidden] { display: none; }
.share-open:focus-visible { outline: 2px solid var(--border-focused); outline-offset: 2px; }
.share-open:active { background: var(--ripple-press); }
@media (hover: hover) {
  .share-open:hover { background: var(--web-ghostHoverBg); border-color: var(--web-ghostHoverBorder2); }
}

/* ---------------------------------------------------------------- the dialog: its own scrim, then the panel */
.sd {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--scrim-map);
  color: var(--text-primary);
  font-family: var(--font-family);
  overflow: auto;
}
.sd[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
html.sd-lock { overflow: hidden; }

.sd-panel {
  width: min(760px, 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 32px 32px;
  border: 1px solid var(--border-default);
  border-radius: 20px;
  background: var(--background-secondary);
  box-shadow: 0 24px 60px var(--shadow-lift);
}
.sd-grab { display: none; }
.sd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sd-head h2 { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--text-primary); }
.sd-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-control);
  border-radius: 22px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}
.sd-close:active { background: var(--ripple-press); }
@media (hover: hover) {
  .sd-close:hover { background: var(--web-ghostHoverBg); }
}

/* ---------------------------------------------------------------- the ticket */
.sd-stage { display: flex; justify-content: center; }
.sd-fit { width: 640px; max-width: 100%; container-type: inline-size; }
.sd-stage[data-format="square"] .sd-fit,
.sd-stage[data-format="story"] .sd-fit { width: 340px; }
/* the preview: the very image that Save and Share send, shown at its real shape. Until it is painted the ticket above stands in. */
.sd-stage[data-preview="ready"] .sd-fit { display: none; }
.sd-preview {
  display: block;
  height: auto;
  max-width: 100%;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--background-primary);
}
.sd-preview[hidden] { display: none; }
.sd-preview[data-format="link"] { width: 640px; aspect-ratio: 1200 / 630; }
.sd-preview[data-format="square"] { width: 340px; aspect-ratio: 1 / 1; }
.sd-preview[data-format="story"] { width: 200px; aspect-ratio: 9 / 16; }

.sd-ticket {
  position: relative;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 16px;
  background: var(--background-card);
  color: var(--text-primary);
}
.sd-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; padding: 22px 26px 18px; }
.sd-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; color: var(--accent-text); }

.sd-route { display: flex; align-items: center; gap: 8px; color: var(--text-tertiary); }
.sd-route { justify-content: flex-end; }
.sd-plane svg { overflow: visible; }
.sd-plane { flex: 0 0 auto; display: inline-flex; color: var(--accent-text); }
.sd-dest { flex: 0 1 auto; max-width: 62%; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.sd-city { font-size: 34px; font-weight: 800; line-height: 1.05; color: var(--text-primary); overflow-wrap: anywhere; }
.sd-country { font-size: 13px; color: var(--text-secondary); }

.sd-show { display: flex; flex-direction: column; gap: 4px; }
.sd-artist { font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--text-primary); overflow-wrap: anywhere; }
.sd-where { font-size: 14px; color: var(--text-secondary); overflow-wrap: anywhere; }
.sd-rule { margin: 0 -12px; border-top: 2px dashed var(--border-default); }
.sd-cells { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.sd-cell { display: flex; flex-direction: column; gap: 4px; }
.sd-cell-label { font-size: 12px; color: var(--text-secondary); }
.sd-cell-value { font-size: 18px; font-weight: 700; color: var(--text-primary); overflow-wrap: anywhere; }
.sd-foot { font-size: 12px; color: var(--text-secondary); }

/* the perforation: notches top and bottom, a dotted cut, the scissors */
.sd-perf { position: relative; flex: 0 0 0; width: 0; align-self: stretch; }
.sd-notch {
  position: absolute;
  left: -15px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  background: var(--background-secondary);
}
.sd-notch-a { top: -15px; }
.sd-notch-b { bottom: -15px; }
.sd-dots { position: absolute; left: -2px; top: 18px; bottom: 18px; border-left: 4px dotted var(--text-tertiary); }
.sd-scissors {
  position: absolute;
  left: -13px;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--background-card);
  color: var(--text-secondary);
}

/* the tear-off stub */
.sd-stub {
  flex: 0 0 150px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  background: var(--badge-background);
}
.sd-stub-label {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border-subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent-text);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.sd-stub-body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px 8px; }
.sd-stub-art { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--badge-text); overflow-wrap: anywhere; }
.sd-stub-art span { display: block; }
.sd-qr { width: 84px; height: 84px; flex: 0 0 auto; border-radius: 8px; overflow: hidden; }
.sd-qr svg { display: block; width: 100%; height: 100%; }
.sd-qr-text { display: block; padding: 6px; font-size: 9px; line-height: 1.2; word-break: break-all; color: var(--text-secondary); }
.sd-stub-tag { text-align: center; font-size: 11px; color: var(--text-secondary); }
.sd-tag-sep { display: none; }

/* narrow container (a phone, or the Square and Story previews): the ticket stands up, the perforation runs sideways, the stub sits below */
@container (max-width: 560px) {
  .sd-ticket { flex-direction: column; }
  .sd-main { gap: 10px; padding: 16px 18px 14px; }
  .sd-kicker { font-size: 11px; }
  .sd-city { font-size: 28px; }
  .sd-country { font-size: 12px; }
  .sd-artist { font-size: 19px; }
  .sd-where { font-size: 13px; }
  .sd-cell-value { font-size: 15px; }
  .sd-cell-label, .sd-foot { font-size: 11px; }
  .sd-rule { margin: 0 -8px; }
  .sd-perf { flex: 0 0 0; width: auto; height: 0; align-self: stretch; }
  .sd-notch { top: -13px; width: 26px; height: 26px; }
  .sd-notch-a { left: -14px; }
  .sd-notch-b { left: auto; right: -14px; bottom: auto; }
  .sd-dots { left: 18px; right: 18px; top: -2px; bottom: auto; border-left: 0; border-top: 4px dotted var(--text-tertiary); }
  .sd-scissors { left: 50%; top: -12px; width: 24px; height: 24px; margin: 0 0 0 -12px; border-radius: 12px; }
  .sd-stub { flex: 0 0 auto; grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "qr label" "qr art" "qr tag"; column-gap: 12px; align-items: center; padding: 14px 18px; }
  .sd-stub-label { grid-area: label; justify-content: flex-start; border-right: 0; writing-mode: horizontal-tb; transform: none; }
  .sd-stub-body { display: contents; }
  .sd-stub-art { grid-area: art; text-align: left; letter-spacing: 0.04em; }
  .sd-stub-art span { display: inline; }
  .sd-stub-art span + span::before { content: " \00b7  "; }
  .sd-qr { grid-area: qr; width: 56px; height: 56px; border-radius: 6px; }
  .sd-stub-tag { grid-area: tag; text-align: left; font-size: 11px; }
  .sd-tag-sep { display: inline; }
  .sd-tag-br { display: none; }
}

/* ---------------------------------------------------------------- options, actions, links */
.sd-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 24px; }
.sd-group { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--background-card); }
.sd-seg {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.sd-seg[aria-pressed="true"] { border-color: var(--accent-primary); background: var(--accent-tint); color: var(--text-primary); }
.sd-seg:active { background: var(--ripple-press); }
@media (hover: hover) {
  .sd-seg:hover { color: var(--text-primary); }
}

.sd-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.sd-btn {
  flex: 1 1 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--border-control);
  border-radius: 12px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.sd-btn[hidden] { display: none; }
.sd-btn-copy, .sd-btn-share { border-color: var(--accent-action); background: var(--accent-action); color: var(--text-inverse); font-weight: 700; }
.sd-btn:active { background: var(--ripple-press); }
.sd-btn-copy:active, .sd-btn-share:active { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
.sd-btn:disabled, .sd-btn[aria-busy="true"] { border-color: var(--border-disabled); background: transparent; color: var(--text-disabled); cursor: progress; }
@media (hover: hover) {
  .sd-btn:hover { background: var(--web-ghostHoverBg); }
  .sd-btn-copy:hover, .sd-btn-share:hover { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
}
.sd-only-narrow { display: none; }

.sd-status { min-height: 1.4em; text-align: center; font-size: 13px; color: var(--text-secondary); }
.sd-status[data-state="error"] { color: var(--accent-error); }
/* spoken by a screen reader, not drawn: the system shows its own notice (Android 13+ clipboard pill) at the same spot */
.sd-status[data-state="quiet"] { color: transparent; }
.sd-theme-note { flex: 1 1 100%; margin: 0; text-align: center; font-size: 12px; color: var(--text-secondary); }
.sd-manual { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.sd-manual[hidden] { display: none; }
.sd-manual input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-control);
  border-radius: 8px;
  background: var(--background-card);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}
.sd-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 4px; font-size: 13px; }
.sd-social a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; justify-content: center; padding: 0 5px; color: var(--accent-text); }

.sd :focus-visible { outline: 2px solid var(--border-focused); outline-offset: 2px; }

/* ---------------------------------------------------------------- phone: a bottom sheet */
@media (max-width: 640px) {
  .sd[open] { align-items: flex-end; padding: 0; }
  .sd-panel { width: 100%; max-height: 100%; overflow: auto; gap: 16px; padding: 12px 20px 28px; border-width: 1px 0 0; border-radius: 24px 24px 0 0; }
  .sd-grab { display: block; align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--border-default); }
  .sd-head h2 { font-size: 19px; }
  .sd-fit, .sd-stage[data-format="square"] .sd-fit, .sd-stage[data-format="story"] .sd-fit { width: 100%; }
  .sd-preview[data-format="link"] { width: 100%; }
  .sd-preview[data-format="square"] { width: min(100%, 260px); }
  .sd-preview[data-format="story"] { width: min(100%, 170px); }
  .sd-options { flex-direction: column; align-items: stretch; gap: 10px; }
  .sd-group .sd-seg { flex: 1 1 0; }
  .sd-btn-share { flex-basis: 100%; }
  .sd-btn-copy { border-color: var(--border-control); background: transparent; color: var(--text-primary); font-weight: 600; }
  .sd-btn-copy:active { background: var(--ripple-press); border-color: var(--border-control); }
  .sd-panel.sd-no-share .sd-btn-copy { border-color: var(--accent-action); background: var(--accent-action); color: var(--text-inverse); font-weight: 700; }
  .sd-panel.sd-no-share .sd-btn-copy:active { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
  .sd-only-wide { display: none; }
  .sd-only-narrow { display: inline; }
}
@media (hover: hover) and (max-width: 640px) {
  .sd-btn-copy:hover { background: var(--web-ghostHoverBg); border-color: var(--border-control); }
  .sd-panel.sd-no-share .sd-btn-copy:hover { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
}

/* ---------------------------------------------------------------- Square or Story selected: the image is the main action, Copy link steps back */
.sd-panel.sd-pic .sd-btn-copy,
.sd-panel.sd-pic.sd-no-share .sd-btn-copy { border-color: var(--border-control); background: transparent; color: var(--text-primary); font-weight: 600; }
.sd-panel.sd-pic .sd-btn-save { border-color: var(--accent-action); background: var(--accent-action); color: var(--text-inverse); font-weight: 700; }
.sd-panel.sd-pic .sd-btn-copy:active,
.sd-panel.sd-pic.sd-no-share .sd-btn-copy:active { background: var(--ripple-press); border-color: var(--border-control); }
.sd-panel.sd-pic .sd-btn-save:active { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
@media (hover: hover) {
  .sd-panel.sd-pic .sd-btn-copy:hover,
  .sd-panel.sd-pic.sd-no-share .sd-btn-copy:hover { background: var(--web-ghostHoverBg); border-color: var(--border-control); }
  .sd-panel.sd-pic .sd-btn-save:hover { background: var(--accent-primaryPressed); border-color: var(--accent-primaryPressed); }
}
.sd-panel .sd-btn:disabled,
.sd-panel .sd-btn[aria-busy="true"] { border-color: var(--border-disabled); background: transparent; color: var(--text-disabled); }

/* ---------------------------------------------------------------- motion: only where the visitor has not asked for less */
@media (prefers-reduced-motion: no-preference) {
  .sd[open] .sd-panel { animation: sd-in 180ms cubic-bezier(0.22, 1, 0.36, 1); }
  .sd-btn, .sd-seg, .share-open, .sd-close { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}
@keyframes sd-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
