/* Pedigree page. Tokens, fonts and colours come from css/site.css. */
html, body.ped-page { height: auto; overflow: auto; position: static; }
body.ped-page { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 18px; line-height: 1.5; }

.ped-top { max-width: 760px; margin: 0 auto; padding: 18px 16px 0; }
.ped-back { color: var(--accent); text-decoration: none; font-size: 16px; }
.ped-back:hover { color: var(--accent-strong); text-decoration: underline; }

.ped-main { max-width: 760px; margin: 0 auto; padding: 8px 16px 80px; }
.ped-main h1, .ped-main h2 { font-family: var(--font-display); font-weight: 500; color: var(--ink-strong); line-height: 1.15; }
.ped-main h1 { font-size: 40px; margin: 8px 0 18px; }
.ped-main h2 { font-size: 30px; margin: 0 0 14px; }
.ped-main p { margin: 0 0 12px; color: var(--ink); }
.ped-section { margin-top: 64px; }
.ped-intro { margin-top: 8px; }
.ped-lead { color: var(--ink-muted); }
.ped-note { font-size: 15px; color: var(--ink-muted); margin: 8px 0 0; }
.ped-error { color: var(--gold-bright); border: 1px solid var(--line-strong); padding: 10px 12px; border-radius: 6px; }
.ped-main p.ped-purpose { font-size: 16px; color: var(--ink-muted); border-left: 3px solid var(--line-strong); padding-left: 12px; }
.ped-main p.ped-callout { font-size: 15px; color: var(--ink); background: var(--accent-wash); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin: 10px 0 14px; }
.ped-main p.ped-callout:empty { display: none; }
#mix-note p { margin: 8px 0 0; }

/* switches */
.ped-controls { display: grid; gap: 18px; margin-bottom: 16px; }
.ped-field-label { display: block; font-size: 16px; color: var(--ink-strong); margin-bottom: 6px; }
.ped-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.ped-seg button { font: inherit; font-size: 16px; color: var(--ink-muted); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; text-align: left; }
.ped-seg button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.ped-seg button[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--ink-strong); }
.ped-seg button:disabled { opacity: .45; cursor: not-allowed; }
.ped-seg button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

/* charts */
.ped-chart-wrap { position: relative; width: 100%; touch-action: pan-y; }
.ped-chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.ped-chart-wrap text { font-family: var(--font-body); fill: var(--ink-muted); font-size: 13px; }
.ped-chart-wrap .ax-title { fill: var(--ink-faint); font-size: 13px; }
.ped-chart-wrap .grid { stroke: var(--ink-faint); stroke-opacity: .25; stroke-width: 1; }
.ped-chart-wrap .ev-line { stroke: var(--ink-muted); stroke-opacity: .55; stroke-width: 1; stroke-dasharray: 3 3; }
.ped-chart-wrap .ev-mark circle { fill: var(--bg); stroke: var(--gold); stroke-width: 1.5; }
.ped-chart-wrap .ev-mark text { fill: var(--gold-bright); font-size: 12px; text-anchor: middle; }
.ped-chart-wrap .range-line { fill: none; stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 4 3; opacity: .85; }
.ped-chart-wrap .mean-line { fill: none; stroke: var(--gold-bright); stroke-width: 2; stroke-linejoin: round; }
.ped-chart-wrap .cross { stroke: var(--ink); stroke-width: 1; opacity: .7; }

