/* =============================================================================
   QRelieve — styles.css
   1. Tokens  2. Reset  3. Utilities  4. Header  5. Hero/Tool  6. Sections
   7. Ads  8. Footer  9. Responsive
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --ink: #18181b;
  --ink-soft: #71717a;
  --line: #e7e7e9;
  --accent: #18181b;
  --accent-ink: #ffffff;
  --accent-soft: #f1f1f2;
  --accent-shadow: rgba(24, 24, 27, .18);
  --good: #15803d;
  --warn: #b45309;
  --bad: #dc2626;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 6px 20px rgba(24, 24, 27, .05);
  --shadow-lg: 0 12px 40px rgba(24, 24, 27, .09);
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e10;
    --surface: #17171a;
    --surface-2: #1e1e21;
    --ink: #f4f4f5;
    --ink-soft: #a1a1aa;
    --line: #2a2a2e;
    --accent: #fafafa;
    --accent-ink: #18181b;
    --accent-soft: #26262a;
    --accent-shadow: rgba(0, 0, 0, .5);
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
  }
}

/* 2. Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px; line-height: 1.6;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
p { text-wrap: pretty; }
input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* 3. Utilities ------------------------------------------------------------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 999; background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 8px; }
.skip-link:focus { top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .72rem 1.1rem; border-radius: var(--radius-sm); font-weight: 700;
  transition: transform .2s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease);
  border: 1.5px solid transparent; white-space: nowrap;
}
.btn.sm { padding: .5rem .8rem; font-size: .9rem; }
.btn.big { padding: .95rem 1.2rem; font-size: 1.02rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px var(--accent-shadow); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px var(--accent-shadow); opacity: .92; }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.text { color: var(--ink-soft); }
.btn.text:hover { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn.is-busy { position: relative; }

/* 4. Header ---------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.25rem; display: inline-flex; align-items: center; gap: .5rem; }
.brand-mark { color: var(--accent); font-size: 1.3rem; }
.header-nav { display: flex; gap: 1.4rem; font-weight: 600; font-size: .95rem; color: var(--ink-soft); }
.header-nav a:hover { color: var(--accent); }

/* 5. Hero + Tool ----------------------------------------------------------- */
.hero { padding: clamp(1.8rem, 4vw, 3rem) 20px 1.2rem; text-align: center; }
.hero h1 { font-family: var(--display); font-size: clamp(2rem, 5vw, 3.2rem); }
.hero .sub { max-width: 720px; margin: 1rem auto 0; color: var(--ink-soft); font-size: clamp(1rem, 2.2vw, 1.15rem); }

.tool-card {
  margin: 1.6rem auto 0; max-width: var(--maxw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: clamp(1.1rem, 2.5vw, 1.8rem); text-align: left;
}
.tool-grid { display: grid; grid-template-columns: 1fr; gap: 1.6rem; }

.field { margin-bottom: 1.05rem; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .4rem; }
.field .hint { font-size: .82rem; color: var(--ink-soft); margin-top: .35rem; }
.controls input[type="text"], .controls select {
  width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
.controls input[type="text"]:focus, .controls select:focus { border-color: var(--accent); outline: none; }
input[type="color"] {
  width: 100%; height: 44px; padding: 3px; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); background: var(--bg); cursor: pointer;
}

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; }
.seg-btn { padding: .5rem 1rem; border-radius: 999px; font-weight: 600; font-size: .92rem; color: var(--ink-soft); }
.seg-btn.is-on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  padding: .5rem .85rem; border: 1.5px solid var(--line); border-radius: 999px;
  font-weight: 600; font-size: .9rem; background: var(--bg); color: var(--ink-soft);
  transition: all .18s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on { background: var(--surface); border-color: var(--accent); color: var(--ink); font-weight: 800; box-shadow: 0 0 0 1px var(--accent) inset; }
.chips.formats .chip { display: inline-flex; align-items: center; gap: .35rem; }
.chips.emojis .emoji-pick { font-size: 1.35rem; width: 46px; height: 46px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); display: grid; place-items: center; }
.chips.emojis .emoji-pick:hover { border-color: var(--accent); }
.chips.emojis .emoji-pick.is-on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent) inset; }
.logo-row { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; }

/* previews */
.previews { display: grid; gap: 1.4rem; }
.preview-block { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.preview-tag { display: inline-block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: .6rem; }
.qr-preview { display: grid; place-items: center; min-height: 220px; }
.qr-preview canvas, .qr-preview svg { width: 220px; height: 220px; border-radius: 8px; }
.dl-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem; }
.dl-row .btn { flex: 1 1 auto; }

.view3d { position: relative; width: 100%; height: 340px; border-radius: var(--radius-sm); overflow: hidden; background: linear-gradient(160deg, var(--surface-2), var(--bg)); cursor: grab; }
.view3d:active { cursor: grabbing; }
.view3d canvas { width: 100% !important; height: 100% !important; }
.view3d-status { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1.2rem; color: var(--ink-soft); font-size: .92rem; line-height: 1.5; }
.threed-controls { margin-top: 1rem; }
.threed-controls > label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .4rem; }
.threed-controls .field { margin-top: 1rem; margin-bottom: 0; }
.threed-controls input[type="text"] { width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }

