/* ── Search Flip (2026-12-01) ─────────────────────────────────────────────
   The flipping-search pattern, KinPella build: a search field that flips
   open in 3D (rotateX around its own horizontal centre line) from a round
   magnifier button into a full pill field. The seat reserves the OPEN
   field's box at all times, so nothing on the page ever reflows. The drop
   shadow is a separate element that never rotates — it only arrives.
   One end button does three jobs: with text it clears; empty it closes;
   the round button reopens. Esc closes. No-JS: the field simply sits
   open and searchable (progressive enhancement — .sf-on is JS-added). */

/* Seat: reserves the open field's box; perspective is set from JS off the
   measured width (×2.2) so the flip reads true at any size. */
.sf-seat { position: relative; display: block; }
.cs-bar .sf-seat { width: 100%; max-width: 560px; }
.pg-filters .sf-seat { width: 100%; max-width: 520px; margin: 0 0 14px; }
.rd-lib-wrap .sf-seat { width: 100%; max-width: 560px; margin-top: 16px; }
.ac-controls .sf-seat { width: 100%; }

/* The shadow: cast on the page, never turns with the field. */
.sf-shadow {
  position: absolute; inset: 10px 12px 0; border-radius: 999px;
  box-shadow: 0 18px 30px -10px rgba(23, 35, 66, .38);
  opacity: 0; pointer-events: none;
  transition: opacity .45s ease .08s;
}
.sf-seat:not(.sf-closed) .sf-shadow { opacity: 1; }
.sf-seat.sf-closed .sf-shadow { transition-delay: 0s; }

/* The field: hinged on its own long centre line. */
.sf-field {
  position: relative; transform-origin: 50% 50%;
  transition: transform .633s cubic-bezier(.55, .08, .4, .95), visibility 0s;
}
.sf-seat.sf-closed .sf-field {
  transform: rotateX(-90deg); visibility: hidden; pointer-events: none;
  transition: transform .633s cubic-bezier(.55, .08, .4, .95), visibility 0s linear .6s;
}
/* JS applies the closed state for the flip-in with motion suppressed. */
.sf-nomotion .sf-field, .sf-nomotion .sf-shadow, .sf-nomotion .sf-open { transition: none !important; }

/* Field chrome for the surfaces whose input used to stand alone
   (courses / programmes / academy). Reading's .rd-search brings its own. */
.sf-box {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1.5px solid #d6dbe6; border-radius: 999px;
  padding: 5px 6px 5px 16px;
}
.sf-box .sf-ico { flex: none; color: #8b96ad; display: flex; }
.sf-field input { flex: 1; min-width: 0; }
.sf-field input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }

/* Neutralise the standalone-input chrome now that the field carries it. */
.sf-field input.cs-search, .sf-field input.pg-search {
  border: 0; background: none; box-shadow: none; border-radius: 0;
  padding: 8px 0; margin: 0; width: auto; max-width: none;
  font-size: 16px; min-height: 44px;
}
.ac-controls .sf-field input {
  border: 0; background: none; box-shadow: none; border-radius: 0;
  padding: 8px 0; margin: 0; width: auto;
  font-size: 16px; min-height: 44px; /* 16px floor (was 14.5px) */
}
.sf-on .rd-search { box-shadow: none; } /* the separate .sf-shadow takes over */

/* Focus ring lives on the field, in each surface's own focus colour. */
.sf-field input:focus-visible { outline: none; }
.cs-bar .sf-field:focus-within, .pg-filters .sf-field:focus-within { outline: 3px solid #55bba5; outline-offset: 2px; }
.rd .sf-field:focus-within { outline: 3px solid #b7a8ff; outline-offset: 2px; }
.ac-controls .sf-field:focus-within { outline: 3px solid #6c57d8; outline-offset: 2px; }

/* The end button: one button, three jobs. Faint × while empty (its job is
   Close); a solid disc × while text is present (its job is Clear). */
.sf-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: transparent; color: #8b96ad; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .2s ease, color .2s ease, transform .12s ease;
}
.sf-btn:active { transform: scale(.92); }
.sf-seat.sf-has .sf-btn { background: #263758; color: #fff; }
.ac-controls .sf-seat.sf-has .sf-btn { background: #6c57d8; }

/* The round button: the closed state. It sits centred in the seat the
   open field reserves, so opening/closing never moves the page. */
.sf-open {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: #263758; color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 20px -8px rgba(38, 55, 88, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
  opacity: 0; scale: .5; pointer-events: none;
  transition: opacity .25s ease, scale .45s cubic-bezier(.34, 1.4, .64, 1);
}
.sf-seat.sf-closed .sf-open { opacity: 1; scale: 1; pointer-events: auto; }
.sf-open:active { scale: .93; }
.rd .sf-open { background: #ffca71; color: #263758; box-shadow: 0 10px 20px -8px rgba(6, 12, 34, .6), inset 0 1px 0 rgba(255, 255, 255, .5); }
.ac-controls .sf-open { background: #6c57d8; }

/* Kids Mode: search controls keep their big targets (≥56px). */
html.kids-mode .sf-btn { width: 56px; height: 56px; }
html.kids-mode .sf-open { width: 56px; height: 56px; }
html.kids-mode .sf-field input { min-height: 52px; }

/* Reduced motion: no flip — states swap instantly. */
@media (prefers-reduced-motion: reduce) {
  .sf-field, .sf-shadow, .sf-open, .sf-btn { transition: none !important; }
}
