/* ============================================================
   BOOKINGS — the customer-facing page.

   Built to the CE Lab design system, not the internal ops one.
   This is the only page in the repo a customer meets on their own
   phone, so it follows the brand the website is heading towards
   rather than the tool Luke uses. Deliberately NOT linking
   packages/ui/tokens.css: that palette is close enough to look
   like a mistake and wrong enough to look cheap.

   The rules taken from the system, which are the ones worth not
   breaking:

   - RZA for display, Haffer for everything else. A page of one
     sans at four sizes is what "functional" looks like.
   - CORAL IS A FILL, ONCE PER SCREEN. The first draft put coral on
     the selected day, the selected time AND the submit button, so
     nothing was emphasised. Selection is ink; coral is the single
     thing you press.
   - 14px radius on surfaces, 8px on buttons, 999px on chips.
   - The eyebrow (12px/700/0.12em/upper/Ink 2) is how this system
     labels a thing. It does a heading's work without shouting.

   MOTION. Everything moves for a reason: to show what changed, or
   to mark that something happened. Times stagger in so a new day
   reads as a new set rather than a flicker; the summary grows out
   of the grid it came from; the tick draws itself because a
   booking is the one moment on this page worth a beat. Nothing
   moves more than 10px or runs longer than 420ms, and all of it
   stops dead under prefers-reduced-motion.
   ============================================================ */

:root {
    --paper:     #faf6ef;   /* page */
    --stone:     #f0e9dd;   /* wash, cards */
    --lines:     #e4dccf;   /* rules and borders */
    --ink:       #1c1915;   /* text */
    --ink-2:     #5f574f;   /* secondary text */
    --ink-3:     #7a7066;   /* tertiary text */
    --coral:     #ff575f;   /* fills only */
    --coral-ink: #d93a43;   /* coral as text */
    --good:      #2f7d4f;   /* status dot */

    --r-card: 14px;
    --r-btn:  8px;

    --sans: 'Haffer', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --display: 'RZA', Georgia, 'Times New Roman', serif;

    /* One easing for everything, so the page has a single hand. */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- the platform header ------------------------------------------------ */

/* A slim version of the site header: the logo and a way to reach a person.
   Not the full nav — a customer halfway through booking a collection should
   not be offered Buy, Sell and a basket, and in the portal iframe it would
   be a second navigation inside a page that already has one. The point is
   to look like the platform, not to leave it. */
.bk-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px clamp(16px, 4vw, 40px);
    background: var(--paper); border-bottom: 1px solid var(--lines);
}
body.embed .bk-top { display: none; }     /* the portal already has one */

.bk-top .logo { display: inline-flex; align-items: center; height: 32px; }
.bk-top .logo img { height: 15px; width: auto; display: block; }
.bk-top .help {
    font-size: 14px; color: var(--ink-2); text-decoration: none;
    padding: 6px 2px; border-bottom: 1px solid transparent;
    transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.bk-top .help:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* --- the page ----------------------------------------------------------- */

.bk { max-width: 560px; margin: 0 auto; padding: 44px 20px 80px; }
body.embed .bk { padding: 20px 16px 36px; }

.eyebrow {
    margin: 0 0 12px;
    font-size: 12px; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-2);
}

.bk h1 {
    margin: 0 0 12px;
    font-family: var(--display); font-weight: 400;
    font-size: clamp(32px, 8vw, 40px); line-height: 1.1; letter-spacing: -0.01em;
}
.bk .sub { margin: 0 0 36px; color: var(--ink-2); max-width: 46ch; }

.bk-msg {
    padding: 56px 0; text-align: center; color: var(--ink-2);
    max-width: 34ch; margin-inline: auto;
}

/* --- entrance ----------------------------------------------------------- */

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* `--i` is set inline per element, so a group arrives as a group rather
   than all at once or one slow queue. */
.rise {
    opacity: 0;
    animation: rise 420ms var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 45ms);
}
.bk-time {
    opacity: 0;
    animation: rise 320ms var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 14ms);
}

/* --- the skeleton ------------------------------------------------------- */

/* Shaped like the thing it is standing in for, so the page does not jump
   when the real slots land. */
