/* ChampiGPS — interface pensée pour une main, en plein soleil, avec des gants.
 * Gros boutons (48 px minimum), forts contrastes, pas d'animation inutile.
 *
 * Thème d'automne : fond crème chaud, en-tête russet, accents ambre.
 * Les couleurs de comestibilité (vert, jaune, gris, orange, rouge sombre) ne
 * sont PAS définies ici : elles vivent dans js/species.js et ne doivent pas
 * bouger, c'est un code de sécurité. Le décor reste donc en retrait.
 */

:root {
  --bg: #f8efe0;
  --bg-deep: #f0e3cd;
  --card: #fffdf7;
  --ink: #2a1f14;
  --muted: #675544;
  --accent: #2f5a35;          /* actions : vert forêt, lisible en plein soleil */
  --accent-soft: #e4eedf;
  --amber: #b4661a;           /* décor d'automne : bandeaux, étiquettes, pied du + */
  --amber-soft: #fbe8cd;
  --amber-line: #e3c58f;
  --russet-dark: #5a3115;
  --russet: #7d4a1e;
  --line: #e4d4bb;
  --red: #b3261e;
  --touch: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top);
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
h3 { margin: 22px 0 6px; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; color: var(--russet); }
.muted { color: var(--muted); font-size: 14.5px; }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 10px 2px; }
.weak { color: #8a4b00; }
.err { color: var(--red); font-size: 14.5px; margin: 6px 0; }
code { font-size: 13px; background: var(--bg-deep); padding: 1px 4px; border-radius: 4px; }

/* ------------------------------------------------------------- en-tête */

header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; color: #fff;
  background: linear-gradient(135deg, var(--russet-dark), var(--russet));
}
header h1 { flex: 1; margin: 0; font-size: 19px; }
.sync { font-size: 12px; opacity: .92; max-width: 42%; text-align: right; }
.sync.busy { opacity: .6; }
.warn {
  margin: 0; padding: 7px 12px; font-size: 12.5px; line-height: 1.3;
  background: var(--amber-soft); color: #553300; border-bottom: 1px solid var(--amber-line);
}

/* --------------------------------------------------------------- vues */