/* warnings */
.warnings { list-style: none; margin: 1.2rem 0 0; padding: 0; display: grid; gap: .5rem; }
.warnings li { padding: .6rem .8rem .6rem 2.2rem; border-radius: var(--radius-sm); font-size: .9rem; position: relative; border: 1px solid var(--line); background: var(--bg); }
.warnings li::before { position: absolute; left: .75rem; top: .6rem; font-size: 1rem; }
.warnings .w-good { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.warnings .w-good::before { content: "✓"; color: var(--good); }
.warnings .w-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.warnings .w-warn::before { content: "!"; color: var(--warn); font-weight: 800; }
.warnings .w-bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.warnings .w-bad::before { content: "✕"; color: var(--bad); }
.warnings .w-info::before { content: "i"; color: var(--accent); font-style: italic; font-weight: 800; }

.privacy-badge { margin-top: 1.1rem; text-align: center; font-size: .9rem; color: var(--ink-soft); }
.engine-error { background: #fdecec; color: #b3272d; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }

/* 6. Sections -------------------------------------------------------------- */
.section { padding: clamp(2.4rem, 6vw, 4rem) 20px; opacity: 0; transform: translateY(16px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.section.in { opacity: 1; transform: none; }
.section h2 { font-family: var(--display); font-size: clamp(1.6rem, 3.6vw, 2.3rem); text-align: center; margin-bottom: 1.8rem; }

.steps { list-style: none; padding: 0; display: grid; gap: 1.2rem; grid-template-columns: 1fr; counter-reset: s; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.step-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); margin-bottom: .9rem; }
.steps h3 { font-size: 1.15rem; margin-bottom: .4rem; }
.steps p { color: var(--ink-soft); font-size: .96rem; }

.use-grid { display: grid; gap: 1.1rem; grid-template-columns: 1fr; }
.use-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.use-card.in { opacity: 1; transform: none; }
.use-ico { font-size: 1.8rem; display: block; margin-bottom: .6rem; }
.use-card h3 { font-size: 1.08rem; margin-bottom: .35rem; }
.use-card p { color: var(--ink-soft); font-size: .93rem; }

.seo-text { max-width: 780px; }
.seo-text h2 { text-align: left; }
.seo-text p { color: var(--ink-soft); margin-bottom: 1rem; }

.faq { max-width: 780px; margin-inline: auto; display: grid; gap: .7rem; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.faq-item summary { padding: 1rem 1.2rem; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; color: var(--accent); font-size: 1.4rem; font-weight: 700; transition: transform .2s var(--ease); }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-a { padding: 0 1.2rem 1.1rem; color: var(--ink-soft); }

/* 7. Ad slots -------------------------------------------------------------- */
.ad-slot {
  display: grid; place-items: center; position: relative;
  border: 2px dashed color-mix(in srgb, var(--ink-soft) 40%, transparent);
  border-radius: var(--radius-sm); background: repeating-linear-gradient(45deg, transparent, transparent 12px, color-mix(in srgb, var(--ink-soft) 6%, transparent) 12px, color-mix(in srgb, var(--ink-soft) 6%, transparent) 24px);
  color: var(--ink-soft); font-weight: 800; letter-spacing: .18em; font-size: .82rem;
}
.ad-slot span { padding: .2rem .6rem; }
.ad-leaderboard { min-height: 96px; margin: 1.6rem 0; }
.ad-incontent { min-height: 250px; margin: 0 0 1rem; }
.ad-footer { min-height: 120px; margin: 1rem 0 2rem; }

.ad-dialog { border: 0; border-radius: var(--radius); padding: 1.4rem; max-width: 420px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.ad-dialog::backdrop { background: rgba(10, 12, 20, .5); backdrop-filter: blur(2px); }
.ad-dialog-title { font-family: var(--display); font-size: 1.3rem; margin-bottom: .9rem; text-align: center; }
.ad-dialog .ad-popup { min-height: 250px; margin-bottom: 1rem; }
.ad-dialog-close { position: absolute; top: .7rem; right: .7rem; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--ink-soft); font-size: 1rem; }
.ad-dialog-close:hover { color: var(--bad); }
.ad-dialog .btn { width: 100%; }

.ad-toast { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .8rem; opacity: 0; transform: translateY(12px); transition: opacity .4s var(--ease), transform .4s var(--ease); }
.ad-toast.in { opacity: 1; transform: none; }
.ad-toast .ad-toast-slot { min-height: 90px; }
.ad-toast-close { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .8rem; box-shadow: var(--shadow); }

/* 8. Footer ---------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 2rem 20px; margin-top: 1rem; }
.footer-inner { display: flex; flex-direction: column; gap: .7rem; align-items: center; text-align: center; }
.footer-nav { display: flex; gap: 1.2rem; color: var(--ink-soft); font-weight: 600; }
.footer-nav a:hover { color: var(--accent); }
.site-footer .small { font-size: .8rem; color: var(--ink-soft); }

/* 9. Responsive ------------------------------------------------------------ */
@media (min-width: 720px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
  .use-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 960px) {
  .tool-grid { grid-template-columns: 1fr 1.05fr; align-items: start; }
  .use-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-preview canvas, .qr-preview svg { width: 260px; height: 260px; }
  .view3d { height: 380px; }
}
@media (max-width: 480px) {
  .header-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .section, .use-card { opacity: 1 !important; transform: none !important; transition: none; }
  html { scroll-behavior: auto; }
}
