/* "Sugerir um spot" on the map (public/suggest.js). Built on the tokens and chips of styles.css and the
   map's own look (map.css): a panel from the bottom (left on wide screens) and a pin standing over the map. */

/* ---------- The ways in ---------- */
/* At the end of the list: a row like the spots' rows, with a + where their dot is. */
.sg-entry {
  width: 100%; display: grid; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 12px;
  min-height: 64px; margin-top: 4px; padding: 9px 16px; border: 0; border-top: 1px solid var(--line); background: none;
  color: inherit; text-align: start; font: inherit; transition: background-color .15s var(--ease-out);
}
@media (hover: hover) { .sg-entry:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); } }
.sg-entry:active { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.sg-entry:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: -3px; border-radius: 12px; }
.sg-entry-ic {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--rain) 70%, transparent); color: var(--rain);
}
.sg-entry-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.sg-entry .mp-name { color: var(--ink); }
/* Search found nothing: offer it there too (only then, not when matches are in another kind), and only
   there: the row at the end of the (empty) list would say the same thing twice. */
#listNone[hidden] ~ .sg-from-search { display: none; }
body:has(#listHint:not([hidden]) #listNone:not([hidden])) .sg-entry { display: none; }

/* ---------- While suggesting: the spots and their card step aside ---------- */
body.sg-on #preview, body.sg-on .mp-skip { display: none !important; }
body.sg-on .mk-wrap { pointer-events: none; }
body.sg-on .mk, body.sg-on .mkc { opacity: .55; }
@media (min-width: 900px) { body.sg-on .mp-sheet { visibility: hidden; } }

/* ---------- The pin in the middle of the free map ---------- */
.sg-cross { position: fixed; z-index: 2; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.sg-pin {
  position: absolute; left: -19px; bottom: 0; width: 38px; height: 38px; color: var(--rain);
  transform-origin: 50% 100%; transition: transform .22s var(--ease-out);
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / .28));
}
.sg-pin svg, .sg-mark svg { display: block; width: 100%; height: 100%; }
.sg-pin path, .sg-mark path { fill: currentColor; stroke: var(--mp-ring); stroke-width: 1.4; }
.sg-pin circle, .sg-mark circle { fill: var(--mp-ring); stroke: none; }
/* The point it marks: a small shadow on the ground, which stays put while the pin lifts. */
.sg-shadow {
  position: absolute; left: -5px; top: -2.5px; width: 10px; height: 5px; border-radius: 50%;
  background: rgb(0 0 0 / .35); transition: transform .22s var(--ease-out), opacity .22s var(--ease-out);
}
.sg-cross.is-moving .sg-pin { transform: translateY(-9px); }
.sg-cross.is-moving .sg-shadow { transform: scale(1.5); opacity: .55; }
/* The chosen place while the details are filled in (a MapLibre marker) */
.sg-mark { width: 34px; height: 34px; color: var(--rain); filter: drop-shadow(0 3px 4px rgb(0 0 0 / .28)); pointer-events: none; }

/* ---------- The panel ---------- */
.sg {
  --sg-kb: 0px; /* the on-screen keyboard's height (suggest.js) */
  position: fixed; z-index: 5; left: 0; right: 0; bottom: var(--sg-kb);
  max-height: calc(100% - var(--mp-top) - 12px - var(--sg-kb)); overflow-y: auto; overscroll-behavior: contain;
  padding: 18px max(18px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; box-shadow: var(--mp-sheet-shadow);
}
.sg[hidden] { display: none; }
.sg.m-in { animation: sg-in .38s var(--ease-sheet) both; }
@keyframes sg-in { from { transform: translateY(100%); } }
.sg-step[hidden] { display: none; }
.sg-step { animation: sg-step .22s var(--ease-out); }
@keyframes sg-step { from { opacity: 0; transform: translateY(6px); } }
.sg-x {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--chip); color: var(--ink); font-size: 22px; line-height: 1;
}
.sg-x:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }
.sg-title { margin: 0 48px 6px 0; font-size: 21px; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; outline: none; }
[dir="rtl"] .sg-title { margin: 0 0 6px 48px; }
.sg-hint { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.4; text-wrap: pretty; }

