/* The pages' components (spec-admin §7, spec-shares §6): the admin page's, My shares', signing in's and
   the site's — every component's look and states, said once, each class starting with ad-, made by
   js/ui.js. On css/theme.css, which every page loads first. */

/* text */
.ad-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ad-header h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.ad-header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.ad-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ad-text { margin: 0 0 10px; }
.ad-muted { color: var(--muted); font-size: 12px; }
.ad-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.ad-link { color: var(--accent); text-decoration: none; font-weight: 500; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.ad-link:hover { text-decoration: underline; }

/* layout */
/* a stack is never wider than its box: what is wider inside it — a table — scrolls, or wraps */
.ad-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ad-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .ad-grid2 { grid-template-columns: minmax(0, 1fr); } }
.ad-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.ad-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.ad-card h2 { margin: 0 0 8px; font-size: 14px; }
.ad-card h2 span { font-weight: 400; font-size: 12px; color: var(--muted); }
.ad-scroll { overflow-x: auto; overscroll-behavior-x: contain; }

/* tile: in the card's box */
.ad-tile-label { font-size: 12px; color: var(--muted); }
.ad-tile-value { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 2px 0; font-variant-numeric: tabular-nums; }
.ad-tile-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* button: primary, secondary, quiet; busy and disabled */
.ad-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.ad-button:hover { border-color: var(--accent); }
.ad-button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.ad-button-primary:hover { filter: brightness(1.06); }
.ad-button-quiet { background: transparent; border-color: transparent; color: var(--accent); }
.ad-button-quiet:hover { background: var(--accent-soft); border-color: transparent; }
.ad-button-danger { background: var(--red); border-color: var(--red); color: #fff; }
.ad-button-danger:hover { filter: brightness(1.06); }
.ad-button:disabled, .ad-button[aria-busy="true"] { opacity: 0.55; cursor: default; filter: none; }
/* the one spinner: a busy button's, loading's, and a step's while it runs (the share's opening) */
.ad-button[aria-busy="true"]::before, .ad-loading::before, .ad-spinner { content: ""; display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ad-spin 0.8s linear infinite; }
@keyframes ad-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .ad-button[aria-busy="true"]::before, .ad-loading::before, .ad-spinner { animation: none; } }
.ad-spinner { width: 16px; height: 16px; margin-top: 4px; color: var(--accent); }

/* field: input, select, search */
.ad-field { display: grid; gap: 4px; min-width: 0; }
.ad-field-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.ad-input, .ad-select { width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--fg); }
.ad-input:hover, .ad-select:hover { border-color: var(--faint); }
.ad-input:disabled, .ad-select:disabled { opacity: 0.55; }
.ad-input[aria-invalid="true"] { border-color: var(--red); }
.ad-field-error { font-size: 12px; color: var(--red-ink); }
.ad-search { display: flex; gap: 8px 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.ad-search > .ad-button, .ad-search > .ad-link { margin-top: 22px; }
.ad-field-error:empty { display: none; }
.ad-input-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; }
/* a form: its fields down, its one button under them */
.ad-form { display: grid; gap: 12px; margin: 14px 0; }
.ad-form > .ad-button { justify-self: start; }
.ad-search > .ad-field:first-child { flex: 1 1 240px; }

/* pill */
.ad-pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.ad-pill-blue { background: var(--accent-soft); color: var(--accent-ink); }
.ad-pill-green { background: var(--green-soft); color: var(--green-ink); }
.ad-pill-amber { background: var(--amber-soft); color: var(--amber-ink); }
.ad-pill-red { background: var(--red-soft); color: var(--red-ink); }
.ad-pill-grey { background: var(--grey-soft); color: var(--muted); }
.ad-pills { display: inline-flex; gap: 4px; flex-wrap: wrap; }
/* chip: a bordered mark on the card's colour — a feature named with its icon, a link to a section */
.ad-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 0.88rem; text-decoration: none; }

/* table */
.ad-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ad-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ad-table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: top; }
.ad-table .ad-num { text-align: right; font-variant-numeric: tabular-nums; }
/* a row's action sits on the row's line of text, not below it */
.ad-table td .ad-button { padding: 3px 8px; margin: -4px 0; border-radius: 7px; }
.ad-table tbody tr:hover { background: var(--line-soft); }
.ad-table caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.ad-pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* key and value */
/* the field column as wide as its longest field, up to half the box, 140px at least so that short fields line up;
   a field longer than half the box wraps, never under its value */
.ad-kv { display: grid; grid-template-columns: fit-content(50%) minmax(0, 1fr); gap: 6px 14px; font-size: 13px; margin: 0; }
.ad-kv dt { color: var(--muted); min-width: min(140px, 100%); overflow-wrap: anywhere; }
.ad-kv dd { margin: 0; overflow-wrap: anywhere; }
.ad-lines { display: grid; gap: 2px; }

/* lists: timeline, status */
.ad-list { list-style: none; margin: 0; padding: 0; }
.ad-list li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.ad-list li:last-child { border-bottom: 0; }
.ad-list-title { font-weight: 500; }
.ad-list-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ad-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-top: 5px; }
.ad-dot-blue { background: var(--accent); }
.ad-dot-green { background: var(--green); }
.ad-dot-amber { background: var(--amber); }
.ad-dot-red { background: var(--red); }
.ad-dot-grey { background: var(--s5); }

