/**
 * Familja Luta — page styles.
 *
 * The design handoff carried everything as inline styles (design-tool output).
 * Those are lifted into classes here, with the same values. Every colour, font,
 * space and radius still comes from a token in tokens.css — no raw hexes.
 */

/* The `hidden` attribute is only `display: none` in the UA sheet, so any author
   `display` — and this file sets `display: flex` on several things it also
   toggles — silently beats it. Restate it so `hidden` always means hidden. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body { background: var(--color-bg); color: var(--color-text); font-family: var(--font-body); min-height: 100vh; }
a:hover { color: var(--color-accent-700); }
summary::marker { color: var(--color-accent); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Skip link — the tree is a big interactive canvas, keyboard users need a way past it. */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--color-bg); color: var(--color-accent-700);
  padding: var(--space-2) var(--space-3); border: 1px solid var(--color-accent);
  border-radius: var(--radius-md); font-size: 14px;
}
.skip-link:focus { left: var(--space-2); top: var(--space-2); }

/* ── shared ─────────────────────────────────────────────────────────────── */
.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.wrap-wide { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.wrap-canvas { max-width: 1560px; margin: 0 auto; padding: 22px 24px 36px; }

/* A heading flanked by hairlines — the section mark used throughout. */
.rule-heading { display: flex; align-items: center; gap: 16px; }
.rule-heading::before,
.rule-heading::after { content: ''; height: 1px; flex: 1; background: var(--color-divider); }
.rule-heading h2 { margin: 0; font-weight: 400; font-size: 38px; text-align: center; }

.kicker {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--color-neutral-600);
}
.kicker-accent { color: var(--color-accent-700); letter-spacing: 0.24em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── nav ────────────────────────────────────────────────────────────────── */
/* Deliberately not sticky: the tree toolbar is the sticky element on this page,
   and two things pinned to top:0 would sit on top of each other. */
.nav { background: var(--color-bg); flex-wrap: wrap; row-gap: var(--space-1); }
.nav-brand { min-width: 0; }
.nav-note {
  font-size: 12px; color: var(--color-neutral-600);
  font-family: var(--font-body); font-weight: 400; margin-left: 8px;
  white-space: nowrap;
}

/* ── header ─────────────────────────────────────────────────────────────── */
.hero { max-width: 880px; margin: 0 auto; padding: 76px 24px 44px; text-align: center; }
.hero h1 { font-size: clamp(46px, 7vw, 74px); font-weight: 400; margin: 0 0 16px; line-height: 1.02; }
.hero-lede {
  font-size: 17px; line-height: 1.7; color: var(--color-neutral-700);
  max-width: 580px; margin: 0 auto;
}
/* A masthead strip, not a grid of cells: one hairline above, one below, and
   short vertical rules between the figures — no enclosure. */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 44px;
  border-top: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider);
}
.stat { position: relative; padding: 22px 10px; }
.stat + .stat::before {
  content: ''; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 1px; background: var(--color-divider);
}
.stat-n {
  font-family: var(--font-heading); font-size: 36px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-l {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--color-neutral-600); margin-top: 7px;
}

/* ── historiati ─────────────────────────────────────────────────────────── */
.chapter { display: flex; align-items: baseline; gap: 16px; margin: 52px 0 16px; }
.chapter-num {
  font-family: var(--font-heading); font-size: 52px; line-height: 1;
  color: var(--color-accent-300);
}
.chapter h3 { margin: 0; font-size: 25px; }

.prose { text-align: justify; font-size: 16px; line-height: 1.8; hyphens: auto; margin: 0 0 16px; }

.pullquote {
  border-top: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider);
  padding: 18px 8px; margin: 24px 0; text-align: center;
}
.pullquote p {
  font-family: var(--font-heading); font-size: 21px; line-height: 1.5;
  font-weight: 400; font-style: italic; margin: 0 auto; max-width: 540px;
}

.table-scroll { overflow-x: auto; margin: 20px 0; }
.table-scroll .table { font-variant-numeric: tabular-nums; min-width: 560px; }
.table tfoot td { font-weight: 600; }

.registry { border-block: 1px solid var(--color-divider); margin: 20px 0; }
.registry > summary {
  cursor: pointer; padding: 14px 2px;
  font-family: var(--font-heading); font-weight: 600; font-size: 17px;
}
.registry > summary:hover { color: var(--color-accent-700); }
.registry-body {
  padding: 2px 2px 16px; font-size: 13.5px; line-height: 1.75;
  color: var(--color-neutral-800);
}
.registry-body p { margin: 0 0 10px; }

.source-note {
  font-size: 13px; color: var(--color-neutral-600); font-style: italic;
  text-align: center; margin: 24px 0 0;
}

/* ── tree toolbar ───────────────────────────────────────────────────────── */
.toolbar {
  position: sticky; top: 0; z-index: 30; margin-top: 24px;
  background: color-mix(in srgb, var(--color-bg) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-divider); border-bottom: 1px solid var(--color-divider);
}
.toolbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 10px 24px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.search { position: relative; flex: 1; min-width: 230px; max-width: 430px; }
/* An underline field, not a boxed one — the toolbar already draws its own rules. */
.search .input {
  height: 44px; background: transparent;
  border: 0; border-bottom: 1px solid var(--color-divider); border-radius: 0;
  padding-left: 26px;
}
.search .input:hover { border-bottom-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.search .input:focus-visible {
  outline: none;
  border-bottom-color: var(--color-accent);
  box-shadow: 0 1px 0 0 var(--color-accent);
}
.search-icon {
  position: absolute; left: 2px; top: 50%; translate: 0 -50%;
  color: var(--color-neutral-500); pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 45;
  background: var(--color-surface); border: 1px solid var(--color-divider);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); overflow: hidden;
}
.search-empty { padding: 12px 14px; font-size: 13px; color: var(--color-neutral-600); }
.search-hit {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  width: 100%; padding: 11px 14px; background: none; border: 0;
  border-bottom: 1px solid var(--color-divider); cursor: pointer;
  font-family: var(--font-body); text-align: left;
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover,
.search-hit[aria-selected='true'] { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.search-hit-name { font-size: 14px; color: var(--color-text); }
.search-hit-meta {
  font-size: 11px; color: var(--color-neutral-600); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The generation index reads as numerals in a contents page, not buttons. */
.gen-chips { display: flex; gap: 2px; overflow-x: auto; margin-left: auto; }
.gen-chip {
  height: 44px; min-width: 36px; padding: 0 9px;
  border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  font-family: var(--font-heading); font-weight: 600; font-size: 16px;
  color: var(--color-neutral-600); white-space: nowrap;
}
.gen-chip:hover { color: var(--color-accent-700); border-bottom-color: var(--color-accent); }

/* ── tree canvas ────────────────────────────────────────────────────────────
   Full-bleed, delimited by hairlines like a plate in a book — not a widget in
   a grey box. The fades at either edge hint that the scene continues. */
.wrap-canvas { max-width: none; padding: 22px 0 36px; }
.viewport {
  position: relative; overflow: hidden;
  height: clamp(480px, 72vh, 860px);
  height: clamp(480px, 72svh, 860px);
  border-block: 1px solid var(--color-divider);
  touch-action: none; cursor: grab; user-select: none;
}
.viewport.is-panning { cursor: grabbing; }
.viewport::before,
.viewport::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 44px;
  z-index: 2; pointer-events: none;
}
.viewport::before { left: 0; background: linear-gradient(to right, var(--color-bg), transparent); }
.viewport::after { right: 0; background: linear-gradient(to left, var(--color-bg), transparent); }

/* Zoom controls live on the canvas, like a map's. */
.zoom-controls {
  position: absolute; right: 12px; bottom: 12px; z-index: 4;
  display: flex; flex-direction: column; gap: 6px;
}
.zoom-controls .btn-icon {
  width: 42px; height: 42px;
  background: color-mix(in srgb, var(--color-bg) 90%, transparent);
  backdrop-filter: blur(6px);
}
.scene { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.scene svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.link-path { fill: none; stroke: var(--color-neutral-400); stroke-width: 1.2px; }

.gen-line { position: absolute; left: 0; height: 0; border-top: 1px dashed var(--color-neutral-300); }
.gen-mark {
  position: absolute; left: 16px;
  font-family: var(--font-heading); font-size: 44px; line-height: 1;
  color: var(--color-accent-300);
}

.node {
  position: absolute; width: 148px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: transparent; border: 0; padding: 6px 2px;
  border-radius: var(--radius-md); cursor: pointer; font-family: var(--font-body);
}
.node:hover { background: color-mix(in srgb, var(--color-accent) 9%, transparent); }
/* The couple: person, marriage tie, spouse — one visual unit, one click target. */
.node-faces { display: flex; align-items: center; justify-content: center; pointer-events: none; }
.node-photo, .node-initials {
  width: 62px; height: 62px; border-radius: 50%; pointer-events: none; flex: none;
}
.node-photo {
  object-fit: cover; border: 2px solid var(--color-accent-400);
  box-shadow: 0 0 0 1px var(--color-divider);
  filter: sepia(0.22) saturate(0.82) contrast(1.05);
}
.node-initials {
  display: grid; place-items: center;
  border: 1.5px solid var(--color-neutral-400); background: var(--color-bg);
  font-family: var(--font-heading); font-size: 20px; color: var(--color-accent-700);
}
.spouse-tie { width: 9px; height: 1px; background: var(--color-neutral-400); flex: none; }
.node-spouses { display: flex; align-items: center; }
.node-photo-sm, .node-initials-sm { width: 40px; height: 40px; }
.node-photo-sm { border-width: 1.5px; }
.node-initials-sm { font-size: 13px; color: var(--color-neutral-700); }
/* A second spouse tucks behind the first rather than widening the node. */
.node-spouses > * + * { margin-left: -12px; }
.node-text { min-width: 0; max-width: 144px; pointer-events: none; }
.node-name { display: block; font-size: 12.5px; line-height: 1.25; color: var(--color-text); }
.node-years {
  display: block; font-size: 10.5px; color: var(--color-neutral-600);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

@keyframes lutaFlash { 0%, 65% { background: var(--color-accent-200); } 100% { background: transparent; } }
.node.is-flash { animation: lutaFlash 2.4s ease-out; }

.canvas-hint {
  position: absolute; left: 16px; bottom: 14px; pointer-events: none; z-index: 3;
  font-size: 11px; color: var(--color-neutral-600);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  padding: 4px 9px; border-radius: var(--radius-sm);
}

/* Shown briefly when a plain wheel rolls over the canvas — the page scrolled,
   and this says how to zoom instead. Same pattern as embedded maps. */
.wheel-hint {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: grid; place-items: center; text-align: center; padding: 0 24px;
  background: color-mix(in srgb, var(--color-neutral-900) 32%, transparent);
  color: var(--color-neutral-100); font-size: 15px; line-height: 1.5;
  opacity: 0; transition: opacity 0.25s ease;
}
.wheel-hint.is-on { opacity: 1; }

/* ── person dialog ──────────────────────────────────────────────────────── */
@keyframes dlgFade { from { opacity: 0; } }
@keyframes dlgRise { from { opacity: 0; transform: translateY(10px); } }
@keyframes dlgSheet { from { transform: translateY(40px); opacity: 0.4; } }

.dialog-backdrop { z-index: 60; animation: dlgFade 0.18s ease-out; }
.person-dialog {
  width: min(580px, 100%); max-height: 88vh; overflow: auto; gap: 14px;
  animation: dlgRise 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

/* On a phone the dialog is a bottom sheet — reachable with a thumb, and the
   safe-area padding keeps the close button above the home indicator.
   It stops well short of the top: a record can run to several screens, and a
   sheet that fills the whole display reads as a page you navigated to rather
   than something covering the tree you can dismiss. */
@media (max-width: 640px) {
  .dialog-backdrop { padding: 0; place-items: end stretch; }
  .person-dialog {
    width: 100%; max-width: none;
    max-height: 80vh; max-height: 80dvh;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    gap: 12px;
    padding: var(--space-3) var(--space-3)
             calc(var(--space-3) + env(safe-area-inset-bottom));
    animation: dlgSheet 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  /* The drag handle is drawn inside the sticky header instead of as a separate
     row, so it cannot scroll away and leave a gap for text to show through.
     The rest of the sheet's mobile treatment lives in the media block at the
     end of this file — it has to come after the .person-head/.person-photo
     rules below, or those win on source order at equal specificity. */
}
.person-head { display: flex; gap: 16px; align-items: center; }
.dialog-close {
  margin-left: auto; align-self: flex-start; flex: none;
  background: none; border: 0; cursor: pointer; padding: 0 2px;
  font-family: var(--font-body); font-size: 26px; line-height: 1;
  color: var(--color-neutral-600);
}
.dialog-close:hover { color: var(--color-accent-700); }
.person-photo, .person-initials {
  width: 84px; height: 84px; flex: none; border-radius: 50%;
  border: 2px solid var(--color-accent-400);
}
.person-photo { object-fit: cover; filter: sepia(0.22) saturate(0.82) contrast(1.05); }
.person-initials {
  display: grid; place-items: center; background: var(--color-accent-100);
  font-family: var(--font-heading); font-size: 28px; color: var(--color-accent-700);
}
.person-head .dialog-title { font-size: 25px; line-height: 1.1; }
.person-years {
  font-size: 13.5px; color: var(--color-neutral-600);
  font-variant-numeric: tabular-nums; margin-top: 3px;
}
.person-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 13px 20px; border-top: 1px solid var(--color-divider); padding-top: 14px;
}
.fact-l {
  font-size: 10px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--color-neutral-600);
}
.fact-v { font-size: 14px; line-height: 1.55; margin-top: 3px; }
.fact-v.tnum { font-variant-numeric: tabular-nums; }
.fact-unset { color: var(--color-neutral-600); }

.lineage {
  font-size: 12.5px; line-height: 1.9; margin-top: 3px; color: var(--color-neutral-700);
}
.lineage button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--color-accent-700); text-decoration: underline;
  text-underline-offset: 2px;
}
.lineage button:hover { color: var(--color-accent-800); }
.lineage [aria-current='true'] { color: var(--color-text); font-weight: 600; }

.partners { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.partner { display: flex; align-items: center; gap: 10px; }
.partner img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none;
  border: 1.5px solid var(--color-accent-400);
  filter: sepia(0.22) saturate(0.82) contrast(1.05);
}
.partner-name { font-size: 14px; }
.partner-year { font-size: 12px; color: var(--color-neutral-600); font-variant-numeric: tabular-nums; }
.union-note { font-size: 12px; color: var(--color-neutral-600); margin-top: 6px; font-style: italic; }

.children { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.children .btn { padding: 6px 11px; font-size: 13px; }
.socials { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.socials .btn { padding: 3px 10px; font-size: 12px; text-decoration: none; }

.bio-block { border-top: 1px solid var(--color-divider); padding-top: 12px; }
.bio-block .fact-l { color: var(--color-accent-700); }
.bio-text { font-size: 14.5px; line-height: 1.75; text-align: justify; margin: 7px 0 0; }
.record-note { font-size: 11.5px; color: var(--color-neutral-600); font-style: italic; margin: 0; }

/* ── suggestions ────────────────────────────────────────────────────────── */
.suggest { border-top: 1px solid var(--color-divider); padding-top: 12px; }
.suggest-head { display: flex; align-items: center; gap: 8px; }
.suggest-head .btn { margin-left: auto; font-size: 12.5px; padding: 3px 8px; }
.suggest-list { display: flex; flex-direction: column; margin-top: 4px; }
.suggest-item { border-top: 1px solid var(--color-divider); padding: 10px 2px; }
.suggest-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.suggest-who {
  font-size: 12.5px; color: var(--color-accent-700);
  font-family: var(--font-heading); font-weight: 600;
}
.suggest-when { font-size: 11px; color: var(--color-neutral-600); font-variant-numeric: tabular-nums; }
.suggest-text { font-size: 13.5px; line-height: 1.6; margin-top: 4px; }
.suggest-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.suggest-form .input[type='text'] { max-width: 240px; }
.suggest-form textarea { min-height: 76px; }
.suggest-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.suggest-hint { font-size: 11px; color: var(--color-neutral-600); line-height: 1.5; max-width: 300px; }
.suggest-status { font-size: 12.5px; line-height: 1.5; }
.suggest-status.is-ok { color: var(--color-accent-700); }
.suggest-status.is-error { color: var(--color-neutral-800); }
/* Honeypot — a real person never sees or fills this. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── property map, embedded as the section's closing figure ─────────────── */
.map-plate { margin: 52px 0 0; }
.map-plate > figcaption {
  text-align: center; font-size: 11.5px; letter-spacing: 0.14em;
  margin-bottom: 14px; padding: 0 24px;
}
.map-frame { border-block: 1px solid var(--color-divider); }
.map-frame iframe {
  display: block; width: 100%; border: 0;
  height: clamp(400px, 62vh, 640px);
  height: clamp(400px, 62svh, 640px);
}

/* ── footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--color-divider);
  padding: 30px 24px 44px; text-align: center;
}
.site-footer strong { font-family: var(--font-heading); font-size: 20px; font-weight: 600; display: block; }
.site-footer p {
  font-size: 12.5px; color: var(--color-neutral-600);
  max-width: 540px; margin: 8px auto 0; line-height: 1.7;
}

/* ── narrow screens ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* "Pejë · nga viti 1700" is a subtitle, not information worth truncating the
     name for — drop it rather than let the header overflow. */
  .nav-note { display: none; }
  .nav { gap: var(--space-3); padding: var(--space-3); }
  .hero { padding: 48px 20px 32px; }

  /* Stats become 2×2: the strip's own hairlines carry on, the vertical rule
     only between columns, one horizontal rule between the rows. */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 18px 8px; }
  .stat:nth-child(3)::before { content: none; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--color-divider); }
  .stat-n { font-size: 30px; }

  .chapter { gap: 12px; flex-wrap: wrap; }
  .chapter-num { font-size: 40px; }
  .prose { text-align: left; hyphens: none; }

  .toolbar-inner { padding: 6px 16px; gap: 4px; }
  .search { max-width: none; flex-basis: 100%; }
  .gen-chips { margin-left: 0; width: 100%; }
  .gen-chip { flex: 1; }

  .wrap-canvas { padding-top: 14px; }
  .viewport {
    height: clamp(420px, 68vh, 760px);
    height: clamp(420px, 68svh, 760px);
  }
  .viewport::before, .viewport::after { width: 20px; }
  .canvas-hint { display: none; }

  .map-frame iframe {
    height: clamp(340px, 52vh, 520px);
    height: clamp(340px, 52svh, 520px);
  }

  /* ── the person sheet on a phone ──
     Whose record this is, and the way out of it, stay put while a biography
     that can run several screens long scrolls underneath. */
  /* Pinned to the top of the scrollport. The negative margins pull it out to
     the sheet's edges so its opaque background covers the full width and the
     padding strip above — otherwise the scrolling biography shows through
     around it. */
  .person-head {
    /* A sticky offset of 0 pins below the scroll container's padding, leaving a
       strip the biography scrolls through. Pulling the offset up by that same
       padding lands the header flush against the top of the sheet. */
    position: sticky; top: calc(-1 * var(--space-3)); z-index: 4;
    gap: 12px;
    margin: calc(-1 * var(--space-3)) calc(-1 * var(--space-3)) 0;
    padding: 18px var(--space-3) 10px;
    background: var(--color-surface);
    box-shadow: 0 1px 0 var(--color-divider);
  }
  /* The grab handle, drawn inside the header so it never scrolls away. */
  .person-head::after {
    content: ''; position: absolute; top: 6px; left: 50%; translate: -50% 0;
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--color-neutral-300);
  }
  .person-photo, .person-initials { width: 56px; height: 56px; }
  .person-initials { font-size: 20px; }
  .person-head .dialog-title { font-size: 20px; }
  .person-years { font-size: 12.5px; margin-top: 2px; }
  .person-tags { margin-top: 6px; }
  .dialog-close { font-size: 30px; padding: 0 4px; }

  .facts { gap: 11px 16px; padding-top: 12px; }
  .bio-text { font-size: 14px; text-align: left; }
  .lineage { line-height: 1.8; }
  /* The trailing "Mbyll" is redundant once the header carries an ×. */
  .person-dialog .dialog-actions { display: none; }
}
