/* Layout and components for the map demo. Every colour, font, radius and shadow comes
   from tokens.css (the generated EJH design-system tokens) — no raw hex below. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Registering the custom property gives it a type, which is what makes it animatable —
   an unregistered custom property changes discretely and the card's accent stripe would
   snap from blue to orange while its pin faded. */
@property --card-accent {
  syntax: "<color>";
  inherits: true;
  initial-value: transparent;
}

/* The wash behind a selected card. Registered for the same reason as the accent: it has
   to fade with the stripe when a pending card turns out to be bookable. */
@property --card-tint {
  syntax: "<color>";
  inherits: true;
  initial-value: transparent;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-foreground);
  background: var(--color-background-tinted);
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--color-heading);
  font-weight: 400;
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--color-border-selected);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Chrome --------------------------------------------------------------------- */

.masthead {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: var(--top-bar-header-height, 3.125rem);
  background: var(--color-system-easyjet);
  color: var(--color-interactive-foreground);
}

.masthead h1,
.masthead a {
  font-size: 1.125rem;
  color: var(--color-interactive-foreground);
  text-decoration: none;
}

.masthead .spacer {
  margin-left: auto;
}

.masthead .criteria {
  font-size: 0.8125rem;
}

/* --- Forms ---------------------------------------------------------------------- */

.search-page {
  display: grid;
  place-items: start center;
  padding: 3rem 1rem;
}

.search-card {
  width: min(56rem, 100%);
  background: var(--color-background);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md-down);
  padding: 1.5rem;
}

.search-card h2 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
}

.lede {
  color: var(--color-foreground-secondary);
  margin: 0 0 1.5rem;
  max-width: 48ch;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.field > span {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-foreground-secondary);
}

select,
input[type="date"],
input[type="number"] {
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.5rem;
  color: var(--color-foreground);
  background: var(--color-background);
  border: 1px solid var(--color-border-input, var(--color-border-default));
  border-radius: var(--radius);
}

select:disabled {
  color: var(--color-foreground-disabled);
  background: var(--color-background-disabled);
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.625rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--color-interactive-foreground);
  background: var(--color-interactive);
  transition: background-color 150ms ease-out;
}

.btn:hover {
  background: var(--color-interactive-hover);
}

.btn:active {
  background: var(--color-interactive-active);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-note {
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
}

/* --- Results split view --------------------------------------------------------- */

.results-page {
  display: grid;
  grid-template-columns: 1fr 2fr;
  height: calc(100dvh - var(--top-bar-header-height, 3.125rem));
}

@media (max-width: 60rem) {
  .results-page {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 1fr;
  }

  .results-list {
    order: 2;
  }
}

.results-list {
  overflow-y: auto;
  padding: 1rem;
  background: var(--color-background-tinted);
  border-right: 1px solid var(--color-border-default);
}

#map {
  height: 100%;
  background: var(--color-background-tinted);
}

.section-head {
  position: sticky;
  top: -1rem;
  z-index: 1;
  margin: 0 -1rem;
  padding: 0.75rem 1rem;
  background: var(--color-background-tinted);
}

.section-head h2 {
  font-size: 1.125rem;
}

.section-head p {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
}

.results-list > section + section {
  margin-top: 1.5rem;
}

/* --- Cards ---------------------------------------------------------------------- */

.card {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0.625rem;
  margin-bottom: 0.625rem;
  background: var(--color-background);
  --card-tint: var(--color-background);
  border: 1px solid var(--color-border-default);
  border-left: 4px solid var(--card-accent);
  border-radius: var(--radius);
  transition:
    box-shadow 150ms ease-out,
    border-color 150ms ease-out,
    background-color 150ms ease-out,
    --card-accent 450ms ease,
    --card-tint 450ms ease; /* keeps the stripe and its wash in step with the pin */
}

/* Three states, one colour language shared by cards and map pins: blue is waiting on the
   API, orange is bookable, grey has been asked about and has nothing. */
.card--priced {
  --card-accent: var(--color-interactive);
  --card-tint: var(--color-primary-100);
}

.card--pending {
  --card-accent: var(--color-system-info);
  --card-tint: var(--color-info-100);
  grid-template-columns: 1fr;
}

.card--unavailable {
  --card-accent: var(--color-neutral-400);
  grid-template-columns: 1fr;
}

.card--unavailable h3 {
  color: var(--color-foreground-secondary);
}

.card:hover {
  box-shadow: var(--shadow-md-down);
}

/* Every priced card already wears an orange stripe, so the selected one has to say more
   than "orange": a ring right around it, and a wash of the same accent behind it. The ring
   is an inset shadow rather than a wider border so the list does not reflow on selection —
   and so :focus-visible keeps the outline to itself. */
.card.is-selected {
  border-color: var(--card-accent);
  background: var(--card-tint);
  box-shadow:
    inset 0 0 0 2px var(--card-accent),
    var(--shadow-lg-down);
}

.card img {
  width: 100%;
  height: 100%;
  min-height: 5rem;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--color-background-tinted);
}