.ped-tip { position: absolute; z-index: 5; pointer-events: none; background: rgba(14,19,34,.97); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px; font-size: 15px; line-height: 1.35; color: var(--ink); width: max-content; max-width: min(280px, 80vw); white-space: normal; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.ped-tip strong { color: var(--ink-strong); font-weight: 500; }
.ped-tip .row { display: flex; align-items: center; gap: 6px; }
.ped-tip .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.ped-tip .muted { color: var(--ink-muted); font-size: 14px; }

.ped-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 0; padding: 0; font-size: 15px; color: var(--ink-muted); }
.ped-legend li { display: flex; align-items: center; gap: 6px; }
.ped-legend .sw { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.ped-events { list-style: none; margin: 12px 0 0; padding: 0; font-size: 15px; color: var(--ink-muted); display: grid; gap: 4px; }
.ped-events li { display: flex; gap: 8px; align-items: baseline; }
.ped-events .num { flex: none; width: 20px; height: 20px; border: 1.5px solid var(--gold); border-radius: 50%; text-align: center; font-size: 12px; line-height: 17px; color: var(--gold-bright); }

.ped-table { margin-top: 14px; font-size: 15px; color: var(--ink-muted); }
.ped-table summary { cursor: pointer; }
.ped-table-scroll { max-height: 320px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; }
.ped-table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.ped-table th, .ped-table td { padding: 4px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ped-table th { position: sticky; top: 0; background: #0e1322; color: var(--ink); font-weight: 500; }

/* family tree */
.ped-tree { list-style: none; margin: 18px 0 0; padding: 0; }
.ped-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 0 0 26px 26px; }
.ped-row::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: -14px; width: 2px; background: var(--line-strong); }
.ped-row:last-child::before { display: none; }
.ped-row::after { content: ""; position: absolute; left: 1px; top: 8px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.ped-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.ped-card h3 { font-family: var(--font-display); font-weight: 500; font-size: 24px; color: var(--ink-strong); line-height: 1.1; }
.ped-card .meta { font-size: 15px; color: var(--ink-muted); margin: 2px 0 8px; }
.ped-card.wife { border-style: dashed; }
.ped-wife-line { font-size: 15px; color: var(--ink-muted); padding: 2px 0 0 2px; }
.ped-wife-line b { color: var(--gold-bright); font-weight: 500; }
.ped-bars { display: grid; gap: 4px; }
.ped-bar { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-muted); }
.ped-bar .track { height: 6px; background: rgba(232,236,245,.08); border-radius: 3px; }
.ped-bar .fill { display: block; height: 6px; border-radius: 3px; }
.ped-bar.rec .fill { background: var(--accent); }
.ped-bar.pot .fill { background: var(--gold); }
.ped-bar .val { min-width: 150px; text-align: right; }
.ped-flag { margin-top: 8px; font-size: 15px; color: var(--gold-bright); }
.ped-record { margin-top: 18px; color: var(--ink); font-style: italic; }

/* households */
.ped-houses { display: grid; gap: 14px; margin-top: 18px; }
.ped-house .name { display: flex; justify-content: space-between; gap: 10px; font-size: 16px; color: var(--ink); }
.ped-house .name span:last-child { color: var(--ink-muted); }
.ped-house .ped-bar { margin-top: 4px; }
.ped-house .ped-bar.size .fill { background: var(--accent); }
.ped-house .ped-bar.share .fill { background: var(--gold); }
.ped-house .ped-bar .val { min-width: 150px; }

.ped-assume { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink); }

/* intro */
.ped-kicker { font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold-bright); margin: 24px 0 0 !important; }
.ped-main h2.ped-h3 { font-size: 24px; margin: 28px 0 8px; }
.ped-terms { margin: 0; display: grid; gap: 10px; }
.ped-terms dt { font-family: var(--font-display); font-size: 21px; font-weight: 500; color: var(--ink-strong); }
.ped-terms dd { margin: 0 0 4px; color: var(--ink); }
.ped-howto { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 6px; color: var(--ink); }
.ped-provisional { color: var(--ink-muted) !important; font-style: italic; margin-top: 18px !important; }
.ped-field-help { margin: 0 0 8px; }
.ped-legend-title { font-size: 15px; color: var(--ink-faint); margin: 14px 0 0 !important; }
.ped-legend-title + .ped-legend, .ped-legend-title + .ped-events { margin-top: 6px; }

