/* One stylesheet, no build step. Sized for a phone held one-handed on a stand.
 *
 * Every colour, radius and gap below comes from the Sitebulb design system, loaded as
 * tokens.css before this file. Nothing here invents a value: where the system has no
 * token for something this app needs, the rule says so rather than picking a near shade.
 *
 * The names on the left are this app's own and are what the 900 lines below reference.
 * The values on the right are the system's. Changing the brand is changing tokens.css. */

/* Filson Soft. Regular and bold only, because no view here renders light or italic. The
 * URLs are filled in at startup with the fingerprinted asset paths, the same way sw.js is
 * given its shell list, because a hash cannot be written into a static file. */

@font-face {
  font-family: 'filson-soft';
  src: url('/asset/c2a1f25fed27/fs-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'filson-soft';
  src: url('/asset/846cd0f60c83/fs-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: var(--sb-color-bg);
  --text: var(--sb-heading-h2);
  --muted: var(--sb-color-body-text);
  --line: var(--sb-color-border);
  --accent: var(--sb-color-blue);
  --accent-ink: var(--sb-color-white);
  --danger: var(--sb-severity-critical);
  --radius: var(--sb-radius-md);

  /* A panel is the page with an outline, not a lighter grey. The system has no surface
   * token for dark, and mixing one would be inventing a value it deliberately does not
   * define. Borders are how the brand separates things on a dark ground.
   *
   * The page colour rather than `transparent`, which looks the same on top of the page
   * and is not the same at all for the menu and the lightbox: those float above other
   * content, and transparent let the page show straight through them. */
  --panel: var(--sb-color-bg);

  /* The shape of the paper visitors draw on. A3 and A2 are both ISO 216, so both are
   * 1:root-2 and one number covers either. Written as A3's millimetres because that says
   * where it came from. Two places want it: the viewfinder guide staff line the paper up
   * inside, and the gallery card that shows the result. */
  --paper-aspect: 297 / 420;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute has to beat anything below, because several controls here are
 * shown and hidden by script and any rule that sets a display would otherwise silently
 * override it. That is not hypothetical: `.offline` needed its own guard for exactly
 * this, and the camera panel would have needed two more. One rule, once. */

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sb-font-body);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

/* Top bar and burger menu */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

/* The logo is white, which is right because the app is always dark. Sized by height so
   the wordmark keeps its proportions. */
.brand img {
  display: block;
  height: 28px;
  width: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The checkbox is the open/closed state. It stays focusable so the burger can be
   reached and toggled from the keyboard, and the label shows the focus ring for it. */
.menu-state {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.burger {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.burger-bars,
.burger-bars::before,
.burger-bars::after {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.burger-bars::before,
.burger-bars::after {
  content: '';
  position: relative;
}

.burger-bars::before {
  top: -6px;
}

.burger-bars::after {
  top: 4px;
}

.menu-state:focus-visible + .burger {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.menu-state:checked + .burger {
  background: var(--accent);
  border-color: var(--accent);
}

.menu-state:checked + .burger .burger-bars,
.menu-state:checked + .burger .burger-bars::before,
.menu-state:checked + .burger .burger-bars::after {
  background: var(--accent-ink);
}

/* Closed by default, so nothing flashes open before the stylesheet applies. */
.menu {
  display: none;
  position: absolute;
  z-index: 10;
  top: 100%;
  right: 0.75rem;
  min-width: 200px;
  flex-direction: column;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--sb-shadow-medium);
}

.menu-state:checked ~ .menu {
  display: flex;
}

.menu a,
.menu .linkish {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  font: inherit;
}

.menu a[aria-current='page'] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* The leads only switch. A button that reads as a toggle: the label on the left, a track
   on the right whose thumb moves across and fills with the accent when it is on. */
.setting {
  margin: 0.25rem 0 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.menu .switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease;
}

.switch[aria-checked='true'] .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch[aria-checked='true'] .switch-track::after {
  transform: translateX(16px);
  background: var(--accent-ink);
}

.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.logout {
  margin: 0.25rem 0 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.linkish {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

/* Buttons, from the brand's own button.css rather than invented here. Same structure: a
 * --button-bg and --button-color that a variant sets, and everything else shared.
 *
 * Three variants, because three is what this app has. .button_grey is the brand's
 * secondary and is deliberately not among them: it paints --sb-heading-h1, which is white
 * in dark, so it would be a white button with white text. Ghost is the secondary here. */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sb-space-xxs);
  min-width: fit-content;
  padding: var(--sb-space-xs) var(--sb-space-sm);
  border: 0;
  border-radius: var(--sb-radius-sm);
  background: var(--button-bg);
  color: var(--button-color);
  font: inherit;
  font-size: var(--sb-space-xs);
  font-weight: bold;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 200ms;
}

.button_green {
  --button-bg: var(--sb-color-green);
  --button-color: var(--sb-color-white);
}

.button_red {
  --button-bg: var(--sb-severity-critical);
  --button-color: var(--sb-color-white);
}

/* The brand's ghost: no fill, a 2px edge in the button colour, and normal weight. On this
 * dark ground the edge is the body text colour, so it reads as a control without
 * competing with the green. */

.button_ghost {
  --button-bg: var(--sb-color-body-text);

  background: none;
  border: 2px solid var(--button-bg);
  color: var(--sb-heading-h2);
  font-weight: normal;
}

/* Lock screen */

.lock {
  max-width: 320px;
  margin: 3rem auto;
  text-align: center;
}

.field {
  display: block;
  margin: 0 0 1rem;
  text-align: left;
}

.field > span {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.lock .field input {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 1.4rem;
}

.error {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* Capture form */

.capture {
  max-width: 520px;
}

/* Camera panel. Named viewfinder, not shot: `.shot` is already the gallery card's photo
 * box further down this file, and a panel that quietly inherited its frame is exactly the
 * bug this prefix avoids.
 *
 * The canvas visitors draw on is a fixed portrait rectangle, so staff get a rectangle of
 * the same shape to line it up inside. The shape itself is --paper-aspect, at the top of
 * this file, and camera.js measures the guide element rather than repeating the number,
 * so changing the canvas means changing that one value. */

.viewfinder {
  margin: 0 0 1rem;
}

/* The blacks in this panel, behind a drawing, and under the lightbox are photographic,
 * not brand surfaces: they are what a camera stage and a letterbox are made of, and the
 * design system has no token for them because sitebulb.com has no camera. They stay
 * literal rather than being mapped onto a near-enough colour. */

.viewfinder-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
}

/* Both fill the stage and sit on top of one another, so whichever is showing occupies
 * the same box. Left in the normal flow they would stack, and the second would be cut
 * off by the stage's own overflow. */

.viewfinder-live,
.viewfinder-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The preview fills the stage, and camera.js undoes exactly this cover transform to work
 * out which part of the sensor frame the guide is sitting over. */

.viewfinder-live {
  object-fit: cover;
}

/* The frozen shot is already cropped, so it is shown whole rather than filled to the
 * stage. Nothing about a review is served by hiding an edge of what will be saved. */

.viewfinder-still {
  object-fit: contain;
}

/* The guide, and the dim outside it. One element does both: the inset ring of shadow
 * spreads far enough to darken the whole stage, so what is inside the box reads as the
 * part that will be kept. */

.viewfinder-guide {
  --viewfinder-guide-aspect: var(--paper-aspect);

  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 86%;
  aspect-ratio: var(--viewfinder-guide-aspect);
  max-width: 86%;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 45%);
  outline: 2px dashed rgb(255 255 255 / 55%);
  outline-offset: -1px;
}

/* Corner brackets, in the accent, so the box is findable against a busy stand. */

.viewfinder-guide::before,
.viewfinder-guide::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent);
}

.viewfinder-guide::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.viewfinder-guide::after {
  right: -1px;
  bottom: -1px;
  border-top: 0;
  border-left: 0;
}

.viewfinder-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.6rem;
  text-align: center;
  color: var(--text);
  font-size: 0.8rem;
  text-shadow: 0 1px 3px rgb(0 0 0 / 90%);
}

.viewfinder-status {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.3em;
}

.viewfinder-status.is-error {
  color: var(--danger);
}

.viewfinder-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.field small {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.field-error {
  display: block;
  margin-top: 0.3rem;
  color: var(--danger);
  font-style: normal;
  font-size: 0.85rem;
}

.check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0 0 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.check input {
  width: 1.35rem;
  height: 1.35rem;
  margin: 0;
  flex: 0 0 auto;
}

.warning {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--sb-color-orange);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--sb-color-orange) 12%, transparent);
}

.warning p {
  margin: 0;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* Gallery */

.toggle {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1.25rem;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}

.toggle a {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.toggle a b {
  font-weight: 700;
  opacity: 0.75;
  margin-left: 0.2rem;
}

.toggle a[aria-current='page'] {
  background: var(--accent);
  color: var(--accent-ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* The whole entry card is one link into that capture. The colours are the card's own,
 * because a card painted link-yellow would be unreadable. */

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* The card is the shape of the paper, not a landscape box the drawing is cropped into.
 * A drawing photographed through the viewfinder is portrait, and a 4:3 frame took the top
 * and bottom off it, which is the one part of a drawing nobody wants trimmed.
 *
 * contain, not cover, so the whole drawing is there. A photo that does not match the
 * paper letterboxes against the black rather than losing its edges, which is what the
 * capture page already does with .full-shot. The box keeps its shape either way, so the
 * grid stays a grid. */

.shot {
  display: block;
  width: 100%;
  aspect-ratio: var(--paper-aspect);
  object-fit: contain;
  background: #000;
}

.card-body {
  padding: 0.8rem;
}

.card-body h2 {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
}

.card-body p {
  margin: 0 0 0.3rem;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.company {
  color: var(--text);
}

.email,
.meta time {
  color: var(--muted);
}

.notes {
  color: var(--muted);
  white-space: pre-wrap;
}

.meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.empty {
  padding: 2rem 0;
  color: var(--muted);
}

/* Leads table
 *
 * Leads have no photo, so they read as rows rather than cards. One markup serves both
 * widths: below the breakpoint at the end of this block the table parts become blocks
 * and each lead turns back into a card, so the leads view scans like the entries view
 * next to it on a phone. */

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.leads {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.leads th,
.leads td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.leads thead th {
  background: var(--sb-color-border);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Each lead is a tbody, so the border goes there and never lands between a lead and its
 * own notes. */

.leads tbody + tbody {
  border-top: 1px solid var(--line);
}

.leads tbody th[scope='row'] {
  font-weight: 600;
}

.leads tbody th[scope='row'] a {
  color: var(--text);
}

.leads td.email {
  color: var(--muted);
}

.leads td[data-label='Captured'] {
  color: var(--muted);
  white-space: nowrap;
}

.notes-row td {
  padding-top: 0;
  color: var(--muted);
}

.notes-row td::before {
  content: 'Notes: ';
  color: var(--muted);
  font-size: 0.78rem;
}

.notes-row .notes {
  display: block;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .table-wrap {
    background: none;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .leads,
  .leads tbody,
  .leads tr,
  .leads th,
  .leads td {
    display: block;
  }

  /* The header row has no column to label at this width; every cell names itself. */

  .leads thead {
    display: none;
  }

  .leads tbody {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.8rem;
    margin: 0 0 1rem;
  }

  .leads th,
  .leads td {
    padding: 0;
    margin: 0 0 0.3rem;
  }

  .leads tbody th[scope='row'] {
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
  }

  /* A lead with no company would otherwise show a label with nothing after it. The
   * cells are rendered empty rather than dashed so this rule can reach them. */

  .leads td:empty {
    display: none;
  }

  .leads td::before {
    content: attr(data-label) ': ';
    color: var(--muted);
    font-size: 0.78rem;
  }

  /* The time is the last line of the card and reads as a time, exactly as on an entry
   * card, so it keeps no label. Every other cell needs one: the prize badge says "Yes",
   * which means nothing once the column heading is off the page. */

  .leads td[data-label='Captured']::before {
    content: none;
  }

  .leads td[data-label='Captured'] {
    white-space: normal;
  }

  .notes-row td {
    white-space: normal;
  }
}

/* Offline notice */

.offline {
  margin: 0;
  padding: 0.6rem 1rem;
  background: var(--danger);
  color: var(--sb-color-white);
  font-weight: 600;
  text-align: center;
}

/* One capture's own page */

.captured-at {
  margin: -0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}

.full-shot {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  margin: 0 0 1.25rem;
  border-radius: var(--radius);
  background: #000;
}

.consent-note {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* What is about to be deleted, laid out plainly so it can be read before confirming. */

.summary {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.summary li {
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}

.summary li:last-child {
  margin-bottom: 0;
}

.summary b {
  display: inline-block;
  min-width: 6rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

/* .button_red carries this now, from the brand's variants. */

/* The privacy notice. Long-form prose, which nothing else in the app is, so it gets a
 * narrower column than the forms and more room between its parts. */

.policy {
  max-width: 34rem;
}

.policy h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.policy p,
.policy li {
  margin: 0 0 0.7rem;
}

.policy ul,
.policy ol {
  margin: 0 0 0.7rem;
  padding-left: 1.2rem;
}

.policy h3 {
  margin: 1rem 0 0.25rem;
  font-size: 0.95rem;
}

.policy-link {
  color: var(--muted);
  font-size: 0.9rem;
}

/* The notice as a lightbox over the capture form.
 *
 * A native <dialog>, so the browser owns the modal behaviour: the backdrop, the focus
 * trap, Escape, and hiding it until it is opened. boot.js only decides when. */

.lightbox {
  width: min(34rem, calc(100vw - 2rem));
  max-height: min(40rem, calc(100vh - 4rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}

.lightbox::backdrop {
  background: #000c;
}

/* The notice scrolls, the close button does not, so it is reachable from anywhere in a
 * long document on a small screen. */

.lightbox-body {
  max-height: calc(min(40rem, 100vh - 4rem) - 5rem);
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The scroll area takes the opening focus, so its ring is deliberate. The box itself
 * never shows one: a ring around the whole dialog reads as a rendering fault. */

.lightbox-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.lightbox:focus {
  outline: none;
}

.lightbox .policy {
  max-width: none;
}

/* Two policies in one scroll, so the second is separated rather than running on from
 * the first. */

.lightbox .policy + .policy {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.lightbox-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

/* Sending a visitor their drawing. Its own row under the edit form, because it is its
 * own form: pressing it must not save half-typed edits. */

.email-send {
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.email-sent {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
