/* ===========================================================================
   Photo markup (markup.js, markupdraw.js, snapshotphotos.js, photolightbox.js).
   Its own file because admin.html does not load styles.css, and the editor
   opens there too (the building page's photos). Loaded after each page's own
   styles; admin's tokens differ a little, hence the fallbacks just below.
   =========================================================================== */
:root {
  --mk-panel-2: var(--panel-2, var(--panel2, #f0efed));
  --mk-info: var(--info, #1f5f8f);
}
/* admin.html styles every <button> as a big red one; nothing here wants its
   minimum height (each control sets its own). Zero specificity past the tag,
   so every class below still wins. */
:where(.mk, .mk-choice, .viewer-bar) button { min-height: 0; }

/* The viewer's "View original" / "Edit" (viewer.js) — words, not icons: a
   contractor should not have to guess which picture they are looking at. */
.viewer-textbtn {
  appearance: none; cursor: pointer; flex: none;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f3f4f1; font-family: inherit; font-size: 0.9rem; font-weight: 600; white-space: nowrap;
}
.viewer-textbtn:active { background: var(--accent); border-color: var(--accent); color: #fff; }
.viewer-textbtn[aria-pressed="true"] { background: #f3f4f1; color: var(--dark); }
.viewer-textbtn[hidden] { display: none; }
.viewer-textbtn:disabled { opacity: 0.5; cursor: default; }
.viewer-textbtn:disabled:active { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.14); color: #f3f4f1; }
/* Under the bar, while Edit waits for marks still saving (viewer.js
   #paintEdit) — the tile's words for it (markedphotos.js#marksWords). */
.viewer-note {
  margin: 0; padding: 8px 14px; z-index: 2;
  background: rgba(25, 25, 21, 0.92); border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f3f4f1; font-size: 0.85rem; font-weight: 600;
}
.viewer-note[hidden] { display: none; }
@media (max-width: 420px) { .viewer-bar .viewer-count { display: none; } }

/* The editor: the viewer's warm-dark stage, the picture fitted to it, tools
   under the thumb. Nothing under the picture scrolls or zooms (touch-action),
   so a finger only ever draws. */
body.mk-open { overflow: hidden; }
.mk {
  position: fixed; inset: 0; z-index: 200;
  background: var(--dark); color: #f3f4f1;
  display: flex; flex-direction: column;
}
.mk-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(25, 25, 21, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mk-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-btn {
  appearance: none; cursor: pointer; flex: none;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.08);
  color: #f3f4f1; font-family: inherit; font-size: 1rem; font-weight: 600;
}
.mk-btn:disabled { opacity: 0.45; cursor: default; }
.mk-save { background: var(--accent); border-color: var(--accent); color: #fff; }
.mk-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.mk-canvas { position: absolute; inset: 0; display: block; touch-action: none; -webkit-user-select: none; user-select: none; }
.mk-loading {
  position: absolute; inset: 0; margin: 0; padding: 24px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: rgba(243, 244, 241, 0.75);
}

/* Label text and the "throw away?" question sit at the TOP of the picture,
   where a phone keyboard never covers them. */
.mk-sheet, .mk-discard {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 12px;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.mk-sheet[hidden], .mk-discard[hidden] { display: none; }
.mk-discard-text { margin: 0; font-size: 0.98rem; }
.mk-input {
  font-family: inherit; font-size: 16px; /* 16px: iOS does not zoom the page */
  min-height: 48px; padding: 0 12px;
  border: 1px solid var(--ink-4); border-radius: 10px; color: var(--ink); background: #fff;
}
.mk-input:focus-visible { outline: 3px solid var(--mk-info); outline-offset: 1px; }
.mk-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-sheet .mk-btn, .mk-discard .mk-btn { background: var(--mk-panel-2); border-color: var(--line); color: var(--ink); }
.mk-sheet .mk-sheet-done, .mk-discard .mk-discard-yes { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.mk-sheet-remove[hidden] { display: none; }

.mk-tools {
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(25, 25, 21, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.mk-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mk-group { display: flex; align-items: center; gap: 6px; }
.mk-tool {
  appearance: none; cursor: pointer;
  min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18); background: transparent;
  color: #f3f4f1; font-family: inherit; font-size: 0.95rem; font-weight: 600;
}
.mk-tool[aria-checked="true"] { background: #f3f4f1; border-color: #f3f4f1; color: var(--dark); }
.mk-tool:disabled { opacity: 0.35; cursor: default; }
.mk-icon { padding: 0; font-size: 1.35rem; }
.mk-swatch, .mk-size {
  appearance: none; cursor: pointer; padding: 0;
  width: 40px; height: 40px; flex: none;
}
.mk-swatch { border-radius: 50%; background: var(--swatch); border: 2px solid rgba(255, 255, 255, 0.35); }
.mk-swatch[aria-checked="true"] { outline: 3px solid #f3f4f1; outline-offset: 2px; }
.mk-size {
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.18); background: transparent;
  display: flex; align-items: center; justify-content: center;
}
.mk-size[aria-checked="true"] { background: rgba(255, 255, 255, 0.18); border-color: #f3f4f1; }
.mk-size-dot { display: block; border-radius: 50%; background: #f3f4f1; }
.mk-size-s .mk-size-dot { width: 6px; height: 6px; }
.mk-size-m .mk-size-dot { width: 11px; height: 11px; }
.mk-size-l .mk-size-dot { width: 18px; height: 18px; }
.mk-tool:focus-visible, .mk-swatch:focus-visible, .mk-size:focus-visible, .mk-btn:focus-visible {
  outline: 3px solid var(--mk-info); outline-offset: 2px;
}
.mk-status { margin: 0; min-height: 1.3em; font-size: 0.85rem; color: rgba(243, 244, 241, 0.75); }
.mk-status-err { color: #ff9e94; font-weight: 600; }

/* The choice offered on a photo the moment it is taken (snapshotphotos.js
   #captureChoice): Mark up, or Done. Under the new photo; it never covers it. */
.mk-choice { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mk-choice button {
  appearance: none; cursor: pointer; margin: 0;
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  font-family: inherit; font-size: 0.9rem; font-weight: 700; line-height: 1;
}
.mk-choice-markup { background: var(--dark); border: 1px solid var(--dark); color: #fff; }
.mk-choice-done { background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.mk-choice button:focus-visible { outline: 3px solid var(--mk-info); outline-offset: 2px; }

/* A Site Snapshot photo that can be marked up is a cell: the thumbnail, then
   its button (snapshotphotos.js). A marked-up one carries a small pen mark. */
.vr-photo-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.vr-photo-markup {
  appearance: none; cursor: pointer; margin: 0;
  min-height: 44px; min-width: 64px; padding: 0 8px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; font-size: 0.8rem; font-weight: 700; white-space: nowrap;
}
.vr-photo-markup:disabled { opacity: 0.5; cursor: default; }
.vr-photo-markup:focus-visible { outline: 3px solid var(--mk-info); outline-offset: 2px; }
.vr-photo-marked {
  position: absolute; left: 3px; bottom: 3px; z-index: 1; pointer-events: none;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.66); color: #fff; font-size: 0.72rem;
}
@media print {
  .mk-choice, .vr-photo-markup { display: none !important; }
}