@keyframes shimmer { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.9; } }
.sk { background: var(--stone); border-radius: var(--r-btn); animation: shimmer 1.4s ease-in-out infinite; }
.sk-title { height: 38px; width: 68%; border-radius: var(--r-card); margin-bottom: 14px; }
.sk-sub   { height: 16px; width: 88%; margin-bottom: 8px; }
.sk-sub2  { height: 16px; width: 54%; margin-bottom: 36px; }
.sk-days  { display: flex; gap: 8px; margin-bottom: 28px; }
.sk-day   { height: 58px; width: 64px; border-radius: var(--r-card); flex: 0 0 auto; }
.sk-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.sk-time  { height: 48px; }

/* --- the day strip ------------------------------------------------------ */

.bk-days {
    display: flex; gap: 8px;
    overflow-x: auto;
    /* Bleeds to the page edge so the strip reads as scrollable and the last
       chip is not cropped against a hard margin. */
    margin: 0 -20px 28px; padding: 2px 20px 12px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.bk-days::-webkit-scrollbar { display: none; }
body.embed .bk-days { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }

.bk-dchip {
    flex: 0 0 auto; scroll-snap-align: start;
    min-width: 64px; padding: 8px 12px 10px;
    border: 1px solid var(--lines); border-radius: var(--r-card);
    background: var(--paper); color: var(--ink);
    font: inherit; line-height: 1.2; text-align: center; cursor: pointer;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
                color 0.18s var(--ease), transform 0.18s var(--ease);
}
.bk-dchip span {
    display: block; font-size: 11px; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2);
    transition: color 0.18s var(--ease);
}
.bk-dchip b {
    display: block; font-size: 20px; font-weight: 700;
    font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.bk-dchip:hover { border-color: var(--ink-3); background: var(--stone); }
.bk-dchip:active { transform: scale(0.97); }
/* Selection is INK. Coral belongs to the one button you press. */
.bk-dchip[aria-pressed="true"] {
    background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.bk-dchip[aria-pressed="true"] span { color: rgba(250, 246, 239, 0.7); }

.bk-dchip:focus-visible,
.bk-time:focus-visible,
.bk-btn:focus-visible,
.bk-top a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* --- the times ---------------------------------------------------------- */

.bk-dhead { margin: 0 0 12px; }

/* A grid: the columns divide the width available, so nothing sticks out at
   375px the way a wrapped flex row with a min-width does. */
.bk-times {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 8px;
}

.bk-time {
    min-height: 48px; padding: 10px 6px;
    border: 1px solid var(--lines); border-radius: var(--r-btn);
    background: var(--paper); color: var(--ink);
    font: inherit; font-size: 15px; font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
                color 0.16s var(--ease), transform 0.16s var(--ease);
}
.bk-time:hover { border-color: var(--ink-3); background: var(--stone); }
.bk-time:active { transform: scale(0.96); }
.bk-time[aria-pressed="true"] {
    background: var(--ink); border-color: var(--ink); color: var(--paper);
    font-weight: 700;
}

/* --- the chosen time ---------------------------------------------------- */

/* Grows out of the grid rather than appearing below it. The 0fr/1fr grid
   trick animates height without knowing the height, which is the only way
   this works for one line of text or three. */
.bk-chosen {
    display: grid; grid-template-rows: 0fr;
    margin-top: 0; opacity: 0;
    transition: grid-template-rows 360ms var(--ease), margin-top 360ms var(--ease),
                opacity 240ms var(--ease);
}
.bk-chosen.on { grid-template-rows: 1fr; margin-top: 28px; opacity: 1; }
.bk-chosen > div { overflow: hidden; }
.bk-chosen .inner {
    padding: 20px 24px; background: var(--stone); border-radius: var(--r-card);
}
.bk-chosen p { margin: 0; }
.bk-chosen .when { font-family: var(--display); font-size: 28px; line-height: 1.25; }
.bk-chosen .where { margin-top: 6px; font-size: 14px; color: var(--ink-2); }

/* --- the form ----------------------------------------------------------- */

.bk-form { margin-top: 36px; padding-top: 32px; border-top: 1px solid var(--lines); }
.bk-form h2 {
    margin: 0 0 22px;
    font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1.2;
}

.bk-field { margin-bottom: 18px; }
.bk-field label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.bk-field .opt { font-weight: 400; color: var(--ink-3); }

.bk-field input,
.bk-field textarea {
    width: 100%; padding: 13px 15px;
    border: 1px solid var(--lines); border-radius: var(--r-btn);
    background: #fff; color: var(--ink);
    font: inherit;
    /* 16px stops iOS zooming the page on focus, which would scroll the slot
       you just picked off screen. */
    font-size: 16px; line-height: 1.4;
    transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.bk-field input::placeholder,
.bk-field textarea::placeholder { color: var(--ink-3); }
.bk-field input:focus,
.bk-field textarea:focus {
    outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink);
}
.bk-field textarea { min-height: 88px; resize: vertical; }

/* --- buttons ------------------------------------------------------------ */

.bk-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; min-height: 52px; padding: 0 24px; margin-top: 10px;
    border: 0; border-radius: var(--r-btn);
    background: var(--coral); color: #fff;
    font: inherit; font-size: 16px; font-weight: 700;
    cursor: pointer;
    transition: background 0.16s var(--ease), transform 0.16s var(--ease),
                opacity 0.16s var(--ease);
}
.bk-btn:hover:not(:disabled) { background: var(--coral-ink); }
.bk-btn:active:not(:disabled) { transform: scale(0.99); }
.bk-btn:disabled { background: var(--lines); color: var(--ink-2); cursor: not-allowed; }

/* Secondary: the system's 1.5px ink outline. */
.bk-btn.ghost {
    background: transparent; color: var(--ink);
    border: 1.5px solid var(--ink); font-size: 15px; min-height: 48px;
}
.bk-btn.ghost:hover:not(:disabled) { background: var(--stone); }
.bk-btn.ghost:disabled { background: transparent; border-color: var(--lines); color: var(--ink-3); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 16px; height: 16px; flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 620ms linear infinite;
}

/* --- messages ----------------------------------------------------------- */

.bk-err {
    margin: 18px 0 0; padding: 13px 16px;
    background: #fff; border: 1px solid var(--lines);
    border-left: 3px solid var(--coral); border-radius: var(--r-btn);
    color: var(--ink); font-size: 15px; line-height: 1.5;
    animation: rise 300ms var(--ease);
}

/* --- confirmation ------------------------------------------------------- */

.bk-done { padding: 12px 0; }

.tick-wrap {
    width: 56px; height: 56px; margin-bottom: 24px;
    border-radius: 50%; background: var(--good);
    display: grid; place-items: center;
    animation: pop 420ms var(--ease) both;
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* The one flourish on the page, and it marks the one moment that matters:
   the booking existing. The stroke draws itself after the circle lands. */
.tick-wrap svg path {
    stroke-dasharray: 26; stroke-dashoffset: 26;
    animation: draw 380ms var(--ease) 200ms forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.bk-pill {
    display: inline-flex; align-items: center; gap: 8px;
    height: 32px; padding: 0 14px; margin-bottom: 18px;
    border: 1px solid var(--lines); border-radius: 999px;
    font-size: 14px; color: var(--ink);
}
.bk-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }

.bk-done .day {
    margin: 0; font-family: var(--display); font-weight: 400;
    font-size: clamp(30px, 7.5vw, 40px); line-height: 1.1; letter-spacing: -0.01em;
}
.bk-done .time {
    margin: 6px 0 0; font-size: clamp(32px, 8vw, 40px); font-weight: 700;
    letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.bk-done .note { margin: 18px 0 0; color: var(--ink-2); max-width: 42ch; }

.bk-card {
    margin: 28px 0 0; padding: 20px 24px;
    border: 1px solid var(--lines); border-radius: var(--r-card);
}
.bk-card p { margin: 0; }
.bk-card .addr { margin-top: 4px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }

.bk-actions { display: flex; gap: 10px; margin-top: 30px; }
.bk-actions .bk-btn { margin-top: 0; }

/* --- motion off --------------------------------------------------------- */

/* Not a courtesy. Staggered movement is exactly what triggers vestibular
   symptoms, and someone booking a bike collection should not have to put
   up with that to do it. */
@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;
    }
    .rise, .bk-time { opacity: 1; }
    .bk-chosen { transition: none; }
}

/* --- who this is for ---------------------------------------------------- */

/* The Own card from the CE Lab system, at booking size: stone image panel,
   brand eyebrow, RZA name. The page already knows whose bike this is and
   which order it came from, so it says so instead of asking. */
.bk-order {
    display: flex; gap: 0; margin: 0 0 32px;
    border: 1px solid var(--lines); border-radius: var(--r-card);
    overflow: hidden;
}
.bk-order .shot {
    flex: 0 0 116px; align-self: stretch; min-height: 108px;
    background: var(--stone) center/cover no-repeat;
    /* Collapses when there is no photo rather than leaving a grey hole —
       a drop-off never has one worth showing. */
    display: none;
}
.bk-order .shot.on { display: block; animation: fade 420ms var(--ease); }
.bk-order .meta { padding: 16px 20px; min-width: 0; }
.bk-order .meta .eyebrow { margin-bottom: 6px; }
.bk-order .name {
    margin: 0; font-family: var(--display); font-size: 21px; line-height: 1.25;
}
.bk-order .facts { margin: 6px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); }

