/* Thereish shared-job viewer. No inline styles anywhere: the CSP is style-src 'self'. */

:root {
  --bg: #F6F8F7;
  --surface: #FFFFFF;
  --ink: #111114;
  --heading: #172A46;
  --muted: #3A4A63;
  --subtle: #5A6A80;
  --qty: #6B6B70;
  --line: #DCE2DF;
  --chip: #E7ECEA;
  --green: #247457;
  --green-hover: #1B5A43;
  --orange: #C2410C;
  --mark-ring: #172A46;
  --mark-dot: #3FA97F;
  --tile-a: #C9D3CF;
  --tile-b: #9FB0AA;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1621;
    --surface: #16212F;
    --ink: #ECEFF3;
    --heading: #E8EEF7;
    --muted: #B4BFCE;
    --subtle: #9AA7B8;
    --qty: #A3A9B3;
    --line: #2A3747;
    --chip: #1F2B3A;
    --green: #4FBF8E;
    --green-hover: #7AD3AC;
    --orange: #F59E66;
    --mark-ring: #E8EEF7;
    --mark-dot: #3FA97F;
    --tile-a: #2A3747;
    --tile-b: #3B4B5E;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

a { color: var(--green); }
a:hover { color: var(--green-hover); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px max(20px, env(safe-area-inset-right)) 30px max(20px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.job { display: flex; flex-direction: column; gap: 20px; }

/* Header */
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.brand strong { color: var(--heading); }
.mark { flex: none; }
.mark-ring { fill: none; stroke: var(--mark-ring); stroke-width: 9; }
.mark-dot { fill: var(--mark-dot); }
.print-link {
  display: none;
  border: 0;
  background: none;
  padding: 4px 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.print-link:hover { color: var(--green-hover); }

/* Site */
.heading { display: flex; flex-direction: column; gap: 6px; }
.site {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--heading);
}
.address { margin: 0; font-size: 15px; color: var(--muted); }

/* Chips */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--chip);
  font-size: 14px;
}
.chip-icon {
  flex: none;
  fill: none;
  stroke: var(--heading);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Card and sections */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.block, .section { display: flex; flex-direction: column; gap: 4px; }
.photos-section { gap: 8px; }
.label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
}
.label-done { color: var(--green); }
.label-found { color: var(--heading); }
.label-follow-up { color: var(--orange); }
.body { margin: 0; font-size: 16px; line-height: 1.45; white-space: pre-wrap; }
.notes { color: var(--muted); }

/* Products */
.products { list-style: none; margin: 0; padding: 0; }
.product {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.product-name { display: flex; flex-direction: column; gap: 2px; }
.product-note { font-size: 13px; color: var(--subtle); white-space: pre-wrap; }
.product-qty { flex: none; color: var(--qty); }

/* Locations page (/l). The download button has its own style, shown at every width:
   .print-link is hidden on phones. */
.actions { margin: 0; }
.download {
  display: inline-block;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.download:hover { border-color: var(--green-hover); color: var(--green-hover); }
.places { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.place {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.place:last-child { border-bottom: 0; }   /* the footer draws the line below the list */
.place-name { font-size: 16px; font-weight: 600; color: var(--heading); }
.place-detail { font-size: 14px; color: var(--subtle); }

/* Photos */
.photos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}
.photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--tile-a), var(--tile-b));
  cursor: zoom-in;
}
.photo:disabled { cursor: default; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-icon {
  fill: none;
  stroke: #FFFFFF;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.photo-failed { cursor: default; }
.photo-failed .photo-icon { opacity: 0.5; }
.small { margin: 0; font-size: 13px; color: var(--subtle); }

/* Footer */
.footer {
  font-size: 12px;
  color: var(--subtle);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.footer p { margin: 0; }

/* Full-size photo */
.lightbox {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000000;
  color: #FFFFFF;
}
.lightbox[open] { display: flex; flex-direction: column; }
.lightbox::backdrop { background: rgba(0, 0, 0, 0.9); }
.lightbox-img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
}
.lightbox-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-button:hover { background: rgba(255, 255, 255, 0.28); }
.lightbox-button:focus-visible { outline-color: #FFFFFF; }
.lightbox-count { min-width: 4em; text-align: center; font-size: 14px; }
.lightbox-close { margin-left: auto; }

/* Computer */
@media (min-width: 640px) {
  .page { padding: 48px 40px; gap: 24px; }
  .job { gap: 24px; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .print-link:not([hidden]) { display: inline-block; }
}

@media (prefers-reduced-motion: no-preference) {
  .photo img { animation: fade-in 160ms ease-out; }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
}

/* Print: black on white, no controls, photos kept in a compact grid. */
@media print {
  :root {
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --ink: #000000;
    --heading: #172A46;
    --muted: #333333;
    --subtle: #444444;
    --qty: #333333;
    --line: #BBBBBB;
    --chip: #FFFFFF;
    --green: #247457;
    --orange: #C2410C;
    --mark-ring: #172A46;
  }
  @page { margin: 16mm; }
  body { font-size: 11pt; }
  .page { max-width: none; padding: 0; gap: 14px; }
  .job { gap: 14px; }
  .print-link, .download, .lightbox, noscript { display: none !important; }
  .chip { border: 1px solid var(--line); padding: 3px 8px; }
  .card { border-radius: 8px; padding: 12px; break-inside: avoid; }
  .label { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .product, .place, .block { break-inside: avoid; }
  .photos { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .photo { background: none; border: 1px solid var(--line); border-radius: 6px; break-inside: avoid; }
  .photo:not(:has(img)) { display: none; }
  .footer { break-inside: avoid; }
  .footer a::after { content: ""; }
}
