/*
 * EncodeLabel: the Quick label page (goes with quick.php and assets/js/page-quick.js).
 *
 * The page is the shell's two-column .tool layout (site.css): the three steps
 * on the left, the label and the sheet on the right, the buttons under them.
 * On a phone the picture is pinned to the top, the steps scroll under it and
 * the buttons are pinned to the bottom. This file only adds what is special
 * to this page:
 *
 *   .qk-head       the heading, with New / Open / Save beside it
 *   .qk-helpers    "QR code for: Wi-Fi network, Contact card" under the box, and .qk-form their pop-ups
 *   .qk-series     the boxes of a numbered series
 *   .qk-extras     the optional lines of words, and "More"
 *   .qk-preview    the label and the sheet: side by side where there is room,
 *                  one at a time (with a Label / Sheet switch) where there is not
 *   .qk-checks     the size read-out and the warnings under the label
 *   .qk-about      the few lines under the tool
 *   .qk-guide      the how-to text, the popular types and the questions under those
 *
 * Colours come from the design tokens only, so the light and the dark theme
 * both work. The label and the sheet themselves are always black on white,
 * because that is what the printer makes.
 */

/* ---- The heading ----------------------------------------------------------------- */
.qk-head { align-items: center; margin-bottom: 16px; }
.qk-head h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }   /* the same size as the Address labels heading (page-address.css) */
.qk-head .qk-lead { margin-top: 4px; font-size: 1rem; }
.qk-tools { flex-wrap: nowrap; align-items: flex-start; }
.qk-save { display: inline-flex; }
.qk-notice { margin-bottom: 14px; }

/* quick.php sends the tool hidden and page-quick.js shows it once every script has run. Until
   then its place is held (a screen high, with nothing in it to see, press or read out), so the
   text under the tool is not shown first and then pushed down the page. !important because the
   shell hides every [hidden] thing with !important. The place is given back when it will never
   be filled: the "Part of this page could not load" note is showing, JavaScript is off (two ways
   of telling, for older and newer browsers), or 15 seconds have gone by and the scripts have
   still not run (a dropped connection): the place then closes by itself. */
.qk[hidden] { display: block !important; visibility: hidden; height: 100dvh; overflow: hidden; animation: qk-give-back 15s step-end forwards; }
@keyframes qk-give-back { to { height: 0; } }
[data-qk-broken]:not([hidden]) ~ .qk[hidden] { display: none !important; }
@media (scripting: none) { .qk[hidden] { display: none !important; } }
noscript:has(> .alert) ~ .qk[hidden] { display: none !important; }

/* ---- Step 1: what goes on the label ---------------------------------------------- */
.qk-single, .qk-series { margin-bottom: 4px; }
.qk-single .ksym-input { margin-bottom: 6px; }

/* "QR code for: Wi-Fi network, Contact card" under the box: two quiet links, each a 44 px target. */
.qk-helpers { container: qkh / inline-size; display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: -6px 0 2px; font-size: .92rem; }
.qk-helpers-label, .qk-helpers-dot { color: var(--muted); }
.qk-helper { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
/* Too narrow for one line (it needs about 19.5em; 20.3em in Arial): "QR code for:" takes a line of its
   own, so the dot never hangs at the end of a line. A 360 px phone keeps one line. */
@container qkh (max-width: 20.4em) {
  .qk-helpers-label { flex-basis: 100%; }
}

/* Their pop-ups (page-quick.js, section 6). The password is hidden with dots in an ordinary text box. */
.qk-form-intro { margin: 0 0 16px; }
.qk-form-more {
  margin: -4px 0 16px; padding: 8px 12px; border-left: 4px solid var(--warn); border-radius: var(--radius-small);
  background: var(--warn-soft); font-size: .92rem;
}
.qk-form-choice { margin-bottom: 8px; }
.qk-form-choice legend { margin-bottom: 0; }
.qk-form-choice .check { padding: 8px 0; }
.qk-form-pass .field { margin-bottom: 4px; }
.qk-secret[data-qk-hide] { -webkit-text-security: disc; }
.qk-form .status-line { margin-top: 4px; }

.qk-series-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 14px; }
.qk-series-head .field-label { margin: 0; }
.qk-series-type { gap: 6px; }
.qk-series-type-icon { display: inline-flex; }
.qk-series .field { margin-bottom: 12px; }
.qk-series .stepper { display: flex; }
.qk-series .stepper > input { flex: 1 1 auto; width: 100%; min-width: 0; }
.qk-series-hint { margin: -4px 0 12px; }
.qk-series-range {
  margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-small);
  background: var(--soft); font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere;
}
.qk-series-range:empty { display: none; }
.qk-series-range strong { font-family: var(--mono); font-size: .95em; }
.qk-series-total { color: var(--muted); white-space: nowrap; }
.qk-series-status:empty { display: none; }

.qk-series-switch { display: flex; margin-top: 6px; }
.qk-switch-hint { margin: -4px 0 0 58px; }