.bk-form .who { margin: 0 0 20px; font-size: 14px; color: var(--ink-2); }
.bk-form .who a { color: var(--ink); }

/* --- the terms ---------------------------------------------------------- */

/* Required, and they are commercial terms rather than blurb — the cleaning
   surcharge and passing on parts. They get the room to be read, not a
   six-point line under a button. */
.bk-ack {
    display: flex; gap: 12px; align-items: flex-start;
    margin: 0 0 14px; padding: 14px 16px;
    background: var(--stone); border-radius: var(--r-btn);
    font-size: 14px; line-height: 1.5; cursor: pointer;
}
.bk-ack input {
    flex: 0 0 auto; width: 20px; height: 20px; margin: 1px 0 0;
    accent-color: var(--ink); cursor: pointer;
}
.bk-ack span { min-width: 0; }
.bk-ack:has(input:checked) { background: var(--paper); box-shadow: inset 0 0 0 1px var(--lines); }

/* --- find us ------------------------------------------------------------ */

/* The location card from the Kingston store page: map beside the address,
   then the three ways in as rows. On a phone it stacks, because a map
   squeezed next to text at 375px is useful to nobody. */
.bk-where { margin-top: 32px; }

.bk-where .box {
    display: grid; grid-template-columns: 1fr;
    border: 1px solid var(--lines); border-radius: var(--r-card); overflow: hidden;
}
@media (min-width: 620px) { .bk-where .box { grid-template-columns: 1fr 1fr; } }

