/* Dark mode is the night sky (default); light mode is snow (data-theme="light"). */
:root {
  color-scheme: dark;
  --sky-top: #070b1a;
  --sky-bottom: #141a3a;
  --ink: #eef1ff;
  --ink-dim: #a9b0d6;
  --ink-faint: #6d74a0;
  --gold: #ffd98a;
  --ice: #9fd4ff;
  --line: rgba(190, 200, 255, 0.28);
  --line-partner: rgba(255, 217, 138, 0.7);
  --kin-parent: #8cc8ff;
  --kin-partner: #f4a3c8; /* pink: partners (Ondřej 30. 9.) */
  --kin-sibling: #ffd98a; /* gold: siblings */
  --card: rgba(18, 23, 52, 0.92);
  --card-edge: rgba(159, 212, 255, 0.18);
  --danger: #ff9a8a;
  --label-halo: rgba(7, 11, 26, 0.85);
  --core: #fffaf0;
  --core-center: #ffffff;
  --core-deceased: #c9c3b5;
  --name-center: #ffffff;
  --glow-1: #fff8e6;
  --glow-2: #ffe7a8;
  --glow-me: #9fd4ff;
  --field: rgba(7, 11, 26, 0.6);
  --row: rgba(7, 11, 26, 0.5);
  --chip-bg: rgba(20, 26, 58, 0.7);
  --accent: #ffd98a;
  --accent-ink: #1a1405;
  --kin-parent-op: 0.55;
  --kin-partner-op: 0.5;
  --kin-sibling-op: 0.42;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-name: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --sky-top: #f4f8fc;
  --sky-bottom: #dde8f2;
  --ink: #17233a;
  --ink-dim: #4c5d78;
  --ink-faint: #7a8aa3;
  --gold: #a86f00;
  --ice: #2d6fb8;
  --kin-parent: #2f6fb8;
  --kin-partner: #c2487e;
  --kin-sibling: #b98200;
  --card: rgba(255, 255, 255, 0.9);
  --card-edge: rgba(45, 111, 184, 0.22);
  --danger: #b3261e;
  --label-halo: rgba(244, 248, 252, 0.9);
  --core: #6f8fb5;
  --core-center: #1f4f8a;
  --core-deceased: #9aa3ad;
  --name-center: #0e1a2e;
  --glow-1: #ffffff;
  --glow-2: #bcd6ef;
  --glow-me: #7fb2e6;
  --field: rgba(255, 255, 255, 0.85);
  --row: rgba(45, 111, 184, 0.06);
  --chip-bg: rgba(255, 255, 255, 0.8);
  --accent: #2d6fb8;
  --accent-ink: #ffffff;
  --kin-parent-op: 0.5;
  --kin-partner-op: 0.55;
  --kin-sibling-op: 0.6;
}

