/* Nasabnama — 2026 design system. No build step: modern CSS only. */
@layer reset, tokens, base, components, utilities;

@view-transition { navigation: auto; }

@layer tokens {
  :root {
    color-scheme: light;
    --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", "Geeza Pro", sans-serif;
    --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Naskh Arabic", serif;
    --step--1: clamp(.82rem, .8rem + .1vw, .9rem);
    --step-0: clamp(1rem, .96rem + .2vw, 1.1rem);
    --step-1: clamp(1.25rem, 1.15rem + .5vw, 1.5rem);
    --step-2: clamp(1.6rem, 1.4rem + 1vw, 2.2rem);
    --step-3: clamp(2.1rem, 1.7rem + 2vw, 3.4rem);
    --radius: 18px; --radius-sm: 11px;
    --maxw: 1120px; --gutter: clamp(16px, 4vw, 32px);

    --paper: oklch(99% .006 85);
    --surface: oklch(100% 0 0);
    --surface-2: oklch(96.5% .012 85);
    --ink: oklch(24% .02 50);
    --muted: oklch(50% .02 60);
    --line: oklch(90% .014 80);
    --brand: oklch(52% .13 30);       /* heritage maroon */
    --brand-ink: oklch(98% .01 85);
    --brand-soft: oklch(96% .03 40);
    --gold: oklch(72% .13 85);
    --male: oklch(52% .11 245);
    --female: oklch(52% .15 355);
    --ok: oklch(48% .12 155);
    --warn: oklch(55% .13 70);
    --bad: oklch(50% .18 25);
    --shadow: 0 1px 2px oklch(40% .03 60 / .05), 0 10px 28px -12px oklch(40% .04 60 / .14);
    --ring: 0 0 0 3px color-mix(in oklab, var(--brand) 35%, transparent);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  img, svg { max-width: 100%; display: block; }
  input, button, select, textarea { font: inherit; color: inherit; }
  :where(ul[role="list"], ol[role="list"]) { list-style: none; padding: 0; }
}

@layer base {
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
  body {
    min-height: 100dvh; display: flex; flex-direction: column;
    font: var(--step-0)/1.65 var(--font-body); color: var(--ink); background: var(--paper);
    background-image: radial-gradient(60rem 30rem at 85% -10%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 70%);
  }
  main { flex: 1; width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; padding-block: clamp(1.5rem, 4vw, 3rem); }
  h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; letter-spacing: -.01em; }
  h1 { font-size: var(--step-3); } h2 { font-size: var(--step-2); } h3 { font-size: var(--step-1); }
  p { text-wrap: pretty; max-width: 70ch; }
  a { color: var(--brand); text-underline-offset: .2em; text-decoration-thickness: .08em; }
  a:hover { text-decoration-thickness: .16em; }
  :focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
  ::selection { background: color-mix(in oklab, var(--gold) 45%, transparent); }
  .skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; z-index: 99; background: var(--surface); padding: .5rem 1rem; border-radius: 8px; }
  [dir="rtl"], .rtl { font-family: var(--font-display); }
}

