/* print.css - "In kết quả" (print.js).
   Self-contained: every rule here targets only .print-results-btn,
   .home-heading-actions or #print-results, plus print rules that apply
   only while the print window is open (html.pr-open). Normal Ctrl+P /
   browser printing of the site is not affected. Uses the colour tokens
   from styles.css (--red, --red-deep, --ink, --muted, --panel-edge). */

/* ---------- Buttons on Home and Kết quả ---------- */
.home-heading-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.print-results-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1.5px solid var(--red);
  border-radius: 11px;
  background: #fff;
  color: var(--red-deep);
  font: 700 13px "Be Vietnam Pro", sans-serif;
  white-space: nowrap;
  cursor: pointer;
}
/* Phones: the title keeps its own line; the buttons sit in a row under it
   (left: In kết quả, right: Lịch quay). Only the Home heading that holds
   the print button is affected. */
@media (max-width: 700px) {
  .home-section-heading:has(> .home-heading-actions) {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .home-heading-actions {
    flex-basis: 100%;
    justify-content: space-between;
  }
}
.print-results-btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.print-results-btn:hover {
  background: #fff1ef;
}
.print-results-btn:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* ---------- Overlay ---------- */
html.pr-open,
html.pr-open body {
  overflow: hidden;
}
#print-results {
  position: fixed;
  inset: 0;
  z-index: 10000;
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--ink);
}
#print-results[hidden],
#print-results [hidden] {
  display: none !important;
}
.pr-scrim {
  position: absolute;
  inset: 0;
  background: rgba(33, 29, 27, .45);
}

/* Step 2: choose one province. Centered dialog on computers, bottom sheet on phones. */
.pr-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(33, 29, 27, .28);
  overflow: hidden;
}
.pr-head {
  margin: 0; /* styles.css gives every <header> margin-bottom: 40px */
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--panel-edge);
}
.pr-grab {
  display: none;
}
.pr-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pr-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.01em;
}
.pr-x {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 8px;
}
.pr-x:focus-visible,
.pr-back:focus-visible,
.pr-print-now:focus-visible,
.pr-link:focus-visible,
.pr-opt:focus-within {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.pr-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px;
  display: grid;
  grid-auto-rows: max-content;
  gap: 12px;
}
.pr-date {
  display: grid;
  gap: 5px;
}
.pr-date > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.pr-date strong {
  font-size: 15px;
}
.pr-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pr-fields.pr-fields-one {
  grid-template-columns: minmax(0, 1fr);
}
.pr-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.pr-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.pr-field select,
.pr-date-btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #e8ded3;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 600 15px "Be Vietnam Pro", sans-serif;
}
.pr-field select:focus-visible,
.pr-date-btn:focus-visible,
.pr-cal button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
@media (max-width: 700px) {
  .pr-fields {
    grid-template-columns: 1fr;
  }
}
.pr-schedule {
  margin: -2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--red-deep);
}
.pr-date-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}
.pr-date-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
}
.pr-date-btn[aria-expanded="true"] {
  border-color: var(--red);
}
.pr-date-btn:disabled {
  cursor: default;
  color: var(--muted);
}
/* Calendar: only days with a result are buttons. */
.pr-cal {
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  padding: 10px;
}
.pr-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.pr-cal-head strong {
  font-size: 14px;
}
.pr-cal-nav {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #faf6f1;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.pr-cal-nav:disabled {
  opacity: .35;
  cursor: default;
}
.pr-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.pr-cal-wd {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 2px 0;
}
.pr-cal-day {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 10px;
  font-size: 14px;
  color: #c9bfb6;
  font-variant-numeric: tabular-nums;
}
.pr-cal-day.today {
  box-shadow: inset 0 0 0 1px #e8ded3;
}
button.pr-cal-day.has {
  border: 1px solid #f1c9c3;
  background: #fff1ef;
  color: var(--red-deep);
  font: 700 14px "Be Vietnam Pro", sans-serif;
  cursor: pointer;
}
button.pr-cal-day.has:hover {
  border-color: var(--red);
}
button.pr-cal-day.sel {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.pr-cal-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.pr-note {
  padding: 18px 12px;
  border: 1px dashed var(--panel-edge);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.pr-note-sub {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}
.pr-link {
  display: block;
  margin: 8px auto 0;
  border: 0;
  background: none;
  color: var(--red);
  font: 700 14px "Be Vietnam Pro", sans-serif;
  cursor: pointer;
}
.pr-group {
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  overflow: hidden;
}
.pr-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #faf6f1;
}
.pr-group-name {
  font-weight: 700;
  font-size: 14px;
}
.pr-group-head small {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.pr-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid #f4ece4;
  font-size: 14px;
  cursor: pointer;
}
.pr-group-head + .pr-opt {
  border-top: 1px solid var(--panel-edge);
}
.pr-group > .pr-opt:first-child {
  border-top: 0;
}
.pr-opt input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--red);
}
.pr-opt.is-off {
  color: var(--muted);
  cursor: default;
}
.pr-why {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--red-deep);
}
.pr-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
/* Note for agents, in the panel (not printed) */
.pr-agent {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--red);
  border-radius: 6px;
  background: #fdf0ee;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}
