/* ═══════════════════════════════════════════════════════
   Obzek.io — Keychain Retain
   Tokens mirror ../../styles.css so the app reads as part of the site.
   ═══════════════════════════════════════════════════════ */

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

/* Author `display` rules outrank the UA stylesheet's `[hidden] { display:none }`,
   so anything toggled via the `hidden` property needs this to actually hide. */
[hidden] { display: none !important; }

:root {
  --bg:           #05020F;
  --bg-surface:   #0A0619;
  --bg-card:      #0F0A22;
  --purple-mid:   #4A1D96;
  --purple-vivid: #6D28D9;
  --gold:         #C47B0A;
  --gold-bright:  #F59E0B;
  --gold-light:   #FCD34D;
  --text:         #EDE8FF;
  --text-sub:     #9D8EC4;
  --text-muted:   #4D4068;
  --border:       rgba(109, 40, 217, 0.22);
  --border-gold:  rgba(245, 158, 11, 0.32);
  --danger:       #F87171;
  --ok:           #34D399;

  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 12px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Same purple wash the landing page uses, so the app doesn't feel bolted on. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -10%, rgba(109,40,217,.20), transparent 65%),
    radial-gradient(45rem 35rem at 95% 5%, rgba(245,158,11,.07), transparent 60%);
}

a { color: var(--gold-light); }

/* The topbar and its tool switcher live in ../shared/css/topbar.css. */

/* ─── LAYOUT ────────────────────────────────────────── */
main { max-width: 1400px; margin: 0 auto; padding: 2.5rem 2rem 4rem; }

.page-head { margin-bottom: 2rem; max-width: 64ch; }
.page-head h1 {
  font-family: var(--font-head); font-weight: 800; font-size: clamp(1.9rem, 4vw, 2.6rem);
  letter-spacing: -.035em; line-height: 1.1;
}
.page-head p { color: var(--text-sub); margin-top: .6rem; font-size: .95rem; }

.layout { display: grid; grid-template-columns: minmax(0,1fr) 420px; gap: 1.5rem; align-items: start; }
.col-build { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 1.5rem 1rem 3rem; }
  .controls { grid-template-columns: 1fr !important; }
}

/* ─── PANEL ─────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.panel-head h2 {
  font-family: var(--font-head); font-size: .95rem; font-weight: 700;
  letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem;
}
.step {
  display: grid; place-items: center; width: 1.4rem; height: 1.4rem;
  border-radius: 50%; font-size: .7rem; font-weight: 700;
  background: rgba(109,40,217,.28); color: var(--gold-light);
  border: 1px solid var(--border);
}

/* ─── BUTTONS ───────────────────────────────────────── */
.btn {
  font-family: var(--font-head); font-size: .8rem; font-weight: 600;
  padding: .55rem .95rem; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; transition: .18s ease; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: none; color: var(--text);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { border-color: var(--border); color: var(--text-sub); }
.btn-ghost:hover:not(:disabled) { border-color: var(--purple-vivid); color: var(--text); background: rgba(109,40,217,.14); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a0d00; font-weight: 700;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-block { width: 100%; margin-top: .75rem; padding: .8rem; }

/* ─── CONTROLS ──────────────────────────────────────── */
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.ctrl { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.ctrl-wide { grid-column: 1 / -1; }
.ctrl > span { font-size: .74rem; color: var(--text-sub); display: flex; justify-content: space-between; gap: .5rem; }
.ctrl > span b { color: var(--gold-light); font-family: var(--font-head); font-variant-numeric: tabular-nums; }

select, input[type="range"], input[type="text"], input[type="url"],
input[type="number"], textarea { width: 100%; font-family: var(--font-body); }
select, input[type="text"], input[type="url"], input[type="number"], textarea {
  padding: .5rem .6rem; border-radius: 8px; font-size: .8rem;
  background: var(--bg-surface); color: var(--text); border: 1px solid var(--border);
}
textarea { resize: vertical; line-height: 1.5; min-height: 4.5rem; }
select { cursor: pointer; }
::placeholder { color: var(--text-muted); }
select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple-vivid); outline-offset: 1px;
}

/* The icon box shows the actual glyph, at a size worth looking at. */
#icon {
  font-family: var(--font-head); font-size: 1.35rem; font-weight: 700;
  text-align: center; padding: .35rem .6rem; line-height: 1.5;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: rgba(109,40,217,.35); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold-bright); border: none; cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold-bright); border: none; cursor: pointer;
}
input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
input:disabled { opacity: .45; cursor: not-allowed; }

.ctrl.check { flex-direction: row; align-items: center; gap: .55rem; }
.ctrl.check span { font-size: .78rem; color: var(--text-sub); }
input[type="checkbox"] {
  width: 1rem; height: 1rem; accent-color: var(--gold-bright);
  cursor: pointer; flex: none;
}

.color-wrap { display: flex; align-items: center; gap: .5rem; }
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2.1rem; padding: 0; cursor: pointer;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

.hint { font-size: .74rem; color: var(--text-muted); margin-top: .7rem; line-height: 1.5; }
.hint em { color: var(--text-sub); font-style: normal; }
/* Inside a control the gap already does the spacing. */
.ctrl > .hint { margin-top: 0; font-family: var(--font-mono); }

/* ─── PREFIXED FIELD ────────────────────────────────── */
/* An address whose first half isn't yours to type. It reads as one continuous
   URL with the input beside it, but is dimmed and unselectable so it never
   looks editable. */
