/*
 * Presentation for the QR Business Card generator.
 *
 * Purpose
 *   Replaces the Bootstrap, jQuery and Popper bundles this page used to pull from two third-party
 *   CDNs. Everything here is hand-written so the deployed site makes zero external requests, which is
 *   what lets the Content-Security-Policy in index.html forbid off-origin loads outright.
 *
 * Design rules that must not be violated
 *   - No @import, no web fonts, no remote URLs of any kind. The CSP blocks them and the privacy
 *     promise in the README depends on their absence.
 *   - No framework may be reintroduced. A form this small does not need one.
 *   - Colours are declared as custom properties and re-declared for dark mode; never hard-code a
 *     colour outside the :root blocks.
 *
 * Related files
 *   - public/index.html - the only document that consumes this file.
 */

/* Palette. Light is the base; dark mode only re-declares the tokens. */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1b1b1f;
  --text-muted: #55555f;
  --border: #d3d3da;
  --accent: #1c5fd6;
  --accent-text: #ffffff;
  --accent-hover: #164ba8;
  --code-bg: #f0f0f3;
  --focus: #1c5fd6;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e24;
    --text: #e9e9ee;
    --text-muted: #a5a5b2;
    --border: #3a3a44;
    --accent: #6aa3ff;
    --accent-text: #10131a;
    --accent-hover: #8bb8ff;
    --code-bg: #14141a;
    --focus: #6aa3ff;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 1.5rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

main {
  max-width: 46rem;
  margin: 0 auto;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.25rem;
  margin: 2.5rem 0 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

.lede {
  color: var(--text-muted);
}

/* Every interactive element shares one visible focus treatment */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Form layout */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.hint {
  display: block;
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="url"] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:invalid:not(:placeholder-shown) {
  border-color: #c2352c;
}

/* Address groups use native disclosure widgets, so no JavaScript and no ARIA bookkeeping */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

summary {
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

details > .details-body {
  padding: 0 0.75rem 0.25rem;
  border-top: 1px solid var(--border);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

fieldset > legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.5rem;
}

/* Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.secondary:hover {
  background: transparent;
  color: var(--accent-hover);
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* QR output. The canvas is scaled up with nearest-neighbour so the modules stay crisp. */
#qrcode {
  display: block;
  width: min(320px, 100%);
  height: auto;
  image-rendering: pixelated;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
}

#qrcode[hidden] {
  display: none;
}

/* Status line for validation and download feedback; announced via aria-live in the markup */
.status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--text-muted);
}

.status[data-state="error"] {
  color: #c2352c;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .status[data-state="error"] {
    color: #ff8b82;
  }
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.875rem;
  white-space: pre-wrap;
  word-break: break-word;
}

ul.links {
  list-style: none;
  padding: 0;
}

ul.links li {
  margin-bottom: 0.35rem;
}

footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}