.pr-agent strong {
  color: var(--red-deep);
}
/* "In theo tỉnh" / "In theo ngày" */
.pr-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: #faf6f1;
}
.pr-mode button {
  border: 0;
  border-radius: 999px;
  padding: 9px 10px;
  background: none;
  color: var(--muted);
  font: 600 14px "Be Vietnam Pro", sans-serif;
  cursor: pointer;
}
.pr-mode button[aria-checked="true"] {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 12px rgba(227, 58, 54, .18);
}
.pr-mode button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
.pr-opt-name {
  display: block;
  font-size: 14px;
}
.pr-opt-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.pr-foot {
  margin: 0; /* styles.css gives every <footer> margin-top + muted 12px text */
  padding: 12px 18px 16px;
  border-top: 1px solid var(--panel-edge);
  font-size: 14px;
  color: var(--ink);
  display: grid;
  gap: 8px;
}
.pr-summary {
  min-height: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.pr-foot .pr-go {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
}
.pr-foot .pr-go:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 700px) {
  .pr-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
  }
  .pr-grab {
    display: block;
    width: 38px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 4px;
    background: var(--panel-edge);
  }
  .pr-foot {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* Step 3: preview. Full screen; pages are real A4 size, scaled by print.js. */
.pr-preview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #e9e4de;
}
.pr-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: #fff;
  border-bottom: 1px solid var(--panel-edge);
}
.pr-back {
  border: 0;
  background: none;
  color: var(--ink);
  font: 700 14px "Be Vietnam Pro", sans-serif;
  padding: 8px 4px;
  cursor: pointer;
}
.pr-toolbar-info {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.pr-print-now {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 18px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: #fff;
  font: 700 15px "Be Vietnam Pro", sans-serif;
  cursor: pointer;
}
.pr-print-now svg {
  width: 18px;
  height: 18px;
}
.pr-pages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 12px calc(22px + env(safe-area-inset-bottom, 0px));
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 26px;
}
.pr-page-fit {
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .16);
}

/* ---------- The printed page: 4 copies of one card (sizes in mm) ---------- */
/* Page content area = A4 (210 x 297) minus 6mm margins = 198 x 285.
   284mm (not 285) keeps rounding from spilling a blank extra page. */
