/* One stylesheet for every page.
   Look: warm cream paper, dark plum outlines, pill shapes with a hard drop
   shadow, one orange accent. */

/* Fonts are served from this site (public/fonts), so no visitor's browser
   calls another company to draw a page. Each file is a variable font that
   covers every weight used here; a browser fetches only the ones whose
   characters appear on the page. */
@font-face {
  font-family: Fredoka;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/fredoka-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Baloo Bhaijaan 2";
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/baloo-bhaijaan-2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Baloo Bhaijaan 2";
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/baloo-bhaijaan-2-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

:root {
  --ink: #2d1f33;
  --cream: #f1e6cf;
  --paper: #fffaf0;
  --tan: #e0cfa8;
  --orange: #f0975a;
  --pink: #f7c9d6;
  --green: #cde5cc;
  --muted: #6b5a6e;
  --line: 2.5px solid var(--ink);
  --drop: 0 4px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: Fredoka, "Baloo Bhaijaan 2", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--cream);
  display: flex;
  flex-direction: column;
}

a { color: var(--ink); text-underline-offset: 2px; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 10px 14px;
  background: var(--paper);
  border-bottom: var(--line);
  flex: none;
}
.site-title { font-weight: 600; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.site-header nav { display: flex; gap: 14px; font-weight: 500; }

/* Normal pages: a centred column. */
.page { width: 100%; max-width: 720px; margin: 0 auto; padding: 14px; }

h1 { font-size: 1.5rem; font-weight: 600; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 22px 0 8px; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 500; margin-bottom: 4px; }
input[type="text"], input[type="date"], input[type="password"], input[type="file"], select {
  font: inherit;
  color: var(--ink);
  width: 100%;
  padding: 9px 12px;
  border: var(--line);
  border-radius: 14px;
  background: var(--paper);
}
select { width: auto; }

button, .button {
  font: inherit;
  font-weight: 500;
  padding: 8px 18px;
  border: var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--drop);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:active, .button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: 0.5; cursor: default; }
button[type="submit"], .button.primary { background: var(--orange); font-weight: 600; }
button.liked { background: var(--pink); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* Status messages */
.msg { padding: 10px 14px; border: var(--line); border-radius: 14px; margin: 10px 0; background: var(--paper); }
.msg.error { background: #fbd9d3; }
.msg.ok { background: var(--green); }
[hidden] { display: none !important; }

/* Cat list */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--paper);
  border: var(--line);
  border-radius: 20px;
  box-shadow: var(--drop);
}
.cat-row .cat-info { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; font-size: 1.1rem; }

/* Admin queue */
.queue-item {
  background: var(--paper);
  border: var(--line);
  border-radius: 20px;
  padding: 12px;
  margin-bottom: 14px;
}
.queue-item .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Maps ---------- */

