/*
 * Orchestra design system (SWMA-VN/team-work: docs/design/apple.md, src/client/index.css,
 * tailwind.config.ts), ported to plain CSS. Token values are copied from team-work's index.css;
 * if they disagree, team-work wins. Same port as the Shopware Orders CS tool (team-work#783).
 * Rules kept: one accent per mode, elevation by surface + hairline (no shadows), weights
 * 300/400/600/700 (never 500), body 17/1.47, the 4/8/12/17/24/32/48 rhythm, 44px targets,
 * one 2px focus ring, no hover colours (press = scale 0.95), state never colour alone.
 * Theme follows the device (Orchestra's "System" mode; design record 0002).
 */
:root {
  color-scheme: light;
  --color-canvas: 255 255 255;
  --color-surface-parchment: 245 245 247;
  --color-surface-pearl: 250 250 252;
  --color-ink: 29 29 31;
  --color-ink-80: 51 51 51;
  --color-ink-48: 110 110 115;
  --color-ink-24: 184 184 189;
  --color-hairline: 224 224 224;
  --color-divider-soft: 240 240 240;
  --color-accent: 0 102 204;
  --color-accent-focus: 0 113 227;
  --color-on-accent: 255 255 255;
  --color-status-success: 29 122 70;
  --color-status-warn: 178 94 0;
  --color-status-danger: 196 39 28;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-canvas: 28 28 30;
    --color-surface-parchment: 10 10 12;
    --color-surface-pearl: 42 42 44;
    --color-ink: 255 255 255;
    --color-ink-80: 204 204 204;
    --color-ink-48: 152 152 157;
    --color-ink-24: 90 90 94;
    --color-hairline: 58 58 60;
    --color-divider-soft: 44 44 46;
    --color-accent: 41 151 255;
    --color-accent-focus: 64 156 255;
    --color-on-accent: 29 29 31;
    --color-status-success: 48 209 88;
    --color-status-warn: 255 159 10;
    --color-status-danger: 255 69 58;
  }
}
:root {
  --canvas: rgb(var(--color-canvas));
  --parchment: rgb(var(--color-surface-parchment));
  --pearl: rgb(var(--color-surface-pearl));
  --ink: rgb(var(--color-ink));
  --ink-80: rgb(var(--color-ink-80));
  --ink-48: rgb(var(--color-ink-48));
  --hairline: rgb(var(--color-hairline));
  --divider-soft: rgb(var(--color-divider-soft));
  --accent: rgb(var(--color-accent));
  --accent-focus: rgb(var(--color-accent-focus));
  --on-accent: rgb(var(--color-on-accent));
  --success: rgb(var(--color-status-success));
  --warn: rgb(var(--color-status-warn));
  --danger: rgb(var(--color-status-danger));
  --font: -apple-system, system-ui, "SF Pro Text", "SF Pro Display", sans-serif;
  --radius-sm: 8px; --radius-md: 11px; --radius-lg: 18px; --radius-pill: 9999px;
  --ease-reveal: cubic-bezier(0.32, 0.08, 0.24, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--parchment); }
body {
  margin: 0; background: var(--parchment); color: var(--ink); font-family: var(--font);
  font-size: 17px; line-height: 1.47; letter-spacing: -0.374px; font-weight: 400;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select { font-family: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent-focus); outline-offset: 2px; }

/* Frosted sticky bar (pattern 2) */
.bar {
  position: sticky; top: 0; z-index: 10; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px max(16px, calc((100% - 560px) / 2)); padding-top: max(8px, env(safe-area-inset-top));
  background: rgb(var(--color-surface-parchment) / 0.8);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: inline-flex; line-height: 0; flex: none; }
.logo { height: 22px; width: auto; }
.logo-on-dark { display: none; }
@media (prefers-color-scheme: dark) { .logo-on-light { display: none; } .logo-on-dark { display: block; } }
.demo-tag {
  flex: 0 1 auto; min-width: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; line-height: 1.33; letter-spacing: -0.12px; color: var(--ink-48);
  border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 4px 12px;
}

/* Segmented control (language switch) */
.lang { flex: none; display: inline-flex; gap: 2px; padding: 2px; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-pill); }
.lang button {
  min-height: 32px; min-width: 44px; padding: 4px 12px; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink-80); font-size: 14px; letter-spacing: -0.224px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* Page */
.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }

.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; }
.steps li { height: 4px; flex: 1; border-radius: var(--radius-pill); background: var(--hairline); transition: background-color 250ms var(--ease-reveal); }
.steps li.on { background: var(--accent); }

