/* ============================================================
   QR Code Studio - editorial system
   Paper & ink, one vermilion accent. Type-led, grid-native.
   ============================================================ */

@font-face {
  font-family: "Newsreader";
  src: url(/assets/fonts/newsreader.woff2) format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url(/assets/fonts/newsreader-italic.woff2) format("woff2");
  font-weight: 400 500;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url(/assets/fonts/hanken-grotesk.woff2) format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url(/assets/fonts/jetbrains-mono.woff2) format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f4f1ea;
  --paper-2: #ece7db;
  --paper-3: #e3ddce;
  --ink: #17160f;
  --ink-2: #57534a;      /* warm-tinted secondary, not gray */
  --ink-3: #8a8578;      /* faint */
  --line: #d7d0c0;
  --line-strong: #c3baa6;
  --accent: #e5361b;     /* vermilion */
  --accent-deep: #b8290f;
  --ok: #2f7d4f;
  --err: #c0301a;

  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 24px 48px -28px rgba(23, 22, 15, 0.45), 0 8px 18px -14px rgba(23, 22, 15, 0.3);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --maxw: 1160px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Living module-grid canvas behind everything */
#bg-grid {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
body > *:not(#bg-grid) { position: relative; z-index: 1; }

/* Browser surfaces themed from the palette */
::selection { background: var(--accent); color: #fff; }
::-moz-selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
html { scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid var(--paper); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

a { color: var(--ink); text-decoration: none; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 440;
  font-optical-sizing: auto;
  font-synthesis: none;
  letter-spacing: -0.02em;
  line-height: 1.06;
  margin: 0;
  text-wrap: balance;
}

/* Micro-labels: mono, annotating data fields (spec style) */
.ey, label, legend, .meta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* -------------------- Layout shell -------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px clamp(20px, 5vw, 56px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand svg { display: block; width: 30px; height: 30px; }
.brand-name { font-family: var(--sans); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand-name em { font-style: normal; color: var(--accent); }

.site-nav { display: flex; align-items: center; gap: clamp(16px, 3vw, 34px); }
.site-nav a {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  position: relative;
  padding: 4px 0;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1px; width: 100%;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform 0.4s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); }

.pill {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.2s var(--ease);
}
.pill svg { width: 13px; height: 13px; }
.pill:hover { background: var(--ink); color: var(--paper); }
.pill.pill-pro { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.pill-pro:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

/* -------------------- Hero -------------------- */
.hero { max-width: var(--maxw); margin: clamp(28px, 6vw, 64px) auto clamp(24px, 4vw, 40px); padding: 0 clamp(20px, 5vw, 56px); }
.hero h1 {
  font-size: clamp(40px, 9vw, 112px);
  font-weight: 420;
  font-variation-settings: "opsz" 72;
  line-height: 0.98;
  max-width: 15ch;
}
.hero h1 .ink-accent { color: var(--accent); font-style: italic; }
.hero-sub {
  margin: clamp(20px, 3vw, 30px) 0 0;
  max-width: 56ch;
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--ink-2);
}
.hero-sub strong { color: var(--ink); font-weight: 600; }

/* word-stagger reveal */
.reveal-word { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .js .reveal-word { opacity: 0; transform: translateY(0.5em) rotate(1.5deg); animation: wordIn 0.9s var(--ease) forwards; animation-delay: var(--d, 0s); }
  @keyframes wordIn { to { opacity: 1; transform: none; } }
}

/* generic scroll reveal (varied per section, see nth rules) */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
  .js .reveal.in { opacity: 1; transform: none; }
}

/* -------------------- Studio (the tool) -------------------- */
.studio {
  max-width: var(--maxw);
  margin: 0 auto clamp(60px, 9vw, 120px);
  padding: 0 clamp(20px, 5vw, 56px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
}
@media (max-width: 900px) { .studio { grid-template-columns: 1fr; } }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(20px, 2.6vw, 32px);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; }
.panel-head h2 { font-size: 22px; font-weight: 480; }
.panel-head .meta { font-size: 10.5px; }

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
label, legend { display: block; margin-bottom: 9px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

textarea, select, input[type="text"] {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 13px;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
  resize: vertical;
}
select { font-family: var(--sans); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2357534a' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; cursor: pointer;
}
textarea:hover, select:hover, input[type="text"]:hover { border-color: var(--line-strong); }
textarea:focus, select:focus, input[type="text"]:focus {
  outline: none; border-color: var(--ink); background: var(--paper);
}

input[type="color"] {
  width: 100%; height: 46px; padding: 4px; cursor: pointer;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input[type="color"]:hover { border-color: var(--line-strong); }
input[type="file"] { width: 100%; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
input[type="file"]::file-selector-button {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  margin-right: 12px; padding: 8px 12px; border: 1px solid var(--ink); background: transparent;
  color: var(--ink); border-radius: 999px; cursor: pointer; transition: all 0.25s var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--ink); color: var(--paper); }

/* range */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 2px; background: var(--line-strong); border-radius: 2px; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--accent);
  transition: transform 0.2s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: var(--accent); border: 3px solid var(--paper); }

/* quick templates */
.quicktypes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quicktypes button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink-2);
  padding: 7px 12px; border-radius: 999px; cursor: pointer; transition: all 0.25s var(--ease);
}
.quicktypes button:hover { border-color: var(--ink); color: var(--ink); }
.quicktypes button.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* pro fieldset */
.pro-section { position: relative; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; margin-top: 6px; }
.pro-section legend { padding: 0 8px; display: inline-flex; align-items: center; gap: 8px; }
.tag { font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.12em; padding: 2px 6px; border-radius: 4px; background: var(--accent); color: #fff; }
.tag-sm { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em; padding: 1px 5px; border-radius: 4px; border: 1px solid currentColor; }
.link-btn { background: none; border: none; padding: 6px 0; cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.link-btn:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }

/* locked overlay */
.locked .pro-section { opacity: 0.5; filter: saturate(0.4); }
.locked .pro-section::after {
  content: "Locked - unlock Pro"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
  background: color-mix(in srgb, var(--paper) 55%, transparent); border-radius: var(--r-md); cursor: pointer;
}

/* -------------------- Preview -------------------- */
.preview { background: var(--paper); border: none; box-shadow: var(--shadow); border-radius: var(--r-lg);
  padding: clamp(22px, 2.6vw, 32px); display: flex; flex-direction: column; align-items: center; position: sticky; top: 22px; }
@media (max-width: 900px) { .preview { position: static; } }

.qr-stage { position: relative; width: 100%; max-width: 320px; margin: 0 auto 22px; }
.qr-canvas {
  position: relative; background: #fff; border-radius: 12px; padding: 18px;
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1/1; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(23,22,15,0.06);
}
.qr-canvas canvas, .qr-canvas svg { width: 100% !important; height: 100% !important; border-radius: 4px; }
/* scan-reveal overlay */
.qr-stage::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 42%;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 22%, transparent), transparent);
  opacity: 0; pointer-events: none; border-radius: 12px;
}
@media (prefers-reduced-motion: no-preference) {
  .qr-stage.scanning .qr-canvas > * { animation: qrClip 0.62s var(--ease); }
  .qr-stage.scanning::after { animation: qrScan 0.62s var(--ease); }
  @keyframes qrClip { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes qrScan { 0% { opacity: 0; transform: translateY(-100%); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(240%); } }
}

.size-row { display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 20px; }
.size-row label { margin: 0; white-space: nowrap; }
.size-row input[type="range"] { flex: 1; }
.size-row output { font-family: var(--mono); font-size: 13px; color: var(--ink); min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }

.download-row { display: flex; gap: 12px; width: 100%; }
.btn {
  flex: 1; font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--ink); background: transparent; color: var(--ink);
  padding: 14px 16px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), transform 0.18s var(--ease), border-color 0.3s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; }