@media (min-width: 640px) {
    .ped-row.has-wife { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
}
@media (max-width: 520px) {
    body.ped-page { font-size: 17px; }
    .ped-main h1 { font-size: 32px; }
    .ped-main h2 { font-size: 26px; }
    .ped-bar .val { min-width: 128px; font-size: 13px; }
    .ped-house .ped-bar .val { min-width: 128px; }
    .ped-house .name { flex-direction: column; gap: 0; }
    .ped-main h2.ped-h3 { font-size: 22px; }
}

#range-note { margin-top: 14px; }

/* v31: argument layout */
.ped-standfirst { font-size: 21px; line-height: 1.45; color: var(--ink) !important; }
.ped-hero { position: relative; width: 100%; margin: 28px 0 0; }
/* Only the two chart graphics extend beyond the shared reading column. */
.ped-chart-wide { width: min(900px, calc(100vw - 32px)); margin-inline: calc((100% - min(900px, 100vw - 32px)) / 2); }
.ped-hero figcaption { width: 100%; }
.ped-caption { font-size: 16px; color: var(--ink) !important; margin-top: 12px !important; }
.ped-caption #range-note { color: var(--ink-muted); }
.ped-hero-switch { margin-top: 22px; max-width: 760px; }
.ped-hero .ped-table { max-width: 760px; }
.ped-num { display: inline-block; min-width: 1.3em; margin-right: 10px; color: var(--gold-bright); }
.ped-fig-title { font-size: 15px; color: var(--ink-faint) !important; margin: 20px 0 8px !important; }
.ped-chart-small { margin-top: 4px; }
.ped-lifespans, .ped-beget { display: grid; gap: 3px; margin-bottom: 16px; }
.ped-lrow { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: 15px; color: var(--ink-muted); }
.ped-lrow .track { height: 8px; background: rgba(232,236,245,.08); border-radius: 3px; }
.ped-lrow .fill { display: block; height: 8px; border-radius: 3px; background: var(--gold); }
.ped-beget .fill { background: var(--accent); }
.ped-lrow .lval { text-align: right; color: var(--ink); }
.ped-small-table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 4px 0 14px; }
.ped-small-table th, .ped-small-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ped-small-table th { color: var(--ink); font-weight: 500; background: transparent; position: static; }
.ped-small-table td { color: var(--ink-muted); }
.ped-thin { max-height: none; border: 0; margin-top: 0; }
.ped-avg { display: grid; gap: 8px; margin: 6px 0 16px; }
.ped-avg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ped-chip { font-size: 15px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line-strong); color: #0e1322; }
.ped-chip.c1 { background: #dfe9f8; } .ped-chip.c2 { background: #a9c4ee; } .ped-chip.c3 { background: #7aa0e0; }
.ped-chip.c4 { background: #5a7fcc; color: #f3f6fc; } .ped-chip.c6 { background: #3d4a85; color: #f3f6fc; }
.ped-op { color: var(--ink-muted); font-size: 18px; }
.ped-invite { margin-top: 18px !important; font-style: italic; }
.ped-section { margin-top: 56px; }
@media (max-width: 520px) {
    .ped-standfirst { font-size: 19px; }
    .ped-lrow { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 40px; font-size: 14px; }
    .ped-small-table { font-size: 14px; }
    .ped-small-table th, .ped-small-table td { padding: 5px 6px; }
}
.ped-avg-head { font-size: 15px; color: var(--ink-faint) !important; margin: 0 !important; }
@media (max-width: 520px) { .ped-chip { font-size: 14px; padding: 3px 7px; } .ped-avg-row { gap: 4px 5px; } }
.ped-house-tools { margin-bottom: 4px; }
.ped-house-tools button { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.ped-house-group summary { cursor: pointer; font-size: 16px; color: var(--ink); padding: 6px 0; }
.ped-house-group .ped-houses { margin: 8px 0 14px; }
.ped-scale { max-width: 760px; margin-bottom: 6px; }
.ped-seg-small button { font-size: 15px; padding: 5px 10px; }
.ped-scale .ped-note { margin-top: 4px; }
.ped-chart-wrap .scatter-label { fill: var(--gold-bright); font-size: 13px; }
.ped-chart-wrap .scatter-label { paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }

/* v33: two-panel hero and readout cards */
.ped-panel { margin-top: 18px; }
.ped-main h2.ped-panel-title { font-size: 24px; margin: 0 0 6px; max-width: 760px; }
.ped-panel-note { margin: 0 0 6px !important; }
.ped-chart-wrap .range-band { fill: var(--accent); opacity: .22; stroke: none; }
.ped-chart-wrap .total-line { fill: none; stroke: var(--accent-strong); stroke-width: 2.2; stroke-linejoin: round; }
.ped-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 22px 0 6px; max-width: 900px; }
.ped-card-stat { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.ped-card-stat h3 { font-family: var(--font-display); font-weight: 500; font-size: 21px; color: var(--ink-strong); margin: 0 0 8px; line-height: 1.2; }
.ped-card-stat p { margin: 0 0 8px; font-size: 16px; }
.ped-card-stat p.big { font-size: 19px; color: var(--ink-strong); }
.ped-linkbtn { font: inherit; font-size: 15px; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.ped-linkbtn:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.ped-explain { margin-top: 0 !important; }
.ped-chart-wrap .span-line { stroke: var(--gold); stroke-width: 2; }
.ped-chart-wrap .span-label { fill: var(--gold-bright); font-size: 13px; }
.ped-chart-wrap .babel-line { stroke: var(--gold-bright); stroke-opacity: .8; }
.ped-main h3.ped-sub { font-family: var(--font-display); font-weight: 500; font-size: 22px; color: var(--ink-strong); margin: 22px 0 8px; }

/* v40: switch at the top of the figure, compact three-segment control */
.ped-hero-switch { max-width: 760px; margin: 6px 0 4px; }
.ped-hero-switch .ped-field-label { font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.ped-seg3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-width: 620px; }
.ped-seg3 button { font: inherit; background: var(--surface-soft); color: var(--ink-muted); border: 0; border-left: 1px solid var(--line); padding: 6px 8px; cursor: pointer; text-align: center; line-height: 1.2; }
.ped-seg3 button:first-child { border-left: 0; }
.ped-seg3 button .nm { display: block; font-size: 15px; }
.ped-seg3 button .rt { display: block; font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.ped-seg3 button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink-strong); box-shadow: inset 0 -3px 0 var(--accent); }
.ped-seg3 button[aria-pressed="true"] .rt { color: var(--ink); }
.ped-seg3 button:disabled { opacity: .45; cursor: not-allowed; }
.ped-seg3 button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: -2px; }
.ped-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; max-width: 900px; }
.ped-panel-head .ped-seg-small button { font-size: 13px; padding: 3px 8px; }
.ped-showing { display: inline-block; margin-left: 6px; font-size: 13px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; }
@keyframes pedflash { 0% { background: rgba(232,200,120,.45); } 100% { background: transparent; } }
.ped-flash { animation: pedflash .6s ease-out; border-radius: 4px; }
@media (max-width: 520px) {
    .ped-hero { margin-top: 12px; }
    .ped-seg3 button .nm { font-size: 13px; }
    .ped-seg3 button .rt { font-size: 12px; }
    .ped-seg3 button { padding: 5px 4px; }
}
.ped-bar .track { position: relative; }
.ped-bar .range { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--ink); opacity: .8; }
.ped-bar .range::before, .ped-bar .range::after { content: ""; position: absolute; top: -4px; width: 1.5px; height: 10px; background: var(--ink); }
.ped-bar .range::before { left: 0; } .ped-bar .range::after { right: 0; }
.ped-houses-cap { color: var(--ink) !important; }
.ped-rare { font-size: 14px; color: var(--gold-bright); margin: 2px 0 4px; }

/* Keep the ranking's horizontal scroll inside the reading column. */
.ped-ranking-scroll { width: 100%; overflow-x: auto; margin-top: 20px; border: 1px solid var(--line-strong); border-radius: 6px; }
.ped-ranking-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ped-ranking { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 16px; line-height: 1.35; }
.ped-ranking caption { padding: 14px; text-align: left; color: var(--ink-muted); }
.ped-ranking th, .ped-ranking td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.ped-ranking thead { background: var(--surface); }
.ped-ranking th { font-weight: 500; color: var(--ink-strong); }
.ped-ranking td:first-child { color: var(--gold); }
.ped-ranking td:nth-child(3), .ped-ranking td:nth-child(4) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ped-ranking th:nth-child(2) { width: 28%; }
.ped-ranking th:last-child { width: 29%; }
.ped-ranking tbody tr:nth-child(even) { background: var(--accent-wash); }
.ped-ranking tbody tr[aria-current="true"], .ped-ranking tbody tr:target { background: var(--accent-wash); box-shadow: inset 3px 0 var(--gold); }
.ped-ranking-help { display: none; }
@media (max-width: 751px) { .ped-ranking-help { display: block; color: var(--ink-muted); font-size: 16px; } }
