/* ==========================================================================
   TYConsulting — Composants : boutons, étiquettes, formulaires, carte du SI
   ========================================================================== */

/* --- Boutons --- */

.btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.2;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur-hover) var(--ease-hover),
    border-color var(--dur-hover) var(--ease-hover),
    color var(--dur-hover) var(--ease-hover);
}

.btn:active {
  transform: scale(0.97);
}

.btn--lg {
  min-height: 3.25rem;
  padding: 0.85rem 1.5rem;
  font-size: 1.0625rem;
}

.btn__icon {
  width: 1.125rem;
  height: 1.125rem;
  stroke-width: 1.75;
  transition: transform var(--dur-hover) var(--ease-out);
}

/* Primaire : bleu-vert profond (AA), remplissage marine qui progresse de gauche à droite */
.btn--primary {
  background: var(--teal-deep);
  color: var(--white);
  border-color: var(--teal-deep);
}

.btn--primary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--navy);
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--dur-ui) var(--ease-out);
}

.btn--outline {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}

.btn--ghost {
  background: var(--white);
  color: var(--navy);
  border-color: var(--color-border);
}

/* Sur fond marine : bleu-vert de la charte, texte marine (12:1) */
.btn--teal {
  background: var(--teal);
  color: var(--navy-900);
  border-color: var(--teal);
}

.btn--teal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--white);
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--dur-ui) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover::before,
  .btn--teal:hover::before {
    clip-path: inset(0 0 0 0);
  }

  .btn--primary:hover {
    border-color: var(--navy);
  }

  .btn--teal:hover {
    border-color: var(--white);
  }

  .btn--outline:hover {
    background: var(--navy);
    color: var(--white);
  }

  .btn--ghost:hover {
    border-color: var(--navy);
  }

  .btn:hover .btn__icon {
    transform: translateX(3px);
  }

  .btn:hover use[href="#i-arrow-down"] {
    transform: translateY(2px);
  }
}

/* --- Étiquettes de section --- */

.section__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent-text);
  margin-bottom: var(--space-4);
}

.section__label::before {
  content: "";
  width: 1.5rem;
  height: 2px;
  border-radius: 1px;
  background: var(--teal);
}

.section__head--dark .section__label {
  color: var(--teal);
}

/* --- Formulaires --- */

.form {
  display: grid;
  gap: var(--space-5);
}

.form__row {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 40em) {
  .form__row {
    grid-template-columns: 1fr 1fr;
  }
}

.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.field__req {
  color: var(--teal-deep);
}

.field__opt {
  font-weight: 400;
  color: var(--color-text-muted);
}

.field__input {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
  background: var(--white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-hover) var(--ease-hover), box-shadow var(--dur-hover) var(--ease-hover);
}

.field__input::placeholder {
  color: #8593A4;
}

.field__input:focus-visible {
  outline: none;
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 3px rgba(19, 168, 158, 0.22);
}

.field__input[aria-invalid="true"] {
  border-color: var(--color-error);
}

/* Champ présélectionné depuis un bouton de la page : surbrillance brève */
.field__input.is-prefilled {
  animation: prefill 1200ms var(--ease-out);
}

@keyframes prefill {
  0%   { box-shadow: 0 0 0 0 rgba(19, 168, 158, 0.6); border-color: var(--teal); }
  100% { box-shadow: 0 0 0 10px rgba(19, 168, 158, 0); }
}

textarea.field__input {
  resize: vertical;
  min-height: 6rem;
}

select.field__input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B2545' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 1.1rem;
  padding-right: 2.5rem;
}

.field__file {
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: var(--fs-sm);
}

.field__file::file-selector-button {
  font: inherit;
  font-family: var(--font-heading);
  font-weight: 500;
  color: var(--navy);
  background: var(--navy-50);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  margin-right: var(--space-3);
  cursor: pointer;
}

.field__file[aria-invalid="true"] {
  border-color: var(--color-error);
}

.field__help {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
}

.field__error {
  display: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--color-error);
}

.field__error:not(:empty) {
  display: block;
}

.form__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.check {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--fs-sm);
  line-height: 1.5;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1rem 0 0;
  accent-color: var(--teal-deep);
  cursor: pointer;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.form__status {
  flex-basis: 100%;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--navy);
}

.form__status:not(:empty),
.form__status--static {
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--teal-deep);
  background: var(--teal-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.form__status.is-error {
  color: var(--color-error);
  border-color: var(--color-error);
  background: #FBECEB;
}

/* --- Carte du système d'information --- */

.simap {
  position: relative;
  width: min(100%, 36rem);
  margin-inline: auto;
}

.simap__frame {
  position: relative;
  aspect-ratio: 480 / 420;
  background:
    radial-gradient(rgba(11, 37, 69, 0.12) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Repères de plan technique aux quatre coins */
.simap__frame::before,
.simap__frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--teal);
  pointer-events: none;
}

.simap__frame::before {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
}

.simap__frame::after {
  right: 10px;
  bottom: 10px;
  border-left: 0;
  border-top: 0;
}

.simap__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  font-family: var(--font-body);
}

.simap__layer {
  fill: rgba(19, 168, 158, 0.06);
  stroke: var(--teal-line);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.simap__layer-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--teal-deep);
}

/* Liens emmêlés : invisibles par défaut (état « après », y compris sans JavaScript) */
.simap__tangle {
  opacity: 0;
}

.simap__tangle path {
  fill: none;
  stroke: #9AA8B8;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.simap__links path {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.simap__node rect {
  fill: var(--white);
  stroke: var(--navy-100);
  stroke-width: 1.25;
}

.simap__node--core rect {
  stroke: var(--navy);
  stroke-width: 1.5;
}

.simap__node text {
  font-size: 13px;
  font-weight: 500;
  fill: var(--navy);
  text-anchor: middle;
}

.simap__node {
  transform-box: fill-box;
  transform-origin: center;
  transform: translate(var(--ax), var(--ay));
  cursor: default;
}

/* Barre : commutateur, état annoncé, rejouer */
.simap__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--fs-sm);
}

.simap__switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--white);
}

.simap__btn {
  min-height: 2.75rem;
  padding: 0.3rem 1rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--navy);
  transition: background-color var(--dur-hover) var(--ease-hover), color var(--dur-hover) var(--ease-hover), transform var(--dur-press) var(--ease-out);
}

.simap__btn:active {
  transform: scale(0.96);
}

.simap__btn[aria-pressed="true"] {
  background: var(--navy);
  color: var(--white);
}

.simap__status {
  color: var(--color-text-muted);
  flex: 1 1 12rem;
}

.simap__replay {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--teal-deep);
  transition: background-color var(--dur-hover) var(--ease-hover);
}

@media (hover: hover) and (pointer: fine) {
  .simap__replay:hover {
    background: var(--teal-soft);
  }
}

/* Sans JavaScript : la carte est présentée dans son état final, sans commandes */
.no-js .simap__bar {
  display: none;
}