.pr-page {
  width: 198mm;
  height: 284mm;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  background: #fff;
  color: #111;
  transform-origin: top left;
  font-family: "Be Vietnam Pro", Arial, sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.pr-card {
  /* Same fonts as the printed result sheets: numbers Arial Bold, prize
     labels + titles Times New Roman (Arimo / Tinos = metric-compatible). */
  --pr-num-font: "Arimo", Arial, "Helvetica Neue", Helvetica, sans-serif;
  --pr-label-font: "Tinos", "Times New Roman", Times, serif;
  /* Prints are often black-and-white, so the two key rows stand out by
     shape and size, not only by red: the lowest prize in a heavy display
     face, Đặc Biệt in bold Times between thick rules. */
  --pr-low-font: "Abril Fatface", "Times New Roman", Times, serif;
  font-family: var(--pr-label-font); /* all card text; numbers + phone override */
  border: .4mm dashed #999;
  padding: 2.2mm 2.6mm;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
/* Top band: [V] title | đổi vé phone | QR. Everything below it is numbers. */
.pr-card-head {
  margin: 0; /* overrides the site-wide header margin */
  display: flex;
  align-items: center;
  gap: 1.6mm;
  padding-bottom: .8mm;
  border-bottom: .6mm solid #111;
}
.pr-mark {
  width: 6.25mm; /* logo is 80 x 64: same 5mm height as the old [V] mark */
  height: 5mm;
  flex: none;
}
.pr-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.pr-title {
  flex: 1;
  min-width: 0;
  line-height: 1.1;
}
.pr-title strong {
  display: block;
  font-size: 2.4mm;
  letter-spacing: .03em;
  color: #333;
}
.pr-title h3 {
  margin: 0;
  font-size: 5.4mm;
  line-height: 1.05;
  color: #111;
  overflow-wrap: anywhere;
}
.pr-title h3 small {
  font-size: 2.3mm;
  font-weight: 400;
  color: #444;
}
.pr-table {
  width: 100%;
  flex: 1;
  border-collapse: collapse;
}
.pr-table th,
.pr-table td {
  padding: .4mm .8mm;
  border-top: .25mm solid #ccc;
  vertical-align: middle;
}
.pr-table th {
  width: 15mm;
  text-align: left;
  font-size: 2.7mm;
  font-weight: 700;
  color: #444;
  white-space: nowrap;
}
.pr-table td {
  text-align: center;
  font: 700 9.4mm/1.02 var(--pr-num-font);
  color: #111;
  font-variant-numeric: tabular-nums;
}
.pr-nums {
  /* Numbers sit in equal-width columns (--cols per line); flex instead of
     grid so a short last line (Giải tư: 3 + 3 + 1) is centered. */
  --cols: 1;
  --gap: 2.5mm;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 var(--gap);
}
.pr-nums span {
  flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
}
.pr-c2 { --cols: 2; }
.pr-c3 { --cols: 3; }
.pr-c4 { --cols: 4; }
.pr-table .pr-c3 { font-size: 8.1mm; } /* 3 five-digit numbers per line (Miền Bắc Giải ba) must fit the width */
.pr-table .pr-c4 { font-size: 7.3mm; } /* 4 numbers per line: the width allows no more */
.pr-table tr.pr-low .pr-c4 { font-size: 11mm; } /* Miền Bắc Giải bảy: four 2-digit numbers, room to stay big */
.pr-table .pr-n7 { --cols: 3; --gap: 2mm; font-size: 8.2mm; } /* Nam/Trung Giải tư: 7 numbers as 3 + 3 + 1 */
.pr-table tr.pr-low td,
.pr-table tr.pr-db td {
  color: #000; /* black, not red: on a B&W printer red comes out as a washed-out grey */
}
.pr-table tr.pr-db {
  background: #ececec;
}
.pr-table tr.pr-db th,
.pr-table tr.pr-db td {
  border-top: .6mm solid #111;
  border-bottom: .6mm solid #111;
}
.pr-table tr.pr-db td {
  font: 700 13mm/1.05 var(--pr-label-font);
}
.pr-table tr.pr-low td {
  font: 400 12mm/1 var(--pr-low-font);
}
/* "In theo ngày": all provinces of a region side by side (like the site's
   results table), one number per line in each column. */
.pr-day-table {
  width: 100%;
  flex: 1;
  margin-top: .6mm;
  border-collapse: collapse;
  table-layout: fixed;
}
.pr-day-table th,
.pr-day-table td {
  padding: .2mm .4mm;
  border-top: .25mm solid #ccc;
  vertical-align: middle;
  text-align: center;
}
.pr-day-table td,
.pr-day-table thead th + th {
  border-left: .25mm solid #e0e0e0;
}
.pr-day-table thead th {
  border-top: 0;
  padding-bottom: .4mm;
  font-size: 3.1mm;
  font-weight: 700;
  line-height: 1.15;
  color: #111;
  overflow-wrap: anywhere;
}
.pr-day-table thead th small {
  display: block;
  margin-top: .2mm;
  font-size: 1.8mm;
  font-weight: 500;
  color: #555;
}
.pr-day-table thead th:first-child,
.pr-day-table tbody th {
  width: 13mm;
}
.pr-day-table tbody th {
  text-align: left;
  font-size: 2.5mm;
  font-weight: 700;
  color: #444;
  line-height: 1.05;
}
.pr-day-table td {
  font: 700 5.6mm var(--pr-num-font);
  color: #111;
  font-variant-numeric: tabular-nums;
}
.pr-day-table td span {
  display: block;
  line-height: 1;
}
.pr-day-table tr.pr-low td,
.pr-day-table tr.pr-db td {
  color: #000;
}
.pr-day-table tr.pr-db {
  background: #ececec;
}
.pr-day-table tr.pr-db th,
.pr-day-table tr.pr-db td {
  border-top: .5mm solid #111;
  border-bottom: .5mm solid #111;
}
.pr-day-table tr.pr-db td {
  font: 700 7mm var(--pr-label-font);
}
/* Đặc Biệt: same heavy display face as the lowest prize (bigger, on a grey
   band between thick rules) so it stands out on a B&W printout. */
.pr-table tr.pr-db td,
.pr-day-table tr.pr-db td {
  font-family: var(--pr-low-font);
  font-weight: 400;
}
.pr-day-table tr.pr-low td {
  font: 400 7.5mm/1 var(--pr-low-font);
}
.pr-day-table.pr-cols-4 td {
  font-size: 5.6mm;
}
.pr-day-table.pr-cols-4 tr.pr-db td {
  font-size: 5.1mm;
}
.pr-day-table.pr-cols-4 tr.pr-low td {
  font-size: 7mm;
}
.pr-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* Prize amount under each prize name, and the line under the table */
.pr-amt {
  display: block;
  margin-top: .2mm;
  font-size: 2.3mm;
  font-weight: 400;
  color: #c8102e;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.pr-day-table .pr-amt {
  margin-top: 0;
  font-size: 1.8mm;
}
.pr-contact {
  flex: none;
  text-align: right;
  line-height: 1.15;
}
.pr-contact small {
  display: block;
  font-size: 2.3mm;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #111;
}
.pr-contact strong {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1mm;
  font: 700 4.2mm var(--pr-num-font);
  color: #111;
  white-space: nowrap;
}
.pr-contact strong svg {
  width: 3.6mm;
  height: 3.6mm;
  flex: none;
}
.pr-qr {
  width: 10.5mm;
  height: 10.5mm;
  flex: none;
}
.pr-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
/* Bottom: extra prizes + the site, one short centered line */
.pr-card-foot {
  margin: 0; /* overrides the site-wide footer rule */
  padding-top: .6mm;
  border-top: .6mm solid #111;
  text-align: center;
  font-size: 2.2mm;
  line-height: 1.25;
  color: #333;
}
.pr-card-foot b {
  color: #111;
}

/* ---------- Printing (only while the print window is open) ---------- */
@media print {
  @page {
    size: A4;
    margin: 6mm;
  }
  html.pr-open,
  html.pr-open body {
    overflow: visible !important;
    height: auto !important;
    background: #fff !important;
  }
  html.pr-open body > *:not(#print-results) {
    display: none !important;
  }
  html.pr-open #print-results {
    position: static;
  }
  html.pr-open .pr-scrim,
  html.pr-open .pr-panel,
  html.pr-open .pr-toolbar {
    display: none !important;
  }
  html.pr-open .pr-preview {
    position: static;
    display: block;
    background: #fff;
  }
  html.pr-open .pr-pages {
    display: block;
    padding: 0;
    overflow: visible;
  }
  html.pr-open .pr-page-fit {
    width: auto !important;
    height: auto !important;
    overflow: visible;
    box-shadow: none;
  }
  html.pr-open .pr-page {
    transform: none !important;
  }
}
