/* Public QR Generator tool (/qr-generator).
 *
 * Built on theme-dark.css and auth.css (aurora backdrop, turning card edge,
 * gold button, ghost buttons, --auth-* tokens), like the other apps; this
 * file adds the hero, the tool card (input panel, result panel with the QR
 * code on its white plate) and the content sections, in the `qg-` namespace.
 *
 * Layout, mobile first: heading and intro, then the tool card, then the
 * content. Inside the card the input and result panels are stacked, and sit
 * side by side from 900px. Nothing is wider than the screen at 320px.
 *
 * Motion (transform and opacity only, nothing under prefers-reduced-motion):
 * a floating, twinkling QR motif in the hero, the QR code scaling in with a
 * scan line when it is generated, a press bounce on the buttons and the
 * scroll reveal of the content (start states only after qr-generator.js
 * marks <html> with `qg-reveal`). The heading and intro never animate.
 */

.qg-body {
  --qg-max: clamp(60rem, 48rem + 18vw, 80rem);
  --qg-surface: rgba(17, 18, 24, 0.82);
  --qg-raised: rgba(255, 255, 255, 0.035);
  --qg-accent: #a98bff;
  --qg-plate: #ffffff;
  --qg-touch: 44px;
  --qg-result-max: 22rem;
}

.qg-body .auth-card__glow {
  animation-duration: 14s;
}

.qg-main {
  display: block;
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
  overflow-x: clip;
}

.qg-container {
  width: 100%;
  max-width: calc(var(--qg-max) + 2 * var(--site-header-gutter));
  margin-inline: auto;
  padding-inline: var(--site-header-gutter);
}

/* ----------------------------------------------------------------- Hero */

.qg-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  gap: clamp(1.5rem, 1rem + 2vw, 2.75rem);
  padding-block: clamp(1.5rem, 1rem + 3vw, 4rem) clamp(2rem, 1.5rem + 3vw, 4.5rem);
  overflow: hidden;
  overflow: clip;
}

.qg-hero__copy {
  display: grid;
  justify-items: start;
  gap: clamp(0.8rem, 0.6rem + 0.6vw, 1.3rem);
  min-width: 0;
}

.qg-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
}

.qg-breadcrumb__list li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--auth-line-strong);
}

.qg-breadcrumb__list a {
  color: var(--auth-muted);
  text-decoration: none;
}

.qg-breadcrumb__list a:hover {
  color: var(--auth-gold);
}

.qg-hero__title {
  font-family: var(--font-brand);
  font-size: clamp(2.4rem, 1.4rem + 3.6vw, 4.6rem);
  font-weight: var(--font-weight-brand);
  line-height: 1.02;
  letter-spacing: -0.035em;
  background: linear-gradient(100deg, var(--auth-text) 25%, var(--auth-gold-strong) 70%, var(--qg-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.qg-hero__lead {
  max-width: 44em;
  color: var(--auth-muted);
  font-size: clamp(1rem, 0.92rem + 0.35vw, 1.2rem);
  line-height: 1.65;
}

.qg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qg-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--qg-raised);
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-medium);
}

.qg-chip__icon {
  width: 1rem;
  height: 1rem;
  color: var(--auth-gold);
}

/* Decorative motif: a stylised QR code, top right. */
.qg-motif {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.qg-motif__code {
  position: absolute;
  top: clamp(1.5rem, 0.5rem + 3vw, 4rem);
  right: clamp(1rem, -1rem + 8vw, 12rem);
  width: clamp(9rem, 6rem + 9vw, 15rem);
  height: auto;
  overflow: visible;
  opacity: 0.55;
  transform: rotate(-6deg);
}

.qg-motif__finder rect {
  fill: none;
  stroke: var(--auth-gold);
  stroke-width: 6;
}

.qg-motif__finder .qg-motif__eye {
  fill: rgba(235, 196, 42, 0.35);
  stroke: none;
}

.qg-motif__finder--b rect {
  stroke: var(--qg-accent);
}

.qg-motif__finder--b .qg-motif__eye {
  fill: rgba(169, 139, 255, 0.35);
}

.qg-motif__finder,
.qg-motif__module {
  transform-box: fill-box;
  transform-origin: center;
}

.qg-motif__module {
  fill: rgba(255, 255, 255, 0.28);
}

.qg-motif__module--b {
  fill: rgba(235, 196, 42, 0.45);
}

.qg-motif__module--c {
  fill: rgba(169, 139, 255, 0.45);
}

/* Phones and tablets: the motif steps back behind the heading. */
@media (max-width: 1023.98px) {
  .qg-motif__code {
    top: 0.5rem;
    right: -1.5rem;
    width: 8rem;
    opacity: 0.28;
  }
}

/* ------------------------------------------------------------ Tool card */

.qg-card {
  position: relative;
  min-width: 0;
  padding: 1px;
  overflow: hidden;
  overflow: clip;
  border-radius: var(--auth-radius);
  background: var(--auth-line);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.qg-card__body {
  position: relative;
  display: grid;
  gap: clamp(0.9rem, 0.7rem + 0.6vw, 1.25rem);
  padding: clamp(0.9rem, 0.6rem + 1.4vw, 2rem);
  border-radius: calc(var(--auth-radius) - 1px);
  background-color: var(--auth-card-solid);
}

.qg-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.25rem;
}

.qg-card__title {
  font-family: var(--font-brand);
  font-size: clamp(1.25rem, 1.05rem + 0.7vw, 1.65rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
}

.qg-card__privacy {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.qg-card__privacy-icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--auth-success);
}

.qg-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.9rem, 0.7rem + 0.8vw, 1.5rem);
}

