/* The free QR code generator: type on the left, the code on the right from 60rem up.
   Font, colours, buttons and fields come from base.css. */
.page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
}

.intro {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2rem;
  min-width: 0; /* lets the form shrink on very narrow screens */
  padding: 1.25rem max(1.25rem, env(safe-area-inset-right)) 2.5rem max(1.25rem, env(safe-area-inset-left));
}

.intro-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* "Create my card" stays on one line, also where the left column is at its narrowest (60rem and just above) */
.intro-top .text-link {
  white-space: nowrap;
}

/* On a phone the mark stays and the name gives its place to the switches and the link (still read aloud) */
@media (max-width: 30rem) {
  .intro-top .brand {
    gap: 0;
    font-size: 0;
  }
}

.fineprint {
  padding: 1rem max(1.25rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  color: var(--muted);
  font-size: 0.875rem;
}

@media (min-width: 60rem) {
  .page {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto;
  }

  .intro {
    padding: 1.5rem clamp(2rem, 5vw, 4.5rem) 1rem;
  }

  .stage {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .fineprint {
    grid-column: 1;
    grid-row: 2;
    padding: 1rem clamp(2rem, 5vw, 4.5rem) 2rem;
  }
}

/* Left side */
.pitch {
  align-self: center;
  min-width: 0;
  max-width: 36rem;
}

h1 {
  font-size: clamp(2.25rem, 3.4vw + 1rem, 3.75rem);
  font-weight: 700;
  line-height: 1.03;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

mark {
  background: none;
  color: var(--accent-text);
}

.lede {
  max-width: 30rem;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 1.125rem;
  text-wrap: pretty;
}

.field {
  margin-top: 2rem;
}

/* Link or contact: the pressed one is filled. */
.switch {
  display: inline-flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.switch .btn {
  color: var(--muted);
}

.switch .btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

.field-row {
  display: flex;
  gap: 0.5rem;
}

.field-row .input {
  flex: 1;
  min-width: 0;
  min-height: 3.5rem;
}

.field-row .btn {
  min-height: 3.5rem;
}

.contact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.contact .label {
  min-width: 0;
  margin: 0;
}

.contact .input {
  margin-top: 0.375rem;
}

.contact .wide {
  grid-column: 1 / -1;
}

@media (max-width: 26rem) {
  .contact .roomy {
    grid-column: 1 / -1;
  }
}

.more {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.hint {
  min-height: 3em; /* two lines, so the page does not jump when the message changes */
  margin-top: 0.625rem;
  text-wrap: balance;
  color: var(--muted);
  font-size: 0.9375rem;
}

.hint.is-error {
  color: var(--danger);
  font-weight: 600;
}

/* Right side: the code on a tinted field */
.stage {
  display: grid;
  place-items: center;
  padding: 2rem max(1.25rem, env(safe-area-inset-right)) 2rem max(1.25rem, env(safe-area-inset-left));
  background: var(--tint);
}

.stage-inner {
  display: grid;
  gap: 1.25rem;
  width: min(100%, 26rem);
}

/* Two columns: the tile gives way so code and buttons fit a short laptop window. */
@media (min-width: 60rem) {
  .stage-inner {
    width: min(100%, 26rem, max(15rem, 100dvh - 18rem));
  }
}

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--r-panel);
  background: #fff;
  box-shadow: var(--shadow);
  forced-color-adjust: none; /* keep white behind the code in Windows contrast themes */
}

.tile > * {
  grid-area: 1 / 1;
}

.tile svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #dcdce1;
}

.stage[data-state="ready"] .tile svg {
  fill: #000;
}

.tile-note {
  display: none;
  max-width: 11ch;
  color: #55555f;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.stage[data-state="empty"] .tile-note-empty,
.stage[data-state="error"] .tile-note-error {
  display: block;
}

.readout {
  display: grid;
  align-content: start;
  gap: 0.125rem;
  min-height: 4.5rem;
}

.stage:not([data-state="ready"]) .readout {
  visibility: hidden;
}

.readout-label {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.readout-target {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-underline-offset: 0.2em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.actions .btn {
  flex: 1 1 0;
}

.actions .btn-primary {
  flex-basis: 100%;
  min-height: 3.5rem;
}

/* Motion: one rise on load, one pop when a code appears. */
@media (prefers-reduced-motion: no-preference) {
  .pitch > *,
  .stage-inner {
    animation: rise 0.6s var(--ease) both;
  }

  .pitch > .lede {
    animation-delay: 0.06s;
  }

  .pitch > .field,
  .stage-inner {
    animation-delay: 0.12s;
  }

  .stage[data-state="ready"] .tile svg {
    animation: pop 0.3s var(--ease);
  }

  @keyframes pop {
    from {
      opacity: 0;
      transform: scale(0.97);
    }
  }
}

/* ---- The two small tools (vCard generator, WiFi QR code) and the foot they share with this page ----
   A tool page has words under the tool: the tool keeps the first screen, the guide follows. */

/* The photo of the contact file: a round view, its button and one line of help */
.shot {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.shot-view {
  display: grid;
  place-items: center;
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  overflow: hidden;
  border: 1.5px dashed var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
}

.shot-view .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.shot-view img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A chosen photo takes the place of the camera */
.shot-view img:not([hidden]) + .icon {
  display: none;
}

.shot-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The WiFi form: its fields stand one under the other. (Only that form: the QR code generator's
   own switch keeps its space.) */
[data-tool="wifi"] > .input + .label,
[data-tool="wifi"] > .switch + .label {
  margin-top: 1rem;
}

[data-tool="wifi"] > .switch {
  margin-bottom: 0;
}

/* Three choices, the last one long in French: on a narrow phone they close up to stay inside the form */
@media (max-width: 23rem) {
  [data-tool="wifi"] > .switch .btn {
    padding-inline: 0.625rem;
  }
}

.tick {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem; /* room for a thumb */
  margin-top: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.tick input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

:is([data-page="vcard"], [data-page="wifi"]) .actions .btn .icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* A long label (French) breaks rather than widen a 320px phone */
:is([data-page="vcard"], [data-page="wifi"]) .actions .btn {
  padding-block: 0.5rem;
  line-height: 1.2;
  white-space: normal;
}

/* "Print a sign" stays on one line: where it does not fit beside SVG (French, 320px) it takes a row of its own */
#print {
  flex: 1 0 auto;
  white-space: nowrap;
}

/* The sign: its two lines show on paper only */
.sheet-title,
.sheet-name {
  display: none;
}

.guide {
  width: min(100% - 2.5rem, 44rem);
  margin-inline: auto;
  padding-block: clamp(3rem, 8vw, 5rem) 1rem;
}

.guide h2 {
  margin-top: 2rem;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.guide h2:first-child {
  margin-top: 0;
}

.guide p {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1.0625rem;
  text-wrap: pretty;
}

/* The last line of the two small tools' questions: what they do with what is typed */
.guide .guide-note {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
}

/* "Print a sign", on the WiFi page: the paper holds the heading, the code and the network name. */
@media print {
  /* Light whatever the theme: with "Background graphics" ticked, the dark theme would print a dark band around the sheet */
  :root[data-page="wifi"] {
    color-scheme: light;
  }

  [data-page="wifi"],
  [data-page="wifi"] body {
    background: #fff;
  }

  [data-page="wifi"] :is(.intro, .guide, .actions, .readout, .sr-only) {
    display: none;
  }

  [data-page="wifi"] .page {
    display: block;
    min-height: 0;
  }

  [data-page="wifi"] .stage {
    display: block;
    padding: 3cm 0 0;
    background: none;
  }

  [data-page="wifi"] .stage-inner {
    width: auto;
    animation: none;
  }

  .sheet {
    display: grid;
    justify-items: center;
    gap: 1.5rem;
    color: #000;
    text-align: center;
  }

  .sheet .tile {
    width: 11cm;
    box-shadow: none;
  }

  .sheet-title {
    display: block;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
  }

  .sheet-name {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    overflow-wrap: anywhere;
  }
}

/* The split page fills the window: the site's foot follows it at once, with no strip of page between */
main.page + .site-foot {
  margin-top: 0;
}

/* "Save to my account", under a link on screen (app.js): the question, the button and the one-line difference
   between the code above, free for ever, and a code kept in the account, which counts its scans */
.keep {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.keep-q {
  font-weight: 700;
}

/* A long label (French) breaks rather than widen a 320 px phone */
.keep .btn {
  max-width: 100%;
  white-space: normal;
}

.keep-why {
  max-width: 24rem;
  color: var(--muted);
  font-size: 0.875rem;
}
