/*
 * chart.css — the CHART pages (P2b): the viewport, the toolbar, Topola's SVG as drawn by the FolialeRenderer
 * (public/assets/chart/chart.js — it returns no CSS of its own, so every box colour is here), and the PRINT
 * layout. Baseline-loaded (Assets::VIEW_CSS) because the chart arrives as a fragment. Colours are
 * --foliale-* / --bs-* variables only; the chart's own tokens are base.css :root's (Dark mode 1).
 */
/* (the chart's tokens — text, lines, boxes, the root person, the generation tints, the gender fills — are base.css
   :root's, Dark mode 1; chart.js recomputes the gender fills from them on every draw) */

/* === the viewport: a scrolling, draggable frame around the SVG ============================== */
.chart-viewport {
    position: relative;
    height: calc(100vh - 15rem);
    min-height: 20rem;
    overflow: auto;
    cursor: grab;
    background: var(--foliale-chart-ground);
}
.chart-viewport.is-panning {
    cursor: grabbing;
    user-select: none;
}
.chart-svg {
    display: block;
    margin: 0 auto;
}

/* the print dialog's OFF-SCREEN copy (chart-print.js): drawn again inside a light-theme .chart-page host so its
   computed colours are the light tokens; laid out (text is measured) but never seen, never printed */
.chart-print-stage {
    position: fixed;
    top: 0;
    left: -200000px;
    pointer-events: none;
}
@media print {
    .chart-print-stage {
        display: none !important;
    }
}

/* === the toolbar ============================================================================= */
.chart-fields-panel {
    min-width: 14rem;
}
.chart-field-move {
    line-height: 1;
}
.chart-field:first-child [data-field-move="up"],
.chart-field:last-child [data-field-move="down"] {
    visibility: hidden;
}

/* === the boxes (FolialeRenderer) ============================================================= */
.chart-svg .detailed text {
    font-family: var(--foliale-font-family);
    fill: var(--foliale-chart-text);
}
.chart-svg .detailed .name {
    font-size: 12px;
    font-weight: 600;
}
.chart-svg .detailed .details {
    font-size: 10px;
}
.chart-svg .detailed .id {
    font-size: 9px;
    fill: var(--foliale-chart-muted);
}
.chart-svg .detailed {
    stroke-width: 1.5px;
}
.chart-svg .detailed rect.border {
    stroke: var(--foliale-chart-box-border);
}
.chart-svg .detailed rect.family {
    stroke: var(--foliale-chart-box-border);
}
.chart-svg .indi {
    cursor: pointer;
}
.chart-svg .link {
    fill: none;
    stroke: var(--foliale-chart-line);
    stroke-width: 1px;
}
.chart-svg .additional-marriage {
    stroke-dasharray: 2;
}

/* colour: none / by gender / by generation (Topola's g.node carries generation-color0…11) */
.chart-svg .detailed rect.nocolor,
.chart-svg .detailed rect.family {
    fill: var(--foliale-chart-box);
}
.chart-svg .detailed rect.background.bygender {
    fill: var(--foliale-chart-unknown-fill);
}
.chart-svg .detailed rect.background.bygender.male {
    fill: var(--foliale-chart-male-fill);
}
.chart-svg .detailed rect.background.bygender.female {
    fill: var(--foliale-chart-female-fill);
}
.chart-svg .detailed rect.border.bygender {
    stroke: var(--foliale-unknown);
}
.chart-svg .detailed rect.border.bygender.male {
    stroke: var(--foliale-male);
}
.chart-svg .detailed rect.border.bygender.female {
    stroke: var(--foliale-female);
}
.chart-svg .generation-color0 .detailed rect.bygeneration,
.chart-svg .generation-color4 .detailed rect.bygeneration,
.chart-svg .generation-color8 .detailed rect.bygeneration { fill: var(--foliale-chart-gen-0); }
.chart-svg .generation-color1 .detailed rect.bygeneration,
.chart-svg .generation-color5 .detailed rect.bygeneration,
.chart-svg .generation-color9 .detailed rect.bygeneration { fill: var(--foliale-chart-gen-1); }
.chart-svg .generation-color2 .detailed rect.bygeneration,
.chart-svg .generation-color6 .detailed rect.bygeneration,
.chart-svg .generation-color10 .detailed rect.bygeneration { fill: var(--foliale-chart-gen-2); }
.chart-svg .generation-color3 .detailed rect.bygeneration,
.chart-svg .generation-color7 .detailed rect.bygeneration,
.chart-svg .generation-color11 .detailed rect.bygeneration { fill: var(--foliale-chart-gen-3); }
.chart-svg .detailed rect.family.bygeneration {
    fill: var(--foliale-chart-box);
}