.qk-extras { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.qk-showtext { margin: 0; }
.qk-lines { margin-top: 10px; }
.qk-lines .field { margin-bottom: 12px; }
.qk-lines-hint { margin: -4px 0 12px; }

/* "More": folded away, because most labels never need it. */
.qk-more { margin: 2px 0 0; }
.qk-more > summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--link);
  font-weight: 600; list-style: none; cursor: pointer;
}
.qk-more > summary::-webkit-details-marker { display: none; }
.qk-more > summary::after {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 0 3px 2px;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.qk-more[open] > summary::after { margin-bottom: -4px; transform: rotate(225deg); }
.qk-more-body { padding: 4px 0 2px; }
.qk-opt + .qk-opt { margin-top: 14px; }
.qk-opt .field { margin-bottom: 0; }
.qk-opt .qk-font { margin: 14px 0 4px; }
.qk-opt .hint { margin-top: 6px; }

/* ---- Step 2 and step 3 -------------------------------------------------------------- */
.qk-paper-hint { margin-top: 10px; }

.qk-designer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  margin: 4px 0 0; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius);
}
.qk-designer p { flex: 1 1 200px; margin: 0; color: var(--muted); font-size: .92rem; }

/* "This prints small" is said once. Where the label and the sheet show side by side, the size read-out under
   the label is always on screen, so the print panel's copy of the same advice in step 3 is left out (the page
   marks that lay-out with data-qk-both). Where only one picture shows at a time, step 3 keeps its copy: the
   label's read-out is out of sight there while the sheet is looked at. Other things to check always show. */
.qk[data-qk-both] .qk-print [data-kpr-warning="small"] { display: none; }
.qk[data-qk-both] .qk-print .kpr-facts:not(:has([data-kpr-warning]:not([data-kpr-warning="small"]), .kpr-note:not([hidden]), .kpr-skipped:not([hidden]))) { display: none; }

/* ---- The label and the sheet ------------------------------------------------------- */
.qk-preview { container: qkp / inline-size; }

.qk-bar { display: flex; flex: none; align-items: center; gap: 10px; min-height: 40px; margin: 0 0 8px; }
.qk-switch { flex: none; }
.qk-switch > button { min-width: 72px; }
.qk-fold { display: none; flex: none; margin-left: auto; }
.qk-folded-note { display: none; color: var(--muted); font-size: .9rem; }

.qk-views { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; }
.qk-view { display: flex; flex: 1 1 auto; flex-direction: column; min-width: 0; min-height: 0; }
.qk-views[data-view="label"] > .qk-view-sheet,
.qk-views[data-view="sheet"] > .qk-view-label { display: none; }

/* The desks take the room there is (the shell's own rule only reaches a desk straight inside .tool-preview). */
.qk-view > .sheet-preview { flex: 1 1 auto; height: auto; min-height: 150px; }
.qk-view-label > .sheet-preview { flex: 1 1 46%; min-height: 200px; }
.qk-view > .kpr-preview-bar { flex: none; }
.qk-view > .kpr-result { flex: none; margin: 4px 0 0; text-align: center; }
.qk-view .kpr-fold { display: none; }          /* this page has its own way of putting the picture away */

/* Nothing typed yet: a sample, shown faintly so nobody takes it for their own label. It is the
   drawing that fades, not the paper: a faded paper lets the dark desk through and turns grey in
   the dark theme, and a label is always white. */
.qk-desk.is-sample .qk-label > svg { opacity: .5; }
.qk-desk.is-waiting .qk-label > svg { opacity: .7; }
.qk-label > svg { display: block; width: 100%; height: 100%; }
/* A one inch label does not need to be a foot wide to be looked at. */
.qk-desk .qk-label { max-width: 460px; max-height: 460px; }

/* What is said about the label: on wide screens it is simply there; on a phone
   one line shows and a tap opens the rest. */
.qk-checks { flex: 0 1 auto; min-height: 0; max-height: 54%; margin-top: 10px; overflow-y: auto; overscroll-behavior: contain; }
.qk-verdict { display: none; }
.qk-meter:empty { display: none; }
.qk-meter .ksym-meter { margin: 0; }

