/* =========================================================
   ScaleSys — /book  (one-question-at-a-time booking flow)
   Builds on tokens + buttons from styles.css
   ========================================================= */
body.book { min-height: calc(100svh / var(--z)); display: flex; flex-direction: column; overflow-x: hidden; }

/* Header */
.bk-head { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 16px var(--gutter); background: rgba(243,238,229,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.bk-logo img { width: 120px; height: auto; }
@media (min-width: 768px) { .bk-logo img { width: 140px; } .bk-head { padding-top: 24px; padding-bottom: 24px; } }
.bk-close { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(18,18,18,.15); transition: background .3s, color .3s, transform .4s var(--ease); }
.bk-close:hover { background: var(--charcoal); color: var(--cream); transform: rotate(90deg); }
.bk-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(18,18,18,.08); }
.bk-progress span { display: block; height: 100%; background: var(--flame); transform-origin: left; transform: scaleX(0); transition: transform .6s var(--ease); }

/* Stage */
.bk-main { flex: 1; display: flex; align-items: center; padding: 32px var(--gutter) calc(96px + env(safe-area-inset-bottom)); }
.bk-form { width: 100%; max-width: 760px; margin: 0 auto; position: relative; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.q { display: none; }
.q.is-active { display: block; }
.q.is-in-up   { animation: qInUp .7s var(--ease) both; }
.q.is-in-down { animation: qInDown .7s var(--ease) both; }
.q.is-out-up   { display: block; animation: qOutUp .35s ease-in both; }
.q.is-out-down { display: block; animation: qOutDown .35s ease-in both; }
@keyframes qInUp { from { opacity: 0; transform: translateY(48px); } }
@keyframes qInDown { from { opacity: 0; transform: translateY(-48px); } }
@keyframes qOutUp { to { opacity: 0; transform: translateY(-40px); } }
@keyframes qOutDown { to { opacity: 0; transform: translateY(40px); } }

.q__num { font: 500 14px/1 var(--f-mono); color: var(--flame); margin: 0 0 14px; display: flex; gap: 6px; align-items: center; }
.q__title { font: 700 clamp(28px, 5.4vw, 52px)/1.08 var(--f-display); letter-spacing: -.035em; margin: 0 0 14px; }
.q--welcome .q__title { font-size: clamp(38px, 8vw, 80px); line-height: 1; max-width: 12ch; }
.q__help { font-size: clamp(16px, 1.6vw, 19px); color: var(--ink-2); margin: 0 0 28px; max-width: 52ch; }
.q__note { font-size: 14px; color: var(--ash); margin: 14px 0 0; max-width: 56ch; }
.q__err { min-height: 22px; margin: 12px 0 0; color: #D23A0A; font-weight: 500; font-size: 15px; }
.q__err:empty { visibility: hidden; }
.q__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; margin-top: 20px; }
.q__actions--center { justify-content: center; }
.q__hint { font-size: 13px; color: var(--ash); display: none; }
@media (hover: hover) and (pointer: fine) { .q__hint { display: inline; } }
kbd { font: 500 11px/1 var(--f-mono); padding: 4px 6px; border-radius: 6px; background: rgba(18,18,18,.07); }
.q__skip { min-height: 52px; color: var(--ink-2); }

/* Welcome step: copy + animated "live stack" (Docker, PostgreSQL, server logs) */
.bk-form:has(.q--welcome.is-active) { max-width: 1160px; }
.welcome { display: grid; gap: 36px; align-items: center; }
.welcome > *, .stackviz, .sv__log, .sv__lines { min-width: 0; }
.q--welcome .q__title { font-size: clamp(36px, 5.2vw, 68px); }
@media (min-width: 960px) { .welcome { grid-template-columns: 1fr 1.05fr; gap: 56px; } }
.welcome__title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.welcome__title .line > span { display: inline-block; }
.stackviz { background: #121212; border-radius: 24px; padding: 16px; color: var(--cream); box-shadow: 0 40px 80px -40px rgba(18,18,18,.55); }
.sv__head { display: flex; justify-content: space-between; font-size: 10px; color: rgba(243,238,229,.5); padding: 2px 4px 12px; }
.sv__head i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #2BB673; margin-right: 6px; animation: blink 1.4s infinite; }
.sv__scene { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 190px; padding: 0 12px; border-radius: 16px; overflow: hidden; background: radial-gradient(120% 100% at 50% 0%, #22211E 0%, #161513 70%); }
.sv__scene::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(243,238,229,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(243,238,229,.035) 1px, transparent 1px); background-size: 22px 22px; }
.sv__node { position: relative; z-index: 1; width: 130px; height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.sv__logo { width: 76px; height: 76px; }
.sv__cap { margin-top: 10px; font-size: 10px; color: rgba(243,238,229,.55); }
/* docker: bobbing on water, containers floating up off it */
.sv__whale { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-7px) rotate(2deg); } }
.sv__waves { position: relative; width: 120px; height: 12px; margin-top: -6px; overflow: hidden; }
.sv__waves i { position: absolute; left: -50%; width: 200%; height: 12px; border-radius: 50%; border-top: 2px solid rgba(36,150,237,.55); animation: wave 2.6s linear infinite; }
.sv__waves i:nth-child(2) { top: 4px; opacity: .6; animation-duration: 3.4s; animation-direction: reverse; }
.sv__waves i:nth-child(3) { top: 8px; opacity: .3; animation-duration: 4.2s; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(25%); } }
.sv__crates { position: absolute; top: 0; left: 50%; width: 0; height: 60px; }
.sv__crates b { position: absolute; left: -22px; bottom: 0; width: 44px; padding: 3px 0; text-align: center; border-radius: 5px; background: rgba(36,150,237,.18); border: 1px solid rgba(36,150,237,.55); color: #9FD2FF; font: 500 9px/1.2 var(--f-mono); opacity: 0; animation: crate 4.5s ease-out infinite; }
.sv__crates b:nth-child(2) { animation-delay: 1.5s; } .sv__crates b:nth-child(3) { animation-delay: 3s; }
@keyframes crate { 0% { transform: translate(0, 40px) scale(.7); opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(var(--dx, 18px), -18px) scale(1); opacity: 0; } }
.sv__crates b:nth-child(1) { --dx: -38px; } .sv__crates b:nth-child(3) { --dx: 38px; }
/* pipe: data packets flowing into postgres */
.sv__pipe { position: relative; z-index: 1; flex: 1; height: 4px; border-radius: 4px; background: repeating-linear-gradient(90deg, rgba(243,238,229,.14) 0 8px, transparent 8px 14px); margin-bottom: 44px; }
.sv__pipe i { position: absolute; top: -3px; left: 0; width: 10px; height: 10px; border-radius: 3px; background: var(--flame); box-shadow: 0 0 10px var(--flame); opacity: 0; animation: packet 2.8s linear infinite; }
.sv__pipe i:nth-child(2) { animation-delay: .7s; background: #2496ED; box-shadow: 0 0 10px #2496ED; } .sv__pipe i:nth-child(3) { animation-delay: 1.4s; } .sv__pipe i:nth-child(4) { animation-delay: 2.1s; background: #2BB673; box-shadow: 0 0 10px #2BB673; }
@keyframes packet { 0% { left: 0; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { left: calc(100% - 10px); opacity: 0; } }
/* postgres: pulses as each write lands */
.sv__elephant { animation: gulp 1.4s ease-in-out infinite; }
@keyframes gulp { 0%, 70%, 100% { transform: scale(1); } 80% { transform: scale(1.08); } }
.sv__ring { position: absolute; top: 32px; left: 50%; width: 96px; height: 96px; margin-left: -48px; border-radius: 50%; border: 2px solid rgba(108,155,222,.6); opacity: 0; animation: ring 1.4s ease-out infinite; }
@keyframes ring { 0%, 70% { transform: scale(.7); opacity: 0; } 78% { opacity: .9; } 100% { transform: scale(1.25); opacity: 0; } }
.sv__q { position: absolute; top: 4px; right: -6px; padding: 3px 6px; border-radius: 5px; background: rgba(43,182,115,.16); color: #6FE0A4; font-size: 9px; opacity: 0; animation: qpop 2.8s ease-out infinite 1s; }
@keyframes qpop { 0%, 60% { opacity: 0; transform: translateY(6px); } 70%, 90% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
/* server log */
.sv__log { margin-top: 12px; border-radius: 14px; background: #0B0B0B; border: 1px solid rgba(243,238,229,.08); overflow: hidden; }
.sv__logbar { display: flex; align-items: center; gap: 5px; padding: 8px 10px; background: #1B1A18; font-size: 9.5px; color: rgba(243,238,229,.45); }
.sv__logbar i { width: 8px; height: 8px; border-radius: 50%; background: #3A3833; }
.sv__logbar i:first-child { background: #FF5F57; } .sv__logbar i:nth-child(2) { background: #FEBC2E; } .sv__logbar i:nth-child(3) { background: #28C840; }
.sv__logbar span { margin-left: 6px; }
.sv__lines { height: 168px; padding: 10px 12px; overflow: hidden; font-size: 11px; line-height: 1.75; text-transform: none; letter-spacing: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.sv__lines p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: rgba(243,238,229,.72); animation: logIn .45s var(--ease) both; }
.sv__lines .t { color: rgba(243,238,229,.35); margin-right: 8px; }
.sv__lines .s-docker { color: #5BB6FF; } .sv__lines .s-pg { color: #8FB3EA; } .sv__lines .s-n8n { color: #FF7A9A; } .sv__lines .s-ok { color: #6FE0A4; } .sv__lines .s-warn { color: #FFD166; }
@keyframes logIn { from { opacity: 0; transform: translateY(8px); } }
.q:not(.is-active) .stackviz * { animation-play-state: paused !important; }
@media (max-width: 959px) {
  .stackviz { padding: 12px; border-radius: 20px; }
  .sv__scene { height: 150px; }
  .sv__node { width: 96px; height: 122px; }
  .sv__logo { width: 58px; height: 58px; }
  .sv__ring { top: 26px; width: 74px; height: 74px; margin-left: -37px; }
  .sv__lines { height: 120px; font-size: 10.5px; }
}

/* Big underlined text fields */
.field {
  width: 100%; border: 0; border-bottom: 2px solid rgba(18,18,18,.18); background: transparent;
  font: 500 clamp(22px, 3.4vw, 32px)/1.3 var(--f-body); color: var(--charcoal); padding: 10px 0 12px; border-radius: 0;
  transition: border-color .3s;
}
.field::placeholder { color: rgba(18,18,18,.25); }
.field:focus { outline: none; border-color: var(--flame); }
.field.is-invalid { border-color: #D23A0A; }

/* Multi-choice */
.choices { display: grid; gap: 10px; margin-bottom: 22px; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice {
  display: flex; align-items: center; gap: 14px; text-align: left; min-height: 56px; padding: 12px 16px;
  border-radius: 14px; border: 1.5px solid rgba(18,18,18,.14); background: rgba(255,255,255,.55);
  font: 500 17px/1.3 var(--f-body); transition: border-color .25s, background .25s, transform .3s var(--ease);
}
.choice kbd { flex: none; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(18,18,18,.2); background: var(--cream); transition: background .25s, color .25s; }
.choice:hover { border-color: var(--charcoal); }
.choice:active { transform: scale(.98); }
.choice[aria-pressed="true"] { border-color: var(--flame); background: #FFE6DB; }
.choice[aria-pressed="true"] kbd { background: var(--flame); color: var(--charcoal); border-color: var(--flame); }
.choice[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: var(--flame-2); font-weight: 700; }
.q__extra { display: grid; gap: 8px; font-size: 15px; color: var(--ink-2); }
.q__extra small { color: var(--ash); }
.q__extra textarea { font: 400 17px/1.5 var(--f-body); border: 1.5px solid rgba(18,18,18,.14); border-radius: 14px; padding: 12px 14px; background: rgba(255,255,255,.55); resize: vertical; min-height: 64px; }
.q__extra textarea:focus { outline: none; border-color: var(--flame); }

/* Dropdown */
.select { position: relative; max-width: 520px; }
.select::after { content: ""; position: absolute; right: 18px; top: 50%; width: 10px; height: 10px; border-right: 2px solid var(--charcoal); border-bottom: 2px solid var(--charcoal); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: 64px; padding: 0 52px 0 20px;
  font: 500 clamp(18px, 2.4vw, 22px)/1 var(--f-body); color: var(--charcoal);
  background: var(--white); border: 1.5px solid rgba(18,18,18,.18); border-radius: 16px; cursor: pointer; transition: border-color .3s;
}
.select select:focus { outline: none; border-color: var(--flame); box-shadow: 0 0 0 4px rgba(255,91,38,.15); }
.select select:invalid { color: rgba(18,18,18,.4); }
.select select.is-invalid { border-color: #D23A0A; }

/* Calendar step: "Editorial dark" (Figma: Calendar 3) */
.bk-form:has(.q--cal.is-active) { max-width: 1120px; }
.calx__heading { margin-bottom: 24px; }
.calx { display: grid; align-items: start; border-radius: var(--radius-lg); overflow: hidden; background: var(--white); box-shadow: 0 40px 90px -45px rgba(18,18,18,.35); }
@media (min-width: 960px) { .calx { grid-template-columns: minmax(300px, 1fr) 2fr; } }
.calx__side { background: var(--charcoal); color: var(--cream); padding: clamp(22px, 3vw, 34px); display: flex; flex-direction: column; }
.calx__label { color: var(--flame); margin: 0 0 12px; }
.calx__title { font: 700 clamp(20px, 2vw, 26px)/1.2 var(--f-display); letter-spacing: -.025em; margin: 0 0 18px; }
.calx__sub { font-weight: 600; font-size: 14px; margin: 0 0 10px; }
.calx__dots { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 14px; color: rgba(243,238,229,.82); }
.calx__dots li { display: flex; gap: 10px; align-items: baseline; }
.calx__dots li::before { content: ""; flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--flame); transform: translateY(-2px); }
.calx__meta li::before { background: rgba(243,238,229,.55); }
.calx__rule { border: 0; border-top: 1px solid rgba(243,238,229,.14); margin: 20px 0; }
.calx__meta-line { display: none; margin: 12px 0 0; font-size: 13px; color: rgba(243,238,229,.7); }
.calx__you { display: flex; align-items: center; gap: 10px; margin-top: 20px; font-size: 13px; color: rgba(243,238,229,.85); }
.calx__avatar { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--flame); color: var(--charcoal); display: grid; place-items: center; font: 600 11px/1 var(--f-body); }
.calx__who { min-width: 0; overflow-wrap: anywhere; }
.calx__main { padding: clamp(12px, 2vw, 24px); min-width: 0; }
.cal { min-height: 540px; }
.cal__loading { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 540px; color: var(--ash); }
.cal__loading span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(18,18,18,.15); border-top-color: var(--flame); animation: spin 0.8s linear infinite; }
.cal__fallback { padding: 40px 24px; text-align: center; }
.cal__fallback p { margin: 0 0 16px; }
@media (max-width: 959px) {
  .calx { background: transparent; box-shadow: none; overflow: visible; gap: 14px; }
  .calx__side { border-radius: 20px; }
  .calx__main { background: var(--white); border-radius: 20px; }
  .calx__sub, .calx__rule, .calx__meta, .calx__cover li:nth-child(3) { display: none; }
  .calx__title { margin-bottom: 10px; }
  .calx__meta-line { display: block; }
  .calx__you { margin-top: 12px; }
}

/* Demo calendar (only with ?demo=1 — for testing the flow without Cal.com) */
.demo-cal { padding: clamp(16px, 3vw, 32px); }
.demo-cal__tag { display: inline-block; font: 500 11px/1 var(--f-mono); text-transform: uppercase; letter-spacing: .1em; background: #FFE6DB; color: var(--flame-2); padding: 6px 10px; border-radius: 99px; margin-bottom: 18px; }
.demo-cal__days { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 20px; }
.demo-cal__day, .demo-cal__slot { min-height: 52px; border-radius: 12px; border: 1.5px solid rgba(18,18,18,.12); font-weight: 500; transition: border-color .2s, background .2s; }
.demo-cal__day[aria-pressed="true"] { background: var(--charcoal); color: var(--cream); border-color: var(--charcoal); }
.demo-cal__slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.demo-cal__slot:hover, .demo-cal__day:hover { border-color: var(--flame); }

/* Thank-you */
.q--done { text-align: center; position: relative; }
.done__burst { position: absolute; left: 50%; top: 60px; width: 0; height: 0; pointer-events: none; }
.done__burst i { position: absolute; left: 0; top: 0; width: 10px; height: 10px; border-radius: 2px; }
.done__badge { width: 112px; height: 112px; margin: 0 auto 24px; }
.done__badge svg { width: 100%; height: 100%; overflow: visible; }
.done__ring { fill: var(--flame); stroke: none; transform-origin: 60px 60px; }
.done__tick { fill: none; stroke: var(--charcoal); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 0; }
.done__eyebrow { color: var(--flame-2); }
.done__title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.done__title .line > span { display: inline-block; }
.done__card { display: inline-block; text-align: left; background: var(--charcoal); color: var(--cream); border-radius: var(--radius); padding: 22px 26px; margin: 18px 0 22px; min-width: min(100%, 420px); }
.done__card .mono { color: var(--flame); margin: 0 0 10px; }
.done__when { font: 700 clamp(20px, 3vw, 28px)/1.25 var(--f-display); letter-spacing: -.02em; margin: 0 0 6px; }
.done__tz { margin: 0; font-size: 14px; color: rgba(243,238,229,.6); }
.done__text { font-size: clamp(16px, 1.6vw, 19px); color: var(--ink-2); max-width: 46ch; margin: 0 auto 8px; }

/* Up / down arrows (desktop) */
.bk-arrows { position: fixed; right: var(--gutter); bottom: calc(20px + env(safe-area-inset-bottom)); display: flex; gap: 2px; z-index: 20; }
.bk-arrows button { width: 44px; height: 40px; display: grid; place-items: center; background: var(--charcoal); color: var(--cream); transition: background .2s, opacity .2s; }
.bk-arrows button:first-child { border-radius: 10px 0 0 10px; }
.bk-arrows button:last-child { border-radius: 0 10px 10px 0; }
.bk-arrows button:hover { background: var(--flame); color: var(--charcoal); }
.bk-arrows button:disabled { opacity: .3; pointer-events: none; }
body.is-final .bk-arrows { display: none; }

/* Mobile: keep the action button reachable above the keyboard */
@media (max-width: 639px) {
  .bk-main { align-items: flex-start; padding-top: 28px; }
  .q__actions .btn { flex: 1; }
  .bk-arrows { display: none; }
}