@layer components {
  /* ---------- header ---------- */
  .site-header { position: sticky; top: 0; z-index: 40; background: color-mix(in oklab, var(--paper) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
  .site-header .bar { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; display: flex; align-items: center; gap: 1rem; min-height: 4rem; }
  .brand { display: flex; align-items: center; gap: .6rem; font: 700 1.25rem/1 var(--font-display); color: var(--ink); text-decoration: none; }
  .brand-mark { width: 2.1rem; height: 2.1rem; border-radius: 11px; background: conic-gradient(from 45deg, var(--brand), var(--gold), var(--brand)); display: grid; place-items: center; color: var(--brand-ink); font-size: 1.1rem; box-shadow: inset 0 0 0 2px color-mix(in oklab, white 25%, transparent); }
  .nav { display: flex; gap: .15rem; margin-inline-start: auto; align-items: center; }
  .nav a { padding: .45rem .8rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: var(--step--1); font-weight: 550; }
  .nav a:hover { color: var(--ink); background: var(--surface-2); }
  .nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
  .menu-toggle { display: none; margin-inline-start: auto; }
  .nav-cta { display: flex; gap: .5rem; align-items: center; }
  @media (max-width: 880px) {
    .menu-toggle { display: block; position: relative; }
    .menu-toggle summary { list-style: none; cursor: pointer; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; }
    .menu-toggle summary::-webkit-details-marker { display: none; }
    .menu-toggle .panel { position: absolute; right: 0; top: calc(100% + .5rem); width: min(20rem, 88vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; display: grid; }
    .menu-toggle .panel a { padding: .7rem .9rem; border-radius: 10px; text-decoration: none; color: var(--ink); }
    .menu-toggle .panel a:hover { background: var(--surface-2); }
    .nav { display: none; }
  }
  @media (min-width: 881px) { .menu-toggle { display: none; } }

  /* ---------- buttons, forms ---------- */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .7rem 1.2rem; border-radius: 999px; border: 1px solid transparent; background: var(--brand); color: var(--brand-ink); font-weight: 650; text-decoration: none; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
  .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
  .btn:active { transform: none; }
  .btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
  .btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
  .btn.small { padding: .4rem .85rem; font-size: var(--step--1); }
  label.field { display: grid; gap: .35rem; font-weight: 600; font-size: var(--step--1); }
  label.field > span.hint { font-weight: 400; color: var(--muted); }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .12s, box-shadow .12s; }
  input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
  .form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
  .err { color: var(--bad); font-weight: 500; font-size: var(--step--1); }
  .hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
  .searchbox { position: relative; display: flex; gap: .5rem; }
  /* [type=search] raises specificity above the generic field rule, so the icon gutter is not overridden */
  .searchbox input[type="search"] { padding-inline-start: 2.9rem; border-radius: 999px; background: var(--surface); }
  .searchbox input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
  .searchbox::before { content: ""; position: absolute; left: 1rem; top: 50%; width: 1.05rem; height: 1.05rem; translate: 0 -50%; background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat; pointer-events: none; }

  /* ---------- surfaces ---------- */
  .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.6rem); box-shadow: var(--shadow); }
  .card.flat { box-shadow: none; }
  a.card { color: inherit; text-decoration: none; display: block; transition: transform .15s, border-color .15s; }
  a.card:hover { transform: translateY(-2px); border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); }
  .grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
  .grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
  .stack { display: grid; gap: 1rem; } .stack-lg { display: grid; gap: clamp(1.5rem, 4vw, 2.5rem); }
  .cluster { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
  .muted { color: var(--muted); } .small { font-size: var(--step--1); }
  .eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: var(--brand); }
  .page-head { display: grid; gap: .5rem; margin-block-end: clamp(1.25rem, 3vw, 2rem); }
  .page-head .sub { color: var(--muted); max-width: 60ch; }

  .hero { position: relative; overflow: hidden; border-radius: calc(var(--radius) + 8px); padding: clamp(1.75rem, 6vw, 4rem); color: var(--ink); border: 1px solid color-mix(in oklab, var(--gold) 35%, var(--line));
      background:
        radial-gradient(40rem 22rem at 100% 0, color-mix(in oklab, var(--gold) 32%, transparent), transparent 65%),
        radial-gradient(34rem 20rem at 0 100%, color-mix(in oklab, oklch(85% .08 190) 40%, transparent), transparent 60%),
        linear-gradient(160deg, oklch(98.5% .015 85), oklch(96.5% .025 70)); box-shadow: var(--shadow); }
  .hero::after { content: ""; position: absolute; inset: 0; opacity: .5; pointer-events: none;
      background: repeating-conic-gradient(from 0deg at 92% 8%, color-mix(in oklab, var(--gold) 30%, transparent) 0 4deg, transparent 4deg 8deg); mask: radial-gradient(circle at 92% 8%, black, transparent 55%); }
  .hero > * { position: relative; z-index: 1; }
  .hero h1 { max-width: 18ch; } .hero p { color: var(--muted); margin-block: 1rem 1.5rem; font-size: var(--step-1); }
  .hero .eyebrow { color: var(--brand); }
  .hero .searchbox input[type="search"] { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .stat-row { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; margin-block-start: 1.5rem; }
  .stat b { display: block; font: 700 var(--step-2)/1 var(--font-display); color: var(--brand); } .stat span { font-size: var(--step--1); color: var(--muted); }

  .notice { border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); background: var(--surface); border-radius: var(--radius-sm); padding: .8rem 1rem; margin-block-end: 1rem; }
  .notice.ok { border-inline-start-color: var(--ok); } .notice.warn { border-inline-start-color: var(--warn); } .notice.bad { border-inline-start-color: var(--bad); }

  .pill { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); font-size: .78rem; font-weight: 650; color: var(--muted); }
  .pill.ok { background: color-mix(in oklab, var(--ok) 16%, transparent); color: var(--ok); }
  .pill.bad { background: color-mix(in oklab, var(--bad) 14%, transparent); color: var(--bad); }
  .pill.warn { background: color-mix(in oklab, var(--warn) 18%, transparent); color: var(--warn); }

  /* ---------- people ---------- */
  .avatar { --c: var(--muted); flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; font: 700 .95rem/1 var(--font-display); color: var(--c); background: color-mix(in oklab, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in oklab, var(--c) 30%, transparent); }
  .avatar.m { --c: var(--male); } .avatar.f { --c: var(--female); } .avatar.lg { width: 5rem; height: 5rem; font-size: 1.8rem; }
  .person { display: flex; align-items: center; gap: .75rem; min-width: 0; text-decoration: none; color: inherit; }
  .person .who { min-width: 0; } .person .who b { display: block; font-weight: 650; overflow-wrap: anywhere; } .person .who small { color: var(--muted); }
  a.person:hover .who b { color: var(--brand); }
  .segmented { display: inline-flex; padding: .25rem; border-radius: 999px; background: var(--surface-2); gap: .15rem; }
  .segmented a { padding: .45rem 1.1rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: var(--step--1); }
  .segmented a[aria-current="true"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
  .alphabet { display: flex; flex-wrap: wrap; gap: .25rem; }
  .alphabet a { width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: 10px; text-decoration: none; font-weight: 650; color: var(--muted); }
  .alphabet a:hover { background: var(--surface-2); color: var(--ink); } .alphabet a[aria-current="true"] { background: var(--brand); color: var(--brand-ink); }
  .facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; } .facts dt { color: var(--muted); } .facts dd { margin: 0; }
  @media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-block-end: .6rem; } }
  .profile-head { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center; }
  .tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-block: 1.25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
  .tabs a { padding: .65rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
  .tabs a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); border-radius: 0; }

  /* table that turns into cards on small screens */
  .table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  table.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
  table.data th { text-align: start; padding: .75rem 1rem; color: var(--muted); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; }
  table.data td { padding: .7rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
  table.data tr:hover td { background: color-mix(in oklab, var(--brand) 4%, transparent); }
  @media (max-width: 720px) {
    table.data thead { display: none; } table.data, table.data tbody, table.data tr, table.data td { display: block; }
    table.data tr { padding: .75rem 1rem; border-top: 1px solid var(--line); } table.data td { border: 0; padding: .15rem 0; }
    table.data td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 600; }
  }

  /* lazy-loaded family trees */
  .tree, .tree ul { list-style: none; margin: 0; padding: 0; }
  .tree ul { margin-inline-start: 1.1rem; padding-inline-start: 1.1rem; border-inline-start: 2px solid color-mix(in oklab, var(--brand) 25%, var(--line)); }
  .tree li { padding-block: .3rem; }
  .tree .node { display: flex; align-items: center; gap: .6rem; }
  .tree button.toggle { width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; color: var(--brand); font-weight: 700; flex: none; }
  .tree button.toggle[aria-expanded="true"] { background: var(--brand); color: var(--brand-ink); }
  .tree .leaf { width: 1.9rem; flex: none; text-align: center; color: var(--line); }
  .tree .loading, .tree .empty { color: var(--muted); font-size: var(--step--1); padding: .3rem 0; }

  /* relationship path */
  .path { list-style: none; padding: 0; position: relative; display: grid; gap: 0; }
  .path li { position: relative; padding: .2rem 0 1.25rem 3.2rem; }
  .path li::before { content: ""; position: absolute; left: 1.2rem; top: 2.5rem; bottom: -.1rem; width: 2px; background: var(--line); }
  .path li:last-child::before { display: none; } .path li:last-child { padding-block-end: 0; }
  .path .avatar { position: absolute; left: 0; top: .1rem; }
  .path .step { margin: 0; padding-block-start: .45rem; max-width: none; }
  .path .rel { color: var(--muted); }

  /* typeahead */
  .picker { position: relative; display: block; }
  .picker ul { position: absolute; z-index: 20; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 16rem; overflow: auto; }
  .picker li { padding: .55rem .75rem; border-radius: 8px; cursor: pointer; font-weight: 500; }
  .picker li:hover, .picker li[aria-selected="true"] { background: var(--brand-soft); }

  /* prose (news/journal/pages) */
  .prose { max-width: 70ch; } .prose > * + * { margin-block-start: 1em; } .prose img { border-radius: var(--radius-sm); height: auto; }
  .prose h2, .prose h3 { margin-block-start: 1.6em; } .prose ul, .prose ol { padding-inline-start: 1.4em; } .prose blockquote { border-inline-start: 3px solid var(--gold); padding-inline-start: 1rem; color: var(--muted); }
  .prose table { width: 100%; border-collapse: collapse; } .prose td, .prose th { padding: .4rem; border: 1px solid var(--line); }
  .post-card h3 { font-size: var(--step-1); } .post-card time { font-size: var(--step--1); color: var(--muted); }
  .comment { padding-block: 1rem; border-top: 1px solid var(--line); } .comment header { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }

  /* lineage diagram (home page) */
  .lineage { margin: 0; }
  .lineage-svg { background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: clamp(.5rem, 2vw, 1.25rem); box-shadow: var(--shadow); }
  .lineage svg { width: 100%; height: auto; display: block; }
  .lin-zone { stroke: none; }
  .lin-zone.abbasi { fill: color-mix(in oklab, oklch(72% .1 285) 14%, transparent); }
  .lin-zone.alavi { fill: color-mix(in oklab, var(--gold) 20%, transparent); }
  .lin-zone.kakori { fill: color-mix(in oklab, oklch(80% .12 150) 20%, transparent); }
  .lin-zone-label { font: 700 46px var(--font-display); fill: color-mix(in oklab, oklch(60% .12 285) 55%, transparent); letter-spacing: .06em; }
  .lin-zone-label.alavi { fill: color-mix(in oklab, var(--gold) 80%, transparent); }
  .lin-band-label { font: 700 40px var(--font-display); fill: color-mix(in oklab, oklch(55% .12 150) 70%, transparent); }
  .lin-lines path { stroke: color-mix(in oklab, var(--brand) 70%, var(--muted)); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
  .lin-lines.dashed path { stroke-dasharray: 3 7; stroke: var(--muted); }
  .lin-lines.marriage path { stroke: var(--gold); stroke-width: 3; }
  .lin-arrowhead { fill: color-mix(in oklab, var(--brand) 70%, var(--muted)); }
  .lin-node rect { fill: color-mix(in oklab, var(--brand) 9%, var(--surface)); stroke: color-mix(in oklab, var(--brand) 55%, transparent); stroke-width: 2; filter: drop-shadow(0 4px 6px oklch(30% .04 40 / .14)); }
  .lin-node.gold rect { fill: color-mix(in oklab, var(--gold) 38%, var(--surface)); stroke: color-mix(in oklab, var(--gold) 90%, black 20%); }
  .lin-node.prophet rect { fill: color-mix(in oklab, var(--gold) 18%, var(--surface)); stroke: var(--gold); stroke-width: 3; }
  .lin-node.soft rect { fill: var(--surface-2); stroke-dasharray: 6 5; }
  .lin-node.kakori rect { fill: color-mix(in oklab, var(--brand) 82%, white 0%); stroke: color-mix(in oklab, var(--brand) 100%, black 25%); }
  .lin-node.kakori .lin-name, .lin-node.kakori .lin-years { fill: oklch(98% .01 85); }
  .lin-name { font: 700 20px var(--font-display); fill: var(--ink); } .lin-name.long { font-size: 17px; }
  .lin-years { font: 600 14px var(--font-body); fill: var(--muted); }
  .lin-hon { font: 500 12px var(--font-display); fill: var(--brand); }
  .lin-small { font: 600 13px var(--font-body); fill: var(--muted); }
  .lin-branch { font: 700 26px var(--font-display); fill: oklch(45% .12 150); }
  .lin-bracket { stroke: oklch(62% .13 150); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
  .lin-badge { fill: var(--surface); stroke: var(--brand); stroke-width: 2.5; }
  .lin-badge-n { font: 700 22px var(--font-display); fill: var(--brand); }
  .lineage-list { display: none; }
  @media (max-width: 760px) {
    .lineage-svg { display: none; }
    .lineage-list { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem 1rem .5rem; box-shadow: var(--shadow); }
    .lineage-list, .lineage-list ol { list-style: none; margin: 0; padding-inline-start: 0; }
    .lineage-list ol { margin-inline-start: .6rem; padding-inline-start: 1rem; border-inline-start: 2px solid color-mix(in oklab, var(--brand) 25%, var(--line)); }
    .lineage-list li { padding-block: .3rem; font-size: var(--step--1); }
    .lineage-list li > span { color: var(--muted); }
    .lineage-list .gen { color: var(--muted); font-style: italic; }
    .lineage-list .house { color: oklch(45% .12 150); font-weight: 700; }
  }

  /* pagination */
  .pager { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin-block-start: 2rem; }
  .pager a, .pager span { min-width: 2.4rem; height: 2.4rem; padding-inline: .7rem; display: grid; place-items: center; border-radius: 999px; text-decoration: none; border: 1px solid var(--line); background: var(--surface); font-size: var(--step--1); font-weight: 600; }
  .pager span[aria-current="page"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); } .pager span.disabled { opacity: .45; }

  /* footer */
  .site-footer { border-top: 1px solid var(--line); background: var(--surface); }
  .site-footer .inner { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; padding-block: 2rem; display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; color: var(--muted); font-size: var(--step--1); }
  .site-footer nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; } .site-footer a { color: inherit; }
}

@layer utilities {
  .center { text-align: center; } .mt { margin-block-start: 1.5rem; } .mt-sm { margin-block-start: .75rem; }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
  @media print { .site-header, .site-footer, .btn, .tabs { display: none !important; } body { background: #fff; } }
}
