/* tokens.css — Vault-SOS Version 4 theme
   Purpose: single source of truth for colors + reusable UI primitives
   Constraint: no frameworks, plain CSS, mobile-first
*/

:root {
  /* Brand tokens */
  --bg: #2B1348;                 /* App background */
  --surface: #321A52;            /* Cards / modals */
  --surface-2: #3A1F60;          /* Header / footer bars */
  --text: #FFFFFF;               /* Primary text */
  --muted: #D6CDE6;              /* Secondary text */
  --border: #4A2A77;             /* Dividers / outlines */

  --primary: #F2B705;            /* Primary CTA */
  --primary-contrast: #1B1028;   /* Text on primary */

  --danger: #7A1630;             /* State-change bar only */
  --danger-contrast: #FFFFFF;

  /* Layout tokens */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;

  --radius-card: 16px;
  --radius-btn: 18px;

  --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.22);

  /* Typography */
  --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --h1: 30px;
  --h2: 20px;
  --body: 16px;
  --small: 13px;

  /* Tap targets */
  --tap-min: 44px;
  --btn-h: 54px;

  /* Content width (desktop) */
  --maxw: 520px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessibility helpers */
:focus-visible {
  outline: 3px solid rgba(242, 183, 5, 0.75);
  outline-offset: 3px;
}

a {
  color: var(--muted);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout container */
.vs-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.vs-header {
  background: var(--surface-2);
  padding: var(--space-2);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.vs-title {
  margin: 0;
  font-size: var(--h1);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.vs-subtitle {
  margin: 6px 0 0 0;
  font-size: var(--small);
  color: var(--muted);
  line-height: 1.2;
}

/* Main content area */
.vs-main {
  flex: 1;
  width: 100%;
  padding: var(--space-3) var(--space-2) var(--space-4);
  display: flex;
  justify-content: center;
}

.vs-stack {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: stretch;
}

/* Motif */
.vs-motif {
  display: flex;
  justify-content: center;
  padding: var(--space-2) 0;
}

.vs-motif img {
  width: min(46vw, 200px);
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.vs-motif-corner {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 900;
  pointer-events: none;
  opacity: 0.85;
}

.vs-motif-corner img {
  width: 52px;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Cards */
.vs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-1);
  padding: var(--space-2);
}

.vs-card-title {
  margin: 0 0 var(--space-1) 0;
  font-size: var(--h2);
  font-weight: 700;
}

.vs-card-muted {
  color: var(--muted);
  font-size: var(--small);
}

/* Forms */
.vs-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vs-label {
  font-size: var(--small);
  color: var(--muted);
}

.vs-input,
.vs-select,
.vs-textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: var(--body);
}

.vs-input::placeholder {
  color: rgba(214, 205, 230, 0.75);
}

.vs-row {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

/* Buttons */
.vs-btn {
  min-height: var(--btn-h);
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.vs-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.vs-btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.vs-btn-primary:hover {
  filter: brightness(1.02);
}

.vs-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: var(--border);
}

.vs-btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.vs-btn-full {
  width: 100%;
}

.vs-btn-two-line {
  flex-direction: column;
  line-height: 1.05;
  padding-top: 12px;
  padding-bottom: 12px;
}

.vs-btn-two-line .vs-btn-sub {
  font-weight: 500;
  font-size: 16px;
  opacity: 0.95;
}

/* Small inline button (use sparingly) */
.vs-chip-btn {
  min-height: var(--tap-min);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

/* Preferences link row */
.vs-pref {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  padding: var(--space-1) 0;
}

.vs-pref svg {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

/* Footer / status bars */
.vs-footer {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 12px var(--space-2);
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.vs-footer-danger {
  background: var(--danger);
  color: var(--danger-contrast);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

/* Modal */
.vs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2);
  z-index: 999;
}

.vs-modal {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-1);
  padding: var(--space-3);
  color: var(--text);
}

.vs-modal h3 {
  margin: 0 0 var(--space-1) 0;
  font-size: 22px;
  font-weight: 800;
}

.vs-modal ul, .vs-modal p {
  color: var(--text);
  line-height: 1.45;
}

.vs-modal .vs-actions {
  margin-top: var(--space-2);
  display: flex;
  justify-content: flex-start;
  gap: var(--space-1);
}

/* QR overlay (Vault-Ops) */
.qr-overlay.hidden { display: none; }
.qr-overlay { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: var(--space-2); }
.qr-overlay-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.72); }
.qr-overlay-content { position: relative; width: min(680px, 96vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-1); padding: var(--space-2); z-index: 1; }
.qr-overlay-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-1); }
.qr-code-wrap { margin-top: var(--space-2); display: flex; align-items: center; justify-content: center; background: #ffffff; border-radius: 14px; padding: 16px; }
.qr-code-wrap canvas, .qr-code-wrap img, .qr-code-wrap svg { max-width: min(76vw, 420px); max-height: min(76vw, 420px); width: auto; height: auto; }

/* Instructions page helpers (scrollable + expandable sections) */
.vs-accordion {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.vs-acc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.vs-acc-summary {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-1);
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.vs-acc-summary:hover {
  background: rgba(255, 255, 255, 0.06);
}

.vs-acc-content {
  padding: 14px 16px;
  color: var(--text);
  line-height: 1.45;
}

/* Bottom action bar (instructions) */
.vs-bottom-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 10px var(--space-2);
  display: flex;
  gap: var(--space-1);
  justify-content: space-between;
}

.vs-bottom-actions .vs-btn {
  min-height: 48px;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 14px;
  flex: 1;
}

@media (min-width: 720px) {
  .vs-main {
    padding-top: var(--space-4);
  }
  .vs-motif img {
    width: 220px;
  }
  .vs-motif-corner {
    top: 14px;
    left: 14px;
  }
  .vs-motif-corner img {
    width: 60px;
  }
}
