/* styles.css — Burn After Reading. Mobile-first, CSS variables, automatic dark mode. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #171a21;
  --muted: #5c6470;
  --border: #dde1e8;
  --accent: #d8532b;        /* ember */
  --accent-ink: #ffffff;
  --ok: #0a7d2a;
  --danger: #c02818;
  --sas: #b23a12;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 24, 33, .08), 0 6px 20px rgba(20, 24, 33, .06);
}
/* Dark palette: automatic by OS preference (unless the user explicitly chose light via the toggle),
   or forced when data-theme="dark". The block is repeated so both selectors receive it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218;
    --surface: #171b24;
    --surface-2: #1f2530;
    --text: #e8ecf3;
    --muted: #9aa4b2;
    --border: #2a313d;
    --accent: #f2633a;
    --accent-ink: #14100e;
    --ok: #3ec26a;
    --danger: #ff6b5a;
    --sas: #ffa07f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --surface: #171b24;
  --surface-2: #1f2530;
  --text: #e8ecf3;
  --muted: #9aa4b2;
  --border: #2a313d;
  --accent: #f2633a;
  --accent-ink: #14100e;
  --ok: #3ec26a;
  --danger: #ff6b5a;
  --sas: #ffa07f;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* Make the `hidden` attribute reliable even on elements whose class sets `display`
   (e.g. .field/.qr) — author display rules otherwise override the UA [hidden] rule. */
