/* RingFollow — field-ready, ring-shaped, blaze-orange. */

@font-face {
  font-family: 'Archivo Black';
  src: url('/fonts/archivo-black.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --forest: #1e2d24;
  --moss: #4c5a45;
  --mist: #eef1e8;
  --bone: #fbfaf6;
  --blaze: #ff5f00;
  --blaze-dark: #d94e00;
  --line: #d8ddd0;
  --danger: #c22f2f;
  --ok: #2f8a3c;
  --radius: 18px;
  --display: 'Archivo Black', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Off-screen but still clickable via its label (display:none breaks iOS). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--forest);
  background:
    radial-gradient(1200px 500px at 50% -200px, #e2e8d9, transparent),
    var(--mist);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px calc(10px + env(safe-area-inset-bottom));
}

.topbar, .card, .tally, .offline-note { width: 100%; max-width: 480px; }

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-ring { width: 30px; height: 30px; flex: none; }
.brand h1 {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
}
.subtitle {
  margin: 0;
  font-size: 0.68rem;
  color: var(--moss);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-switch {
  display: flex;
  border: 2px solid var(--forest);
  border-radius: 999px;
  overflow: hidden;
}
.lang-switch button {
  border: 0;
  background: transparent;
  font: 700 0.75rem var(--body);
  color: var(--forest);
  padding: 6px 10px;
  cursor: pointer;
}
.lang-switch button[aria-pressed='true'] { background: var(--forest); color: var(--bone); }

.offline-note {
  background: var(--forest);
  color: var(--bone);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.85rem;
  margin: 0 0 10px;
}

/* ---------- Card ---------- */
.card {
  background: var(--bone);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(30, 45, 36, 0.08);
  padding: 12px 14px;
  view-transition-name: card;
}

/* ---------- Photo zone ---------- */
.photo-zone {
  display: flex;
  align-items: center;
  gap: 12px;
}
.photo-side { flex: 1; min-width: 0; text-align: left; }

.ring-button {
  position: relative;
  flex: none;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: conic-gradient(var(--blaze) 0deg, #ff8a3d 120deg, var(--blaze) 360deg);
  box-shadow: 0 8px 22px rgba(255, 95, 0, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.ring-button:active { transform: scale(0.94); }
.ring-button-hole {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--bone);
  box-shadow: inset 0 2px 8px rgba(30, 45, 36, 0.18);
}
.ring-button-label {
  position: relative;
  text-align: center; /* <label> lacks <button>'s centered default */
  font-family: var(--display);
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--forest);
  max-width: 64px;
  overflow-wrap: break-word;
}
@media (prefers-reduced-motion: no-preference) {
  .ring-button { animation: breathe 3.2s ease-in-out infinite; }
  @keyframes breathe {
    0%, 100% { box-shadow: 0 8px 22px rgba(255, 95, 0, 0.35); }
    50% { box-shadow: 0 8px 34px rgba(255, 95, 0, 0.55); }
  }
}

.hint { color: var(--moss); font-size: 0.72rem; margin: 0 0 6px; }

/* photo chips */
.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  padding: 0;
  margin: 0;
}
.chips li {
  --progress: 0deg;
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(var(--blaze) var(--progress), var(--line) var(--progress));
  transition: background 0.2s;
}
.chips li.done { background: var(--ok); }
.chips li.error { background: var(--danger); }
.chips li.queued { background: repeating-conic-gradient(var(--moss) 0 12deg, var(--line) 12deg 24deg); }
.chips li img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
@media (prefers-reduced-motion: no-preference) {
  .chips li { animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
  @keyframes pop { from { transform: scale(0.4); opacity: 0; } }
}

/* ---------- OCR stepper ---------- */
.ocr {
  margin-top: 10px;
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}
.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.62rem;
  text-align: center;
  color: var(--moss);
  opacity: 0.45;
  transition: opacity 0.25s;
  flex: 1;
  min-width: 0;
}
.steps li span:not(.dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.steps li.active, .steps li.done-step { opacity: 1; }
.steps li.done-step { color: var(--forest); }
.dot {
  width: 14px; height: 14px; flex: none;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: transparent;
  transition: border-color 0.25s, background 0.25s;
}
.steps li.active .dot { border-color: var(--blaze); }
@media (prefers-reduced-motion: no-preference) {
  .steps li.active .dot { animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 50% { transform: scale(1.35); } }
}
.steps li.done-step .dot { border-color: var(--ok); background: var(--ok); }
.steps li.failed .dot { border-color: var(--danger); background: var(--danger); }
.step-extra { font-variant-numeric: tabular-nums; font-size: 0.6rem; }
.ocr-note { margin: 6px 0 0; font-size: 0.75rem; color: var(--blaze-dark); font-weight: 600; }

.ghost {
  margin-top: 6px;
  background: transparent;
  border: 2px solid var(--forest);
  color: var(--forest);
  border-radius: 999px;
  padding: 5px 12px;
  font: 600 0.75rem var(--body);
  cursor: pointer;
}
.ghost:active { transform: scale(0.97); }

/* ---------- Form ---------- */
form { margin-top: 10px; display: grid; gap: 10px; }
.field { display: grid; gap: 3px; margin: 0; border: 0; padding: 0; }
.label {
  font-family: var(--display);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--moss);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
input[type='text'], input[type='date'], input[type='tel'], input[type='email'] {
  font: 1rem var(--body);
  color: var(--forest);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  width: 100%;
  min-height: 44px;
}
input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--blaze);
  outline-offset: 2px;
}
#ringText { font-size: 1.15rem; letter-spacing: 0.05em; font-weight: 700; text-transform: uppercase; }
#ringText::placeholder { font-size: 0.95rem; font-weight: 400; letter-spacing: normal; text-transform: none; }
#ringText.shimmer {
  background-image: linear-gradient(100deg, #fff 40%, #ffe3d1 50%, #fff 60%);
  background-size: 300% 100%;
  animation: shimmer 1.1s ease-out 2;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -60% 0; } }

