/* =========================================================
   ContainerBooking — booking page
   Numbered row sections that unlock as you go.
   Builds on styles.css (same palette/type system).
   ========================================================= */

.bk { padding: 70px 0 110px; }
.bk__head { max-width: 640px; margin-bottom: 56px; }
.bk__head h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); margin: 6px 0 14px; }
.bk__lede { color: var(--ink-soft); font-size: 1.12rem; }

/* ---------- Route chart (upright world map, block border) ----------
   Hidden until stage 02 unlocks; sits between 01 and 02, so 01 stays above it. */
.bk-map {
  position: relative; overflow: hidden; background: #f7f4ec;
  border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--paper), inset 0 0 0 2px rgba(226,85,43,.45);
  width: 100%;
  max-height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; border-width: 0;
  transition: max-height .8s var(--ease), opacity .6s var(--ease),
              margin-top .8s var(--ease), margin-bottom .8s var(--ease);
}
.bk-map.is-open {
  max-height: 720px; opacity: 1; margin-bottom: 6px; border-width: 3px;
}
.bk-map__stage { width: 100%; aspect-ratio: 2560 / 995; }
.bk-map__stage canvas { display: block; width: 100%; height: 100%; }
.bk-map__tag {
  position: absolute; top: 12px; left: 12px; font-size: .68rem; letter-spacing: .12em;
  color: var(--paper); background: var(--ink);
  padding: .4em .9em; border-radius: 3px;
}
/* phones: the chart is short, keep its label from covering a corner of it */
@media (max-width: 600px) {
  .bk-map__tag { top: 7px; left: 7px; font-size: .56rem; letter-spacing: .1em; padding: .35em .7em; }
}

/* ---------- Step rows (widgets) ---------- */
.bk-step {
  display: grid; grid-template-columns: 260px 1fr; gap: 48px;
  padding: 44px 0; border-top: 1px solid var(--line);
  max-height: 2200px;
  transition: max-height .8s var(--ease), opacity .5s var(--ease);
  overflow: hidden;
}
.bk-step:last-of-type { border-bottom: 1px solid var(--line); }

.bk-step__label { position: relative; }
.bk-step__num {
  display: block; font-family: "IBM Plex Mono", monospace; font-size: .95rem;
  color: var(--accent); margin-bottom: 10px; letter-spacing: .08em;
}
.bk-step__label h2 { font-size: 1.6rem; margin-bottom: 6px; }
.bk-step__label p { color: var(--ink-soft); font-size: .92rem; max-width: 24ch; }
.bk-step__hint {
  display: inline-block; margin-top: 14px; font-family: "IBM Plex Mono", monospace;
  font-size: .72rem; color: var(--accent); border: 1px dashed var(--accent);
  border-radius: 30px; padding: .35em .8em; opacity: 0;
  transition: opacity .3s;
}

/* locked state: only the faded top of the widget peeks through */
.bk-step.is-locked {
  max-height: 148px; opacity: .75;
  pointer-events: none; user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 8%, transparent 88%);
          mask-image: linear-gradient(to bottom, #000 8%, transparent 88%);
}
.bk-step.is-locked .bk-step__hint { opacity: 1; pointer-events: none; }

/* ---------- Field rows ---------- */
.bk-step__fields { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.bk-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.bk-step__fields textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 8px; padding: .72em .8em; width: 100%; resize: vertical;
}
.bk-step__fields textarea:focus { outline: none; border-color: var(--accent); }
.bk-step__fields .field input, .bk-step__fields .field select { background: var(--paper-2); }

/* incoterm plain-language note */
.bk-incoterm-note { display: block; font-style: normal; margin-top: 7px; font-size: .85rem; color: var(--ink-soft); min-height: 1.2em; }

/* ---------- Service tiles ---------- */
.bk-services__label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; margin-bottom: 10px; }
.bk-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.bk-tile {
  font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: .88rem;
  padding: .6em 1em; border-radius: 40px; border: 1.5px solid var(--line);
  background: var(--paper-2); color: var(--ink-soft); cursor: pointer;
  transition: all .18s var(--ease);
}
.bk-tile:hover { border-color: var(--ink); color: var(--ink); }
.bk-tile.is-on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- Derived arrival (never asked for, measured from MyFreight) ---------- */
.bk-field-note { justify-content: flex-start; }
.bk-eta-hint {
  font-size: .85rem; line-height: 1.45; color: var(--ink-soft);
  border-left: 2px solid var(--line); padding: .1em 0 .1em .7em;
}
.bk-eta-hint strong { color: var(--ink); font-weight: 600; }

.bk-eta {
  display: grid; gap: 6px; margin-top: 14px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-2);
  transition: border-color .2s var(--ease);
}
.bk-eta[hidden] { display: none; }
.bk-eta__label { font-size: .68rem; letter-spacing: .09em; color: var(--ink-soft); }
.bk-eta__value {
  font-family: "Space Grotesk", sans-serif; font-size: 1.5rem; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1; color: var(--ink);
}
.bk-eta__note { font-size: .85rem; color: var(--ink-soft); min-height: 1.2em; }
.bk-eta[data-state="idle"] .bk-eta__value { color: var(--ink-soft); }
.bk-eta[data-state="loading"] .bk-eta__value { color: var(--ink-soft); }
.bk-eta[data-state="ok"] { border-color: var(--accent); }
.bk-eta[data-state="ok"] .bk-eta__value { color: var(--accent); }
.bk-eta[data-state="unknown"] .bk-eta__value { font-size: 1.05rem; color: var(--ink); }

.bk-rate[data-state="ok"] { border-color: var(--ink); }
.bk-rate[data-state="ok"] .bk-eta__value { color: var(--ink); }
.bk-rate[data-state="unknown"] .bk-eta__value { font-size: 1.05rem; }
.bk-rate__lines { display: grid; gap: 3px; margin-top: 6px; font-size: .82rem; color: var(--ink-soft); }
.bk-rate__line { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Date validation note ---------- */
.bk-date-note { display: block; font-style: normal; font-size: .85rem; color: var(--accent); min-height: 1.2em; margin-top: -6px; }

/* ---------- Autocomplete ---------- */
.bk-ac { position: relative; }
.bk-ac__list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 18px 40px -18px rgba(20,42,46,.35);
  overflow: hidden; padding: 5px;
}
.bk-ac__item {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  width: 100%; text-align: left; font: inherit; font-size: .93rem; color: var(--ink);
  background: none; border: none; border-radius: 7px; padding: .6em .75em; cursor: pointer;
}
.bk-ac__item:hover, .bk-ac__item.is-active { background: var(--paper); }
.bk-ac__item.is-active { outline: 1.5px solid var(--accent); outline-offset: -1.5px; }
.bk-ac__tag { font-size: .66rem; letter-spacing: .08em; color: var(--accent); border: 1px solid var(--line); border-radius: 20px; padding: .25em .6em; white-space: nowrap; }

/* ---------- Cargo: confirmed summaries stacked above one active editor ----------
   Only ever ONE full 6-option picker on screen (the active row, always last).
   Everything already added collapses to a one-line summary above it. */
.bk-cargo-row {
  padding-bottom: 24px; margin-bottom: 20px; border-bottom: 1px solid var(--line);
  opacity: 1; transform: translateY(0);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}
.bk-cargo-row .field--sm { max-width: 110px; margin-bottom: 14px; }

.bk-cargo-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px;
  opacity: 1; transform: translateY(0);
  transition: opacity .45s var(--ease), transform .45s var(--ease);
}
.bk-cargo-summary img { opacity: .6; flex: 0 0 auto; }
.bk-cargo-summary__qty { color: var(--accent); font-size: .88rem; }
.bk-cargo-summary__label { flex: 1; font-size: .92rem; font-weight: 500; }

/* newly-confirmed/added row: starts hidden + shifted down, then eases up
   into place so it's unmistakably clear something just happened */
.bk-cargo-row.is-entering, .bk-cargo-summary.is-entering { opacity: 0; transform: translateY(28px); }

.bk-cargo-summary .bk-x, .bk-cargo-row .bk-x {
  height: 32px; width: 32px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 6px; cursor: pointer; color: var(--ink-soft); font-size: .9rem;
}
.bk-cargo-summary .bk-x:hover, .bk-cargo-row .bk-x:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 3D container-type picker: always-visible card grid ----------
   Each card shows a proper, clearly-sized 3D preview at a fixed good
   angle (no distracting auto-spin) — it only turns gently on hover. */
.bk-typegrid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px;
}
.bk-typecard {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  background: var(--paper-2); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
.bk-typecard:hover { border-color: var(--ink-soft); transform: translateY(-2px); }
.bk-typecard.is-on { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.bk-typecard__stage {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden;
  background: var(--paper); opacity: 0; transition: opacity .35s;
}
.bk-typecard__stage.is-loaded { opacity: 1; }
.bk-typecard__stage canvas { display: block; width: 100%; height: 100%; }
.bk-typecard__label { font-size: .84rem; font-weight: 500; text-align: center; }
@media (max-width: 640px) {
  .bk-typegrid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- compact picker (rows added via "+ Add container") ----------
   A small button that reveals the same card grid in a popover, so extra
   rows don't each take up the full grid's height. */
.bk-typepick { position: relative; }
.bk-typebtn {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 46px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  transition: border-color .15s;
}
.bk-typebtn:hover { border-color: var(--accent); }
.bk-typebtn__stage {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 7px; overflow: hidden;
  background: var(--paper); opacity: 0; transition: opacity .35s;
}
.bk-typebtn__stage.is-loaded { opacity: 1; }
.bk-typebtn__stage canvas { display: block; width: 100%; height: 100%; }
.bk-typebtn__label { flex: 1; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-typebtn__chev { flex: 0 0 auto; color: var(--ink-soft); }

.bk-typepanel {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 33;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(20,42,46,.4); padding: 12px;
  max-height: 420px; overflow-y: auto;
}
.bk-typepanel .bk-typegrid { margin-top: 0; }

/* ---------- Submit ---------- */
.bk-fineprint { font-size: .82rem; color: var(--ink-soft); }
#bk-submit { align-self: flex-start; }

/* ---------- View-only (reading back an already-submitted booking) ----------
   Same page, same layout — every section stays fully open (none of the
   is-locked masking) and every field is a real disabled input holding the
   real submitted value, not a redrawn summary that could drift from it. */
.bk-back {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  color: var(--ink-soft); font-family: "IBM Plex Mono", monospace; font-size: .8rem;
  text-decoration: none; margin-bottom: 20px; background: none; border: none; padding: 0;
}
.bk-back:hover { color: var(--accent); }

.bk.is-viewonly .field input:disabled,
.bk.is-viewonly .field select:disabled,
.bk.is-viewonly .field textarea:disabled {
  opacity: 1; color: var(--ink); cursor: default; background: var(--paper);
}
.bk.is-viewonly .bk-tiles { pointer-events: none; }
.bk.is-viewonly .bk-tile:hover { border-color: var(--line); color: var(--ink-soft); }
.bk.is-viewonly .bk-tile.is-on:hover { border-color: var(--ink); color: var(--paper); }
.bk.is-viewonly .bk-cargo-summary .bk-x { display: none; }
/* .bk-row/.btn set their own `display`, which otherwise beats the [hidden]
   attribute's UA rule at equal specificity — same trap already worked
   around below for .bk-done. */
#bk-row-meta[hidden], #bk-add[hidden], #bk-submit[hidden] { display: none; }
.bk-view-status { font-size: .82rem; color: var(--ink-soft); }
.bk-view-status b { color: var(--ink); }

/* ---------- Confirmation ---------- */
.bk-done { text-align: center; padding: 90px 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.bk-done[hidden] { display: none; }   /* display:flex would otherwise defeat the hidden attribute */
.bk-done h2 { font-size: 2.2rem; }
.bk-done p { color: var(--ink-soft); }

/* ---------- Login gate ---------- */
.bk-login { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.bk-login[hidden] { display: none; }
.bk-login__backdrop { position: absolute; inset: 0; background: rgba(20, 42, 46, .55); backdrop-filter: blur(2px); }
.bk-login__card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: var(--paper-2); border-radius: var(--r); box-shadow: 0 24px 60px rgba(20, 30, 28, .28);
  padding: 40px 36px 32px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.bk-login__card img { margin-bottom: 14px; }
.bk-login__card h3 { font-size: 1.4rem; margin: 0 0 8px; }
.bk-login__card > p { color: var(--ink-soft); font-size: .92rem; margin: 0 0 22px; }
.bk-login__close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: var(--ink-soft); font-size: .95rem; cursor: pointer; transition: background .15s, color .15s;
}
.bk-login__close:hover { background: var(--line); color: var(--ink); }
.bk-login__btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: .92rem; color: var(--ink);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.bk-login__btn + .bk-login__btn { margin-top: 10px; }
.bk-login__btn:hover { border-color: var(--ink); background: var(--paper); }
.bk-login__error { color: var(--accent); font-size: .82rem; margin: 16px 0 0; }
.bk-login__error[hidden] { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .bk-step { grid-template-columns: 1fr; gap: 22px; padding: 34px 0; }
  .bk-step__label p { max-width: none; }
}
@media (max-width: 480px) {
  .bk-typebtn__label { font-size: .82rem; }
}