.qk-advice { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); font-size: .92rem; }
.qk-advice-why { margin: 0 0 10px; }
.qk-advice-title { margin: 0 0 4px; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.qk-advice-list { display: grid; gap: 4px; margin: 0; padding: 0 0 0 18px; line-height: 1.5; }
.qk-advice-list .link-button { font-weight: 600; text-align: left; }

.qk-warnings { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.qk-meter:empty + .qk-advice[hidden] + .qk-warnings, .qk-meter:has(> [hidden]) + .qk-advice[hidden] + .qk-warnings { margin-top: 0; }
.qk-warning {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px;
  border-left: 4px solid var(--warn); border-radius: var(--radius-small); background: var(--warn-soft);
  font-size: .92rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere;
}
.qk-warning.is-error { border-left-color: var(--error); background: var(--error-soft); }
.qk-warning-icon { flex: none; color: var(--warn); }
.qk-warning.is-error .qk-warning-icon { color: var(--error); }

/* Room for both pictures: the label on the left, the sheet on the right, no switch. */
@container qkp (min-width: 700px) {
  .qk-bar { display: none; }
  .qk-views { flex-direction: row; gap: 14px; }
  .qk-views > .qk-view,
  .qk-views[data-view="label"] > .qk-view-sheet,
  .qk-views[data-view="sheet"] > .qk-view-label { display: flex; flex: 1 1 0; }
}

/* ---- Phones: the picture pinned to the top ---------------------------------------- */
@media (max-width: 760px) {
  .qk-head { margin-bottom: 10px; }
  .qk-head .qk-lead { display: none; }
  .qk-head h1 { font-size: 1.5rem; }
  .qk-tools .btn { padding-left: 10px; padding-right: 10px; }

  .qk-bar { margin-bottom: 6px; }
  .qk-fold { display: inline-flex; }
  .qk-view > .sheet-preview, .qk-view-label > .sheet-preview { flex: none; height: clamp(140px, 27dvh, 250px); min-height: 0; padding: 12px; }
  .qk-view > .sheet-preview:has(> .sheet-note:not([hidden])) { padding-bottom: 38px; }
  .qk-view > .kpr-preview-bar { min-height: 36px; margin-top: 4px; }
  .qk-view > .kpr-result { margin-top: 0; font-size: .95rem; }

  /* Put away: only the bar is left, so the steps have the whole screen. */
  .qk-preview.is-folded .qk-views { display: none; }
  .qk-preview.is-folded .qk-switch { display: none; }
  .qk-preview.is-folded .qk-folded-note { display: inline; }
  .qk-preview.is-folded .qk-bar { margin-bottom: 0; }

  .qk-checks { max-height: none; margin-top: 4px; overflow: visible; }
  .qk-verdict {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; margin: 0; padding: 4px 2px;
    border: 0; background: none; color: var(--ink); font: inherit; font-size: .92rem; font-weight: 600; text-align: left; cursor: pointer;
  }
  .qk-verdict-mark { display: inline-flex; flex: none; color: var(--ok); }
  .qk-checks[data-kind="warn"] .qk-verdict-mark { color: var(--warn); }
  .qk-checks[data-kind="error"] .qk-verdict-mark { color: var(--error); }
  .qk-verdict-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .qk-verdict-more { display: inline-flex; flex: none; color: var(--muted); }
  .qk-verdict[aria-expanded="true"] .qk-verdict-more { transform: rotate(180deg); }
  .qk-verdict:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-small); }
  .qk-checks-body { display: none; max-height: 34dvh; padding: 2px 0 6px; overflow-y: auto; overscroll-behavior: contain; }
  .qk-checks-body.is-open { display: block; }
  /* One short message and nothing behind it: the whole sentence shows, and there is nothing to open. */
  .qk-checks[data-plain] .qk-verdict { align-items: flex-start; cursor: default; }
  .qk-checks[data-plain] .qk-verdict-text { overflow: visible; white-space: normal; }
  .qk-checks[data-plain] .qk-verdict-more { display: none; }
  .qk-checks[data-plain] .qk-checks-body { display: none; }
}

/* ---- Under the tool ---------------------------------------------------------------- */
.qk-about { margin: 40px 0 0; padding-top: 28px; border-top: 1px solid var(--line); }
.qk-about h2 { margin: 0 0 18px; }
.qk-about .fine-print { margin: 0; }

/* The how-to text: three short sections side by side where there is room, one under the
   other on narrower screens, kept to a comfortable line length; then the popular types
   and the questions. */
.qk-guide { margin: 40px 0 0; padding-top: 28px; border-top: 1px solid var(--line); }
.qk-guide h2 { margin: 0 0 12px; font-size: 1.25rem; }
.qk-guide p { margin: 0 0 12px; }
.qk-guide-uses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 36px; }
.qk-guide-uses > section > :last-child { margin-bottom: 0; }
.qk-guide-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.qk-guide-types, .qk-guide-questions { max-width: 46rem; margin-top: 40px; }
.qk-guide-types a.chip { min-height: 44px; }
.qk-guide-questions .faq-list { margin-bottom: 0; }
@media (max-width: 1000px) {
  .qk-guide-uses { grid-template-columns: minmax(0, 46rem); gap: 28px; }
}
@media (max-width: 760px) {
  .qk-guide { margin-top: 32px; padding-top: 24px; }
  .qk-guide-types, .qk-guide-questions { margin-top: 32px; }
}

@media (prefers-reduced-motion: no-preference) {
  .qk-label { transition: opacity .15s; }
}

/* Windows high-contrast mode: the label keeps its real black and white (the shell does this for .sheet-paper). */
@media (forced-colors: active) {
  .qk-warning, .qk-advice, .qk-series-range { border: 1px solid CanvasText; }
}
