/* The report box: the form assets/report.js draws, the dialog it lives in on
 * the front page, the round button that opens it, and /report/ as a page.
 * Tokens (--ink, --paper, --edge, the type stacks) come from styles.css, which
 * every page that loads this one loads first.
 *
 * Everything here is prefixed report- because the same file lands on the front
 * page, where styles.css already owns .btn and friends and a shared name would
 * be a fight over which page wins.
 */

/* --- the button in the corner ---------------------------------------------
 * Fixed, bottom right, on top of the page. Ink on paper with a ring of paper
 * around it, so it separates from the black bands it scrolls over in either
 * theme. Above the top bar (50); below the emulator's full-screen stage
 * (200), and hidden outright while that stage is up, because the one thing a
 * person playing full screen must not tap by accident is a form.
 */
.report-fab {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 60;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  box-shadow:
    0 0 0 3px var(--paper),
    0 4px 14px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  transition: transform 0.08s ease;
}
.report-fab svg {
  width: 1.6rem;
  height: 1.6rem;
  display: block;
}
.report-fab:hover {
  transform: translateY(-2px);
}
.report-fab:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}
html.immersive .report-fab {
  display: none;
}

/* --- the dialog -----------------------------------------------------------
 * A centred card of about 480px on a desk; the whole bottom of the screen on
 * a phone. The dialog itself has no padding and never scrolls: the sheet
 * inside it does both, so a click that lands on the dialog element is a click
 * on the backdrop and nothing else, which is what closes it.
 */
.report-dialog {
  padding: 0;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  width: min(30rem, calc(100vw - 2rem));
  max-width: none;
  max-height: none;
  overflow: visible;
}
.report-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.report-sheet {
  max-height: calc(100vh - 2rem - 6px);
  max-height: calc(100dvh - 2rem - 6px);
  overflow: auto;
  padding: 1.4rem 1.5rem 1.5rem;
}
html.report-open {
  overflow: hidden;
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.1rem;
}
.report-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.01em;
  margin: 0 0 0.3rem;
}
.report-lead {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--muted);
  margin: 0;
}
.report-close {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

/* --- the form -------------------------------------------------------------- */
.report-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}
/* The two choices share a row. Halves put "An idea" under "Something broke";
 * the left column takes what its chips need and the device chips, which are
 * shorter, get the rest. */
.report-choices {
  grid-template-columns: max-content minmax(0, 1fr);
}
.report-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0 0 1.1rem;
  min-width: 0;
}
.report-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.report-label small {
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
}
.report-hint {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--muted);
  margin: 0;
}
.report-form textarea,
.report-form input[type="text"],
.report-form input[type="email"] {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper-2);
  border: 2px solid var(--edge);
  border-radius: 0;
  padding: 0.65rem 0.75rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.report-form textarea {
  min-height: 7.5rem;
  line-height: 1.45;
  resize: vertical;
}
.report-form textarea:focus,
.report-form input:focus {
  outline: 3px solid var(--ink);
  outline-offset: 1px;
  border-color: var(--ink);
}

/* Choices are chips: the input stays in the document, invisible and on top
 * of its own label, so it is still focusable and clickable; the span is what
 * you see. */
.report-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.report-chips label {
  position: relative;
}
.report-chips input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.report-chips span {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  border: 2px solid var(--edge);
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
}
.report-chips input:checked + span {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.report-chips input:focus-visible + span {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.report-photo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.report-photo input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.report-photo input:focus-visible + .report-btn {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
.report-thumb {
  max-height: 4.5rem;
  max-width: 7rem;
  border: 2px solid var(--edge);
}

/* Same clothes as styles.css's .btn, a size down, so the box reads as part of
 * the site and not as a form that wandered in. */
.report-btn {
  font-family: var(--display);
  font-size: 1.15rem;
  letter-spacing: 0.03em;
  line-height: 1.1;
  padding: 0.45em 1em 0.33em;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  display: inline-block;
  cursor: pointer;
  text-decoration: none;
}
.report-btn.primary {
  background: var(--ink);
  color: var(--paper);
  font-size: 1.35rem;
  padding: 0.5em 1.4em 0.38em;
}
.report-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.report-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}
.report-status {
  flex: 1 1 12rem;
  min-height: 1.4em;
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}
.report-status.err {
  color: var(--ink);
  font-weight: 600;
}

.report-done {
  border: 3px solid var(--ink);
  padding: 1.2rem 1.3rem;
}
.report-done h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1;
  margin: 0 0 0.3rem;
}
.report-num {
  font-family: var(--mono);
  font-size: 1.3rem;
}
.report-done p {
  margin: 0.4rem 0;
}

/* The honeypot: off screen, never display:none, so a bot that reads the DOM
 * still sees a field to fill. */
.report-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* .report-btn is display:inline-block, which would otherwise beat the hidden
 * attribute on the Remove button. Scoped to the mount so it cannot reach the
 * rest of the page. */
[data-report-mount] [hidden] {
  display: none !important;
}

/* --- /report/ as a page of its own ------------------------------------------ */
.report-page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 5rem;
}
.report-page .report-title {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  margin-bottom: 0.5rem;
}
.report-page .report-lead {
  font-size: 1.25rem;
  margin-bottom: 1.75rem;
}
/* Small print, under the form rather than above it: what happens to a report
   is worth saying and is not worth a paragraph before the box it describes. */
.report-fine {
  margin-top: 1.75rem;
  max-width: 46ch;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}
.report-back {
  display: inline-block;
  margin-top: 2rem;
  color: var(--muted);
}

/* --- phones: a sheet up from the bottom, one column ------------------------ */
@media (max-width: 600px) {
  .report-dialog {
    width: 100vw;
    margin: 0;
    inset: auto 0 0 0;
    border-width: 3px 0 0 0;
  }
  .report-sheet {
    max-height: calc(100vh - 3rem);
    max-height: calc(100dvh - 3rem);
    padding: 1.2rem var(--gutter) calc(1.25rem + env(safe-area-inset-bottom));
  }
  .report-title {
    font-size: 1.8rem;
  }
  .report-row,
  .report-choices {
    grid-template-columns: 1fr;
  }
  .report-form textarea {
    min-height: 6.5rem;
  }
  .report-foot .report-btn.primary {
    flex: 1 1 100%;
    text-align: center;
  }
  .report-status:empty {
    display: none;
  }
}