.card h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.card .resort,
.card .ksp {
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
  margin: 0.125rem 0 0;
}

.card .stars {
  color: var(--color-system-easyjet);
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
}

.card .rating {
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
}

.price {
  margin-top: 0.375rem;
}

.price strong {
  font-size: 1.125rem;
  color: var(--color-heading);
}

.price span {
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
}

.no-price {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
}

/* The badge is what actually carries the meaning — the marker colour only echoes it. */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.25rem;
}

.badge--priced {
  color: var(--color-system-easyjet);
  background: var(--color-system-easyjet-secondary);
}

.badge--pending {
  color: var(--color-system-info);
  background: var(--color-system-info-secondary);
}

.badge--unavailable {
  color: var(--color-foreground-secondary);
  background: var(--color-background-tinted);
}

/* A slow pulse while a hotel is queued, so a long queue reads as working, not stuck. */
.badge--pending {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

/* --- Map markers ---------------------------------------------------------------- */

.pin {
  /* <i> is inline, and an inline box ignores width/height — without this the map markers
     collapse into thin white slivers. The legend only looked right because its flex
     container was blockifying them. */
  display: block;
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 2px solid var(--color-interactive-foreground);
  box-shadow: var(--shadow-sm-down);
  /* A pin arrives once and then only ever changes class, so the colour change is a
     transition on a live element rather than a new element appearing already-orange. */
  transition:
    background-color 450ms ease,
    opacity 450ms ease,
    transform 180ms ease-out,
    box-shadow 180ms ease-out;
  /* backwards, not forwards: once it has popped in, the class rules own the transform
     again, so selecting a pin still scales it. */
  animation: pin-in 260ms cubic-bezier(0.34, 1.4, 0.64, 1) backwards;
}

@keyframes pin-in {
  from {
    transform: scale(0);
  }
}

.pin--priced {
  background: var(--color-interactive);
}

.pin--pending {
  background: var(--color-system-info);
}

.pin--unavailable {
  background: var(--color-neutral-400);
  opacity: 0.7;
}

.pin.is-selected {
  transform: scale(1.6);
  box-shadow: var(--shadow-md);
}

.pin-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* A priced pin carries its per-person price and grows into a pill. Empty pins — pending,
   unavailable, and the legend swatches — keep the 1rem dot above. */
.pin:not(:empty) {
  width: auto;
  height: auto;
  padding: 0.1875rem 0.4375rem;
  font: 0.6875rem/1 var(--font-sans);
  color: var(--color-interactive-foreground);
  white-space: nowrap;
}

/* 1.6 is a lot of pill. */
.pin:not(:empty).is-selected {
  transform: scale(1.2);
}

.leaflet-popup-content {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  margin: 0.625rem;
}

.leaflet-popup-content strong {
  display: block;
  font-size: 0.9375rem;
  color: var(--color-heading);
}

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

.status {
  padding: 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-foreground-secondary);
  background: var(--color-background);
  border: 1px dashed var(--color-border-default);
  border-radius: var(--radius);
}

.status--error {
  color: var(--color-system-error);
  background: var(--color-system-error-secondary);
  border-style: solid;
  border-color: var(--color-system-error-tertiary);
}

/* --- Toasts --------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 1rem;
  /* Clears Leaflet's attribution bar, which has to stay legible for the OSM licence. */
  bottom: 2rem;
  z-index: 1000; /* above Leaflet's controls */
  display: grid;
  gap: 0.5rem;
  justify-items: end;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-foreground-inverted);
  background: var(--color-background-inverted);
  border-left: 3px solid var(--toast-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md-down);
  animation: toast-in 150ms ease-out;
}

/* One colour per API surface, so the call pattern is readable at a glance. The bar uses
   the saturated token; the label uses the light end of the same ramp, because the
   mid-ramp colours do not carry enough contrast against the inverted background. */
.toast--geo {
  --toast-accent: var(--color-system-easyjet); /* REST search by destination */
  --toast-label: var(--color-system-easyjet-tertiary);
}

.toast--map {
  --toast-accent: var(--color-system-info); /* GraphQL hotels in bounds */
  --toast-label: var(--color-system-info-tertiary);
}

.toast--codes {
  --toast-accent: var(--color-system-success); /* REST search by accomCodes */
  --toast-label: var(--color-system-success-tertiary);
}

.toast--error {
  --toast-accent: var(--color-system-error);
  --toast-label: var(--color-system-error-tertiary);
}

.toast .api {
  font-weight: 600;
  color: var(--toast-label);
}

.toast.is-leaving {
  animation: toast-out 200ms ease-out forwards;
}

.toast .ms {
  font-variant-numeric: tabular-nums;
  color: var(--color-neutral-400);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(0.75rem);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(0.75rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-leaving,
  .pin,
  .badge--pending {
    animation: none;
  }

  .pin {
    transition: none;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--color-foreground-secondary);
  margin-bottom: 0.75rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend .pin {
  width: 0.75rem;
  height: 0.75rem;
}
