/* ==========================================================================
   MakeMyBio – Biodata document: shared skeleton
   Markup: templates/biodata/document.html (identical for every design).
   Each design file (royal-red.css, …) only restyles `.bd--<style>`.

   Units
   • The document is a CSS container, so 1cqi = 1% of the page width.
     A preview card and the printed 210 mm A4 page therefore look identical.
   • Text and spacing inside the frame use `em`, so the auto-fit (JS sets
     --bd-fit between 1 and ~0.7) scales the whole content proportionally.
   ========================================================================== */

.bd {
  /* Design tokens – overridden per design */
  --bd-bg: #ffffff;
  --bd-ink: #2B2522;
  --bd-soft: #6F655E;
  --bd-accent: #B08D52;
  --bd-display: "Cormorant Garamond", "Tiro Devanagari Hindi", "Noto Serif Devanagari", Georgia, serif;
  --bd-text: "Mukta", "Noto Sans Devanagari", "Nirmala UI", "Mangal", system-ui, sans-serif;
  --bd-base: 1.9cqi;      /* body text size at fit = 1 */
  --bd-fit: 1;
  /* Fonts for the other Indian scripts, after each design's own fonts: a design's Latin and
     Devanagari fonts keep drawing those letters, and Gujarati, Bengali, Tamil … letters fall
     through to these (loaded on the creator page). Ends with the fonts phones and Windows ship. */
  --bd-script-display: "Noto Serif Gujarati", "Noto Serif Bengali", "Noto Serif Gurmukhi", "Noto Serif Tamil",
    "Noto Serif Telugu", "Noto Serif Kannada", "Noto Serif Malayalam", "Noto Serif Oriya", "Nirmala UI", sans-serif;
  --bd-script-text: "Noto Sans Gujarati", "Noto Sans Bengali", "Noto Sans Gurmukhi", "Noto Sans Tamil",
    "Noto Sans Telugu", "Noto Sans Kannada", "Noto Sans Malayalam", "Noto Sans Oriya", "Nirmala UI", sans-serif;

  container-type: inline-size;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 210 / 297;  /* A4 portrait */
  overflow: hidden;
  background: var(--bd-bg);
  color: var(--bd-ink);
  font-family: var(--bd-text), var(--bd-script-text);
  border-radius: 2px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  text-rendering: optimizeLegibility;
}
.bd *, .bd *::before, .bd *::after { box-sizing: border-box; }
.bd [hidden] { display: none !important; }
.bd p, .bd dl, .bd dd, .bd dt { margin: 0; }

/* ---------- Frame: the content box that must fit on one page ---------- */
.bd__frame {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 8cqi 8cqi 7cqi;
  font-size: calc(var(--bd-base) * var(--bd-fit));
  line-height: 1.4;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.bd__frame > * { flex-shrink: 0; }
.bd__name.is-empty { opacity: .45; }
.bd .bd__title.is-blessing { text-transform: none; letter-spacing: .02em; font-size: 1.05em; }   /* preview placeholder before a name is typed */

/* Long biodata that cannot fit one page even at the smallest text size:
   grow to two pages instead of clipping anything. */
.bd.is-long { aspect-ratio: auto; height: auto; }
.bd.is-long .bd__frame { position: relative; inset: auto; min-height: 282.86cqi; overflow: visible; } /* exactly two A4 pages */
.bd__row { break-inside: avoid; }

/* ---------- Title, header, photo ---------- */
.bd__title {
  text-align: center;
  font-size: .82em;
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--bd-accent);
  margin-bottom: 1.4em;
}
.bd__head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1em; }
.bd__photo {
  flex: none;
  width: 11.5em;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: .8em;
  background: #ECE5DA;
  color: #CDBFAD;
}
.bd__photo-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bd__photo-ph { display: none; width: 100%; height: 100%; fill: currentColor; }
.bd--placeholder .bd__photo-ph { display: block; }
.bd--no-photo .bd__photo { display: none; }

.bd__name {
  font-family: var(--bd-display), var(--bd-script-display);
  font-weight: 700;
  font-size: 2.6em;
  line-height: 1.08;
  color: var(--bd-ink);
}
.bd__tagline { margin-top: .35em; font-size: 1.05em; color: var(--bd-soft); }

/* Optional top motif (e.g. Ganesh Royal); hidden unless a design shows it */
.bd__motif { display: none; }