@media (min-width: 900px) {
  .qg-workspace {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: start;
  }
}

.qg-panel {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
  padding: clamp(0.85rem, 0.7rem + 0.6vw, 1.25rem);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--qg-raised);
}

.qg-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1rem;
}

.qg-panel__label {
  color: var(--auth-text);
  font-size: var(--auth-fs-body);
  font-weight: var(--font-weight-semibold);
}

.qg-counter {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
}

.qg-counter.is-over {
  color: var(--auth-error);
  font-weight: var(--font-weight-semibold);
}

.qg-input {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--auth-line-strong);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-field);
  color: var(--auth-text);
  font-family: var(--font-mono);
  font-size: max(16px, var(--font-size-sm));
  line-height: 1.55;
  resize: vertical;
  overflow-wrap: anywhere;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.qg-input::placeholder {
  color: var(--auth-subtle);
}

.qg-input:hover:not([disabled]) {
  background-color: var(--auth-field-hover);
}

.qg-input:focus-visible {
  border-color: var(--auth-gold);
  outline: 2px solid var(--auth-gold);
  outline-offset: 2px;
}

.qg-input[aria-invalid="true"] {
  border-color: var(--auth-error);
}

.qg-input[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.qg-hint {
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.qg-message {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(255, 138, 138, 0.35);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-error-soft);
  color: var(--auth-error);
  font-size: var(--auth-fs-small);
  line-height: 1.5;
}

.qg-message[hidden] {
  display: none;
}

.qg-message__icon {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
}

.qg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.qg-generate {
  width: auto;
  flex: 1 1 12rem;
}

.qg-generate[disabled] {
  cursor: not-allowed;
}

.qg-kbd {
  padding: 0.1rem 0.45rem;
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.35);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}

.qg-button {
  min-height: var(--qg-touch);
  justify-content: center;
}

.qg-button:focus-visible,
.qg-generate:focus-visible {
  outline: 2px solid var(--auth-gold-strong);
  outline-offset: 3px;
}

/* --------------------------------------------------------------- Result */

.qg-panel--result {
  justify-items: center;
}

.qg-panel--result .qg-panel__head {
  justify-self: stretch;
}

.qg-result {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  width: 100%;
}

.qg-result__plate {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: var(--qg-result-max);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px dashed var(--auth-line-strong);
  border-radius: var(--auth-radius-sm);
  background-color: rgba(255, 255, 255, 0.02);
}