/* Card: canvas + hairline, never a shadow (pattern 3). One quiet reveal when a step appears. */
section {
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 32px 24px;
  animation: route-fade-in 260ms var(--ease-reveal) backwards;
}
@media (max-width: 420px) { section { padding: 24px 17px; } }
@keyframes route-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Type ramp */
.eyebrow { margin: 0 0 8px; color: var(--ink-48); font-size: 12px; line-height: 1.33; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.15; letter-spacing: -0.374px; font-weight: 600; text-wrap: balance; }
@media (max-width: 420px) { h1 { font-size: 28px; } }
h1[tabindex="-1"]:focus { outline: none; }
.lede { margin: 0 0 24px; color: var(--ink-80); }
.small, small { color: var(--ink-48); font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; }
small { display: block; margin-top: 4px; }
.note { margin: 0 0 24px; padding: 12px 17px; border-radius: var(--radius-md); background: var(--parchment); color: var(--ink-80); font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; }

/* Fields (the Field contract: label, control, help, error) */
.field { display: block; margin-bottom: 17px; min-width: 0; }
.field > span { display: block; margin-bottom: 4px; color: var(--ink-48); font-size: 12px; line-height: 1.33; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
input, select {
  width: 100%; height: 44px; padding: 0 12px;
  font-size: 16px; letter-spacing: normal; color: var(--ink);    /* 16px: no iOS focus zoom */
  background-color: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-md);
  appearance: none; -webkit-appearance: none; margin: 0;
}
/* Our chevron in ink-48 (no engine arrow), drawn in CSS so it follows the theme. */
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-48) 50%), linear-gradient(135deg, var(--ink-48) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 12px) 19px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px;
}
input::placeholder { color: var(--ink-48); opacity: 1; }
input:focus, select:focus { border-color: var(--accent); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent-focus); outline-offset: 2px; }
/* Error wins over every other border treatment. */
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.row { display: grid; grid-template-columns: 9.5rem 1fr; gap: 12px; }
@media (max-width: 380px) { .row { grid-template-columns: 1fr; gap: 0; } }

/* Colour choice: a radio group of tiles. Selected = accent border AND a check mark. */
.colours { border: 0; padding: 0; margin: 8px 0 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.colour {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 17px; padding: 24px 12px;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--radius-lg); cursor: pointer;
  transition: transform 150ms var(--ease-reveal);
}
.colour:active { transform: scale(0.95); }
.colour input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.colour:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.colour:has(input:checked)::after {
  content: "✓"; position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 700; line-height: 1;
}
.colour:has(input:focus-visible) { outline: 2px solid var(--accent-focus); outline-offset: 2px; }
.watch { width: 100%; max-width: 150px; height: auto; aspect-ratio: 1; object-fit: contain; }
/* The black watch disappears on a dark card, so dark mode puts both photos on white, like psaim.info. */
@media (prefers-color-scheme: dark) { .watch { background: #fff; border-radius: var(--radius-lg); padding: 8px; } }
.colour-name { font-size: 21px; line-height: 1.19; letter-spacing: -0.24px; font-weight: 600; text-align: center; text-wrap: balance; }

#s2-lede { margin-bottom: 24px; }
.watch-cards { display: grid; gap: 12px; margin: 0 0 24px; }
.watch-card { padding: 17px; border: 1px solid var(--hairline); border-radius: var(--radius-lg); background: var(--parchment); }
.watch-card[aria-invalid="true"] { border-color: var(--danger); }
.watch-card[aria-invalid="true"] .watch-card-title::before { content: "⚠ "; color: var(--danger); }
.watch-card:focus { outline: 2px solid var(--accent-focus); outline-offset: 2px; }
.watch-card-title { margin: 0 0 12px; font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; color: var(--ink-48); }
.watch-card-title b { color: var(--ink); font-weight: 600; }
.compact-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.colour.compact { gap: 8px; padding: 12px 8px; border-radius: var(--radius-md); min-width: 0; }
.colour.compact:has(input:checked)::after { top: 4px; right: 4px; width: 20px; height: 20px; font-size: 12px; }
.colour.compact .watch { max-width: 76px; }
@media (prefers-color-scheme: dark) { .colour.compact .watch { border-radius: var(--radius-md); padding: 4px; } }
.colour.compact .colour-name { font-size: 17px; line-height: 1.24; letter-spacing: -0.374px; }

/* Buttons: primary pill, secondary ghost pill. No hover colour; press = scale(0.95). */
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; max-width: 100%; padding: 11px 22px; border-radius: var(--radius-pill);
  font-size: 17px; line-height: 1.24; font-weight: 400; letter-spacing: -0.374px; white-space: nowrap; cursor: pointer;
  text-decoration: none; transition: transform 150ms var(--ease-reveal);
}
.primary:active, .secondary:active { transform: scale(0.95); }
.primary { width: 100%; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); }
.secondary { border: 1px solid var(--accent); background: transparent; color: var(--accent); }
.primary[disabled], .secondary[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.actions { display: grid; grid-template-columns: auto 1fr; gap: 12px; }

/* Error: always-mounted live region, a warning glyph plus words. */
.error { min-height: 1.43em; margin: 0 0 12px; color: var(--danger); font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; }
.error:not(:empty)::before { content: "⚠ "; }

/* Done */
.done-mark { width: 56px; height: 56px; margin-bottom: 24px; border-radius: 50%; background: var(--success); position: relative; }
.done-mark::after { content: ""; position: absolute; left: 19px; top: 12px; width: 13px; height: 24px; border: solid var(--canvas); border-width: 0 4px 4px 0; transform: rotate(45deg); }
/* Key/value rows with inset hairlines */
.summary { margin: 0 0 24px; padding: 8px 17px; border-radius: var(--radius-md); background: var(--parchment); display: grid; grid-template-columns: fit-content(40%) 1fr; column-gap: 17px; font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; }
.summary dt, .summary dd { padding: 8px 0; border-bottom: 1px solid var(--divider-soft); }
.summary dt:nth-last-of-type(1), .summary dd:last-of-type { border-bottom: 0; }
.summary dt { color: var(--ink-48); }
.summary dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; white-space: pre-line; }

/* Step 1 notice: the choose-by date, big. Warm orange tone, friendly words; no glyph of alarm. */
.notice { margin: 0 0 24px; padding: 17px; border: 2px solid var(--warn); border-radius: var(--radius-lg); background: rgb(var(--color-status-warn) / 0.08); }
.notice.loading .notice-label, .notice.loading .notice-head { visibility: hidden; }
.notice-label { margin: 0 0 4px; font-size: 14px; line-height: 1.29; letter-spacing: -0.224px; font-weight: 600; color: var(--warn); }
.notice-head { margin: 0 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.notice-title { font-size: 28px; line-height: 1.15; letter-spacing: -0.374px; font-weight: 600; color: var(--ink); text-wrap: balance; overflow-wrap: anywhere; }
.notice-left { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 12px; border-radius: var(--radius-pill); background: var(--warn); color: var(--canvas); font-size: 14px; line-height: 1.29; font-weight: 600; white-space: nowrap; }
.notice-text { margin: 0 0 17px; padding-top: 12px; border-top: 1px solid rgb(var(--color-status-warn) / 0.25); font-size: 17px; line-height: 1.47; color: var(--ink); }
.notice .ack { margin: 0; font-size: 17px; font-weight: 600; align-items: center; }
/* Same warm orange as the step 1 notice. */
.final-note { margin: 0 0 17px; padding: 12px 17px; border: 1px solid var(--warn); border-radius: var(--radius-md); background: rgb(var(--color-status-warn) / 0.08); color: var(--ink); font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; }
/* Acknowledgement tick box: 24px box in a 44px row; error = danger outline + the form's ⚠ message. */
.ack { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; margin: 0 0 17px; cursor: pointer; font-size: 14px; line-height: 1.43; letter-spacing: -0.224px; color: var(--ink); }
.ack input { flex: none; width: 24px; height: 24px; margin: 0; padding: 0; appearance: auto; -webkit-appearance: checkbox; accent-color: var(--accent); cursor: pointer; }
.ack input[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; }
.ack span { padding-top: 2px; }
.notice .ack span { padding-top: 0; }
.phone-group { margin-bottom: 17px; }
.phone-row { display: grid; grid-template-columns: 6.5rem 1fr; gap: 12px; }
.phone-row .field { margin-bottom: 0; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Reduced motion, in one place: durations near zero so end events still fire. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Staff page */
.admin .wrap { max-width: 720px; }
.admin .bar { padding-left: max(16px, calc((100% - 720px) / 2)); padding-right: max(16px, calc((100% - 720px) / 2)); }
.gap { margin-top: 24px; }
.h2 { font-size: 21px; line-height: 1.19; letter-spacing: -0.24px; }
.admin section .small + .small { margin-top: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 45%), 1fr)); gap: 12px; margin: 24px 0 17px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 17px; border-radius: var(--radius-md); background: var(--parchment); min-width: 0; }
.tile .n { font-size: 34px; line-height: 1.15; letter-spacing: -0.374px; font-weight: 600; font-variant-numeric: tabular-nums; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 8px; }
.admin-actions .primary { width: auto; }
.as-button { text-decoration: none; }
input[type=file] { height: auto; min-height: 44px; padding: 4px; border-style: dashed; }
/* File button = the utility rect (ink fill, canvas text, 8px radius, 44px). */
input[type=file]::file-selector-button {
  margin-right: 12px; min-height: 44px; padding: 8px 15px; border: 0; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--canvas); font-family: inherit; font-size: 14px; font-weight: 400; cursor: pointer;
}
/* Native date field: same height and look as the others (Orchestra's DateField is not ported here). */
input[type=date] { display: block; line-height: 42px; }
@media (max-width: 520px) { .admin-actions > * { width: 100%; } }
