/* Charte Twisto — widget recherche de circuit scolaire */
:root {
  --twisto-blue: #104975;
  --twisto-blue-dark: #0c3a5e;
  --twisto-focus: #98d2ff;
  --twisto-light-blue: #eef6fb;
  --twisto-row-bg: #f0f8ff;
  --twisto-border: #d0dde6;
  --twisto-text: #383c43;
  --twisto-radius: 3px;
  --twisto-font: "Inter", system-ui, -apple-system, sans-serif;
  --twisto-gap-hero: 30px;
  --twisto-gap-fields: 20px;
  --twisto-gap-label: 4px;
  --twisto-motion-duration: 0.24s;
  --twisto-motion-duration-fast: 0.18s;
  --twisto-motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--twisto-font);
  color: var(--twisto-text);
  background: #fff;
  line-height: 1.5;
}

.twisto-widget {
  max-width: 1100px;
  margin: 0 auto;
}

/* —— Hero —— */
.twisto-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: var(--twisto-gap-hero);
  background: var(--twisto-blue);
  color: #fff;
  border-radius: var(--twisto-radius);
  overflow: visible;
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  .twisto-hero {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.twisto-hero__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--twisto-gap-hero);
  padding: 50px;
  position: relative;
  z-index: 2;
  overflow: visible;
}

@media (max-width: 768px) {
  .twisto-hero__form {
    padding: 30px 24px;
    gap: 24px;
  }
}

.twisto-hero__heading {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) both;
}

.twisto-hero__fields > .twisto-field[data-field="commune"] {
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) 0.05s both;
}

.twisto-hero__form h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
}

.twisto-hero__intro {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.twisto-hero__fields {
  display: flex;
  flex-direction: column;
  gap: var(--twisto-gap-fields);
  width: 100%;
}

.twisto-field {
  margin: 0;
  position: relative;
  z-index: 1;
}

.twisto-field:focus-within,
.twisto-field:has(.twisto-autocomplete__list:not([hidden])) {
  z-index: 20;
}

.twisto-field--step2[hidden],
.twisto-results[hidden] {
  display: none !important;
}

.twisto-field--step2:not([hidden]) {
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) both;
}

.twisto-field label {
  display: block;
  margin-bottom: var(--twisto-gap-label);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.5;
  color: #fff;
}

.twisto-autocomplete {
  position: relative;
}