[hidden] { display: none !important; }
body {
  font: 16px/1.55 -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand {
  font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  background: none; border: 0; color: var(--text); cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; gap: 6px;
}
.brand span { border-bottom: 2px solid transparent; }
.brand:hover span { border-color: var(--accent); }
.tag { font-size: 12px; color: var(--muted); margin-left: auto; }

main { flex: 1; padding: 18px; }

/* ---- screens ---- */
.screen { display: none; animation: fade .18s ease; }
.screen.active { display: block; }
.screen.scroll { overflow-y: auto; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h2 { font-size: 20px; line-height: 1.25; margin: 4px 0 16px; letter-spacing: -.01em; }

/* ---- home cards ---- */
.cards { display: grid; gap: 14px; }
.card {
  text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: grid; gap: 6px; cursor: pointer; color: var(--text); font: inherit;
}
button.card:hover { border-color: var(--accent); transform: translateY(-1px); transition: .15s; }
.card-static { cursor: default; }
.card-emoji { font-size: 26px; }
.card-title { font-size: 17px; font-weight: 650; }
.card-sub { color: var(--muted); font-size: 14px; }

.identity-strip { margin: 20px 2px 6px; font-size: 13px; color: var(--muted); }
.identity-strip code { color: var(--text); }
.home-nav { display: flex; gap: 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---- fields ---- */
.field { display: block; margin: 0 0 16px; font-size: 13px; color: var(--muted); font-weight: 600; }
.field > select, .field input, .field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.field textarea { resize: vertical; min-height: 48px; font-family: ui-monospace, Menlo, Consolas, monospace; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 6px; }
.copy-row input, .copy-row textarea { margin-top: 0; }
.copy-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; flex: 1 1 150px; min-width: 0; }

/* ---- buttons ---- */
.primary-btn, .ghost-btn {
  font: inherit; font-weight: 650; border-radius: 10px; padding: 11px 16px; cursor: pointer; white-space: nowrap;
}
.primary-btn { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: translateY(1px); }
.ghost-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.ghost-btn:hover { border-color: var(--accent); }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.link-btn.danger { color: var(--danger); }
.link-btn.back { margin-top: 14px; display: inline-block; color: var(--muted); }
.link-btn.back:hover { color: var(--accent); }

/* ---- notes / prose ---- */
.note { color: var(--muted); font-size: 14px; margin: 14px 0; }
.note.burned { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.prose { color: var(--text); font-size: 15px; }
.prose h3 { font-size: 15px; margin: 18px 0 6px; }
.prose ul { margin: 6px 0; padding-left: 20px; }
.prose li { margin: 4px 0; color: var(--muted); }
.prose li strong { color: var(--text); }

/* ---- safety number ---- */
.sas-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; margin: 8px 0 16px;
}
.sas-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sas { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 34px; font-weight: 700; letter-spacing: .14em; color: var(--sas); margin: 6px 0; }
.sas-hint { display: block; font-size: 13px; color: var(--muted); }

/* ---- results / qr / verified ---- */
.result { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.qr { display: flex; justify-content: center; margin: 6px 0 16px; }
.qr canvas { max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; border-radius: 10px; }
.verified { font-size: 14px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); margin-bottom: 12px; }
.verified.warn { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow); z-index: 20; max-width: 90%;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* ---- PIN / passphrase mode ---- */
.field small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.45; }
.field .opt { font-weight: 400; color: var(--muted); }
.note.lock { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.check-field { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; font-size: 14px; cursor: pointer; }
.check-field input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.check-field span { color: var(--muted); }
.check-field strong { color: var(--text); }
.reveal-error { color: var(--danger); font-size: 14px; font-weight: 600; margin: 8px 0; }

/* ---- contacts ---- */
.contacts-list { display: grid; gap: 10px; margin: 8px 0 16px; }
.contact-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.contact-main { flex: 1; min-width: 0; }
.contact-name { font-weight: 650; }
.contact-fp { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.contact-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.contact-badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.contact-badge.no { background: var(--surface-2); color: var(--muted); }
.contact-actions { display: flex; gap: 6px; align-items: center; }
.icon-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.icon-x:hover { color: var(--danger); background: var(--surface-2); }
.contacts-empty { color: var(--muted); font-style: italic; padding: 8px 0; }

/* ---- burn effect ---- */
#burn-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 9999; pointer-events: none; }
#app.burning { transition: opacity 1.8s ease, filter 1.8s ease, transform 1.8s ease; opacity: 0; filter: sepia(1) brightness(.35) contrast(1.5); transform: scale(.985) translateY(6px); pointer-events: none; }
.burn-cover { position: fixed; inset: 0; z-index: 9998; background: #0b0708; opacity: 0; transition: opacity .35s ease; pointer-events: none; }
.burn-banner { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 10000; font-size: 40px; font-weight: 800; letter-spacing: .02em; color: #ffb86b; text-shadow: 0 0 18px rgba(242,99,58,.85); pointer-events: none; }
.burn-btn { margin-top: 10px; background: linear-gradient(180deg, #f2633a, #c0281a); border-color: #c0281a; color: #fff; }
.burn-btn:hover { filter: brightness(1.08); }

/* ---- light/dark toggle ---- */
.theme-toggle {
  margin-left: auto; width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---- "How it works" explainer (shared by the Home step-through and the per-screen illustrations) ---- */
.howto .art { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; }
.howto .art * { transform-box: fill-box; }
.howto .cap { max-width: 460px; margin: 12px auto 0; text-align: center; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.howto .cap b { color: var(--text); display: block; font-size: 15.5px; margin-bottom: 3px; }
.howto.no-trust .trust-only { display: none; }

/* per-screen single illustration (create / send / reveal) */
.screen-illo { margin: 2px auto 14px; }
.screen-illo .art { max-width: 300px; }

/* Home step-through */
.home-howto { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.home-howto-title { font-size: 18px; text-align: center; margin: 0 0 14px; }
.ht-stage { max-width: 460px; margin: 0 auto; }
.ht-scene { min-height: 250px; display: flex; flex-direction: column; justify-content: center; }
.ht-ctrls { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; }
.ht-nav { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.ht-nav:hover { border-color: var(--accent); color: var(--accent); }
.ht-dots { display: flex; gap: 8px; }
.ht-dot { width: 9px; height: 9px; padding: 0; border-radius: 999px; border: 0; background: var(--border); cursor: pointer; }
.ht-dot.on { background: var(--accent); }

.card-hint { display: block; margin-top: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.primary-btn:disabled { opacity: .55; cursor: default; }

/* ---- QR modal ---- */
.modal { position: fixed; inset: 0; z-index: 9990; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-card .qr canvas { display: block; max-width: 78vw; height: auto; border-radius: 8px; }
