/*
 * ROSE'S design system v1 -- Workshop Dark (site and app).
 * Source: ROSES_Design_System.pdf. Every colour, size, duration and easing
 * below is taken from it; change them HERE, not in individual pages.
 *
 * Rules from the system:
 *  - One rose (--acc), spent carefully: primary button, selected border,
 *    tags, the strop line and focus. Never large areas.
 *  - --line is decoration only; anything you can press or type in uses
 *    --line-strong.
 *  - 3px corners everywhere. Only ticks and dots are round.
 *  - No shadows. The only "shadow-like" thing is the focus ring: a 2px
 *    ground-coloured gap, then 2px of rose.
 *  - Four motions only (rise, strop, pole, tick). With reduced motion on,
 *    every move is instant and the pole stands still.
 */

/* ---------- Fonts ----------
 * Mono: IBM Plex Mono (SIL Open Font Licence), served from public/fonts/
 * (see public/fonts/README.md). To change the font later, add the new
 * files there, point the three @font-face rules below at them and update
 * --mono in :root. Also update MONO in lib/customer-emails.ts.
 * Sans: the design's sans face isn't confirmed yet -- set --sans below once
 * it is. */
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: local("IBM Plex Mono"), local("IBMPlexMono"), url("/fonts/IBMPlexMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-style: normal; font-display: swap;
  src: local("IBM Plex Mono SemiBold"), local("IBMPlexMono-SemiBold"), url("/fonts/IBMPlexMono-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 700; font-style: normal; font-display: swap;
  src: local("IBM Plex Mono Bold"), local("IBMPlexMono-Bold"), url("/fonts/IBMPlexMono-Bold.woff2") format("woff2"); }

:root {
  /* Colour -- Workshop Dark */
  --bg: #0f0f0e; --card: #181716; --fg: #eee9df; --mut: #a39d92;
  --line: #2c2a27; --line-strong: #6a645b; --acc: #c9808a; --on: #0f0f0e;
  --err-fg: #e8a3ab; --err-bg: #2a1418; --err-line: #4a1f27;
  --ok-fg: #8fce9c; --ok-bg: #122318; --ok-line: #1f4a2a;

  /* Type */
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hf: var(--mono); /* older name, still used in places */

  /* Space */
  --space-1: 4px; --space-1-5: 6px; --space-2: 8px; --space-2-5: 10px; --space-3: 12px;
  --space-card: 13px; --space-3-5: 14px; --space-4: 16px; --space-10: 40px;
  --radius: 3px;

  /* Motion */
  --dur-instant: 90ms; --dur-fast: 160ms; --dur-base: 240ms; --dur-slow: 420ms;
  --dur-stagger: 45ms; --dur-pole: 1100ms;
  --ease-cut: cubic-bezier(.2, .8, .2, 1);    /* default: anything arriving */
  --ease-exit: cubic-bezier(.4, 0, 1, 1);     /* anything leaving */
  --ease-swing: cubic-bezier(.65, 0, .35, 1); /* strop, state to state */
  --ease-set: cubic-bezier(.34, 1.4, .64, 1); /* ticks only: small overshoot */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.4 var(--sans);
  padding-bottom: env(safe-area-inset-bottom, 0);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--acc); color: var(--on); }