.map-full { flex: 1; min-height: 0; }
.map-small { height: 300px; border: var(--line); border-radius: 18px; overflow: hidden; }
.leaflet-container { background: #ecdfc4; font-family: inherit; }
/* Fallback raster tiles, pulled towards the cream palette. */
.tinted-tiles { filter: sepia(0.55) saturate(0.7) brightness(1.04); }

/* Main map page: title and actions float over the map. */
.map-page { position: relative; }
.map-overlay {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
.map-overlay > * { pointer-events: auto; }
.map-title {
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  padding: 8px 16px;
  background: var(--paper);
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--drop);
}
.map-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.map-actions .button.primary { font-size: 1.05rem; padding: 10px 22px; }
.map-page > .msg { position: absolute; z-index: 1001; top: 70px; left: 12px; right: 12px; }
.map-note { background: var(--paper); border: var(--line); border-radius: 14px; padding: 6px 12px; }

/* Round zoom / locate buttons. */
.leaflet-bar, .leaflet-touch .leaflet-bar { border: none !important; background: none; box-shadow: none; display: flex; flex-direction: column; gap: 10px; }
.leaflet-container .leaflet-bar a, .leaflet-container .leaflet-bar button {
  width: 42px !important;
  height: 42px !important;
  line-height: 36px !important;
  font-size: 22px;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: var(--line) !important;
  border-radius: 50% !important;
  box-shadow: var(--drop);
}
.leaflet-bar a:hover, .leaflet-bar button:hover { background: #fff; color: var(--ink); }
.leaflet-bar a.leaflet-disabled { background: var(--tan); color: var(--muted); }
.leaflet-bottom.leaflet-right .leaflet-control { margin: 0 14px 14px 0; }
.leaflet-bottom.leaflet-right .leaflet-control-attribution { margin: 0; }
.leaflet-control-attribution { background: rgba(255, 250, 240, 0.8) !important; font-size: 10px; }

/* Cat pins: round photo, pastel ring, like-count badge. */
.cat-pin-icon { background: none; border: none; }
.cat-pin { position: relative; width: 66px; height: 74px; }
.cat-pin-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  font-size: 30px;
  background: var(--ring, var(--pink));
  border: var(--line);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--ink);
  overflow: hidden;
  padding: 1.5px; /* the thin pastel ring between outline and photo */
}
.cat-pin-photo { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.cat-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 0;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--ink);
  border-bottom-width: 0;
}
.cat-pin-badge {
  position: absolute;
  right: -10px;
  bottom: 8px;
  min-width: 26px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  color: var(--ink);
  background: var(--pink);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.cat-pin-icon:hover .cat-pin-face, .cat-pin-icon:focus-visible .cat-pin-face { transform: translateY(-2px); }

/* Popup card. */
.leaflet-popup-content-wrapper {
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--ink);
}
.leaflet-popup-content { margin: 0; font-size: 15px; line-height: 1.35; }
.leaflet-popup-tip { background: var(--ink); box-shadow: none; }
.leaflet-container a.leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  font: 600 18px/23px inherit;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.cat-card-photo {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #fbe3a4;
  border-bottom: 3px solid var(--ink);
}
.cat-card-body { padding: 12px 16px 14px; }
.cat-card .card-cats { list-style: none; margin: 0 0 4px; padding: 0; padding-inline-end: 24px; }
.cat-card .card-cats .cat-name { font-size: 1.15rem; line-height: 1.25; }
.cat-card .card-cats li:first-child .cat-name { font-size: 1.35rem; }
.leaflet-container .card-cats a { color: var(--ink); }
.cat-card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.cat-card-row a { font-weight: 500; font-size: 0.9rem; }
.leaflet-container .cat-card-row a { color: var(--ink); }
.like-pill { padding: 6px 16px; font-weight: 600; white-space: nowrap; }

/* ---------- Language ---------- */

/* Arabic: its own rounded face first, and a little more line height. */
:root[lang="ar"] body { font-family: "Baloo Bhaijaan 2", Fredoka, ui-rounded, system-ui, sans-serif; line-height: 1.6; }
/* Hide the English source text until the Arabic has been swapped in. */
.i18n-pending body { visibility: hidden; }

button.lang-switch { padding: 3px 12px; font-size: 0.9rem; box-shadow: 0 3px 0 var(--ink); }
.site-header nav { align-items: center; flex-wrap: wrap; }
.map-actions .lang-switch { padding: 6px 16px; font-size: 1rem; box-shadow: var(--drop); }

/* The maps stay left-to-right (dir="ltr" on the container); card content
   inside popups follows the page direction. */
[dir="rtl"] .leaflet-container a.leaflet-popup-close-button { right: auto; left: 8px; }
.leaflet-popup-content [dir="rtl"] { text-align: right; }

/* ---------- Browsing pages (map, sighting, cat, list) ---------- */

/* A cat's face cut out of a photo (pictures.ts). */
.cat-face {
  display: inline-block;
  flex: none;
  width: 64px;
  height: 64px;
  border: var(--line);
  border-radius: 50%;
  background-color: var(--tan);
  background-repeat: no-repeat;
}
.cat-face.large { width: 88px; height: 88px; }
.cat-face.portrait { width: 132px; height: 132px; box-shadow: var(--drop); }

/* A cat as a linked row (cat-row.ts): the list, friends, cats in a photo. */
a.cat-row { color: var(--ink); text-decoration: none; }
a.cat-row:hover .cat-name { text-decoration: underline; }
.cat-info { display: flex; flex-direction: column; }
.cat-info .cat-name { overflow-wrap: anywhere; }
.cat-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cat-cards .cat-row { height: 100%; margin: 0; }

