/* Jage portal. Colours are the iPhone's HunterPalette (ios/Jage/Jage/HunterTheme.swift in Caelu/jage), light and
   dark; the only new one is the bark marker (ochre), used for marks, not text. Type is the system
   UI font, as on the iPhone. Targets are at least 44 px; focus is always visible. */

:root {
  --ink: #202a24;              /* HunterPalette.ink */
  --secondary: #5b685e;        /* secondary(light) 5.6:1 on --page */
  --forest: #24543c;           /* HunterPalette.forest */
  --on-forest: #ffffff;
  --primary: #24543c;
  --on-primary: #ffffff;
  --page: #fbfcf9;             /* drawerSurface(light) */
  --surface: #ffffff;          /* controlSurface(light) */
  --selected: #e9f0e8;         /* selectedSurface(light) */
  --on-selected: #1c4b31;      /* onPrimaryContainer(light) */
  --line: #dce2dc;             /* line(light) */
  --danger: #7b3935;           /* leaveAction(light) */
  --bark: #b8690f;             /* bark markers: 3:1 against map tiles */
  --shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 2px 8px rgb(0 0 0 / 0.06);
  --radius: 12px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef4ef;            /* darkInk */
    --secondary: #b5c0b8;      /* secondary(dark) */
    --primary: #81c997;        /* activeStatus(dark) */
    --on-primary: #123522;     /* onPrimary(dark) */
    --page: #1d2721;           /* drawerSurface(dark) */
    --surface: #232d26;        /* controlSurface(dark) */
    --selected: #304739;       /* selectedSurface(dark) */
    --on-selected: #d4f0dc;    /* onPrimaryContainer(dark) */
    --line: #47564a;           /* line(dark) */
    --danger: #f0aaa0;         /* leaveAction(dark) */
    --bark: #e0a458;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--page);
  display: flex;
  flex-direction: column;
}
h1 { font-size: 1.375rem; line-height: 1.3; margin: 0; }
h2 { font-size: 1.0625rem; line-height: 1.35; margin: 0 0 var(--space-2); }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* --- Top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  min-height: 56px;
  background: var(--forest); color: var(--on-forest);
}
.brand { display: flex; align-items: center; gap: var(--space-2); }
.wordmark { font-size: 1.375rem; font-weight: 800; letter-spacing: -0.01em; }
.account { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.live { font-size: 0.875rem; display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.live[data-state="live"]::before { background: #8fe0a6; opacity: 1; }

/* --- Buttons and fields --- */
.button {
  font: inherit; font-weight: 600;
  min-height: 44px; padding: 0 var(--space-4);
  border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  transition: background-color 150ms ease, border-color 150ms ease;
}
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.primary:hover { filter: brightness(1.08); }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.button.secondary:hover { background: var(--selected); }
.button.secondary[aria-pressed="true"] { background: var(--selected); color: var(--on-selected); border-color: var(--primary); border-width: 2px; font-weight: 700; }
.button.quiet { background: transparent; color: var(--ink); }
.button.quiet:hover { background: var(--selected); }
.button.quiet.on-brand { color: var(--on-forest); border-color: rgb(255 255 255 / 0.5); }
.button.quiet.on-brand:hover { background: rgb(255 255 255 / 0.12); }
.button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.button.danger:hover { background: var(--selected); }
.button:disabled { cursor: progress; opacity: 0.7; }
.button.small { min-height: 44px; padding: 0 var(--space-3); font-weight: 500; }

label { display: block; font-weight: 600; margin: var(--space-3) 0 var(--space-1); }
input {
  font: inherit; width: 100%; min-height: 44px; padding: 0 var(--space-3);
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--secondary); border-radius: 10px;
}
input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.field-error { color: var(--danger); font-size: 0.9375rem; min-height: 1.5em; margin-top: var(--space-1); }
.hint, .lead { color: var(--secondary); }
.lead { margin-bottom: var(--space-2); }
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-5); }

/* --- Start page and shop --- */
body.site { display: block; }
body.site main { max-width: 1040px; margin: 0 auto; padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: calc(var(--space-6) * 2); }
.topbar .brand { color: inherit; text-decoration: none; }
a.button { text-decoration: none; }
.hero { padding: var(--space-6) 0; }
.hero h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); line-height: 1.15; max-width: 18ch; margin-bottom: var(--space-4); }
.hero .lead { font-size: 1.1875rem; max-width: 52ch; margin-bottom: var(--space-5); }
.hero .row { margin-bottom: var(--space-3); }
.features h2, .buy h2 { font-size: 1.5rem; margin-bottom: var(--space-4); }
.feature-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.feature-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
.feature-list h3 { font-size: 1.0625rem; margin: 0 0 var(--space-2); }
.feature-list p { color: var(--secondary); }
.buy { max-width: 560px; }
.price { font-size: 1.75rem; font-weight: 800; margin-bottom: var(--space-3); }
.price .hint { font-size: 1rem; font-weight: 400; }
.buy-list { margin: 0 0 var(--space-4); padding-left: 1.2em; }
.buy-list li { margin-bottom: var(--space-1); }
select {
  font: inherit; min-height: 44px; padding: 0 var(--space-3); color: var(--ink); background: var(--surface);
  border: 1px solid var(--secondary); border-radius: 10px;
}
.visually-hidden-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.footer { max-width: 1040px; margin: 0 auto; padding: var(--space-5); color: var(--secondary); border-top: 1px solid var(--line); }
.footer a { color: inherit; }
.notice { background: var(--selected); color: var(--on-selected); border: 1px solid var(--primary); border-radius: 10px; padding: var(--space-3) var(--space-4); }