/* Focus: 2px ground gap, then 2px rose. The only ring there is. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* ---------- Type scale ---------- */
.display { font: 700 56px/.95 var(--mono); letter-spacing: -.01em; margin: 0; }
.logo, .wordmark { font: 700 24px/1 var(--mono); letter-spacing: .14em; }
h1 { font: 700 24px/1.15 var(--mono); margin: var(--space-2) 0 var(--space-4); }
.k, .eyebrow { font: 400 12px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mut); margin-bottom: var(--space-2); }
.price { font: 600 20px/1.1 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { font: 400 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--acc); }
.mut, .small { color: var(--mut); font-size: 14px; line-height: 1.4; }
label, .label { display: block; font: 700 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--mut); margin-bottom: var(--space-1-5); }
p { margin: 0 0 var(--space-4); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; min-height: 50px; padding: var(--space-3-5) var(--space-4); margin-bottom: var(--space-2-5);
  background: var(--acc); color: var(--on); border: 1px solid var(--acc); border-radius: var(--radius);
  font: 700 14px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; text-align: center;
  cursor: pointer; transition: background var(--dur-instant) var(--ease-cut), border-color var(--dur-instant) var(--ease-cut), color var(--dur-instant) var(--ease-cut);
}
.btn:active { filter: brightness(.92); }
.btn.g { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn.g:hover { border-color: var(--fg); }
.btn.danger { background: transparent; color: var(--err-fg); border-color: var(--err-line); }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--card); color: var(--mut); border-color: var(--line); cursor: not-allowed; filter: none; }
.btn .arrow { margin-left: auto; font-weight: 400; }
.btn.go { justify-content: space-between; }
.link { background: none; border: 0; padding: var(--space-1-5) 0; color: var(--acc); font: 400 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }

/* ---------- Fields ---------- */
input, select, textarea {
  display: block; width: 100%; min-height: 48px; padding: var(--space-3) var(--space-3-5); margin-bottom: var(--space-2-5);
  background: var(--card); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 15px/1.3 var(--sans); transition: border-color var(--dur-fast) var(--ease-cut);
}
input::placeholder { color: #6f6a62; }
input[type="checkbox"] { display: inline-block; width: auto; min-height: 0; margin: 0 var(--space-1-5) 0 0; accent-color: var(--acc); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mut) 50%), linear-gradient(135deg, var(--mut) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field { margin-bottom: var(--space-3); }
.hint { color: var(--mut); font-size: 14px; margin: calc(-1 * var(--space-1)) 0 var(--space-3); }

/* Code boxes: six boxes that behave like one field (typing, paste, and the
   phone's "fill code from email" all work -- see codeBoxes() in app.js). */
.code { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-2); margin-bottom: var(--space-3); max-width: 372px; }
.code input { min-height: 56px; margin: 0; padding: 0; text-align: center; font: 600 22px/1 var(--mono); font-variant-numeric: tabular-nums; }
.code input:focus { border-color: var(--acc); }