/* A sighting as a row (sighting-row.ts): the cat page and the map's list. */
.sighting-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sighting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding-block: 8px;
  padding-inline: 8px 14px;
  background: var(--paper);
  border: var(--line);
  border-radius: 18px;
}
.sighting-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--ink); text-decoration: none; text-align: start; }
.sighting-link:hover .sighting-date { text-decoration: underline; }
button.sighting-link { padding: 0; font-weight: 400; background: none; border: none; border-radius: 12px; box-shadow: none; }
button.sighting-link:active { transform: none; box-shadow: none; }
.sighting-thumb { flex: none; width: 56px; height: 56px; object-fit: cover; background: var(--tan); border: var(--line); border-radius: 12px; }
.sighting-link[aria-current="true"] .sighting-thumb { border-color: var(--orange); }
.sighting-info { display: flex; flex-direction: column; min-width: 0; }
.sighting-date { font-weight: 500; }
.sighting-map { flex: none; font-size: 0.9rem; font-weight: 500; }

/* Like button (like-button.ts) and the row it sits in. */
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 10px 0; }
.like-msg { display: block; margin-top: 6px; }

/* Sighting page. */
.sighting-photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  background: var(--tan);
  border: var(--line);
  border-radius: 20px;
  box-shadow: var(--drop);
}
.sighting-photo + h1 { margin-top: 18px; overflow-wrap: anywhere; }

/* Cat page. */
.profile { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 20px; margin-top: 8px; }
.profile-info { flex: 1; min-width: 200px; }
.profile h1 { margin: 0 0 2px; overflow-wrap: anywhere; }
.profile p { margin: 0; }
.add-again { margin-top: 24px; }

/* Map: the locate control is a real button, styled like Leaflet's zoom links. */
.leaflet-bar button.locate-button { display: block; padding: 0; font-weight: 400; }

/* Map: "+n" on a pin whose photo has friends in it. */
.cat-pin-friends {
  position: absolute;
  left: -8px;
  top: -2px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  color: var(--ink);
  background: var(--green);
  border: 2px solid var(--ink);
  border-radius: 999px;
}