.bk-where .map {
    position: relative; min-height: 190px; background: var(--stone);
    /* No map is a quiet, correct-looking panel rather than a broken frame. */
    opacity: 0; transition: opacity 420ms var(--ease);
}
.bk-where .map.on { opacity: 1; }
.bk-where .map iframe { display: block; width: 100%; height: 100%; min-height: 190px; border: 0; }

.bk-where .body { padding: 20px 22px; }
.bk-where .place { margin: 0; font-size: 16px; font-weight: 700; }
.bk-where .addr  { margin: 4px 0 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); }

.bk-where .row {
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px 0; border-top: 1px solid var(--lines);
    font-size: 14px; line-height: 1.45;
}
.bk-where .row:first-of-type { margin-top: 14px; }
.bk-where .row strong { font-size: 13px; }
.bk-where .row span { color: var(--ink-2); }

.bk-where .dir { width: auto; margin-top: 16px; padding: 0 18px; min-height: 44px; text-decoration: none; }

/* With the map gone the card is one column, not a half-empty two. */
.bk-where .box:not(:has(.map)) { grid-template-columns: 1fr; }
.bk-order .more { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); }

/* --- the bikes on a visit ----------------------------------------------- */

/* Up to three, each its own row. A visit is the one booking where the
   customer chose what it is about, so the page shows them back exactly
   what they picked before asking for a time. */
.bk-bikes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 32px; }

.bk-bike {
    display: flex; align-items: stretch;
    border: 1px solid var(--lines); border-radius: var(--r-card); overflow: hidden;
}
.bk-bike .shot {
    flex: 0 0 92px; min-height: 76px;
    background: var(--stone) center/cover no-repeat;
}
.bk-bike .meta { padding: 12px 16px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.bk-bike .name { margin: 0; font-size: 15px; line-height: 1.35; }
/* No tabular-nums here. It gives the thousands comma a full digit's
   advance, so £6,295 renders as "£6 , 295". Tabular figures are for
   aligning columns, which a price in a sentence is not. */
.bk-bike .price { margin: 3px 0 0; font-size: 14px; font-weight: 700; }
