/* Contact form feedback: sending, failure and the confirmation panel. Loaded only on pages with the contact form.
   Themes set --contact-accent (confirmation mark) and --contact-alert (failures). */
#contact-form { --contact-ease: cubic-bezier(.23, 1, .32, 1); }
#contact-fields .field, #contact-fields > .small-note { transition: opacity .2s ease; }
#contact-form[aria-busy="true"] :is(#contact-fields .field, #contact-fields > .small-note) { opacity: .5; }
#contact-form button[type="submit"] { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
#contact-form[aria-busy="true"] button[type="submit"] { cursor: progress; }
#contact-form[aria-busy="true"] button[type="submit"]::before {
  content: ''; flex: none; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: contact-spin .6s linear infinite;
}
#contact-form button[type="submit"]:active:not(:disabled), #contact-again:active { scale: .97; }
#message-count { margin: -16px 0 24px; text-align: right; font-variant-numeric: tabular-nums; }
#contact-status { margin: 20px 0 0; }
#contact-status:focus { outline: none; }
#contact-status:not([hidden]) { animation: contact-in .24s var(--contact-ease); }
#contact-status[data-tone="error"] {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-left: 3px solid var(--contact-alert, #a3271f);
  background: color-mix(in srgb, var(--contact-alert, #a3271f) 8%, transparent);
}
#contact-status[data-tone="error"]::before {
  content: '!'; flex: none; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  background: var(--contact-alert, #a3271f); color: #fff; font: 700 .8125rem/1 var(--sans, sans-serif);
}
#contact-status[data-tone="slow"] { color: var(--muted); }
#contact-fallback { margin: 10px 0 0; }
#contact-fallback a { text-decoration: underline; text-underline-offset: 4px; overflow-wrap: anywhere; }
.contact-sent { padding: 8px 0; }
.contact-sent:not([hidden]) { animation: contact-in .32s var(--contact-ease); }
.contact-sent:focus { outline: none; }
.contact-sent-mark {
  display: block; width: 56px; height: 56px; margin-bottom: 22px;
  fill: none; stroke: var(--contact-accent, var(--wine)); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
}
/* The mark rests fully drawn; the animation only draws it in, so it stays visible wherever animation is off. */
.contact-sent-mark :is(circle, path) { stroke-dasharray: 1 1; stroke-dashoffset: 0; }
.contact-sent:not([hidden]) .contact-sent-mark circle { animation: contact-draw .5s var(--contact-ease) .08s backwards; }
.contact-sent:not([hidden]) .contact-sent-mark path { animation: contact-draw .3s var(--contact-ease) .34s backwards; }
.contact-sent h3 { margin-bottom: 10px; font: 1.75rem/1.15 var(--serif); }
.contact-sent p { color: var(--muted); max-width: 46ch; }
.contact-sent .button { margin-top: 28px; }
#tasting-fields:not([hidden]) { animation: contact-in .24s var(--contact-ease); }
@keyframes contact-spin { to { rotate: 360deg; } }
@keyframes contact-in { from { opacity: 0; translate: 0 8px; } }
@keyframes contact-fade { from { opacity: 0; } }
@keyframes contact-draw { from { stroke-dashoffset: 1; } }
@media (prefers-reduced-motion: reduce) {
  #contact-status:not([hidden]), .contact-sent:not([hidden]), #tasting-fields:not([hidden]) { animation-name: contact-fade; }
  .contact-sent:not([hidden]) .contact-sent-mark :is(circle, path) { animation: none; }
  #contact-form[aria-busy="true"] button[type="submit"]::before { animation-duration: 1.2s; }
}

/* Vivant (Lienhardt): a printed card for the confirmation, a rounded tomato note for failures. */
[data-theme="vivant"] {
  #contact-form, .contact-sent { --contact-accent: var(--tomato); --contact-alert: var(--tomato); }
  #contact-status[data-tone="error"] { border: 1.5px solid var(--tomato); border-radius: 14px; background: #f8e3dc; font: 400 .9375rem/1.5 var(--text); }
  #contact-status[data-tone="error"]::before { font-family: var(--display); }
  #contact-fallback a { color: var(--tomato); }
  .contact-sent { padding: clamp(28px, 4vw, 44px); border: 1.5px solid var(--ink); border-radius: 22px; background: #fffdf8; }
  .contact-sent h3 { font-size: clamp(1.6rem, 2.4vw, 2rem); line-height: 1.1; }
}

/* Affiche (breweries): a poster block with the red offset shadow of the visit card. */
[data-theme="affiche"] {
  #contact-form, .contact-sent { --contact-accent: var(--red); --contact-alert: var(--red); }
  #contact-status[data-tone="error"] { border: 2.5px solid var(--ink); border-left-width: 8px; border-left-color: var(--red); background: var(--cream); }
  .contact-sent { padding: clamp(24px, 3vw, 36px); border: 2.5px solid var(--ink); background: var(--cream); box-shadow: 10px 10px 0 var(--red); }
  .contact-sent h3 { font-size: clamp(2rem, 3.4vw, 2.8rem); line-height: 1; }
}

/* Valduc: the visit card's slate and yellow rule for the confirmation, signal red for failures. */
[data-theme="affiche"][data-producer-id="valduc"] {
  #contact-form, .contact-sent { --contact-accent: var(--sun); --contact-alert: var(--red); }
  #contact-status[data-tone="error"] { border: 1px solid rgb(238 48 49 / .5); border-left: 3px solid var(--red); background: rgb(238 48 49 / .1); color: #fff; }
  #contact-status[data-tone="error"]::before { font-family: var(--text); }
  #contact-fallback a { color: #fff; text-decoration-color: var(--red); }
  .contact-sent { background: var(--grain), #202020; border: var(--rule); border-top: 3px solid var(--sun); box-shadow: none; }
  .contact-sent h3 { font-size: clamp(2.2rem, 3.6vw, 3rem); line-height: 1; text-transform: none; }
  .contact-sent p { color: #e8e6e1; }
}
