/* The request popover: a native modal <dialog> any page can carry. Tokens come from
   /tokens.css. A centred card on a desk, a bottom sheet on a phone. */

.req{
  width:min(30rem, calc(100vw - 2rem)); max-height:min(90dvh, 44rem); padding:0; margin:auto;
  border:1px solid var(--border-soft); border-radius:24px 20px 20px 20px;
  background:var(--bg-card); color:var(--fg); box-shadow:var(--shadow-modal);
  overflow:auto; overscroll-behavior:contain;
  font:500 var(--t-18)/1.5 var(--font-body);
  /* closed state: the exit runs back to these */
  opacity:0;
  transition-property:opacity, translate, display, overlay;
  transition-duration:.26s; transition-timing-function:var(--ease-out);
  transition-behavior:allow-discrete;
}
.req[open]{
  opacity:1; transition-duration:.38s;
  @starting-style{ opacity:0; }
}
@media (prefers-reduced-motion:no-preference){
  .req{ translate:0 16px; }
  .req[open]{ translate:0 0; @starting-style{ translate:0 16px; } }
}
.req::backdrop{
  background:rgb(10 10 10 / 0); overflow:hidden; overscroll-behavior:contain;
  transition-property:background-color, display, overlay;
  transition-duration:.26s; transition-timing-function:var(--ease-out);
  transition-behavior:allow-discrete;
}
.req[open]::backdrop{
  background:var(--scrim, rgb(10 10 10 / .4));
  @starting-style{ background:rgb(10 10 10 / 0); }
}

.req-in{ display:grid; gap:14px; padding:22px 24px 24px; }
.req-head{ display:flex; align-items:flex-start; gap:12px; }
.req h2{ margin:0; font:400 2rem/.92 var(--font-display); letter-spacing:var(--track-display);
  text-transform:uppercase; }
.req-x{
  margin:-6px -8px 0 auto; flex:none; width:44px; height:44px; display:grid; place-items:center;
  border:0; border-radius:var(--radius-pill); background:none; color:var(--fg-muted); cursor:pointer;
}
.req-x:hover{ color:var(--fg); background:var(--ghost); }
.req-x svg{ width:16px; height:16px; }

.req-f{ display:grid; gap:6px; }
.req label{ font:500 var(--t-13)/1 var(--font-data); letter-spacing:.16em; text-transform:uppercase; }
.req input,.req textarea{
  width:100%; padding:11px 12px; border:1px solid var(--border-strong); border-radius:10px;
  background:var(--bg); color:var(--fg); font:inherit; font-size:max(1rem, 1em);
}
.req textarea{ min-height:7.5rem; resize:vertical; }
.req input:focus-visible,.req textarea:focus-visible{ outline:2px solid transparent; box-shadow:var(--focus-ring); border-radius:10px; }
/* an error shows only once the visitor has left the field or tried to send */
.req :is(input:user-invalid, textarea:user-invalid, [aria-invalid="true"]){
  border-color:var(--danger-tint); box-shadow:inset 3px 0 0 var(--danger-tint); }
.req :is(input, textarea):focus-visible:is(:user-invalid, [aria-invalid="true"]){
  box-shadow:inset 3px 0 0 var(--danger-tint), var(--focus-ring); }
.req ::placeholder{ color:var(--fg-muted); opacity:1; }

/* the honeypot: out of sight, out of the tab order, still in the form */
.req-hp{ position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0; overflow:hidden;
  clip-path:inset(50%); white-space:nowrap; }

.req-foot{ display:flex; flex-wrap:wrap; align-items:center; gap:10px 16px; margin-top:4px; }
.req-send{
  display:inline-flex; align-items:center; justify-content:center; height:44px; padding:0 24px;
  border:0; border-radius:var(--radius-pill); background:var(--accent); color:var(--on-accent);
  font:600 var(--t-13)/1 var(--font-body); white-space:nowrap; cursor:pointer;
  transition:background .3s var(--ease-out);
}
.req-send:hover{ background:var(--accent-hover); }
.req-send[disabled]{ opacity:.6; cursor:progress; }
.req-msg{ flex:1 1 12rem; min-height:1.2em; margin:0; font-size:var(--t-13); }
.req-msg[data-kind="error"]{ color:var(--danger-tint); }
.req-note{ margin:0; font:500 var(--t-13)/1.6 var(--font-data); letter-spacing:.04em; }

/* sent: the form gives way to one line and a way out */
.req-done{ display:none; gap:16px; padding:28px 24px 26px; }
.req[data-state="sent"] .req-in{ display:none; }
.req[data-state="sent"] .req-done{ display:grid; }
.req-done p{ margin:0; }

@media (max-width:560px){
  .req{ width:100%; max-width:none; margin:auto 0 0; max-height:92dvh;
    border-radius:20px 20px 0 0; border-width:1px 0 0; }
  .req-in{ padding:18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .req-done{ padding-bottom:calc(26px + env(safe-area-inset-bottom)); }
}