/* color donuts */
.color-row { display: flex; flex-wrap: wrap; gap: 6px; }
.color-chip {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid var(--chip, #999);
  background: radial-gradient(circle at center, var(--bone) 42%, var(--chip, #999) 43%);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.color-chip[aria-checked='true'] {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px var(--bone), 0 0 0 6px var(--forest);
}
.color-chip.suggested { box-shadow: 0 0 0 3px var(--bone), 0 0 0 5px var(--blaze); }

/* species buttons */
.species-row { display: flex; flex-wrap: wrap; gap: 6px; }
.species-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--forest);
  border-radius: 999px;
  padding: 6px 10px;
  font: 600 0.78rem var(--body);
  cursor: pointer;
  min-height: 36px;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.species-btn:active { transform: scale(0.96); }
.species-btn[aria-checked='true'] {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--bone);
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.gps {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: 2px solid var(--forest);
  border-radius: 10px;
  background: #fff;
  color: var(--forest);
  font: 600 0.85rem var(--body);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.gps svg { flex: none; }
.gps span { overflow: hidden; text-overflow: ellipsis; }
.gps.ok { border-color: var(--ok); color: var(--ok); }
.gps-status { margin: 2px 0 0; font-size: 0.72rem; color: var(--moss); }

.more { border: 1.5px solid var(--line); border-radius: 10px; padding: 2px 12px 10px; }
.more summary {
  cursor: pointer;
  font: 600 0.82rem var(--body);
  color: var(--moss);
  padding: 8px 0 4px;
  list-style-position: outside;
}
.more[open] summary { color: var(--forest); }
.more .field { margin-top: 8px; }

/* submit */
.submit {
  border: 0;
  border-radius: 12px;
  min-height: 52px;
  background: var(--blaze);
  color: #fff;
  font-family: var(--display);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 95, 0, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
}
.submit:active { transform: translateY(2px); box-shadow: 0 2px 8px rgba(255, 95, 0, 0.35); }
.submit:disabled { background: var(--moss); box-shadow: none; }
.submit.shake { animation: shake 0.4s; }
@keyframes shake { 25% { translate: -6px 0; } 50% { translate: 6px 0; } 75% { translate: -4px 0; } }

/* ---------- Tableau de chasse ---------- */
.tally { margin-top: 10px; }
.tally h2 {
  font-family: var(--display);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.tally-count {
  background: var(--blaze);
  color: #fff;
  border-radius: 999px;
  min-width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 0.85rem var(--body);
  padding: 0 8px;
}
.tally ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tally li {
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.tally li .ring-dot {
  width: 18px; height: 18px; flex: none;
  border-radius: 50%;
  border: 4px solid var(--chip, var(--moss));
  background: var(--bone);
}
.tally li .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally li .status-ok { color: var(--ok); font-weight: 700; }
.tally li .status-wait { color: var(--moss); font-size: 0.8rem; }
.tally-empty { color: var(--moss); font-size: 0.85rem; border-style: dashed !important; }
@media (prefers-reduced-motion: no-preference) {
  .tally li.fresh { animation: land 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
  @keyframes land { from { transform: translateY(-18px) scale(0.9); opacity: 0; } }
}

/* ---------- Confetti & toast ---------- */
#confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  z-index: 50;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 80px);
  background: var(--forest);
  color: var(--bone);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.9rem;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 60;
  max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 640px) {
  .topbar { padding-top: 26px; }
  .card { padding: 30px 34px; }
}