.qg-result.is-ready .qg-result__plate {
  border: 0;
  background-color: var(--qg-plate);
  box-shadow: 0 24px 60px -28px var(--auth-gold-glow), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.qg-result__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.qg-result__canvas[hidden] {
  display: none;
}

/* An outdated QR code stays visible but steps back until it is generated again
   (on the plate: the canvas's reveal animation keeps its own opacity at 1). */
.qg-result.is-stale .qg-result__plate {
  opacity: 0.4;
}

.qg-result__scan {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 18%;
  background: linear-gradient(180deg, transparent, rgba(169, 139, 255, 0.22) 60%, rgba(235, 196, 42, 0.4) 100%);
  opacity: 0;
  pointer-events: none;
}

.qg-empty {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  text-align: center;
}

.qg-empty[hidden] {
  display: none;
}

.qg-empty__icon {
  width: 3rem;
  height: 3rem;
  fill: rgba(255, 255, 255, 0.22);
}

.qg-empty__text {
  max-width: 18rem;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.55;
}

.qg-status {
  min-height: 1.5em;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.5;
  text-align: center;
}

.qg-download {
  width: 100%;
  max-width: var(--qg-result-max);
}

/* -------------------------------------------------------------- Content */

.qg-content {
  display: grid;
  gap: clamp(2.25rem, 1.5rem + 2.5vw, 3.75rem);
}

.qg-section {
  display: grid;
  gap: 0.85rem;
  max-width: 52rem;
  color: var(--auth-muted);
  font-size: var(--auth-fs-body);
  line-height: 1.7;
}

.qg-section__title {
  color: var(--auth-text);
  font-family: var(--font-brand);
  font-size: clamp(1.4rem, 1.15rem + 1vw, 2rem);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.qg-how {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .qg-how {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .qg-section:has(.qg-how) {
    max-width: none;
  }

  .qg-how {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.qg-how__step,
.qg-faq__item {
  position: relative;
  padding: clamp(1rem, 0.85rem + 0.6vw, 1.5rem);
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  background-color: var(--qg-surface);
  font-size: var(--auth-fs-small);
}

.qg-how__step {
  display: grid;
  align-content: start;
  gap: 0.4rem;
}

.qg-how__number {
  position: absolute;
  top: 0.4rem;
  right: 0.9rem;
  color: rgba(255, 255, 255, 0.07);
  font-family: var(--font-brand);
  font-size: 3rem;
  line-height: 1;
}

.qg-how__title {
  color: var(--auth-text);
  font-size: 1.05rem;
  font-weight: var(--font-weight-semibold);
}

.qg-section--privacy {
  padding: clamp(1.1rem, 0.9rem + 1vw, 1.75rem);
  border: 1px solid rgba(94, 224, 160, 0.25);
  border-radius: var(--auth-radius-sm);
  background: linear-gradient(135deg, rgba(94, 224, 160, 0.08), rgba(255, 255, 255, 0.02));
}

.qg-faq {
  max-width: none;
}

.qg-faq__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
}

@media (min-width: 900px) {
  .qg-faq__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.qg-faq__question {
  margin-bottom: 0.4rem;
  color: var(--auth-text);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  font-weight: var(--font-weight-semibold);
}

.qg-contact {
  margin-top: 1rem;
  font-size: var(--auth-fs-small);
}

.qg-contact a {
  color: var(--auth-gold);
}

/* --------------------------------------------------------------- Phones */

@media (max-width: 479.98px) {
  .qg-actions .qg-generate,
  .qg-actions .qg-button {
    flex: 1 1 100%;
  }

  .qg-kbd {
    display: none;
  }
}

/* --------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: no-preference) {
  .qg-motif__code {
    animation: qg-float 11s ease-in-out infinite alternate;
  }

  .qg-motif__finder {
    animation: qg-breathe 4.8s ease-in-out infinite;
  }

  .qg-motif__finder--b { animation-delay: 1.2s; }
  .qg-motif__finder--c { animation-delay: 2.4s; }

  .qg-motif__module {
    animation: qg-twinkle 3.4s ease-in-out infinite;
  }

  .qg-motif__module--b { animation-delay: 0.6s; }
  .qg-motif__module--c { animation-delay: 1.3s; }
  .qg-motif__module--d { animation-delay: 2s; }

  .qg-hero.is-offscreen .qg-motif__code,
  .qg-hero.is-offscreen .qg-motif__finder,
  .qg-hero.is-offscreen .qg-motif__module {
    animation-play-state: paused;
  }

  .qg-result__canvas {
    transition: opacity 260ms var(--auth-ease);
  }

  .qg-result.is-ready .qg-result__canvas {
    animation: qg-reveal-code 620ms var(--auth-ease) both;
  }

  .qg-result.is-ready .qg-result__plate {
    animation: qg-pop 520ms var(--auth-ease) both;
  }

  .qg-result.is-ready .qg-result__scan {
    animation: qg-scan 1.4s 220ms ease-in-out 1;
  }

  .qg-message:not([hidden]) {
    animation: qg-appear 260ms var(--auth-ease) both;
  }

  .qg-button,
  .qg-generate {
    transition: transform var(--transition-fast), border-color var(--transition-fast),
      background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-normal);
  }

  .qg-button:hover:not([disabled]) {
    transform: translateY(-1px);
  }

  .qg-button:active:not([disabled]) {
    transform: translateY(1px) scale(0.98);
  }

  .qg-button.is-pressed,
  .qg-generate.is-pressed {
    animation: qg-press 360ms var(--auth-ease);
  }

  .qg-how__step,
  .qg-faq__item {
    transition: transform var(--transition-normal), border-color var(--transition-normal);
  }

  .qg-how__step:hover,
  .qg-faq__item:hover {
    transform: translateY(-2px);
    border-color: var(--auth-line-strong);
  }

  .qg-reveal [data-reveal] {
    transition: opacity 650ms var(--auth-ease), transform 650ms var(--auth-ease);
  }

  .qg-reveal [data-reveal]:not(.is-revealed) {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-aurora,
  .auth-card__glow {
    animation: none;
  }

  .auth-submit::before {
    transition: none;
  }
}

@keyframes qg-float {
  from { transform: rotate(-6deg) translate3d(0, 0, 0); }
  to { transform: rotate(-2deg) translate3d(-8px, 14px, 0); }
}

@keyframes qg-breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes qg-twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes qg-pop {
  from { transform: scale(0.94); }
  to { transform: scale(1); }
}

@keyframes qg-reveal-code {
  from { opacity: 0; transform: scale(0.9) rotate(-2deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes qg-scan {
  0% { opacity: 0; transform: translate3d(0, -100%, 0); }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(0, 560%, 0); }
}

@keyframes qg-press {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes qg-appear {
  from { opacity: 0; transform: translate3d(0, -4px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