.note { font-family: var(--sans); font-size: 13px; color: var(--ink-2); margin: 16px 0 0; text-align: center; max-width: 42ch; }

/* -------------------- Editorial feature list (no card grid) -------------------- */
.feats { max-width: var(--maxw); margin: 0 auto clamp(60px, 9vw, 120px); padding: 0 clamp(20px, 5vw, 56px); }
.feats > h2 { font-size: clamp(28px, 4vw, 46px); font-weight: 440; max-width: 18ch; margin-bottom: clamp(30px, 4vw, 54px); }
.feats > h2 em { font-style: italic; color: var(--accent); }
.feat-row {
  display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(16px, 4vw, 64px);
  padding: clamp(22px, 3vw, 34px) 0; border-top: 1px solid var(--line);
  align-items: baseline;
}
.feat-row:last-child { border-bottom: 1px solid var(--line); }
.feat-row h3 { font-size: clamp(21px, 2.4vw, 30px); font-weight: 460; }
.feat-row p { margin: 0; color: var(--ink-2); font-size: 16px; max-width: 60ch; }
.feat-row .idx { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: 0.1em; display: block; margin-bottom: 10px; }
@media (max-width: 720px) { .feat-row { grid-template-columns: 1fr; gap: 10px; } }

/* -------------------- FAQ -------------------- */
.faq { max-width: 860px; margin: 0 auto clamp(70px, 10vw, 130px); padding: 0 clamp(20px, 5vw, 56px); }
.faq > h2 { font-size: clamp(26px, 3.6vw, 40px); font-weight: 440; margin-bottom: clamp(22px, 3vw, 36px); }
.faq details { border-top: 1px solid var(--line); padding: 6px 0; }
.faq details:last-of-type { border-bottom: 1px solid var(--line); }
.faq summary {
  list-style: none; cursor: pointer; padding: 18px 40px 18px 0; position: relative;
  font-family: var(--display); font-size: clamp(18px, 2vw, 23px); font-weight: 440; letter-spacing: -0.015em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 4px; top: 50%; width: 13px; height: 13px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13'%3E%3Cpath d='M6.5 1v11M1 6.5h11' stroke='%23e5361b' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat;
  transform: translateY(-50%); transition: transform 0.35s var(--ease);
}
.faq details[open] summary::after { transform: translateY(-50%) rotate(135deg); }
.faq details p { margin: 0 0 18px; color: var(--ink-2); font-size: 16px; max-width: 68ch; }
.faq details a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* -------------------- Footer -------------------- */
.site-footer { border-top: 1px solid var(--line); padding: 40px clamp(20px, 5vw, 56px) 64px; max-width: var(--maxw); margin: 0 auto; }
.site-footer .meta { font-size: 11px; color: var(--ink-2); line-height: 1.9; }
.site-footer a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* -------------------- Modal -------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  transition: opacity 0.4s var(--ease);
}
@supports (backdrop-filter: blur(2px)) { .modal-backdrop { backdrop-filter: blur(3px); } }
@starting-style { .modal-backdrop { opacity: 0; } }
.modal {
  background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow);
  max-width: 440px; width: 100%; padding: clamp(26px, 3vw, 38px); position: relative;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
