/* Jätä viesti -yhteydenottolomake (partials/viesti-lomake.php) ja sen sivuvalikon modaali
   (partials/viesti-dialog.php). nav.js lataa tämän ensimmäisellä avauksella; yhteystiedot-sivu linkittää
   sen itse upotettua lomaketta varten. Ulkoasu seuraa tarjousmodaalia, jotta lomakkeet tuntuvat samalta. */

/* ─── Modaali ────────────────────────────────────────────── */
html:has(.viesti-dialog[open]) { overflow: hidden; }

.viesti-dialog {
  width: min(680px, calc(100vw - 32px)); max-width: none; max-height: min(92dvh, 900px);
  margin: auto; padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 24px; background: #fff; color: var(--text);
  font-family: var(--font); box-shadow: 0 32px 90px rgba(18, 26, 59, 0.3);
}
.viesti-dialog[open] { display: flex; flex-direction: column; animation: viesti-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); }
.viesti-dialog::backdrop { background: rgba(15, 21, 41, 0.6); backdrop-filter: blur(3px); }
@keyframes viesti-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

.viesti-dialog-head {
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.viesti-dialog-kicker {
  grid-column: 2; justify-self: center; display: inline-flex; align-items: center; gap: 8px;
  color: var(--navy); font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
}
.viesti-dialog-kicker::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--grad-tilt); }
.viesti-dialog-close {
  grid-column: 3; display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--navy-dark); cursor: pointer; transition: background 0.15s;
}
.viesti-dialog-close:hover { background: var(--navy-50); }
.viesti-dialog-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px 32px 32px; }
.viesti-dialog h2 {
  margin: 0 0 8px; color: var(--navy-deeper); font-size: clamp(24px, 3.4vw, 30px); font-weight: 800;
  line-height: 1.15; letter-spacing: -0.01em;
}
.viesti-dialog h2:focus { outline: none; }
.viesti-lead { margin: 0 0 22px; color: var(--text-muted); font-size: 16px; line-height: 1.55; }

/* ─── Lomake ─────────────────────────────────────────────── */
.viesti-lomake [hidden] { display: none !important; }
.viesti-lomake :focus-visible { outline: 3px solid rgba(233, 30, 133, 0.4); outline-offset: 2px; }
.viesti-lomake button,
.viesti-lomake input,
.viesti-lomake textarea { font: inherit; }
.viesti-form { display: grid; gap: 18px; }
.viesti-form label:not([class]),
.viesti-chips legend { display: block; margin-bottom: 6px; padding: 0; color: var(--navy-dark); font-size: 14px; font-weight: 700; }
.viesti-form label:not([class]) > span { color: var(--text-muted); font-weight: 500; }
.viesti-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.viesti-form input:not([type="radio"]),
.viesti-form textarea {
  box-sizing: border-box; width: 100%; min-width: 0; padding: 12px 14px; border: 1px solid #c8ccd8; border-radius: 12px;
  background: #fff; color: var(--text); font-size: 15px;
}
.viesti-form textarea { resize: vertical; }
.viesti-form input::placeholder,
.viesti-form textarea::placeholder { color: #7c8190; opacity: 1; }
.viesti-form input:focus-visible,
.viesti-form textarea:focus-visible { outline: 3px solid rgba(233, 30, 133, 0.33); outline-offset: 0; border-color: var(--pink); }
.viesti-hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.viesti-chips { margin: 0; padding: 0; border: 0; }
.viesti-chip { display: inline-block; margin: 0 6px 8px 0; cursor: pointer; }
.viesti-chip input { position: absolute; opacity: 0; pointer-events: none; }
.viesti-chip span {
  display: inline-block; padding: 9px 15px; border: 1px solid #c8ccd8; border-radius: 999px;
  color: var(--navy-dark); font-size: 14px; font-weight: 600; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.viesti-chip input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; }
.viesti-chip input:focus-visible + span { outline: 3px solid rgba(233, 30, 133, 0.4); outline-offset: 2px; }

.viesti-privacy { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; }
.viesti-privacy a,
.viesti-warning a { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
.viesti-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.viesti-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 13px 22px;
  border: 1px solid var(--navy); border-radius: 12px; background: var(--navy); color: #fff;
  font-weight: 700; text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.viesti-btn:hover { border-color: var(--navy-dark); background: var(--navy-dark); color: #fff; }
.viesti-btn--ghost { border-color: #c8ccd8; background: transparent; color: var(--navy); }
.viesti-btn--ghost:hover { border-color: var(--navy); background: var(--navy-50); color: var(--navy); }
.viesti-btn:disabled { opacity: 0.6; cursor: wait; }
.viesti-status { min-height: 1.4em; margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.viesti-status:empty { display: none; }
.viesti-status.is-error { color: #b91c1c; }

.viesti-done { display: grid; justify-items: center; gap: 10px; padding: 20px 0 8px; text-align: center; }
.viesti-done:focus { outline: none; }
.viesti-done-icon { display: grid; width: 68px; height: 68px; margin-bottom: 6px; place-items: center; border-radius: 50%; background: var(--grad-tilt); color: #fff; }
.viesti-done-title { color: var(--navy-deeper); font-size: 22px; font-weight: 800; }
.viesti-done p { max-width: 460px; margin: 0; color: var(--text-muted); font-size: 16px; line-height: 1.55; }
.viesti-done .viesti-warning { padding: 12px 14px; border-radius: 12px; background: #fef3c7; color: #92400e; font-size: 14px; }

@media (max-width: 600px) {
  .viesti-dialog { width: 100vw; max-height: 100dvh; border-radius: 0; }
  .viesti-dialog-body { padding: 22px 18px 26px; }
  .viesti-fields { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .viesti-dialog[open] { animation: none; }
}