.twisto-autocomplete__control {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 46px;
  background-color: #fff;
  border: 2px solid #fff;
  border-radius: 3px;
  overflow: visible;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.twisto-autocomplete:focus-within .twisto-autocomplete__control {
  border-color: var(--twisto-focus);
  box-shadow: 0 0 0 3px var(--twisto-focus);
}

.twisto-autocomplete input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 12px 48px 12px 16px;
  border: none;
  border-radius: 3px;
  font-family: var(--twisto-font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--twisto-text);
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.twisto-autocomplete input:focus {
  outline: none;
}

@media (max-width: 768px) {
  .twisto-autocomplete input {
    /* ≥16px évite le zoom auto iOS au focus */
    font-size: 16px;
  }
}

.twisto-autocomplete input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.twisto-autocomplete input::placeholder {
  color: #6b7280;
}

/* Chevron — zone cliquable élargie (≈44px), icône 12×12 alignée à droite */
.twisto-autocomplete__chevron {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.twisto-autocomplete__chevron:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.twisto-autocomplete__chevron-icon {
  display: block;
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.twisto-autocomplete__list {
  position: absolute;
  z-index: 100;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 2px solid var(--twisto-focus);
  border-radius: var(--twisto-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transform-origin: top center;
}

.twisto-autocomplete__list:not([hidden]) {
  animation: twisto-dropdown-in var(--twisto-motion-duration-fast) var(--twisto-motion-ease) both;
}

.twisto-autocomplete__list li {
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  color: var(--twisto-text);
  font-size: 14px;
  line-height: 1.5;
  transition: background-color 0.12s ease;
  -webkit-tap-highlight-color: rgba(16, 73, 117, 0.12);
  touch-action: manipulation;
  user-select: none;
}

@media (max-width: 768px) {
  .twisto-autocomplete__list li {
    font-size: 16px;
    padding: 14px 16px;
  }
}

.twisto-autocomplete__list li:hover,
.twisto-autocomplete__list li[aria-selected="true"] {
  background: var(--twisto-light-blue);
}

.twisto-autocomplete__list li:active {
  background: #dcecf7;
}

.twisto-hero__visual {
  position: relative;
  align-self: stretch;
  min-height: 220px;
  overflow: hidden;
  background: var(--twisto-blue-dark);
  border-radius: 0 var(--twisto-radius) var(--twisto-radius) 0;
}

.twisto-hero__visual-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 40% center;
  border-radius: 0 var(--twisto-radius) var(--twisto-radius) 0;
  animation: twisto-fade-in var(--twisto-motion-duration) var(--twisto-motion-ease) 0.08s both;
}

@media (max-width: 768px) {
  .twisto-hero__visual {
    aspect-ratio: 16 / 9;
    min-height: 0;
    width: 100%;
  }

  .twisto-hero__visual-img {
    object-position: center center;
    border-radius: 0 0 var(--twisto-radius) var(--twisto-radius);
  }
}

/* —— Résultats —— */
.twisto-results {
  position: relative;
  z-index: 0;
  margin-top: var(--twisto-gap-hero);
  padding: 24px;
  border: 1px solid var(--twisto-border);
  border-radius: var(--twisto-radius);
  background: #fff;
}

.twisto-results:not([hidden]) {
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) both;
}

.twisto-animate-in {
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) both;
}

.twisto-arret-section {
  margin-bottom: 24px;
  animation: twisto-fade-up var(--twisto-motion-duration) var(--twisto-motion-ease) both;
}

.twisto-arret-section:last-child {
  margin-bottom: 0;
}

.twisto-arret-section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--twisto-text);
}

.twisto-ligne-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--twisto-row-bg);
  border-radius: var(--twisto-radius);
}

.twisto-ligne-row:last-child {
  margin-bottom: 0;
}

.twisto-ligne-picto-slot {
  flex-shrink: 0;
  width: 64px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.twisto-ligne-picto {
  display: block;
  height: 42px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.twisto-ligne-badge {
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.twisto-ligne-badge--fallback {
  background: var(--twisto-primary, #104975);
  color: #fff;
}

.twisto-ligne-badge--long {
  font-size: 11px;
  padding: 0 8px;
  letter-spacing: -0.02em;
}

.twisto-ligne-label {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--twisto-text);
}

.twisto-ligne-download {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--twisto-blue);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.5;
  text-decoration: none;
}

.twisto-ligne-download:hover .twisto-ligne-download__label {
  text-decoration: underline;
}

.twisto-ligne-download__icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--twisto-blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.twisto-ligne-download:hover .twisto-ligne-download__icon {
  background: var(--twisto-blue-dark);
}

.twisto-ligne-download__icon svg {
  width: 17px;
  height: 17px;
}

.twisto-ligne-download__label {
  line-height: 1.5;
}

@media (max-width: 768px) {
  .twisto-ligne-download {
    gap: 0;
  }

  .twisto-ligne-download__label {
    display: none;
  }
}

.twisto-empty,
.twisto-loading {
  padding: 16px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}

.twisto-error {
  color: #b42318;
  font-size: 14px;
}

/* —— Animations discrètes —— */
@keyframes twisto-fade-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes twisto-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes twisto-dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .twisto-hero__heading,
  .twisto-hero__fields > .twisto-field[data-field="commune"],
  .twisto-hero__visual-img,
  .twisto-field--step2:not([hidden]),
  .twisto-autocomplete__list:not([hidden]),
  .twisto-results:not([hidden]),
  .twisto-animate-in,
  .twisto-arret-section {
    animation: none !important;
  }

  .twisto-autocomplete__control,
  .twisto-autocomplete__list li,
  .twisto-ligne-download__icon {
    transition: none;
  }
}
