/*
 * Utmanz — large-format banner (Panaflex / flex printing).
 * The sheet is designed on a fixed canvas (long side 1800 CSS px) and scaled to the
 * banner's physical size for print; Chrome keeps it vector in the PDF.
 */

/* ---------- Screen: preview chrome ---------- */
body.poster-page { background: #18211D; color: #fff; min-height: 100vh; }
.poster-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 12px 24px; background: rgba(5, 34, 27, .95); border-bottom: 1px solid rgba(217, 184, 114, .25); }
.poster-back { display: inline-flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, .85); font: 500 14px/1 var(--f-ui); }
.poster-back svg { width: 16px; height: 16px; }
.poster-back:hover { color: #fff; }
.poster-sizes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.poster-label { font: 600 11px/1 var(--f-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-400); margin-right: 6px; }
.size-chip { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); color: rgba(255, 255, 255, .85); font: 600 12.5px/1 var(--f-ui); }
.size-chip:hover { border-color: var(--gold-400); color: #fff; }
.size-chip.is-active { background: var(--gold-500); border-color: var(--gold-500); color: var(--em-950); }
.poster-help { margin: 14px 24px 0; padding: 10px 16px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .78); font-size: 13.5px; }
.poster-help strong { color: var(--gold-400); }
.poster-help em { font-style: normal; color: #fff; }
.poster-stage { position: relative; padding: 20px 24px 40px; overflow: hidden; }

/* ---------- The sheet (design canvas) ---------- */
.sheet {
  --pad: 34px;
  position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: 1800px; height: 1200px; margin: 0; overflow: hidden; color: var(--ink);
  background: var(--pattern) 0 0 / 60px 60px, var(--ivory);
  transform-origin: 0 0; box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.sheet::before { content: ""; position: absolute; inset: 0; background: rgba(250, 247, 240, .9); pointer-events: none; }
.sheet > * { position: relative; }
/* canvas sizes (long side 1800) */
.sheet.s-3x2, .sheet.s-6x4 { height: 1200px; }
.sheet.s-4x3 { height: 1350px; }
.sheet.s-6x3, .sheet.s-8x4, .sheet.s-10x5 { height: 900px; }
.sheet.is-portrait { width: 1200px; height: 1800px; }
.sheet.s-3x4 { width: 1350px; }

.sheet-head { display: grid; justify-items: center; gap: 4px; padding: calc(var(--pad) * .8) var(--pad) calc(var(--pad) * .55); color: #fff;
  background: radial-gradient(900px 300px at 50% -40%, rgba(201, 162, 90, .35), transparent 70%), linear-gradient(160deg, var(--em-800), var(--em-950)); border-bottom: 4px solid var(--gold-500); }
.sheet-head::before { content: ""; position: absolute; inset: 0; background-image: var(--pattern); background-size: 64px; opacity: .1; pointer-events: none; }
.sheet-logo { position: relative; height: 92px; width: auto; }
.sheet-title { position: relative; margin: 0; font: 400 40px/2 var(--f-ur); color: var(--gold-200); direction: rtl; text-align: center; }

.sheet-tree { position: relative; overflow: hidden; margin: 18px var(--pad) 0; border: 1.5px solid var(--line-strong); border-radius: 24px; background: #fff; }
.sheet-tree-canvas { position: absolute; top: 0; left: 0; width: max-content; padding: 28px; transform-origin: 0 0; }
.sheet .person-note[data-note] { -webkit-line-clamp: 4; line-clamp: 4; cursor: default; }
.sheet a { color: inherit; }

.sheet-silsila { margin: 16px var(--pad) 0; padding: 16px 22px 18px; border-radius: 20px; background: linear-gradient(180deg, var(--gold-100), #fff); border: 1.5px solid var(--gold-200); }
.sheet-silsila-title { margin: 0 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; direction: rtl; }
.sheet-silsila-title [lang="ur"] { font: 700 26px/1.9 var(--f-ur); color: var(--em-900); }
.sheet-silsila-title .count { font: 600 12px/1 var(--f-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-700); direction: ltr; }
.chain { --fs: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0; padding: 0; list-style: none; font: 400 var(--fs)/1.9 var(--f-ur); color: var(--em-900); }
.chain li { position: relative; display: inline-flex; align-items: center; gap: .4em; padding: 0 .55em 0 .25em; border-radius: 999px; background: #fff; border: 1px solid var(--line-strong); white-space: nowrap; }
/* gold connector from each generation to the next (the chain runs right to left) */
.chain li + li::before { content: ""; position: absolute; inset-inline-start: -16px; top: 50%; width: 15px; border-top: 2px solid var(--gold-500); }
.chain .n { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 .35em; border-radius: 999px; background: var(--em-800); color: #fff; font: 600 max(9px, calc(var(--fs) * .62))/1 var(--f-ui); }
.chain li.is-self { background: var(--em-800); color: #fff; border-color: var(--gold-500); box-shadow: 0 0 0 2px var(--gold-200); }
.chain li.is-self .n { background: var(--gold-500); color: var(--em-950); }

.sheet-foot { display: flex; justify-content: space-between; gap: 20px; margin: 14px var(--pad) 0; padding: 12px 0 calc(var(--pad) * .8); border-top: 1px solid var(--gold-500); font: 500 14px/1.4 var(--f-ui); color: var(--muted); }
.sheet-foot span:first-child { color: var(--em-800); font-weight: 600; letter-spacing: .06em; }

/* ---------- Print: the sheet at the banner's real size, no margins ---------- */
@page p-3x2 { size: 36in 24in; margin: 0; }
@page p-4x3 { size: 48in 36in; margin: 0; }
@page p-6x3 { size: 72in 36in; margin: 0; }
@page p-6x4 { size: 72in 48in; margin: 0; }
@page p-8x4 { size: 96in 48in; margin: 0; }
@page p-10x5 { size: 120in 60in; margin: 0; }
@page p-2x3 { size: 24in 36in; margin: 0; }
@page p-3x4 { size: 36in 48in; margin: 0; }
@page p-4x6 { size: 48in 72in; margin: 0; }
.s-3x2 { page: p-3x2; } .s-4x3 { page: p-4x3; } .s-6x3 { page: p-6x3; } .s-6x4 { page: p-6x4; } .s-8x4 { page: p-8x4; }
.s-10x5 { page: p-10x5; } .s-2x3 { page: p-2x3; } .s-3x4 { page: p-3x4; } .s-4x6 { page: p-4x6; }

@media print {
  html, body.poster-page { background: #fff !important; margin: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .poster-bar, .poster-help { display: none !important; }
  .poster-stage { padding: 0 !important; height: auto !important; overflow: visible; }
  .sheet { box-shadow: none; transform: scale(var(--print-scale, 1)) !important; }
}

/* Landscape banners are wide: large families sit in one row instead of a tall grid */
.sheet.is-landscape .tree ul.family-grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 160px; }
.sheet.is-landscape .family-group { grid-template-columns: repeat(5, 160px); }

/* ---------- Landscape banners: tree and silsila side by side ---------- */
.sheet.is-landscape { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.sheet.is-landscape .sheet-head, .sheet.is-landscape .sheet-foot { grid-column: 1 / -1; }
.sheet.is-landscape .sheet-tree { margin: 18px 0 0 var(--pad); }
.sheet.is-landscape .sheet-silsila { display: flex; flex-direction: column; min-height: 0; margin: 18px var(--pad) 0 16px; overflow: hidden; }
.sheet.is-landscape .chain { display: block; flex: 1; min-height: 0; column-count: 2; column-gap: 14px; column-fill: auto; }
.sheet.is-landscape .chain li { display: flex; width: 100%; margin: 0 0 .25em; white-space: normal; break-inside: avoid; border-radius: .6em; }
.sheet.is-landscape .chain li + li::before { display: none; }
.sheet.is-landscape .sheet-silsila-title { flex-direction: column; align-items: flex-end; gap: 6px; margin-bottom: 12px; }
.sheet.is-landscape .sheet-silsila-title [lang="ur"] { line-height: 1.7; }