/* states: loading, empty, error, note */
.ad-loading { color: var(--muted); padding: 18px 0; }
.ad-loading::before { margin-right: 8px; vertical-align: -1px; }
.ad-empty { color: var(--muted); text-align: center; padding: 22px 0; font-size: 13px; }
.ad-banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; border: 1px solid; }
.ad-banner-red { background: var(--red-soft); color: var(--red-ink); border-color: var(--red); }
.ad-banner-amber { background: var(--amber-soft); color: var(--amber-ink); border-color: var(--amber); }
.ad-banner-blue { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.ad-banner-green { background: var(--green-soft); color: var(--green-ink); border-color: var(--green); }
.ad-note { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 12px; }

.ad-center { max-width: 460px; margin: 12vh auto; padding: 0 16px; }
/* a centred card says one thing under another — its heading, its text, a note, its button —, never two on a line */
.ad-center > .ad-card { display: grid; gap: 12px; }
.ad-center > .ad-card > .ad-header { margin-bottom: 0; }
.ad-center > .ad-card > .ad-text, .ad-center > .ad-card > .ad-form { margin: 0; }
.ad-center > .ad-card > .ad-button, .ad-center > .ad-card > .ad-link { justify-self: start; }

/* a phone */
@media (max-width: 760px) {
  /* a table with cards: each row a card, its main cell the title, every other cell a line named by its
     column, its actions at the end */
  .ad-table-cards, .ad-table-cards tbody, .ad-table-cards tr, .ad-table-cards td { display: block; }
  .ad-table-cards thead { display: none; }
  .ad-table-cards tr { margin: 0 0 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
  .ad-table-cards tbody tr:hover { background: var(--card); }
  .ad-table-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  .ad-table-cards td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .ad-table-cards td.ad-main-cell { display: block; text-align: left; padding-bottom: 6px; font-size: 15px; overflow-wrap: anywhere; }
  .ad-table-cards td.ad-main-cell::before, .ad-table-cards td:not([data-label])::before { content: none; }
  .ad-table-cards td:last-child:not([data-label]) { justify-content: flex-end; padding-top: 8px; }
  /* two tiles a row, not one: the counts read at a glance */
  .ad-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ad-tile { padding: 12px; }
  .ad-kv { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}

/* verdict: the check page's answer */
.ad-verdict { border-radius: 12px; border: 1px solid; padding: 14px 16px; margin-bottom: 14px; }
.ad-verdict h1 { margin: 0; font-size: 20px; line-height: 1.3; }
.ad-verdict p { margin: 4px 0 0; font-size: 14px; }
.ad-verdict-green { background: var(--green-soft); color: var(--green-ink); border-color: var(--green); }
.ad-verdict-amber { background: var(--amber-soft); color: var(--amber-ink); border-color: var(--amber); }
.ad-verdict-red { background: var(--red-soft); color: var(--red-ink); border-color: var(--red); }
.ad-verdict-grey { background: var(--grey-soft); color: var(--muted); border-color: var(--line); }
.ad-verdict .ad-verdict-sub { font-weight: 600; }
/* the stamp and the pages */
.ad-drawing { display: block; max-width: 100%; height: auto; }
.ad-caption { font-size: 12px; color: var(--muted); margin: 8px 0 0; overflow-wrap: anywhere; }
.ad-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.ad-image { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.ad-image-button { padding: 0; border: 0; background: none; cursor: zoom-in; position: relative; display: block; }
.ad-image-button span { position: absolute; right: 6px; bottom: 4px; font-size: 11px; color: var(--muted); }
.ad-large { display: grid; gap: 10px; }
.ad-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.ad-file-label { position: relative; cursor: pointer; }
.ad-file-label:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.ad-dashed { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.ad-checklist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.ad-checklist li { display: flex; gap: 8px; align-items: baseline; }
.ad-check { max-width: 560px; width: 100%; display: grid; gap: 14px; }
.ad-check .ad-card h2 { text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* the lightbox (js/lightbox.js, spec-signing §6): a picture over the whole window, scrolled and pinch-zoomed inside */
.ad-stamp-button { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: zoom-in; }
.ad-stamp-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
html.ad-lightbox-open, html.ad-lightbox-open body { overflow: hidden; }
.ad-lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; box-sizing: border-box; overflow: auto; background: rgba(0, 0, 0, 0.55); cursor: zoom-out; touch-action: pinch-zoom pan-x pan-y; overscroll-behavior: contain; }
.ad-lightbox-dialog { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 50vw; max-width: 100%; padding: 14px; box-sizing: border-box; border-radius: 14px; background: #fff; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); }
.ad-lightbox-frame { display: flex; align-items: center; justify-content: center; padding-top: 30px; }
.ad-lightbox-frame svg { display: block; width: 100%; height: auto; max-height: 50vh; max-height: 50dvh; }
.ad-lightbox-frame img { display: block; max-width: 100%; max-height: 50vh; max-height: 50dvh; }
.ad-lightbox-close { position: absolute; top: 8px; right: 8px; z-index: 1; min-height: 32px; padding: 4px 12px; border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 999px; background: #f3f3f5; color: #222; font: inherit; font-size: 13px; cursor: pointer; }
.ad-lightbox-close:focus-visible { outline: 2px solid #3a6df0; outline-offset: 2px; }
.ad-lightbox-hint { margin: 0; text-align: center; color: #6b7080; font-size: 12px; }
@media (max-width: 700px) { .ad-lightbox-dialog { width: 92vw; } }
