/* Booking Machine's booking page: phone first, the business's own colours from its config.
   ui-ux-standards §12 film grain, §14 motion from the first build, §1 red border on a refused field,
   §16 an answer within 400 ms. Every motion stops under prefers-reduced-motion. */

:root {
  --ink: #0d1b2a; --paper: #f7f4ee; --accent: #1f7a8c;
  --line: color-mix(in srgb, var(--ink) 14%, transparent);
  --soft: color-mix(in srgb, var(--ink) 6%, transparent);
  --bad: #b3261e;
  --radius: 14px;
  --gap: clamp(14px, 3.5vw, 22px);
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--paper); color: var(--ink); }

body {
  font: 400 17px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding: 0 16px env(safe-area-inset-bottom);
}

/* Film grain (ui-ux-standards §12), the same recipe as lead-pancakes. */
body::after {
  content: ""; position: fixed; inset: -50%; pointer-events: none; z-index: 9;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 7s steps(6) infinite;
}
@keyframes grain { to { transform: translate3d(0, 0, 0) rotate(.0001deg); } 50% { transform: translate3d(-3%, 2%, 0); } }

.wrap { max-width: 44rem; margin: 0 auto; padding: 28px 0 56px; }

/* ---- the business as the host ---- */
.host { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.host .logo { width: 46px; height: 46px; color: var(--accent); flex: none; }
.host h1 { font-size: clamp(22px, 5.6vw, 30px); line-height: 1.15; margin: 0; letter-spacing: -.02em; }
.host .what { margin: 2px 0 0; color: color-mix(in srgb, var(--ink) 62%, transparent); font-size: 15px; }

.logo-drop { transform-origin: 32px 34px; animation: drop-in .9s cubic-bezier(.2,.9,.2,1) both; }
.logo-wave { stroke-dasharray: 4 7; animation: drift 9s linear infinite; }
.logo-wave-2 { animation-duration: 13s; animation-direction: reverse; }
.logo-spark { animation: shine 4.5s ease-in-out infinite; }
.host:hover .logo-drop { animation: bob 1.4s ease-in-out infinite; }
@keyframes drop-in { from { transform: translateY(-14px) scale(.8); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-3deg); } }
@keyframes drift { to { stroke-dashoffset: -44; } }
@keyframes shine { 40% { opacity: .15; } 60% { opacity: .8; } }

/* ---- sections reveal as they arrive ---- */
.card {
  background: color-mix(in srgb, var(--paper) 88%, #fff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--gap); margin-top: 18px;
  animation: rise .5s cubic-bezier(.2,.9,.2,1) both;
}
.card:nth-of-type(2) { animation-delay: .07s; }
.card:nth-of-type(3) { animation-delay: .13s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .09em; margin: 0 0 12px;
     color: color-mix(in srgb, var(--ink) 55%, transparent); }

/* ---- the event types ---- */
.events { display: grid; gap: 10px; }
.event {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 11px;
  background: transparent; color: inherit; font: inherit;
  transition: border-color .18s, background .18s, transform .18s;
}
.event:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-1px); }
.event[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.event .mins { color: color-mix(in srgb, var(--ink) 55%, transparent); font-size: 15px; white-space: nowrap; }

/* ---- the days and times ---- */
.day + .day { margin-top: 16px; }
.day h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.time {
  padding: 11px 6px; border-radius: 10px; border: 1.5px solid var(--line);
  background: transparent; color: inherit; font: 600 16px/1 inherit; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.time:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-1px); }
.time[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.time:focus-visible, .event:focus-visible, .field input:focus-visible, .field textarea:focus-visible,
.send:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* A skeleton that holds the final size, so nothing jumps when the times arrive (§16). */
.skeleton { display: grid; gap: 8px; }
.skeleton .bar, .skeleton .grid span {
  background: linear-gradient(90deg, var(--soft) 25%, color-mix(in srgb, var(--ink) 11%, transparent) 37%, var(--soft) 63%);
  background-size: 400% 100%; border-radius: 10px; animation: sweep 1.3s ease-in-out infinite;
}
.skeleton .bar { height: 18px; width: 9rem; }
.skeleton .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.skeleton .grid span { height: 42px; }
@keyframes sweep { to { background-position: -100% 0; } }

/* ---- the form ---- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.field .req { color: var(--accent); }
.field input, .field textarea {
  width: 100%; font: inherit; color: inherit; padding: 12px 13px;
  background: color-mix(in srgb, var(--paper) 60%, #fff);
  border: 1.5px solid var(--line); border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 86px; resize: vertical; }
/* §1: a refused field keeps a red border and a soft glow until it is right, never a toast alone. */
.field.bad input, .field.bad textarea { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.field .why { display: none; margin: 6px 0 0; font-size: 14px; color: var(--bad); }
.field.bad .why { display: block; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.send {
  width: 100%; margin-top: 4px; padding: 15px 18px; cursor: pointer;
  font: 600 17px/1 inherit; color: #fff; background: var(--accent);
  border: 0; border-radius: 12px; transition: transform .12s, filter .12s;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.send:hover { filter: brightness(1.06); }
.send:active, .send[data-busy="pressed"] { transform: scale(.985); filter: brightness(.94); }
.send[disabled] { cursor: progress; }
.spin { width: 17px; height: 17px; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff;
        border-radius: 50%; animation: turn .7s linear infinite; display: none; }
.send[data-busy="waiting"] .spin { display: block; }
@keyframes turn { to { transform: rotate(360deg); } }

.chosen { font-size: 16px; margin: 0 0 14px; padding: 11px 13px; border-radius: 11px;
          background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chosen b { font-weight: 700; }
.note { font-size: 14px; color: color-mix(in srgb, var(--ink) 58%, transparent); margin: 12px 0 0; }
.problem { margin: 12px 0 0; padding: 11px 13px; border-radius: 11px; font-size: 15px;
           background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.empty { padding: 10px 0; color: color-mix(in srgb, var(--ink) 58%, transparent); }

/* ---- the booking is made ---- */
.done { text-align: center; padding: 10px 0 4px; }
.done .tick { width: 54px; height: 54px; margin: 0 auto 10px; border-radius: 50%; color: #fff;
  background: var(--accent); display: grid; place-items: center; font-size: 27px;
  animation: pop .45s cubic-bezier(.2,1.5,.3,1) both; }
.done h2 { color: var(--ink); font-size: 20px; text-transform: none; letter-spacing: 0; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation: none !important; transition: none !important; }
  body::after { opacity: .03; }
}
