/*
 * Styles for the public contribution form.
 *
 * Standalone rather than sharing papa/admin.css: this is a visitor-facing
 * page, not an admin screen, and the admin sheet carries a lot of weight it
 * would never use. The palette deliberately matches the rest of the public
 * site (dark, the same blue accent) so it does not feel like a different
 * product bolted on.
 */

:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: rgba(255, 255, 255, .10);
  --text: #e9eef5;
  --muted: rgba(233, 238, 245, .62);
  --accent: #2f8cff;
  --accent-soft: rgba(47, 140, 255, .16);
  --warn: #ffb000;
  --warn-soft: rgba(255, 176, 0, .14);
  --danger: #ff6b6b;
  --ok: #4ecb8d;
  --radius: .5rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}

/* --- site header --------------------------------------------------------- */

.site-bar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.site-bar-inner {
  max-width: 52rem;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Matches index.html's .side-menu-header so the two read as one site. */
.brand {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.brand .brand-dot {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  flex: 0 0 auto;
  transform: translateY(.28rem);
  margin-right: .12rem;
}

.lang-pick {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
}
.lang-pick select {
  width: auto;
  padding: .25rem 1.5rem .25rem .45rem;
  font-size: .85rem;
}

@media (max-width: 30rem) {
  .site-bar-inner { flex-wrap: wrap; gap: .5rem; }
  .lang-pick { font-size: .8rem; }
}

a { color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.lede { color: var(--muted); margin: 0 0 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* --- panels ------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.note {
  background: var(--accent-soft);
  border: 1px solid rgba(47, 140, 255, .3);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  font-size: .9rem;
  margin: .75rem 0;
}

.note-warn {
  background: var(--warn-soft);
  border-color: rgba(255, 176, 0, .35);
  color: #ffd979;
}

.error-text { color: var(--danger); font-size: .9rem; margin-top: .4rem; }

.scope-list { margin: 0 0 .85rem; padding-left: 1.2rem; }
.scope-list li { margin-bottom: .6rem; line-height: 1.45; }
.scope-list li:last-child { margin-bottom: 0; }

/* --- controls ----------------------------------------------------------- */

label { display: block; font-size: .9rem; margin-bottom: .25rem; }

input[type="text"], input[type="email"], input[type="url"],
input[type="date"], input[type="search"], textarea, select {
  width: 100%;
  padding: .5rem .6rem;
  border-radius: .35rem;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(47, 140, 255, .5);
  outline-offset: 1px;
}

textarea { resize: vertical; min-height: 6rem; }

.field { margin-bottom: .9rem; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 12rem; margin-bottom: .9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .9rem;
  border-radius: .35rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  /* Anchors styled as buttons would otherwise inherit the link underline. */
  text-decoration: none;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn.primary { background: var(--accent-soft); border-color: rgba(47, 140, 255, .45); }
.btn.primary:hover { background: rgba(47, 140, 255, .28); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }

/* Under the panel, not beside the brand: an escape hatch rather than a
   primary action, so it sits where the eye lands after reading the options. */
.back-map { margin-top: 1.25rem; }
/* The arrow lives in CSS rather than in the string, so nine translations do
   not each have to remember to carry it (or agree on which way it points). */
.back-map .btn::before { content: "\2190"; opacity: .7; }
.actions .spacer { flex: 1 1 auto; }

/* --- step 1: what are you sending -------------------------------------- */

.kind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .75rem;
}

.kind-card {
  text-align: left;
  padding: .9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.kind-card:hover { border-color: rgba(47, 140, 255, .5); background: rgba(47, 140, 255, .08); }
.kind-card strong { display: block; margin-bottom: .2rem; }
.kind-card span { color: var(--muted); font-size: .86rem; }

/* --- autocomplete ------------------------------------------------------- */

.ac { position: relative; }

.ac-list {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: 100%;
  margin-top: .15rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: .35rem;
  max-height: 15rem;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

.ac-item {
  padding: .45rem .6rem;
  cursor: pointer;
  font-size: .92rem;
}
.ac-item:hover, .ac-item.is-active { background: var(--accent-soft); }
.ac-item small { color: var(--muted); }
.ac-empty { padding: .45rem .6rem; color: var(--muted); font-size: .9rem; }

/* A chosen entity, shown instead of the input once picked. */
.chosen {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .6rem;
  border-radius: .35rem;
  background: var(--accent-soft);
  border: 1px solid rgba(47, 140, 255, .3);
}
.chosen .grow { flex: 1 1 auto; min-width: 0; }

/* --- photo -------------------------------------------------------------- */

.photo-drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.photo-drop:hover, .photo-drop.is-over { border-color: var(--accent); color: var(--text); }

.photo-preview-wrap { position: relative; display: inline-block; max-width: 100%; }
.photo-preview { display: block; max-width: 100%; border-radius: var(--radius); }

/* Face-tag boxes drawn over the preview, in 0..1 coordinates so they survive
   the image being re-encoded or displayed at any size. */
.tag-box {
  position: absolute;
  border: 2px solid var(--warn);
  border-radius: .2rem;
  pointer-events: none;
}
.tag-box-label {
  position: absolute;
  left: 0; top: 100%;
  transform: translateY(2px);
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: .7rem;
  padding: .05rem .3rem;
  border-radius: .2rem;
  white-space: nowrap;
}

/* A pin marks a point rather than an area, so it is drawn centred on its
   coordinates instead of anchored at a top-left corner. */
.tag-pin {
  position: absolute;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid rgba(0, 0, 0, .55);
  pointer-events: none;
}
.tag-pin .tag-box-label { left: 50%; transform: translate(-50%, 4px); }

.draw-pin {
  position: absolute;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--warn);
  border: 2px solid rgba(0, 0, 0, .6);
  /* Draggable, unlike the read-only .tag-pin on the preview. */
  cursor: grab;
  touch-action: none;
}
.draw-pin:active { cursor: grabbing; }

.tag-mode {
  width: auto;
  flex: 0 0 auto;
  padding: .25rem .4rem;
  font-size: .85rem;
}

.tag-hint { margin: .1rem 0 .5rem; }
.tag-list { display: flex; flex-direction: column; gap: .4rem; }
.tag-list:not(:empty) { margin-top: .5rem; }
.tag-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .55rem;
  border-radius: .35rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.tag-row .grow { flex: 1 1 auto; min-width: 0; }
.tag-row .tag-what { font-size: .92rem; }
.tag-row .tag-kind { color: var(--muted); font-size: .8rem; }

/* --- the box-drawing overlay ------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.overlay-inner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: min(52rem, 100%);
  max-height: 100%;
  overflow: auto;
}

.overlay-stage { position: relative; display: inline-block; touch-action: none; }
.overlay-stage img {
  display: block;
  max-width: 100%;
  max-height: 65vh;
  border-radius: .3rem;
  /* An <img> is natively draggable, which hijacked attempts to nudge a
     marker into a "copy the image" drag. */
  user-select: none;
  -webkit-user-drag: none;
}

.draw-box {
  position: absolute;
  border: 2px solid var(--warn);
  background: rgba(255, 176, 0, .12);
  cursor: move;
  touch-action: none;
}
.draw-handle {
  position: absolute;
  width: 14px; height: 14px;
  background: var(--warn);
  border-radius: 50%;
  touch-action: none;
}
.draw-handle.tl { left: -7px; top: -7px; cursor: nwse-resize; }
.draw-handle.tr { right: -7px; top: -7px; cursor: nesw-resize; }
.draw-handle.bl { left: -7px; bottom: -7px; cursor: nesw-resize; }
.draw-handle.br { right: -7px; bottom: -7px; cursor: nwse-resize; }

/* --- progress ----------------------------------------------------------- */

.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.step-pip {
  font-size: .8rem;
  color: var(--muted);
  padding: .2rem .55rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: transparent;
  font-family: inherit;
}
.step-pip.is-current { color: var(--text); border-color: rgba(47, 140, 255, .5); background: var(--accent-soft); }
/* Only completed steps go anywhere, so only they get the affordance. */
.step-pip.is-done {
  color: var(--ok);
  border-color: rgba(78, 203, 141, .35);
  cursor: pointer;
}
.step-pip.is-done:hover { background: rgba(78, 203, 141, .12); border-color: rgba(78, 203, 141, .6); }
.step-pip.is-done:focus-visible { outline: 2px solid rgba(47, 140, 255, .6); outline-offset: 2px; }

.code-input {
  font-size: 1.5rem;
  letter-spacing: .4rem;
  text-align: center;
  max-width: 10rem;
}

.busy { opacity: .6; pointer-events: none; }

.spinner {
  width: 1rem; height: 1rem;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

/* --- done --------------------------------------------------------------- */

.done-mark {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--ok);
  margin-bottom: .5rem;
}