@starting-style { .modal { opacity: 0; transform: translateY(16px) scale(0.97); } }
.modal-close { position: absolute; top: 16px; right: 18px; background: none; border: none; cursor: pointer; color: var(--ink-2); padding: 4px; line-height: 0; }
.modal-close svg { width: 20px; height: 20px; }
.modal-close:hover { color: var(--ink); }
.modal h2 { font-size: 30px; font-weight: 460; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.modal .price-note { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 22px; }
.pro-list { list-style: none; margin: 0 0 24px; padding: 0; }
.pro-list li { padding: 11px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; font-size: 15.5px; }
.pro-list li svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.pro-list li strong { font-weight: 600; }
.license-box { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 22px; }
.license-row { display: flex; gap: 10px; margin-top: 10px; }
.license-row input { flex: 1; }
.license-row .btn { flex: 0 0 auto; }
.license-msg { font-family: var(--mono); font-size: 12px; margin: 12px 0 0; min-height: 18px; letter-spacing: 0.02em; }
.license-msg.ok { color: var(--ok); }
.license-msg.err { color: var(--err); }

/* barcode-specific tweaks */
.bc-stage { max-width: 360px; aspect-ratio: auto; padding: 24px; }
.bc-error { font-family: var(--mono); font-size: 12px; color: var(--err); margin-top: 10px; }

[hidden] { display: none !important; }

@media (max-width: 620px) {
  .site-header { padding: 16px 20px; }
  .site-nav { gap: 16px; }
  .site-nav a:not(.nav-cross) { display: none; }
  .pill { padding: 8px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