/* Ornamental divider (tinted with mask so each design can recolour it) */
.bd__divider {
  display: block;
  width: 18em;
  max-width: 70%;
  height: 1.2em;
  margin: 1.4em auto;
  background: var(--bd-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 8'%3E%3Cpath d='M0 4h46M74 4h46' stroke='%23000' stroke-width='.8'/%3E%3Cpath d='M60 0l4 4-4 4-4-4zM52 4l2.2-2.2L56.4 4l-2.2 2.2zM63.6 4l2.2-2.2L68 4l-2.2 2.2z' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 8'%3E%3Cpath d='M0 4h46M74 4h46' stroke='%23000' stroke-width='.8'/%3E%3Cpath d='M60 0l4 4-4 4-4-4zM52 4l2.2-2.2L56.4 4l-2.2 2.2zM63.6 4l2.2-2.2L68 4l-2.2 2.2z' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Sections & rows ---------- */
.bd__body { display: flex; flex-direction: column; gap: 1.15em; }
.bd__sec { break-inside: avoid; }
.bd__sec-title {
  font-size: .92em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--bd-accent);
  margin-bottom: .45em;
}
.bd__row { display: grid; grid-template-columns: 34% 1fr; gap: .9em; padding: .14em 0; }
.bd__row dt { font-weight: 600; color: var(--bd-soft); }
.bd__row dd { color: var(--bd-ink); white-space: pre-line; }

/* ---------- Corners (hidden unless a design enables them) ---------- */
.bd__decor { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.bd__frame { z-index: 1; }
.bd__corner {
  display: none;
  position: absolute;
  width: 13cqi;
  height: 13cqi;
  background: var(--bd-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23000'%3E%3Cpath d='M4 58V16Q4 4 16 4h42' stroke-width='1.6'/%3E%3Cpath d='M9 58V19q0-10 10-10h39' stroke-width='.7'/%3E%3C/g%3E%3Cg fill='%23000'%3E%3Ccircle cx='16' cy='16' r='3'/%3E%3Cpath d='M16 16c6-9 15-9 20-4-7 0-13 2-20 4zM16 16c-9 6-9 15-4 20 0-7 2-13 4-20zM19 19c7 1 12 5 13 11-5-3-9-6-13-11z'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%23000'%3E%3Cpath d='M4 58V16Q4 4 16 4h42' stroke-width='1.6'/%3E%3Cpath d='M9 58V19q0-10 10-10h39' stroke-width='.7'/%3E%3C/g%3E%3Cg fill='%23000'%3E%3Ccircle cx='16' cy='16' r='3'/%3E%3Cpath d='M16 16c6-9 15-9 20-4-7 0-13 2-20 4zM16 16c-9 6-9 15-4 20 0-7 2-13 4-20zM19 19c7 1 12 5 13 11-5-3-9-6-13-11z'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}
.bd__corner--tl { top: 2.5cqi; left: 2.5cqi; }
.bd__corner--tr { top: 2.5cqi; right: 2.5cqi; transform: scaleX(-1); }
.bd__corner--bl { bottom: 2.5cqi; left: 2.5cqi; transform: scaleY(-1); }
.bd__corner--br { bottom: 2.5cqi; right: 2.5cqi; transform: scale(-1, -1); }

/* ---------- Watermark (free downloads) ---------- */
.bd__watermark {
  position: absolute;
  left: 0; right: 0; bottom: 2.4cqi;
  z-index: 2;
  text-align: center;
  font-family: var(--bd-text), var(--bd-script-text);
  font-size: 1.25cqi;
  letter-spacing: .06em;
  color: var(--bd-soft);
  opacity: .7;
}
.bd--no-watermark .bd__watermark { display: none; }

/* ---------- Hindi / Devanagari typography ----------
   Devanagari has no capitals and breaks when letter-spaced; it also needs
   more line height for matras. */
.bd:not(:lang(en)) { --bd-display: "Tiro Devanagari Hindi", "Noto Serif Devanagari", "Nirmala UI", "Mangal", serif; }
.bd:not(:lang(en)) .bd__frame { line-height: 1.55; }
.bd:not(:lang(en)) .bd__title,
.bd:not(:lang(en)) .bd__sec-title { text-transform: none; letter-spacing: 0; }
.bd:not(:lang(en)) .bd__title { font-size: 1.05em; }
.bd:not(:lang(en)) .bd__sec-title { font-family: var(--bd-display), var(--bd-script-display); font-weight: 400; font-size: 1.12em; }
.bd:not(:lang(en)) .bd__name { font-family: var(--bd-display), var(--bd-script-display); font-weight: 400; line-height: 1.3; }
.bd:not(:lang(en)) .bd__row dt { font-weight: 500; }
.bd:not(:lang(en)) .bd__row dt,
.bd:not(:lang(en)) .bd__row dd { overflow-wrap: anywhere; }
/* Scripts with tall letters need a little more line height */
.bd:is(:lang(ta), :lang(ml), :lang(te), :lang(kn), :lang(or), :lang(bn)) .bd__frame { line-height: 1.6; }

/* ==========================================================================
   Print: only the prepared A4 page is printed (see #printArea in creator).
   ========================================================================== */
.print-area { position: fixed; left: -10000px; top: 0; width: 210mm; pointer-events: none; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { width: 210mm; height: 297mm; margin: 0 !important; padding: 0 !important; background: #fff !important; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { position: static; left: 0; width: 210mm; height: 297mm; overflow: hidden; }
  .print-area .bd { width: 210mm; height: 297mm; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
  .print-area:has(.bd.is-long), .print-area .bd.is-long { height: auto; overflow: visible; }
  /* Not paid yet (browser Ctrl+P): print a notice instead of the biodata. */
  .print-area.is-locked .bd { display: none !important; }
  .print-area.is-locked::before {
    content: "Please use the Download PDF button on MakeMyBio to download your biodata.";
    display: block; padding: 40mm 20mm; font: 16pt/1.5 sans-serif; text-align: center; color: #444;
  }
}

/* Two-column designs built as a wrapping flex column need a definite height
   to keep their columns when they grow to two pages. */

.bd--signature.is-long .bd__frame,
.bd--professional.is-long .bd__frame,
.bd--black-luxury.is-long .bd__frame,
.bd--modern-luxury.is-long .bd__frame { height: 282.86cqi; }
