/* Support modal. Native <dialog>, so Esc and the focus trap come from the platform. */

/* Dead centre, both axes, on every screen.
   The browser's own dialog styles get this right via `inset: 0; margin: auto`, but any
   rule that sets a single margin edge — as the old mobile sheet did — silently defeats
   it, so the centring is stated explicitly rather than inherited. */
.hg-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: 10px;
  padding: 0;
  max-width: 30rem;
  width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  color: #1a1a1a;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.hg-modal::backdrop {
  background: rgba(20, 20, 20, 0.55);
}

.hg-modal-inner {
  padding: 1.5rem 1.5rem 1.2rem;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  position: relative;
  margin: 0;
}

.hg-modal h2 {
  font-size: 1.25rem;
  margin: 0 0 0.7rem;
  padding-right: 1.5rem; /* clear of the close button */
  line-height: 1.25;
}

.hg-modal p { margin: 0 0 0.7rem; }

.hg-x {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  border: 1px solid transparent;
  background: none;
  font-size: 1.7rem;
  line-height: 1;
  color: #777;
  cursor: pointer;
  padding: 0 0.45rem 0.15rem;
  border-radius: 6px;
}
.hg-x:hover { color: #111; background: #f2f2f2; border-color: #e2e2e2; }

.hg-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.9rem;
}

.hg-primary,
.hg-secondary {
  font: inherit;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  flex: 1 1 auto;
}

.hg-primary { background: #b3341f; color: #fff; }
.hg-primary:hover { background: #992c1a; }
.hg-secondary { background: #fff; color: #333; border-color: #d5d5d5; }
.hg-secondary:hover { background: #f6f6f6; }

/* Visible keyboard focus: the modal is reachable by Tab and must show where you are. */
.hg-modal :focus-visible {
  outline: 2px solid #b3341f;
  outline-offset: 2px;
}

.hg-links,
.hg-fine {
  font-size: 0.85rem;
  color: #666;
  margin: 0.4rem 0 0;
}
.hg-fine { font-size: 0.78rem; margin-top: 0.7rem; }
.hg-links a,
.hg-fine a { color: #b3341f; }

.hg-input {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin: 0.2rem 0 0.5rem;
  text-transform: none;
}
#hg-code { text-transform: uppercase; letter-spacing: 0.06em; }

.hg-msg { min-height: 1.2rem; font-size: 0.88rem; color: #555; }

.hg-note {
  background: #f7f4ef;
  border: 1px solid #e6dfd4;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  font-size: 0.86rem;
  margin: 0 0 0.9rem;
  text-align: center;
}

.hg-code-shown {
  font: 600 1.15rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  background: #f3f3f3;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  text-align: center;
  margin: 0.6rem 0 0.9rem;
  user-select: all; /* one click selects the whole code */
}

.hg-field { margin: 0 0 0.8rem; }
.hg-field label { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; }
.hg-field textarea {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  min-height: 4.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  resize: vertical;
}
.hg-count { font-size: 0.78rem; color: #999; text-align: right; }

/* Phones: still centred, just narrower gutters and stacked buttons.
   Deliberately NOT a bottom sheet — `margin: auto 0 0` would override the centring above. */
@media (max-width: 30rem) {
  .hg-modal {
    width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
  }
  .hg-modal-inner { padding: 1.2rem 1.1rem 1rem; }
  .hg-actions { flex-direction: column; }
  .hg-primary, .hg-secondary { width: 100%; }
}

/* A short message panel, such as the thanks after feedback. */
.hg-centred { text-align: center; }
.hg-send { width: 100%; margin-top: .2rem; }

/* Permanent feedback panel, bottom-left beneath the destination panel.
   Collapsed to a single button until opened so it never competes with the map. */
.hg-fb-panel {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  width: min(24.5rem, calc(100vw - 2.5rem));
  z-index: 40;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.hg-fb-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 0.95rem;
  border: 0;
  background: #fff;
  cursor: pointer;
  text-align: left;
  color: #1a1a1a;
}
.hg-fb-toggle:hover { background: #fafafa; }
.hg-fb-chev { color: #999; transition: transform 0.15s ease; }
.hg-fb-panel.is-open .hg-fb-chev { transform: rotate(180deg); }

.hg-fb-body {
  padding: 0 0.95rem 0.95rem;
  border-top: 1px solid #eee;
  max-height: 60vh;
  overflow-y: auto;
}
.hg-fb-body .hg-field { margin-top: 0.8rem; }
.hg-fb-body textarea { min-height: 3.4rem; }
.hg-fb-thanks { margin: 0.9rem 0 0.2rem; font-size: 0.92rem; }

/* On a phone the destination panel already fills the screen; the feedback panel sits
   flush to the bottom edge rather than floating above it. */
@media (max-width: 38rem) {
  .hg-fb-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-radius: 10px 10px 0 0;
  }
}
