/* QRQuick — style.css */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --border: #e2e4ee;
  --text: #171a26;
  --text-muted: #5d6274;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #ede9fe;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(23, 26, 38, .05), 0 8px 24px rgba(23, 26, 38, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2330;
  --border: #2a2f3d;
  --text: #e8eaf2;
  --text-muted: #9aa1b5;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-soft: #2a2145;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

.container { width: min(1120px, 100% - 2rem); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff;
  padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; gap: 1rem;
  height: 60px;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  text-decoration: none; color: var(--text); font-weight: 700;
  font-size: 1.15rem; letter-spacing: -.01em;
}
.brand-mark { display: block; }
.main-nav { display: flex; gap: .25rem; margin-left: auto; }
.main-nav a {
  color: var(--text-muted); text-decoration: none;
  padding: .45rem .8rem; border-radius: var(--radius-sm);
  font-size: .92rem; font-weight: 500;
  transition: color .15s, background .15s;
}
.main-nav a:hover { color: var(--text); background: var(--surface-2); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

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

.hero { padding: 3.25rem 0 1.5rem; text-align: center; }
.hero h1 {
  margin: 0; font-size: clamp(2.1rem, 5vw, 3.4rem);
  letter-spacing: -.035em; font-weight: 800; line-height: 1.1;
}
.subtitle {
  margin: .6rem 0 0; font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--text-muted);
}

/* ---------- Generator layout ---------- */

.generator { padding-bottom: 3rem; }
.generator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) {
  .generator-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
}

/* ---------- Type tabs ---------- */

.type-tabs {
  display: flex; flex-wrap: wrap; gap: .4rem;
}
.type-tab {
  appearance: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted);
  padding: .5rem .85rem; border-radius: 999px;
  font: inherit; font-size: .88rem; font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.type-tab:hover { border-color: var(--accent); color: var(--accent); }
.type-tab.is-active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}
.type-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Dynamic form ---------- */

.dynamic-fields {
  display: grid; gap: .9rem;
  margin-top: 1.2rem;
}
.field { display: grid; gap: .35rem; }
.field label, .custom-field label {
  font-size: .85rem; font-weight: 600; color: var(--text);
}
.hint { font-weight: 400; color: var(--text-muted); font-size: .78rem; }

input[type="text"], input[type="email"], input[type="tel"], input[type="url"],
input[type="password"], input[type="number"], select {
  font: inherit; font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus-visible, select:focus-visible, button:focus-visible,
input[type="color"]:focus-visible, input[type="range"]:focus-visible,
input[type="file"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="tel"]:focus,
input[type="url"]:focus, input[type="password"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

.field-error {
  display: none;
  font-size: .8rem; color: var(--danger); font-weight: 500;
}
.field.has-error .field-error { display: block; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }

.form-actions {
  display: flex; gap: .5rem; margin-top: 1rem;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none; border: 1px solid transparent;
  font: inherit; font-size: .92rem; font-weight: 600;
  padding: .6rem 1.1rem; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-muted); }

.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; margin-top: .9rem; }

/* ---------- Customize ---------- */

.customize {
  margin-top: 1.6rem; padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.section-title {
  margin: 0 0 .9rem; font-size: 1rem; font-weight: 700;
}
.custom-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem;
  margin-bottom: .9rem;
}
@media (max-width: 560px) { .custom-row { grid-template-columns: 1fr; } }
.custom-field { display: grid; gap: .35rem; align-content: start; }
.custom-field-wide { grid-column: 1 / -1; }
.custom-field label { font-size: .82rem; }

input[type="color"] {
  width: 100%; height: 42px; padding: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="file"] {
  font-size: .85rem; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: .55rem .7rem; background: var(--surface-2); width: 100%;
}
.logo-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.logo-warning {
  margin: .5rem 0 0; font-size: .8rem; color: #b45309;
}
[data-theme="dark"] .logo-warning { color: #fbbf24; }

/* ---------- Preview ---------- */

.preview-panel {
  display: flex; flex-direction: column;
  position: sticky; top: 76px;
}
@media (max-width: 900px) { .preview-panel { position: static; } }

.preview-stage {
  position: relative;
  display: grid; place-items: center;
  min-height: 320px;
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
}
#qrCanvas {
  width: min(100%, 380px);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border-radius: 4px;
}
.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; color: var(--text-muted); text-align: center; padding: 1rem;
}
.preview-empty svg { opacity: .5; }
.preview-empty p { margin: 0; font-size: .92rem; }
.preview-empty[hidden] { display: none; }

.preview-hint {
  min-height: 1.4em;
  margin: .7rem 0 .4rem;
  font-size: .85rem; color: var(--text-muted); text-align: center;
}
.preview-hint.error { color: var(--danger); }

.export-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: .55rem;
}
.export-actions .btn-primary { grid-column: 1 / -1; }
@media (max-width: 480px) { .export-actions { grid-template-columns: 1fr; } }

.privacy-note {
  margin: 1rem 0 0;
  font-size: .8rem; color: var(--text-muted);
  text-align: center;
}

/* ---------- About ---------- */

.about { padding: 2.5rem 0 3.5rem; }
.about h2 {
  margin: 0 0 1.2rem; font-size: 1.6rem; letter-spacing: -.02em;
}
.about-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; } }
.about-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.3rem;
}
.about-card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.about-card p { margin: 0; font-size: .9rem; color: var(--text-muted); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.6rem 0;
}
.footer-inner {
  display: flex; flex-wrap: wrap; gap: .4rem 1.5rem;
  align-items: baseline; justify-content: space-between;
}
.footer-inner p { margin: 0; font-size: .9rem; color: var(--text-muted); }
.footer-meta { font-size: .82rem !important; }

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

@media (prefers-reduced-motion: no-preference) {
  .panel { animation: rise .35s ease both; }
  .preview-panel { animation: rise .35s .06s ease both; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- Print ---------- */

@media print {
  body * { visibility: hidden; }
  #qrCanvas, #qrCanvas * { visibility: visible; }
  #qrCanvas {
    position: fixed; inset: 0; margin: auto;
    width: 90vmin; height: 90vmin;
  }
}