.sg-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sg-actions .sg-btn { flex: 1 1 140px; }
.sg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 16px;
  border-radius: 14px; font: 700 16px/1.2 var(--font); transition: transform .12s var(--ease-out), opacity .15s, background-color .15s;
}
.sg-btn:active { transform: scale(var(--press)); }
.sg-btn:disabled { opacity: .6; cursor: default; }
.sg-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }
.sg-btn[hidden] { display: none; }
.sg-primary { border: 0; background: var(--ink); color: var(--bg); }
.sg-sec { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.sg-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.sg-btn.is-busy svg { animation: mp-spin 1s linear infinite; }

/* Something to say (already on the map, an error): a tinted box, with its button after the text. */
.sg-msg {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; padding: 11px 14px;
  border-radius: 12px; background: color-mix(in srgb, var(--puddles) 13%, transparent); color: var(--ink); font-size: 15px; line-height: 1.4;
}
.sg-msg[hidden] { display: none; }
.sg-msg[data-code="exists"] { background: color-mix(in srgb, var(--rain) 13%, transparent); }
.sg-link-btn {
  min-height: 36px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font: 700 14px/1.2 var(--font);
}
.sg-link-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }

/* ---------- Pin step: location first, then a spot to jump near ---------- */
.sg-loc { width: 100%; margin-top: 14px; }
.sg-findbox[hidden] { display: none; }
.sg-findbox .sg-label { margin-top: 12px; }
.sg-find { min-height: 44px; padding-block: 10px; }
.sg-found { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.sg-found[hidden] { display: none; }
.sg-found li + li { border-top: 1px solid var(--line); }
.sg-hit {
  display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 44px; padding: 10px 14px; border: 0;
  background: none; color: var(--ink); font: 600 15px/1.3 var(--font); text-align: start;
}
.sg-hit:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.sg-hit:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: -3px; }
.sg-hit-sub { margin-inline-start: auto; color: var(--ink-2); font-weight: 500; font-size: 14px; }

/* A field's own error, right under it */
.sg-field-err { margin: 6px 0 0; color: var(--ink); font-size: 14px; line-height: 1.4; padding-inline-start: 10px; border-inline-start: 3px solid var(--puddles); }
.sg-field-err[hidden] { display: none; }
.sg-input[aria-invalid="true"] { border-color: var(--puddles); }

/* ---------- Details ---------- */
.sg-pinrow {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 4px; padding: 10px 12px; border: 0; border-radius: 12px;
  background: color-mix(in srgb, var(--rain) 10%, transparent); color: var(--ink); font: 600 15px/1.2 var(--font); text-align: start;
}
.sg-pinrow-ic { flex: none; width: 20px; height: 20px; color: var(--rain); }
.sg-pinrow-ic svg { display: block; width: 100%; height: 100%; }
.sg-pinrow-ic path { fill: currentColor; } .sg-pinrow-ic circle { fill: var(--surface); }
.sg-pinrow .sg-link { margin-inline-start: auto; color: var(--rain); font-weight: 700; }
.sg-pinrow:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }
.sg-label { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0 6px; font-size: 14px; font-weight: 700; color: var(--ink); }
.sg-count { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sg-input {
  display: block; width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font: 16px/1.35 var(--font); /* 16px: iOS doesn't zoom in */
}
.sg-input::placeholder { color: var(--ink-2); opacity: 1; }
.sg-input:focus { outline: 2px solid color-mix(in srgb, var(--ink) 35%, transparent); outline-offset: 0; }
.sg-note { resize: vertical; min-height: 72px; }
.sg-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.sg-kinds .chip { min-height: 40px; padding: 8px 14px; font-size: 15px; font-weight: 600; }
.sg-kinds .chip[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.sg-kinds .chip:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }
.sg-send { width: 100%; margin-top: 16px; }
.sg-fine { margin: 12px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.sg-fine a { color: inherit; text-underline-offset: 2px; }

/* ---------- Sent ---------- */
.sg-done { padding-top: 4px; }
.sg-check {
  display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 12px; border-radius: 50%;
  background: var(--dry); color: #fff;
}
.sg-check svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.sg-check path { stroke-dasharray: 24; stroke-dashoffset: 0; animation: sg-tick .45s .1s var(--ease-out) both; }
@keyframes sg-tick { from { stroke-dashoffset: 24; } }
.sg-done .sg-title { margin-inline-end: 0; }

/* ---------- Wide screens: the panel takes the list's place on the left ---------- */
@media (min-width: 900px) {
  .sg {
    left: max(16px, env(safe-area-inset-left)); right: auto; top: calc(var(--mp-top) + 12px); bottom: auto; width: 380px;
    max-height: calc(100% - var(--mp-top) - 28px); border-radius: 20px; padding-bottom: 18px; box-shadow: 0 10px 40px rgb(0 0 0 / .16);
  }
  .sg.m-in { animation-name: sg-in-wide; }
  @keyframes sg-in-wide { from { opacity: 0; transform: translateX(-12px); } }
}

@media (prefers-reduced-motion: reduce) {
  .sg.m-in, .sg-step, .sg-check path, .sg-btn.is-busy svg { animation: none; }
  .sg-pin, .sg-shadow { transition: none; }
}