/* confidence (Topola's QUAY 0–3, kept from the prototype): a weaker border dash, a paler fill */
.chart-svg .detailed rect.border.confidence2,
.chart-svg .detailed rect.family.confidence2 { stroke-dasharray: 8 4; }
.chart-svg .detailed rect.border.confidence1,
.chart-svg .detailed rect.family.confidence1 { stroke-dasharray: 3 3; }
.chart-svg .detailed rect.border.confidence0,
.chart-svg .detailed rect.family.confidence0 { stroke-dasharray: 1 3; }
.chart-svg .detailed rect.background.confidence1 { fill-opacity: 0.6; }
.chart-svg .detailed rect.background.confidence0 { fill-opacity: 0.35; }

/* the root: the person the chart was opened from — the border always, the fill only when uncoloured (a
   colour scheme keeps its meaning on the root's box too) */
.chart-svg .chart-root rect.background.nocolor {
    fill: var(--foliale-chart-root-fill);
    fill-opacity: 1;
}
.chart-svg .chart-root rect.border,
.chart-svg .detailed .chart-root rect.border.bygender,
.chart-svg .detailed .chart-root rect.border.bygender.male,
.chart-svg .detailed .chart-root rect.border.bygender.female {
    stroke: var(--foliale-chart-root);
    stroke-width: 3px;
}

/* === THE EVERYONE CHART (E1, everyone.js): the lettered markers, their captions (the size of a box's place text —
   .details), the label of the people linked to nobody, the ring on a marker's twin; the names behind "Show their names" */
.chart-svg .everyone-marker {
    cursor: pointer;
}
.chart-svg .everyone-marker-line {
    fill: none;
    stroke: var(--foliale-chart-line);
    stroke-width: 1.5px;
}
.chart-svg .everyone-marker-circle {
    fill: var(--foliale-chart-box);
    stroke: var(--foliale-chart-text);
    stroke-width: 1.5px;
}
.chart-svg .detailed .everyone-letter {
    font-size: 11px;
    font-weight: 600;
}
.chart-svg .detailed .everyone-letter.is-long {
    font-size: 9px;
}
.chart-svg .everyone-ring {
    fill: none;
    stroke: var(--foliale-action);
    stroke-width: 4px;
}
.chart-svg .everyone-label {
    font-family: var(--foliale-font-family);
    font-size: 14px;
    font-weight: 600;
    fill: var(--foliale-chart-text);
}
.chart-everyone-names summary {
    color: var(--foliale-link);
    cursor: pointer;
}
.chart-everyone-names ul {
    column-width: 16rem;
}

/* === PRINT: A4 landscape (the @page rule rides in the chart view itself, so only a chart page prints
   landscape); rails, toolbar, header, footer hidden; one title line; the SVG scaled to fit the printable
   area with its aspect kept (viewBox + the default xMidYMid meet). No tiling. ================== */
@media print {
    body:has(.chart-page) .app-sidebar,
    body:has(.chart-page) .app-rightpanel,
    body:has(.chart-page) .app-header,
    body:has(.chart-page) .app-footer,
    .chart-page .chart-heading,
    .chart-page .chart-toolbar,
    .chart-page .chart-notice,
    .chart-page .chart-status {
        display: none !important;
    }
    body:has(.chart-page) .app-shell,
    body:has(.chart-page) .app-centre,
    body:has(.chart-page) .app-content {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    body:has(.chart-page) #app-centre-content {
        padding: 0 !important;
    }
    .chart-page .chart-print-title {
        display: block !important;
        margin: 0 0 4mm;
        font-size: 11pt;
        font-weight: 600;
    }
    .chart-page .chart-viewport {
        height: auto;
        min-height: 0;
        overflow: visible;
        border: 0 !important;
    }
    .chart-page .chart-svg {
        width: 100% !important;
        height: 175mm !important;   /* 210mm − 2 × 10mm margins − the title line */
    }
}
