/*! © 2015–2026 YourWeb (yourweb.se). All rights reserved. Proprietary – see LICENSE.md */
/* QR-kod för Google-recensioner (/verktyg/qr-kod-google-recensioner/). Styles only this tool uses,
   prefix .qr-. Linked after /verktyg/verktyg.css. */

/* ───────────────────────── Link field ───────────────────────── */

/* Under the link field: green for a Google link, blue for any other address. */
.qr-note {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  color: var(--st, var(--text-soft));
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

.qr-note .icon {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.12rem;
  stroke-width: 2.2;
}

/* ───────────────────────── Result ───────────────────────── */

.qr-head {
  display: grid;
  justify-items: start;
  gap: 0.7rem;
}

.qr-head__text {
  max-width: 40rem;
  color: var(--text-soft);
}

.qr-head .btn {
  margin-top: 0.3rem;
}

.qr-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.qr-work > * {
  min-width: 0;
}

.qr-preview,
.qr-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
  align-content: start;
  padding: 1rem;
}

.qr-preview > *,
.qr-controls > * {
  min-width: 0;
}

/* The buttons below the preview follow the width of this card, not the width of the window. */
.qr-preview {
  container: qr-card / inline-size;
}

@media (min-width: 40rem) {
  .qr-preview,
  .qr-controls {
    padding: 1.35rem;
  }
}

@media (min-width: 64rem) {
  .qr-work {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    gap: 1.5rem;
  }

  .qr-preview,
  .qr-controls {
    padding: 1.6rem;
  }
}

/* The three designs as tiles. The radio button is hidden; the tile shows the state. */
.qr-designs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.qr-design,
.qr-level {
  position: relative;
  display: block;
  min-width: 0;
  cursor: pointer;
}

.qr-design__box {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.35rem;
  height: 100%;
  min-height: 4.6rem;
  padding: 0.55rem 0.25rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.qr-design__glyph {
  width: 1.5rem;
  height: 1.5rem;
}

.qr-design:hover .qr-design__box,
.qr-level:hover .qr-level__box {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.qr-design input:checked + .qr-design__box,
.qr-level input:checked + .qr-level__box {
  border-color: var(--paper-100);
  background: var(--paper-100);
  color: var(--ink-900);
}

.qr-design input:focus-visible + .qr-design__box,
.qr-level input:focus-visible + .qr-level__box {
  outline: 3px solid var(--yellow-500);
  outline-offset: 3px;
}

@media (min-width: 24rem) {
  .qr-design__box {
    font-size: 0.86rem;
  }
}

/* Very narrow phones: one tile per row, so that no word has to be broken. */
@media (max-width: 21.5rem) {
  .qr-designs {
    grid-template-columns: minmax(0, 1fr);
  }

  .qr-design__box {
    grid-auto-flow: column;
    justify-content: start;
    justify-items: start;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.4rem 1rem;
    font-size: 0.92rem;
    text-align: left;
  }
}

/* The sheet of paper on a dark stage. The SVG carries its own white background. */
.qr-stage {
  display: grid;
  place-items: center;
  padding: 1.25rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(22rem 14rem at 50% 115%, rgb(var(--accent-rgb) / 0.16), transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.075) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--surface-sunken);
}

.qr-sheet {
  width: min(100%, var(--sheet, 16.5rem));
  filter: drop-shadow(0 1rem 1.6rem rgb(0 0 0 / 0.5));
}

.qr-sheet svg {
  display: block;
  width: 100%;
  height: auto;
}

.qr-sheet[data-design="kod"] {
  --sheet: 15rem;
}

.qr-size {
  margin-top: -0.4rem;
  color: var(--text-dim);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
}

@media (min-width: 64rem) {
  .qr-sheet {
    --sheet: 20rem;
  }

  .qr-sheet[data-design="kod"] {
    --sheet: 18rem;
  }

  .qr-stage {
    padding: 1.75rem 1.25rem;
  }
}

.qr-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.qr-actions .btn {
  min-width: 0;
  padding-inline: 0.6rem;
  gap: 0.4rem;
  white-space: nowrap;
}

.qr-actions .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.qr-preview .notice__title {
  text-wrap: balance;
}

@media (max-width: 21.5rem) {
  .qr-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@container qr-card (min-width: 39rem) {
  .qr-actions {
    grid-template-columns: repeat(4, auto);
    justify-content: start;
  }

  .qr-actions .btn {
    padding-inline: 1rem;
  }
}

.qr-facts {
  display: grid;
  gap: 1rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}

.qr-facts .kv > div {
  align-content: start;
}

.qr-contents {
  display: grid;
  gap: 0.5rem;
}

.qr-contents .kv-title {
  margin: 0;
}

/* ───────────────────────── Options ───────────────────────── */

.qr-controls__title {
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.qr-levels-field {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.qr-levels-field legend {
  margin-bottom: 0.1rem;
  padding: 0;
}

.qr-levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.qr-level__box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.5rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.qr-level__box b {
  font-size: 1rem;
  font-weight: 800;
}

.qr-level input:disabled + .qr-level__box {
  cursor: not-allowed;
  opacity: 0.4;
}

@media (min-width: 26rem) {
  .qr-levels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.qr-level-help {
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ───────────────────────── Print ─────────────────────────
   With a result on the page, only the chosen design is printed, at its real size in millimetres and centred.
   Without a result (or in a browser without :has()) the page prints as usual. */

@media print {
  @page {
    margin: 12mm;
  }

  /* Browsers without :has(): at least the controls of the result stay off the paper. */
  .qr-head,
  .qr-controls,
  .qr-designs,
  .qr-size,
  .qr-actions,
  .qr-preview > .notice {
    display: none !important;
  }

  body:has(#resultat:not([hidden])) {
    background: #fff !important;
    color: #000 !important;
  }

  body:has(#resultat:not([hidden])) > :not(main),
  body:has(#resultat:not([hidden])) main > :not(#resultat) {
    display: none !important;
  }

  #resultat:not([hidden]) {
    display: block !important;
    padding: 0 !important;
  }

  #resultat:not([hidden]) :not(.qr-sheet):not(.qr-sheet *):not(:has(.qr-sheet)) {
    display: none !important;
  }

  #resultat:not([hidden]) .shell,
  #resultat:not([hidden]) .result__stack,
  #resultat:not([hidden]) .qr-work,
  #resultat:not([hidden]) .qr-preview,
  #resultat:not([hidden]) .qr-stage {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }

  /* Centred on the sheet of paper, in a region that also fits Letter paper without a second page. */
  #resultat:not([hidden]) .qr-stage {
    display: grid !important;
    place-items: center;
    min-height: 240mm;
  }

  .qr-sheet {
    --sheet-w: 60mm;
    --sheet-h: 60mm;
    width: var(--sheet-w);
    height: var(--sheet-h);
    margin: 0;
    filter: none;
    break-inside: avoid;
  }

  .qr-sheet[data-design="skylt"] {
    --sheet-w: 105mm;
    --sheet-h: 148mm;
  }

  .qr-sheet[data-design="klistermarke"] {
    --sheet-w: 80mm;
    --sheet-h: 80mm;
  }

  .qr-sheet svg {
    width: var(--sheet-w);
    height: var(--sheet-h);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ───────────────────────── Forced colours (Windows high contrast) ───────────────────────── */

@media (forced-colors: active) {
  .qr-design input:checked + .qr-design__box,
  .qr-level input:checked + .qr-level__box {
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }

  /* The sheet is a picture of paper: it stays black on white whatever the colour scheme. */
  .qr-sheet,
  .qr-sheet * {
    forced-color-adjust: none;
  }
}