.prefixed {
  display: flex; align-items: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 .6rem;
  transition: border-color .2s;
}
.prefixed:focus-within { border-color: var(--border-gold); }
.prefixed .prefix {
  flex: none; color: var(--text-muted);
  font-family: var(--font-mono); font-size: .8rem;
  white-space: nowrap; user-select: none; cursor: text;
}
.prefixed input {
  flex: 1; min-width: 0;
  border: none; background: transparent; border-radius: 0;
  padding: .5rem 0; font-family: var(--font-mono); font-size: .8rem;
}
.prefixed input:focus-visible { outline: none; }

@media (max-width: 400px) {
  .prefixed .prefix, .prefixed input { font-size: .74rem; }
}

/* ─── PAYLOAD READOUT ───────────────────────────────── */
/* What the code will actually carry, scheme and all — the difference between
   a tag that opens a page and one that offers to copy a string. */
.payload { font-size: .74rem; color: var(--text-muted); }
.payload code {
  font-family: var(--font-mono); font-size: .74rem; color: var(--gold-light);
  word-break: break-all;
}

/* ─── EMOJI QUICK PICKS ─────────────────────────────── */
.emoji-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.emoji-btn {
  width: 2.3rem; height: 2.3rem; font-size: 1.15rem; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-surface); transition: .15s ease;
}
.emoji-btn:hover { border-color: var(--gold-bright); background: rgba(245,158,11,.08); transform: translateY(-1px); }
.emoji-btn:focus-visible { outline: 2px solid var(--purple-vivid); outline-offset: 1px; }

/* ─── SHRINK BOX ────────────────────────────────────── */
/* Its own frame because it changes what every other millimetre on the page
   means — printed size stops equalling finished size the moment it's on. */
.shrink-box {
  border: 1px dashed var(--border-gold);
  border-radius: 10px;
  padding: .9rem 1rem;
  background: rgba(245,158,11,.04);
  display: flex; flex-direction: column; gap: .8rem;
}
.shrink-box .hint:first-of-type { color: var(--gold-light); }
.shrink-box > div { display: flex; flex-direction: column; gap: .35rem; }

/* ─── PREVIEW ───────────────────────────────────────── */
.stage {
  position: relative; border-radius: var(--r); overflow: hidden;
  background: repeating-conic-gradient(#151024 0% 25%, #100c1c 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
  display: grid; place-items: center; min-height: 200px;
  padding: .9rem;
}
.stage-sheet { min-height: 150px; }
#cardPreview, #sheetPreview {
  display: block; max-width: 100%;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.55));
}

.meta {
  margin-top: .7rem; font-size: .76rem; color: var(--text-sub);
  text-align: center; font-variant-numeric: tabular-nums;
}

/* The scannability line. It is the one number on this page that decides
   whether the finished object works at all, so it carries its own colour. */
.scan-out {
  margin-top: .45rem; padding: .45rem .6rem; border-radius: 8px;
  font-family: var(--font-mono); font-size: .68rem; text-align: center;
  border: 1px solid var(--border); color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.scan-out.ok   { border-color: rgba(52,211,153,.35);  color: var(--ok); }
.scan-out.warn { border-color: var(--border-gold);    color: var(--gold-light); }
.scan-out.bad  { border-color: rgba(248,113,113,.45); color: var(--danger); }

.notices { list-style: none; margin-top: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.notices:empty { display: none; }
.notices li {
  font-size: .74rem; line-height: 1.45; padding: .45rem .6rem .45rem 1.7rem;
  border-radius: 8px; position: relative;
  background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-sub);
}
.notices li::before { position: absolute; left: .6rem; top: .45rem; font-size: .7rem; }
.notices li.err  { border-color: rgba(248,113,113,.4); color: #FCA5A5; }
.notices li.err::before  { content: '✕'; color: var(--danger); }
.notices li.warn { border-color: var(--border-gold); }
.notices li.warn::before { content: '!'; color: var(--gold-bright); font-weight: 700; }
.notices li.info::before { content: 'i'; color: var(--purple-vivid); font-weight: 700; font-style: italic; }

.result-meta { margin-top: .6rem; font-size: .74rem; color: var(--text-sub); text-align: center; }

.footnote { margin-top: 2rem; font-size: .76rem; color: var(--text-muted); text-align: center; max-width: 74ch; margin-inline: auto; }
.footnote strong { color: var(--text-sub); }

/* ─── TOAST ─────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: 200; padding: .7rem 1.1rem; border-radius: 9px;
  background: var(--bg-card); border: 1px solid var(--border-gold);
  font-size: .8rem; box-shadow: 0 12px 40px rgba(0,0,0,.5); max-width: 90vw;
}
.toast.err { border-color: rgba(248,113,113,.5); color: var(--danger); }

/* ─── PRINTING ──────────────────────────────────────── */
/* The sheet is rasterised to a single image first, so what prints is exactly
   what was previewed — no reflow, no resampled QR modules. */
.print-area { display: none; }
.print-area img { display: block; width: 100%; height: 100%; object-fit: contain; }

@media print {
  body { background: #fff; }
  body::before, #topbar, main, .toast { display: none !important; }
  .print-area {
    display: block !important;
    position: absolute; inset: 0; margin: 0; padding: 0;
    width: 100%; height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