/* ---------- Notices ---------- */
.err, .ok-msg, .notice {
  padding: var(--space-3) var(--space-3-5); margin-bottom: var(--space-2-5); border-radius: 0; border: 1px solid; font-size: 14px; line-height: 1.4;
  animation: rise var(--dur-base) var(--ease-cut) both;
}
.err { color: var(--err-fg); background: var(--err-bg); border-color: var(--err-line); }
.ok-msg { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.err::before, .ok-msg::before { font: 700 12px var(--mono); letter-spacing: .08em; }
.err::before { content: "ERROR \00B7  "; }
.ok-msg::before { content: attr(data-label) " \00B7  "; }
.ok-msg:not([data-label])::before { content: "DONE \00B7  "; }

/* ---------- Cards ---------- */
.card {
  display: block; width: 100%; margin-bottom: var(--space-2-5); padding: var(--space-card);
  background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: left; font: inherit;
}
button.card { border-color: var(--line-strong); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-cut); }
button.card:hover { border-color: var(--fg); }
button.card.sel, .sel { border-color: var(--acc) !important; }
button.card[disabled] { opacity: .55; cursor: not-allowed; }
.card .title { font: 700 16px/1.25 var(--mono); }
.card .title .tag { margin-left: var(--space-1-5); vertical-align: 1px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.total { border-top: 1px solid var(--line); margin-top: var(--space-2); padding-top: var(--space-2); }

/* ---------- Chips (who's booking, barber filters) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.chips button, .g3 button {
  padding: var(--space-2-5) var(--space-3); background: var(--card); color: var(--fg);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 400 12px/1.25 var(--mono); letter-spacing: .04em; cursor: pointer; transition: border-color var(--dur-fast) var(--ease-cut);
}
.chips button.sel { border-color: var(--acc); }

/* ---------- Date strip ---------- */
.dates { display: flex; gap: var(--space-2); overflow-x: auto; margin: 0 calc(-1 * var(--space-4)) var(--space-4); padding: 2px var(--space-4) var(--space-1); scroll-padding-inline: var(--space-4); scrollbar-width: none; scroll-snap-type: x proximity; }
.dates::-webkit-scrollbar { display: none; }
.dates button {
  position: relative; flex: 0 0 auto; width: 62px; padding: var(--space-2-5) 0 var(--space-3);
  background: var(--card); color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  text-align: center; cursor: pointer; scroll-snap-align: start; transition: border-color var(--dur-fast) var(--ease-cut);
}
.dates .dow { display: block; font: 400 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin-bottom: var(--space-1-5); }
.dates .num { display: block; font: 700 20px/1 var(--mono); font-variant-numeric: tabular-nums; }
.dates .mon { display: block; font: 400 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin-top: var(--space-1); }
.dates button.sel { border-color: var(--acc); }

/* The strop: a 2px rose line drawn left to right under whatever is picked. */
.strop, .dates button.sel::after {
  content: ""; display: block; height: 2px; background: var(--acc);
  transform-origin: left center; animation: strop var(--dur-slow) var(--ease-swing) both;
}
.dates button.sel::after { position: absolute; left: 8px; right: 8px; bottom: 5px; }

/* ---------- Time slots ---------- */
.slots, .g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.slots button {
  min-height: 46px; background: transparent; color: var(--fg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 400 14px/1 var(--mono); font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-cut), color var(--dur-fast) var(--ease-cut), border-color var(--dur-fast) var(--ease-cut);
}
.slots button.sel { background: var(--acc); border-color: var(--acc) !important; color: var(--on); font-weight: 700; }
.slots button.taken { border-style: dashed; border-color: var(--line); color: #6f6a62; text-decoration: line-through; cursor: not-allowed; }

/* ---------- Loading: the pole (the only loader, always with words) ---------- */
.loading { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-3-5); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font: 400 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--mut); margin-bottom: var(--space-4); }
.pole { flex: 0 0 auto; width: 10px; height: 28px; border: 1px solid var(--fg); border-radius: 2px; overflow: hidden;
  background: repeating-linear-gradient(-45deg, var(--fg) 0 4px, var(--acc) 4px 8px, var(--bg) 8px 12px);
  background-size: 100% 34px; animation: pole var(--dur-pole) linear infinite; }

/* ---------- Status: dot + word ---------- */
.status { display: inline-flex; align-items: center; gap: var(--space-1-5); font: 400 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.status.confirmed { color: var(--ok-fg); } .status.confirmed::before { background: currentColor; }
.status.pending { color: var(--acc); }
.status.completed { color: var(--mut); } .status.completed::before { background: currentColor; }
.status.cancelled, .status.declined, .status.no_show { color: var(--mut); text-decoration: line-through; }

/* ---------- The tick (saved for the moment someone is booked) ---------- */
.tick { display: flex; flex-direction: column; align-items: center; gap: var(--space-2-5); margin: var(--space-4) 0 var(--space-4); }
.tick svg { width: 64px; height: 64px; }
.tick .ring { fill: none; stroke: var(--acc); stroke-width: 2; stroke-dasharray: 176; stroke-dashoffset: 176; animation: draw var(--dur-slow) var(--ease-swing) forwards; transform: rotate(-90deg); transform-origin: center; }
.tick .mark { fill: none; stroke: var(--acc); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw var(--dur-slow) var(--ease-set) var(--dur-slow) forwards; }
.tick .word { font: 400 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ok-fg); }

/* ---------- Screens and the rise ---------- */
.scr { display: none; }
.scr.on { display: block; animation: rise var(--dur-base) var(--ease-cut) both; }
.rise > * { animation: rise var(--dur-base) var(--ease-cut) both; animation-delay: calc(var(--i, 0) * var(--dur-stagger)); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes strop { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pole { to { background-position: 0 34px; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .pole { animation: none !important; }
}
