/* Saving, projects, File menu, print. Uses the colours and classes from app.css. */

/* ---------- top bar: save status, Projects, File ---------- */
.top-actions { align-items: center; }
.save-status { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.save-status[data-state="error"] { color: var(--danger); font-weight: 600; }

.menu > summary.top-btn::-webkit-details-marker { display: none; }
.menu > summary.top-btn { list-style: none; }
.menu-pop button:disabled { opacity: .4; cursor: default; background: transparent; }
.menu-pop button { color: var(--text); font-size: 15px; }

@media (min-width: 721px) {
  .top-btn {
    display: inline-flex; align-items: center; gap: 8px; width: auto; padding: 0 14px 0 12px;
    border-radius: 999px; color: var(--text); font-size: 14px; font-weight: 560;
  }
  .top-btn:hover { border-color: var(--muted); }
  .top-actions .menu-pop { left: auto; right: 0; min-width: 290px; }
}

@media (max-width: 720px) {
  .top-btn .lbl { display: none; }
  .top-actions { gap: 6px; }
  /* just a coloured dot on a phone; the words stay for screen readers */
  .save-status { font-size: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--done); flex: none; }
  .save-status[data-state="saving"] { background: var(--highlight); }
  .save-status[data-state="error"] { background: var(--danger); }
  .menu-pop button { min-height: 46px; }
}
@media (max-width: 380px) {
  .brand-name { display: none; }
}

/* ---------- Projects ---------- */
.dlg-projects { width: min(720px, calc(100vw - 24px)); }
.dlg-projects .dlg-form { padding: 16px; }
.dlg-projects .dlg-body { max-height: min(64vh, 600px); overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; }
.pj-new { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.pj-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 10px; }
.pj-empty { padding: 20px 8px; text-align: center; color: var(--muted); }

.pj-card { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px 12px; padding: 12px; min-width: 0; }
.pj-thumb {
  width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.pj-thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; image-rendering: pixelated; }
.pj-nothumb { width: 100%; height: 100%; background: var(--surface-2); }
.pj-info { min-width: 0; }
.pj-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-open-badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; vertical-align: 1px;
  background: var(--accent-soft); color: var(--text); font-size: 12px; font-weight: 600;
}
.pj-line { color: var(--muted); font-size: 13px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.pj-bar { height: 6px; margin-top: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.pj-bar span { display: block; height: 100%; background: var(--done); }
.pj-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 480px) {
  .dlg-projects { width: calc(100vw - 16px); }
  .pj-new .btn { flex: 1 1 140px; }
  .pj-actions .btn { flex: 1 1 0; padding: 0 8px; }
  .pj-actions .btn .ico { display: none; }
}

/* ---------- Print ---------- */
#printArea { display: none; }

#printArea .pr-page { font-family: var(--font); color: #000; }
#printArea h1 { margin: 0 0 2mm; font: 700 20pt/1.2 var(--font-display); letter-spacing: -.01em; }
#printArea h2 { margin: 0 0 3mm; font: 650 12pt/1.2 var(--font-display); }
#printArea .pr-size { margin: 0; font-size: 10.5pt; color: #444; }
#printArea .pr-chart {
  display: block; margin: 6mm auto 0; width: auto; height: auto;
  max-width: 100%; max-height: 205mm;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
#printArea .pr-notes { margin: 5mm 0 0; font-size: 9.5pt; color: #333; white-space: pre-wrap; }
#printArea .pr-foot { margin: 4mm 0 0; font-size: 8pt; color: #888; text-align: right; }
#printArea .pr-rows { break-before: page; page-break-before: always; font-family: var(--font); color: #000; }
#printArea .pr-cols { column-count: 2; column-gap: 8mm; font-size: 7.5pt; line-height: 1.35; }
#printArea .pr-cols p { margin: 0 0 1.3mm; break-inside: avoid; }
#printArea .pr-cols .pr-legend { color: #444; margin-bottom: 3mm; }

/* To look at the print page on screen: add class "print-preview" to <body> (in the console). */
body.print-preview .app, body.print-preview .toast { display: none; }
body.print-preview #printArea {
  display: block; box-sizing: border-box; width: 210mm; max-width: 100%; margin: 12px auto; padding: 14mm;
  background: #fff; color: #000; box-shadow: var(--shadow-lg);
}
body.print-preview { overflow: auto; height: auto; }
body.print-preview html, html:has(body.print-preview) { height: auto; }

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000 !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
}