main { position: relative; flex: 1; min-height: 0; }
main > section { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
#viewMap { overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--bg-deep); }

.listtop { position: sticky; top: 0; z-index: 2; padding: 10px 12px 6px; background: var(--bg); }
#gpsinfo { margin-top: 6px; }
.banner {
  margin: 0 12px 4px; padding: 10px 12px; border-radius: 12px;
  background: var(--amber-soft); border: 1px solid var(--amber-line); font-size: 15px;
}
.linkbtn {
  background: none; border: 0; padding: 2px 0; font: inherit; font-size: 14.5px;
  color: var(--accent); font-weight: 700; text-decoration: underline;
}
.linkbtn.del { color: var(--red); }

#cards { padding: 4px 12px 110px; }
.card {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 8px 0; font: inherit; color: inherit;
}
.card .main { flex: 1; min-width: 0; display: block; }
.card .title { display: block; font-size: 17.5px; font-weight: 700; margin-bottom: 5px; }
.card .muted { display: block; margin-top: 4px; }
.dist { font-size: 18px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.empty {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin: 10px 0;
}
.empty p { margin: 6px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px;
  background: var(--bg-deep); border-radius: 999px; padding: 3px 9px;
}
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tag { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 2px 7px; }
.tag.season { background: #dcebd9; color: #1d4a28; }
.tag.revisit { background: #fbe0bc; color: #6b3d00; }
.tag.spent { background: #e8e1d4; color: #4a4036; }
.tag.photo { background: #e6e9f2; color: #1a3c6b; }

/* -------------------------------------------------------------- boutons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touch); padding: 12px 14px;
  border: 1.5px solid var(--accent); border-radius: 12px;
  background: var(--card); color: var(--accent);
  font: inherit; font-weight: 700; text-align: center; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.wide { display: flex; width: 100%; margin-top: 10px; }
.btn.small {
  min-height: 36px; padding: 6px 12px; font-size: 14px;
  background: transparent; border-color: rgba(255, 255, 255, .7); color: #fff;
}
.btn:disabled { opacity: .55; }
.pickbar .btn.small { border-color: var(--accent); color: var(--accent); }
.badge { background: #fff; color: var(--russet-dark); border-radius: 10px; padding: 0 6px; }
.iconbtn {
  min-width: 40px; min-height: 40px; border: 0; background: none;
  font-size: 24px; line-height: 1; color: var(--muted);
}

nav {
  position: relative; display: flex; align-items: center; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; min-height: var(--touch); border: 0; background: none;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--muted);
}
.tab.active { color: var(--russet); }
.fab {
  width: 64px; height: 64px; margin-top: -28px; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--amber), #8e4a12);
  color: #fff; font-size: 34px; line-height: 1;
  box-shadow: 0 3px 12px rgba(63, 32, 8, .4);
}
.locate {
  position: absolute; right: 12px; bottom: 16px; z-index: 500;
  width: 54px; height: 54px; border: 0; border-radius: 50%;
  background: var(--card); color: var(--accent); font-size: 26px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.pickbar {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--amber-soft); border: 2px solid var(--russet); border-radius: 12px;
  padding: 10px 12px; font-weight: 700;
}

/* ------------------------------------------------------- champs de saisie */

input[type=search], input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: var(--touch); padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
.field { margin: 14px 0; }
.field .t { display: block; margin-bottom: 5px; font-size: 15px; font-weight: 700; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.row.gap { margin-top: 8px; }

/* ------------------------------------------------------ panneau du bas */

.sheet { position: fixed; inset: 0; z-index: 1000; }
.sheet-bg { position: absolute; inset: 0; background: rgba(42, 25, 10, .5); }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; max-height: 92%;
  background: var(--bg); border-radius: 20px 20px 0 0;
}
.sheet-head {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grab { width: 34px; height: 4px; border-radius: 3px; background: var(--amber-line); margin: 0 3px; }
.sheet-content {
  overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.sticky-actions {
  position: sticky; bottom: 0; display: flex; gap: 8px;
  padding: 10px 0 2px; background: linear-gradient(to bottom, rgba(248, 239, 224, .6), var(--bg) 40%);
}
.sticky-actions .btn { flex: 1; }
.big { font-size: 18px; margin: 10px 0 4px; }
.note { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.coords { font-variant-numeric: tabular-nums; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.actions.one { grid-template-columns: 1fr; }
.warnbox {
  background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 12px;
  padding: 12px; margin: 12px 0; font-size: 15px;
}
.warnbox.danger { background: #fde8e6; border-color: #f0b8b2; }
.warnbox p { margin: 6px 0; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.preview ul, .speclist, .harvests, .members { margin: 6px 0; padding-left: 18px; }
.speclist li, .harvests li { margin: 8px 0; }
.harvests, .members { list-style: none; padding-left: 0; }
.harvests li, .members li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0;
}
.members li { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.mbacts { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* -------------------------------------------------------- liste d'espèces */

.sp-q { margin-bottom: 6px; }
.sp-sel { margin: 2px 0 6px; }
.sp-list {
  max-height: 300px; overflow: auto; padding: 0 10px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 10px;
}
.sp-list h4 { margin: 12px 0 2px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.sp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--bg-deep);
}
.sp-item:last-child { border-bottom: 0; }
.sp-item input { width: 24px; height: 24px; min-height: 0; flex: none; }
.sp-item small { display: block; color: var(--muted); font-size: 12.5px; font-style: italic; }
.sp-item.off { opacity: .55; }
.sp-item small .dot { width: 9px; height: 9px; margin-right: 3px; vertical-align: -1px; }
.imp-tools { display: grid; gap: 8px; margin: 10px 0 6px; }
.imp-tools .row { margin: 0; }
.btn.small.ghost { background: var(--card); border-color: var(--line); color: var(--accent); }
.fchips { display: flex; flex-wrap: wrap; gap: 8px; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px;
  padding: 8px 13px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--card); font: inherit; font-size: 15px; color: var(--ink);
}
.fchip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }

/* --------------------------------------------------------------- photos */

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumb {
  position: relative; aspect-ratio: 1 / 1; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-deep);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bigphoto { width: 100%; border-radius: 12px; background: var(--bg-deep); }

/* ------------------------------------------------- messages et dialogues */

.modal { position: fixed; inset: 0; z-index: 1400; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-bg { position: absolute; inset: 0; background: rgba(42, 25, 10, .55); }
.modal-box {
  position: relative; width: 100%; max-width: 380px;
  background: var(--bg); border-radius: 16px; padding: 18px;
}
.modal-box p { margin: 0 0 6px; }
.toast {
  position: fixed; left: 12px; right: 12px; z-index: 1600;
  bottom: calc(86px + env(safe-area-inset-bottom));
  background: #2a1f14; color: #fff; border-radius: 12px;
  padding: 12px 14px; font-size: 15px; box-shadow: 0 3px 14px rgba(0, 0, 0, .35);
}
.toast.bad { background: #6d1710; }

/* -------------------------------------------------------------- boussole */

.compass { position: fixed; inset: 0; z-index: 1500; background: var(--bg); overflow: auto; }
.compass-box { padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.compass-box h2 { margin: 6px 0 14px; font-size: 21px; }
.rose {
  position: relative; width: 230px; height: 230px; margin: 10px auto 16px;
  border: 3px solid var(--russet); border-radius: 50%; background: var(--card);
}
.needle {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 92px; line-height: 1; color: var(--accent);
  transition: transform .18s linear;
}
.needle.nohead { color: #9b8a76; }
.north {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 700; color: var(--muted);
}

/* ------------------------------------------------------------ connexion */

.auth {
  position: fixed; inset: 0; z-index: 2000; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 50% 0%, var(--bg) 40%, var(--bg-deep));
}
.authbox { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; }
.authbox h1 { margin: 0; font-size: 26px; color: var(--russet-dark); }
.authbox p { margin: 0; }

/* ------------------------------------------------ feuilles qui tombent */

/* Décor pur : la couche ne reçoit aucun clic et se range sous les panneaux.
 * Elle s'arrête quand l'écran est caché, et ne démarre pas du tout si le
 * téléphone demande moins d'animations ou si le réglage est décoché. */
.leaves {
  position: fixed; inset: 0; z-index: 999;
  pointer-events: none; overflow: hidden;
  contain: layout paint;
}
.leaves.paused * { animation-play-state: paused !important; }
.leaf {
  position: absolute; top: -14vh; left: var(--x);
  width: var(--size); height: var(--size);
  opacity: var(--opacity);
  animation: cg-fall var(--fall) linear var(--delay) infinite;
  will-change: transform;
}
.leaf svg {
  display: block; width: 100%; height: 100%;
  animation: cg-sway var(--sway) ease-in-out var(--delay) infinite alternate,
             cg-spin var(--spin) linear var(--delay) infinite;
}
@keyframes cg-fall {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(var(--drift), 128vh, 0); }
}
@keyframes cg-sway {
  from { transform: translateX(-14px); }
  to   { transform: translateX(14px); }
}
@keyframes cg-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(var(--turn)); }
}
@media (prefers-reduced-motion: reduce) {
  .leaves { display: none; }
}

/* ------------------------------------------------------------- écrans larges */

@media (min-width: 760px) {
  body { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet-body { left: 50%; transform: translateX(-50%); width: 100%; max-width: 760px; }
  .gallery { grid-template-columns: repeat(4, 1fr); }
}

.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }
