/* ==========================================================================
   Silsilah Keluarga Howan — style.css
   ========================================================================== */

/* ---------- Token warna ---------- */
:root {
  --bg: #f8f3ea;
  --bg-deep: #efe6d4;
  --surface: #ffffff;
  --ink: #2a2018;
  --muted: #7b6e5f;
  --line: #cfc1a9;
  --gold: #b07f22;
  --gold-soft: #f6ead0;
  --male: #2f6db5;
  --male-soft: #e2edfa;
  --female: #c2467a;
  --female-soft: #fbe5ee;
  --shadow: 0 1px 2px rgba(60, 40, 10, .08), 0 6px 18px rgba(60, 40, 10, .07);
  --radius: 14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120d;
    --bg-deep: #1e1810;
    --surface: #241e16;
    --ink: #f2e9d9;
    --muted: #a99b87;
    --line: #4a3f31;
    --gold: #e0b45a;
    --gold-soft: #3a2f1a;
    --male: #7ab0f0;
    --male-soft: #1d2b3f;
    --female: #f08cb8;
    --female-soft: #3d1f2e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
}
a { color: var(--gold); }
code { background: var(--bg-deep); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 16px 28px;
  background:
    radial-gradient(900px 260px at 50% -40%, var(--gold-soft), transparent 70%),
    var(--bg);
}
.hero-small { padding: 36px 16px 12px; }
.hero-inner { max-width: 900px; margin: 0 auto; }
.eyebrow { letter-spacing: .28em; text-transform: uppercase; font-size: .74rem; font-weight: 600; color: var(--gold); }
.hero h1 { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 3.6rem); margin: 6px 0 4px; line-height: 1.1; }
.hero h1 span { color: var(--gold); }
.lead { margin: 0; color: var(--muted); font-size: 1.05rem; }

.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 24px 0 0; padding: 0; }
.stats > div {
  min-width: 120px; padding: 10px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stats dt { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-family: var(--serif); font-size: 1.6rem; font-weight: 700; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-block: 1px solid var(--line);
  padding: 10px 16px;
}
.toolbar-inner { max-width: 1100px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font-size: .9rem; }
.seg-btn[aria-pressed="true"] { background: var(--gold); color: #fff; font-weight: 600; }
.search { flex: 1 1 220px; min-width: 0; }
.search input {
  width: 100%; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit;
}
.ctrl-group { display: inline-flex; gap: 6px; align-items: center; }
.btn {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: .9rem;
}
.btn:hover { border-color: var(--gold); }
.btn-icon { width: 36px; padding: 8px 0; text-align: center; font-size: 1.05rem; line-height: 1; }
.zoom-val { min-width: 3.2em; text-align: center; font-size: .85rem; color: var(--muted); }

body[data-view="diagram"] #listCtrls,
body[data-view="diagram"] .list-wrap { display: none; }
body[data-view="list"] #zoomCtrls,
body[data-view="list"] .diagram-wrap { display: none; }

/* ---------- Legend ---------- */
.legend {
  max-width: 1100px; margin: 14px auto 0; padding: 0 16px;
  display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center;
  font-size: .86rem; color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-hint { margin-left: auto; font-style: italic; }
.dot {
  width: 22px; height: 22px; border-radius: 50%; font-style: normal;
  display: inline-grid; place-items: center; font-size: 14px; font-weight: 700; line-height: 1; flex: none;
}
.dot-L { background: var(--male-soft); color: var(--male); }
.dot-P { background: var(--female-soft); color: var(--female); }
.dot-howan { background: var(--surface); box-shadow: 0 0 0 2px var(--gold); }
.legend-amp { color: var(--gold); font-family: var(--serif); font-weight: 700; font-style: normal; width: 22px; text-align: center; }

/* ---------- Avatar (dipakai di semua tampilan) ---------- */
.avatar {
  position: relative; flex: none;
  width: var(--size, 72px); height: var(--size, 72px);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--size, 72px) * .48); font-weight: 700; line-height: 1;
  background: var(--male-soft); color: var(--male);
  box-shadow: 0 0 0 2px var(--line);
}
.avatar.P { background: var(--female-soft); color: var(--female); }
.avatar.U { background: var(--line); color: var(--muted); }
.avatar.howan { box-shadow: 0 0 0 3px var(--gold); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar .gbadge {
  position: absolute; right: -3px; bottom: -3px;
  width: calc(var(--size, 72px) * .32); height: calc(var(--size, 72px) * .32);
  min-width: 16px; min-height: 16px;
  border-radius: 50%; display: grid; place-items: center;
  font-size: calc(var(--size, 72px) * .22); line-height: 1; font-weight: 700;
  background: var(--male-soft); color: var(--male);
  border: 2px solid var(--surface);
}
.avatar.P .gbadge { background: var(--female-soft); color: var(--female); }
.avatar.mini { --size: 28px; }
.avatar.mini .gbadge { display: none; }

/* ==========================================================================
   TAMPILAN DIAGRAM
   ========================================================================== */
.diagram-wrap { overflow: auto; padding: 12px 0 72px; cursor: grab; -webkit-overflow-scrolling: touch; }
.diagram-wrap.dragging { cursor: grabbing; user-select: none; }
.diagram { width: max-content; min-width: 100%; padding: 16px 28px; }

.diagram ul { display: flex; justify-content: center; list-style: none; margin: 0; padding: 28px 0 0; position: relative; }
.diagram ul.droot { padding-top: 0; }
.diagram li { position: relative; padding: 28px 9px 0; display: flex; flex-direction: column; align-items: center; }
.diagram ul.droot > li { padding-top: 0; }

/* garis penghubung */
.diagram li::before, .diagram li::after {
  content: ""; position: absolute; top: 0; width: 50%; height: 28px;
  border-top: 2px solid var(--line);
}
.diagram li::before { right: 50%; }
.diagram li::after { left: 50%; border-left: 2px solid var(--line); }
.diagram li:first-child::before, .diagram li:last-child::after { border: 0; }
.diagram li:last-child::before { border-right: 2px solid var(--line); border-radius: 0 9px 0 0; }
.diagram li:first-child::after { border-radius: 9px 0 0 0; }
.diagram li:only-child::before { display: none; }
.diagram li:only-child::after { border-top: 0; border-radius: 0; }
.diagram ul.droot > li::before, .diagram ul.droot > li::after { display: none; }
.diagram ul ul::before {
  content: ""; position: absolute; top: 0; left: 50%; height: 28px;
  border-left: 2px solid var(--line);
}

.unit { display: inline-flex; align-items: flex-start; justify-content: center; }
.dlink { width: 28px; height: 2px; background: var(--gold); margin-top: 35px; flex: none; }

.dnode {
  --size: 72px;
  width: 108px; display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.dnode[disabled] { cursor: default; }
.dname { font-size: .8rem; line-height: 1.2; max-width: 108px; overflow-wrap: anywhere; }
.dnode.howan .dname { font-weight: 700; }
.dnode.union .dname::before { content: "& "; color: var(--gold); font-weight: 700; }
.dnode.union .avatar { border: 2px dashed var(--line); box-shadow: none; }
.dnode:not([disabled]):hover .avatar { transform: translateY(-2px); }
.avatar { transition: transform .15s ease, box-shadow .15s ease; }
.dnode.hit .avatar, .card.hit { box-shadow: 0 0 0 4px var(--gold), 0 0 16px var(--gold); }
.dsearching .dnode, .searching .row { opacity: .3; transition: opacity .15s; }
.dsearching .dnode.hit, .searching .row.hit { opacity: 1; }

/* ==========================================================================
   TAMPILAN DAFTAR
   ========================================================================== */
.list-wrap { max-width: 1100px; margin: 0 auto; padding: 12px 16px 72px; overflow-x: auto; }
ul.tree { list-style: none; margin: 0; padding: 0 0 0 26px; }
ul.tree.root { padding-left: 0; }
ul.tree li { position: relative; padding: 8px 0 0 24px; }
ul.tree.root > li { padding-left: 0; }
ul.tree:not(.root) > li::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--line);
}
ul.tree:not(.root) > li::after {
  content: ""; position: absolute; left: 0; top: 31px; width: 20px; border-top: 2px solid var(--line);
}
ul.tree:not(.root) > li:last-child::before { height: 31px; bottom: auto; }
li.collapsed > ul.tree { display: none; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 44px; }
.toggle {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer; padding: 0; display: inline-grid; place-items: center; line-height: 1;
}
.toggle:hover { border-color: var(--gold); color: var(--gold); }
.toggle::before { content: "−"; }
li.collapsed > .row .toggle::before { content: "+"; }
.toggle-spacer { width: 26px; flex: none; }

.card {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 14px 4px 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow); font-size: .95rem; white-space: nowrap; cursor: pointer;
}
.card:hover { border-color: var(--gold); }
.card[disabled] { cursor: default; }
.card.howan { border-color: var(--gold); background: var(--gold-soft); font-weight: 700; }
.card.spouse { font-size: .9rem; }
.amp { color: var(--gold); font-weight: 700; font-family: var(--serif); }
.badge { font-size: .75rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 1px 9px; }

/* ==========================================================================
   JENDELA DETAIL
   ========================================================================== */
dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line); border-radius: 20px; padding: 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(20, 14, 6, .5); backdrop-filter: blur(2px); }
.d-close {
  position: absolute; top: 10px; right: 12px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--bg-deep); cursor: pointer; font-size: 1.3rem; line-height: 1;
}
.d-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; padding-right: 30px; }
.d-head .avatar { --size: 96px; }
.d-head h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 1.4rem; line-height: 1.2; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .74rem; padding: 2px 10px; border-radius: 999px; background: var(--bg-deep); color: var(--muted); }
.tag-howan { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.d-body { margin: 0; display: grid; gap: 12px; }
.d-body dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.d-body dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 3px 12px; font-size: .88rem; cursor: pointer;
}
.chip:hover { border-color: var(--gold); }
.chip-static { cursor: default; }

/* ==========================================================================
   HALAMAN PANDUAN FOTO
   ========================================================================== */
.page { max-width: 860px; margin: 0 auto; padding: 8px 16px 64px; }
.card-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-top: 18px; box-shadow: var(--shadow);
}
.card-block h2 { margin: 0 0 10px; font-family: var(--serif); font-size: 1.2rem; }
.spec { padding-left: 20px; }
.muted { color: var(--muted); }
.table-scroll { overflow-x: auto; }
.foto-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.foto-table th, .foto-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.foto-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pill { font-size: .75rem; padding: 2px 10px; border-radius: 999px; background: var(--bg-deep); color: var(--muted); }
.pill-ok { background: #dff3e1; color: #1f7a33; font-weight: 600; }
@media (prefers-color-scheme: dark) { .pill-ok { background: #1c3322; color: #7fd392; } }

/* ---------- Lain-lain ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.foot {
  display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
  padding: 0 16px 40px; font-size: .82rem; color: var(--muted);
}

@media (max-width: 600px) {
  .toolbar { position: static; }
  .legend-hint { margin-left: 0; width: 100%; }
  ul.tree { padding-left: 14px; }
  ul.tree li { padding-left: 16px; }
  ul.tree:not(.root) > li::after { width: 12px; }
  .card { white-space: normal; }
  .d-head .avatar { --size: 72px; }
}
@media print {
  .toolbar, .legend-hint, .foot { display: none; }
  li.collapsed > ul.tree { display: block; }
  body { background: #fff; }
}