/* Map card: "Seen n times" looks like a link but is a button. */
.link-button {
  padding: 0 2px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: none;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button:active { transform: none; box-shadow: none; }

/* Map: the list of one cat's sightings, a dialog (a bottom sheet on phones). */
.sheet {
  width: min(420px, calc(100vw - 24px));
  max-height: min(80vh, 640px);
  padding: 0;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 6px 0 var(--ink);
}
.sheet::backdrop { background: rgba(45, 31, 51, 0.45); }
.sheet-body { padding: 14px 16px 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; overflow-wrap: anywhere; }
.close-button { flex: none; width: 38px; height: 38px; padding: 0; font-size: 20px; line-height: 1; box-shadow: 0 3px 0 var(--ink); }
@media (max-width: 520px) {
  .sheet { margin-bottom: 12px; }
}
/* ---------- end of browsing pages ---------- */

/* ---------- Adding a sighting (submit.html) ---------- */

.step-count { margin: 18px 0 0; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.step h2 { margin-top: 2px; }
.step h2:focus { outline: none; }
.step h2:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.step-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Step 1 */
.photo-preview { display: block; max-width: 200px; max-height: 200px; margin-top: 8px; border: var(--line); border-radius: 14px; }
.pin-tools { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.field-label { font-weight: 500; margin: 0 0 4px; }
.pin-coords { margin: 6px 0; }

/* Step 2: the photo next to the pipeline stages. */
.upload-view { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.upload-photo { width: 160px; max-width: 100%; aspect-ratio: 1; object-fit: cover; border: var(--line); border-radius: 18px; background: var(--tan); }
.stage-list { list-style: none; margin: 0; padding: 0; flex: 1 1 220px; display: flex; flex-direction: column; gap: 8px; }
.stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  background: var(--paper);
  border: var(--line);
  border-radius: 14px;
}
.stage::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}
.stage-label { flex: 1; font-weight: 500; }
.stage-state { font-size: 0.85rem; color: var(--muted); }
.stage[data-state="working"]::before { border-color: var(--ink) var(--orange) var(--orange); animation: stage-spin 0.9s linear infinite; }
.stage[data-state="done"] { background: var(--green); }
.stage[data-state="done"]::before { content: "✓"; }
.stage[data-state="failed"] { background: #fbd9d3; }
.stage[data-state="failed"]::before { content: "×"; }
.stage[data-state="waiting"] .stage-label { color: var(--muted); }
@keyframes stage-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .stage[data-state="working"]::before { animation: none; background: var(--orange); }
}

/* Step 3: one card per cat in the photo. */
.cat-choices { display: flex; flex-direction: column; gap: 14px; }
.cat-choice {
  margin: 0;
  padding: 12px 14px 14px;
  min-width: 0;
  background: var(--paper);
  border: var(--line);
  border-radius: 20px;
  box-shadow: var(--drop);
}
.cat-choice legend { padding: 0 6px; font-weight: 600; background: var(--paper); border-radius: 999px; }
.cat-choice[data-role="skipped"] { opacity: 0.7; }
.cat-choice.has-error { border-color: #c0392b; }
.cat-choice-body { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.face-crop {
  flex: none;
  width: 96px;
  height: 96px;
  border: var(--line);
  border-radius: 50%;
  box-shadow: var(--drop);
  background-color: var(--tan);
  background-repeat: no-repeat;
}
.face-crop.small { width: 72px; height: 72px; }
.choice-options { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 2px solid var(--tan);
  border-radius: 14px;
  cursor: pointer;
}
.choice-option:has(input:checked) { border-color: var(--ink); background: #fbe3a4; }
.choice-option:has(input:disabled) { cursor: default; opacity: 0.6; }
.choice-option input[type="radio"] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--orange); }
.choice-text { display: flex; flex-direction: column; min-width: 0; }
.choice-title { font-weight: 500; overflow-wrap: anywhere; }
.match-portrait {
  flex: none;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background-color: var(--tan);
  background-repeat: no-repeat;
}
.new-name { margin: 0 0 4px; padding-inline-start: 40px; }
.field-error { margin: 8px 0 0; font-weight: 500; color: #a1281b; }

/* Step 4 */
.done-cats { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.done-cats li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.done-cats .cat-name { overflow-wrap: anywhere; }
.badge.known { background: var(--pink); }

/* ---------- Moderation (admin.html, English only) ---------- */

.admin-page { max-width: 960px; }
.admin-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.admin-bar-actions, .tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button[aria-pressed="true"] { background: var(--orange); font-weight: 600; }
.admin-sighting h3 { margin: 0 0 10px; }
.admin-sighting h4 { margin: 14px 0 6px; }
.admin-facts { margin-top: 8px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.admin-cats { display: flex; flex-direction: column; gap: 12px; }
.admin-cat { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; padding-top: 10px; border-top: 2px dashed var(--tan); }
.admin-cat-info { flex: 1 1 240px; min-width: 0; }
.admin-matches { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.admin-match { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.correction { margin: 10px 0 0; padding: 8px 10px; border: 2px solid var(--tan); border-radius: 14px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.correction legend { font-weight: 500; padding: 0 4px; }
.correction .choice-option { flex-wrap: wrap; }
input.inline-input { width: 6em; padding: 4px 8px; border-radius: 10px; }
input.inline-input.wide { width: 14em; max-width: 100%; }
.cat-tools { margin-top: 28px; }
.tool-fields { display: flex; flex-wrap: wrap; gap: 0 12px; }
.tool-fields .field { flex: 1 1 200px; }

/* Detected cats and people outlined on the photo. Boxes are in the photo's
   own coordinates, so the frame is always left-to-right. */
.detect-frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; direction: ltr; }
.detect-frame img { display: block; max-width: 100%; max-height: 420px; border-radius: 10px; }
.detect-box { position: absolute; border: 3px solid var(--orange); border-radius: 6px; pointer-events: none; }
.detect-box.friend { border-color: #d76a8a; border-style: dashed; }
.detect-box.person { border-color: #c0392b; }
.detect-box.head { border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); }
.detect-box span {
  position: absolute;
  left: -3px;
  top: -3px;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink);
  background: var(--orange);
  border-radius: 6px 0 6px 0;
}
.detect-box.friend span { background: var(--pink); }
.detect-box.person span { background: #c0392b; color: #fff; }
.analysis { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { padding: 2px 10px; font-size: 0.85rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--green); }
.badge.warn { background: #fbd9d3; }
/* ---------- end of adding a sighting and moderation ---------- */