* { box-sizing: border-box; }
/* .login, .sheet, .legend set display, which would otherwise override the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  color: var(--ink);
  font: 15px/1.45 var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#sky, #map { position: fixed; inset: 0; width: 100%; height: 100%; }
#map { touch-action: manipulation; }

/* Stars */
.star { cursor: pointer; }
.star .halo { fill: url(#glow); }
.star.center .halo { fill: url(#glow-me); }
.star .core { fill: var(--core); }
.star.center .core { fill: var(--core-center); }
.glow-1 { stop-color: var(--glow-1); }
.glow-2 { stop-color: var(--glow-2); }
.glow-me { stop-color: var(--glow-me); }
.star .name {
  font: 600 15px/1 var(--font-name);
  fill: var(--ink);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--label-halo);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.star.center .name { font-size: 19px; fill: var(--name-center); }
.star .year {
  font: 500 11px/1 var(--font);
  fill: var(--ink-dim);
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  paint-order: stroke;
  stroke: var(--label-halo);
  stroke-width: 3px;
}
.star.far .name { font-size: 12.5px; fill: var(--ink-dim); font-weight: 500; }
.star.far .year { fill: var(--ink-faint); }
.star.deceased .core { fill: var(--core-deceased); }
.star.deceased .name { font-style: italic; }
.star:focus { outline: none; }
.star:focus-visible .name { fill: var(--gold); }

.edge { fill: none; }
.edge.parent { fill: var(--kin-parent); fill-opacity: var(--kin-parent-op); stroke: none; }
.edge.partner { stroke: var(--kin-partner); stroke-opacity: var(--kin-partner-op); stroke-width: 3.2; } /* half the wide end of a parent line */
.edge.sibling { stroke: var(--kin-sibling); stroke-opacity: var(--kin-sibling-op); stroke-width: 3.2; }

.legend {
  position: fixed; left: 16px; top: calc(env(safe-area-inset-top, 0px) + 44px);
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--ink-dim); pointer-events: none;
}
.legend span { display: flex; align-items: center; gap: 8px; }
.sw { display: inline-block; width: 26px; height: 6px; }
.sw.parent { background: var(--kin-parent); opacity: 0.65; clip-path: polygon(0 0, 100% 42%, 100% 58%, 0 100%); }
.sw.partner { height: 3px; background: var(--kin-partner); opacity: 0.6; }
.sw.sibling { height: 3px; background: var(--kin-sibling); opacity: 0.52; }

/* Chrome */
#bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  pointer-events: none;
}
#bar > * { pointer-events: auto; }
.brand { font: 600 13px/1 var(--font); letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); }
.bar-actions { display: flex; gap: 8px; }

button { font: inherit; color: inherit; cursor: pointer; }
.chip {
  background: var(--chip-bg); border: 1px solid var(--card-edge);
  border-radius: 999px; padding: 7px 14px; color: var(--ink);
}
.chip:hover { border-color: var(--ice); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; }

.hint {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  margin: 0 auto; max-width: 30em; text-align: center; color: var(--ink-dim); font-size: 13px;
  pointer-events: none;
}

.card, .sheet {
  background: var(--card); border: 1px solid var(--card-edge);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.login {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 380px); padding: 28px 24px; border-radius: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.login h1 { margin: 0; font: 600 30px/1.1 var(--font-name); }
.lead { margin: 0 0 10px; color: var(--ink-dim); }

form { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--ink-dim); }
input {
  font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--card-edge); border-radius: 10px; padding: 11px 12px; width: 100%;
}
input[type="checkbox"] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.msg { min-height: 1.3em; margin: 2px 0; color: var(--gold); font-size: 14px; }
.msg.error { color: var(--danger); }
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 12px 16px; font-weight: 600;
}
.primary:disabled { opacity: 0.6; }
.ghost { background: none; border: 1px solid var(--card-edge); border-radius: 10px; padding: 10px 14px; color: var(--ink); }
.danger-link { background: none; border: 0; color: var(--danger); padding: 8px 0; text-align: left; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  margin: 0 auto; width: min(100%, 520px);
  max-height: 78vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; border-bottom: 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex; flex-direction: column; gap: 12px;
  animation: rise 0.25s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet h2 { margin: 0; font: 600 24px/1.15 var(--font-name); text-wrap: balance; }
.sheet .sub { margin: 2px 0 0; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--ink-dim); padding: 0 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.section-label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin: 4px 0 -4px; }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.results button {
  width: 100%; text-align: left; background: var(--row); border: 1px solid transparent;
  border-radius: 10px; padding: 10px 12px; color: var(--ink);
}
.results button:hover { border-color: var(--card-edge); }
.results button.active { border-color: var(--ice); background: rgba(159, 212, 255, 0.12); }
.results .y { color: var(--ink-dim); font-variant-numeric: tabular-nums; margin-left: 6px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}
.twin-q { margin: 0; flex-basis: 100%; }

.seg { display: flex; gap: 4px; background: var(--field); border: 1px solid var(--card-edge); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 9px 4px; color: var(--ink-dim); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lead-small { margin: 0; color: var(--ink-dim); font-size: 13px; }
.results button:disabled { opacity: 0.55; cursor: default; }

/* Public landing page: only the name. */
.landing {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding-inline: 16px; text-align: center;
}
.landing h1 { margin: 0; font: 600 clamp(40px, 9vw, 84px)/1 var(--font-name); letter-spacing: 0.01em; color: var(--ink); text-wrap: balance; }

/* Someone whose details the viewer does not get. */
.star.hidden-person .name { font-style: italic; font-weight: 400; fill: var(--ink-faint); }
.star.hidden-person .core { fill: var(--ink-faint); }

.protect { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.protect .mustang { font-size: 20px; min-width: 1.2em; text-align: center; font-variant-numeric: tabular-nums; }
.protect .lead-small { flex-basis: 100%; }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
details > summary.section-label { cursor: pointer; margin: 4px 0; }
details[open] > summary.section-label { margin-bottom: 8px; }

/* Administrator's overview. */
.admin { display: flex; flex-direction: column; gap: 10px; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.log li { background: var(--row); border-radius: 10px; padding: 8px 12px; line-height: 1.4; overflow-wrap: anywhere; }
.log .meta { display: block; font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.log .y { color: var(--ink-dim); font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tile { background: var(--row); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.tile strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--ink-dim); }
.people { width: 100%; border-collapse: collapse; font-size: 13px; }
.people th { text-align: left; font-weight: 500; color: var(--ink-faint); padding: 4px 6px; border-bottom: 1px solid var(--card-edge); }
.people td { padding: 6px; border-bottom: 1px solid var(--row); vertical-align: top; }
.people .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.people .y { color: var(--ink-faint); }