/* --- Loading (until we know whether the visitor is signed in) --- */
.loading { flex: 1; display: grid; place-content: center; justify-items: center; gap: var(--space-3); color: var(--secondary); }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Login --- */
.login { flex: 1; display: grid; place-items: center; padding: var(--space-6) var(--space-4); }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin-bottom: var(--space-3); }
.login-card .button.primary { width: 100%; margin-top: var(--space-2); }
.login-card .button.quiet { width: 100%; margin-top: var(--space-2); }

/* --- App layout: list and details beside the map; stacked on narrow screens --- */
.app { flex: 1; display: grid; grid-template-columns: minmax(320px, 400px) 1fr; min-height: 0; }
.side { overflow-y: auto; padding: var(--space-5); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-4); }
/* In a scrolling column nothing may shrink, or the tabs and cards collapse to nothing. */
.side > *, .panel > *, .detail > * { flex-shrink: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.map-wrap { position: relative; min-height: 0; }
.map { position: absolute; inset: 0; }
.map-note {
  position: absolute; left: 50%; top: var(--space-4); transform: translateX(-50%); z-index: 500;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: var(--space-2) var(--space-4); box-shadow: var(--shadow); font-size: 0.9375rem;
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 45vh auto; }
  .map-wrap { grid-row: 1; min-height: 45vh; }
  .side { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .email { display: none; }
}

.claim h2 { margin-bottom: var(--space-1); }
.claim .row { margin-top: var(--space-2); }
.empty { color: var(--secondary); }

/* --- Pejl list --- */
.collars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.collar {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4); min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: background-color 150ms ease, border-color 150ms ease;
}
.collar:hover { background: var(--selected); }
.collar[aria-current="true"] { background: var(--selected); border-color: var(--primary); border-width: 2px; color: var(--on-selected); }
.collar-name { font-weight: 600; overflow-wrap: anywhere; }
.collar-meta { grid-column: 1 / -1; color: var(--secondary); font-size: 0.9375rem; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.collar[aria-current="true"] .collar-meta { color: inherit; }
.badge {
  font-size: 0.8125rem; font-weight: 600; padding: 2px var(--space-2); border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap; align-self: start;
}

/* --- Details of the chosen pejl --- */
.detail { display: flex; flex-direction: column; gap: var(--space-4); border-top: 1px solid var(--line); padding-top: var(--space-4); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.detail-head h2 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
.serial { color: var(--secondary); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); margin: 0; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: var(--space-2) var(--space-3); }
.fact dt { color: var(--secondary); font-size: 0.8125rem; }
.fact dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.block h3 { font-size: 1rem; margin: 0 0 var(--space-2); }
.status-line { font-size: 0.9375rem; margin-top: var(--space-2); }
.status-line[data-sync="pending"] { color: var(--secondary); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button {
  font: inherit; min-height: 44px; border: 0; background: var(--surface); color: var(--ink); cursor: pointer;
  border-right: 1px solid var(--line); padding: var(--space-1) var(--space-2); font-weight: 500;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.segmented button:disabled { cursor: default; }
.segmented button:hover:not([aria-pressed="true"]):not(:disabled) { background: var(--selected); }

.range { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.barks { list-style: none; margin: var(--space-2) 0 0; padding: 0; font-size: 0.9375rem; }
.barks li { display: flex; justify-content: space-between; padding: var(--space-1) 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.shares { list-style: none; margin: 0 0 var(--space-2); padding: 0; }
.shares li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) 0; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: var(--space-2); }
.inline-form input { flex: 1; }
.rename { display: flex; gap: var(--space-2); }
.rename input { flex: 1; }

/* --- Tabs and hunts --- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs button { font: inherit; font-weight: 600; min-height: 44px; border: 0; background: var(--surface); color: var(--ink); cursor: pointer; }
.tabs button + button { border-left: 1px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--primary); color: var(--on-primary); }
.panel { display: flex; flex-direction: column; gap: var(--space-4); }
.code { font-size: 1.75rem; font-weight: 800; letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.people li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.people .who { display: flex; flex-direction: column; min-width: 0; }
.people .who strong { overflow-wrap: anywhere; }
.people .who span { color: var(--secondary); font-size: 0.9375rem; }
.checks { display: flex; flex-direction: column; gap: var(--space-1); margin: var(--space-2) 0; }
.checks label { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; margin: 0; min-height: 44px; }
.checks input { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 44px; }
.switch input { width: 44px; height: 26px; min-height: 0; accent-color: var(--primary); }
.person-marker { display: grid; justify-items: center; }
.person-dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: #202a24; color: #ffffff; border: 2px solid #ffffff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
  font-size: 0.75rem; font-weight: 800;
}

/* --- Map markers --- */
/* Leaflet puts the marker's top-left corner on the position; shift so the dot's centre sits there. */
.dog-marker, .person-marker { position: absolute; left: 0; top: 0; transform: translate(-50%, -12px); }
.dog-marker.selected { transform: translate(-50%, -15px); }
.person-marker { transform: translate(-50%, -13px); }
.dog-marker { display: grid; place-items: center; }
.dog-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--forest); border: 3px solid #ffffff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
}
.dog-marker.selected .dog-dot { width: 24px; height: 24px; }
.dog-label {
  margin-top: 2px; padding: 0 6px; border-radius: 6px; font-size: 0.8125rem; font-weight: 700; white-space: nowrap;
  background: #ffffff; color: #202a24; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.2);
}
.leaflet-container { font: inherit; background: var(--page); }

.dialog { max-width: min(420px, calc(100% - 32px)); color: var(--ink); }
.dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog p { margin-bottom: var(--space-4); color: var(--secondary); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
