/* Gifts Test: system fonts only so the app works fully offline. */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --text: #1B1F24;
  --muted: #565E6B;          /* 6.0:1 on --bg */
  --border: #D9D4C9;
  --primary: #1F4E79;        /* 8.7:1 with white text */
  --primary-hover: #183E61;
  --on-primary: #FFFFFF;
  --accent: #C8902E;         /* fill only (bars, rules) */
  --accent-text: #8A5A0B;    /* darkened accent for text: 5.9:1 on white */
  --accent-soft: #F6ECD9;
  --selected: #E6EEF7;
  --bar-track: #E7E2D7;
  --bar-fill: #8197AE;
  --danger: #A12C2C;
  --focus: #1F4E79;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151C;
    --surface: #18202A;
    --text: #EEF1F4;
    --muted: #A9B2BE;
    --border: #2C3743;
    --primary: #8CC0F0;
    --primary-hover: #A9D1F5;
    --on-primary: #0B1B2B;
    --accent: #E0B15A;
    --accent-text: #E8C27A;
    --accent-soft: #2A2416;
    --selected: #1C2D40;
    --bar-track: #26303C;
    --bar-fill: #5F7690;
    --danger: #F08A8A;
    --focus: #8CC0F0;
    --shadow: none;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

main { max-width: 36rem; margin: 0 auto; min-width: 0; }
.statement, .gift-card, .bar-name { overflow-wrap: anywhere; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 2rem; letter-spacing: -.01em; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 .75rem; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--accent-text);
  margin: .75rem 0 .25rem;
}
/* The logo file is white on transparent, so it is used as a mask and filled
   with the text color: dark in light mode, white in dark mode. */
.logo {
  width: min(12.5rem, 100%);
  aspect-ratio: 518 / 168;
  margin: .5rem 0 1.25rem;
  background-color: var(--text);
  -webkit-mask: url("icons/captivate-logo.png") left center / contain no-repeat;
          mask: url("icons/captivate-logo.png") left center / contain no-repeat;
  -webkit-print-color-adjust: exact;
          print-color-adjust: exact;
}
#screen-results .logo { width: min(9rem, 100%); margin-bottom: .5rem; }

.lead { font-size: 1.125rem; color: var(--muted); }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  margin: 1.25rem 0;
  box-shadow: var(--shadow);
}

.scale-list {
  list-style: none;
  padding: 0;
  margin: .5rem 0 .75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: .375rem;
}
.scale-list li { display: flex; align-items: center; gap: .5rem; }
.scale-num {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: .875rem;
}

.field { display: block; margin: 1rem 0; }
.field > span { display: block; font-weight: 600; margin-bottom: .375rem; }
.field input {
  width: 100%;
  font: inherit;
  padding: .75rem .875rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  min-height: 3rem;
  padding: .75rem 1.25rem;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #1A0B0B; } }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.actions { display: flex; flex-direction: column; gap: .75rem; margin: 1.25rem 0; }
.actions .btn { width: 100%; }

.privacy {
  font-size: .9375rem;
  color: var(--muted);
  padding-left: 1.75rem;
  position: relative;
}
.privacy::before {
  content: "";
  position: absolute;
  left: .25rem; top: .2em;
  width: 1rem; height: 1rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1 4 4v6c0 5.5 3.4 10.7 8 12 4.6-1.3 8-6.5 8-12V4l-8-3z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1 4 4v6c0 5.5 3.4 10.7 8 12 4.6-1.3 8-6.5 8-12V4l-8-3z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.install {
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  padding-top: .75rem;
}
.install summary { cursor: pointer; font-weight: 600; padding: .5rem 0; color: var(--primary); }
.install p { font-size: .9375rem; }

/* Question screen */
.progress-wrap { margin: .5rem 0 1.5rem; }
.progress-label { font-size: .9375rem; color: var(--muted); font-weight: 600; margin-bottom: .375rem; font-variant-numeric: tabular-nums; }
.progress { height: .5rem; background: var(--bar-track); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .25s ease; }

.statement {
  font-size: 1.5rem;
  font-weight: 600;
  min-height: 5.5em;
  display: flex;
  align-items: center;
  margin: 0 0 1.25rem;
}

.options { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.option {
  font: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  gap: .875rem;
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  min-height: 3.75rem;
  padding: .875rem 1.125rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .15s, background-color .15s;
}
.option .scale-num { background: var(--bar-track); color: var(--text); }
.option[aria-checked="true"] { border-color: var(--primary); background: var(--selected); }
.option[aria-checked="true"] .scale-num { background: var(--primary); color: var(--on-primary); }

.nav { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.nav .btn { flex: 1 1 8rem; }

/* Results */
.gift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 6px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}
.gift-rank { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); margin: 0 0 .25rem; }
.gift-card h2 { font-size: 1.75rem; margin-bottom: .25rem; }
.gift-meta { color: var(--muted); font-size: .9375rem; margin-bottom: .875rem; }
.gift-meta strong { color: var(--text); }
.gift-card h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.ministries { list-style: none; padding: 0; margin: 0; display: grid; gap: .625rem; }
.ministries li { padding-left: .875rem; border-left: 3px solid var(--accent); }
.ministries strong { display: block; }
.ministries span { color: var(--muted); font-size: .9375rem; }

.callout {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: .875rem 1rem;
  margin: 1rem 0;
}
.callout p:last-child { margin: 0; }

.section-title { font-size: 1.25rem; margin-top: 2rem; }
.bars { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .625rem; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; align-items: baseline; }
.bar-name { font-weight: 600; }
.bar-score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9375rem; }
.bar-track { display: block; grid-column: 1 / -1; height: .625rem; background: var(--bar-track); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar-fill); border-radius: inherit; }
.bar-row.is-top .bar-fill { background: var(--accent); }
.bar-row.is-top .bar-name { color: var(--accent-text); }

.status { min-height: 1.5em; text-align: center; font-weight: 600; color: var(--primary); }

/* Dialog */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: min(28rem, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-actions { display: flex; gap: .75rem; margin-top: 1.25rem; flex-wrap: wrap; }
.dialog-actions .btn { flex: 1 1 8rem; }

[hidden] { display: none !important; }

@media (min-width: 30rem) {
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { width: auto; flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}

/* Print: results only, expanded, no controls. */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #bbb; --shadow: none; }
  body { padding: 0; font-size: 11pt; background: #fff; }
  .screen:not(#screen-results), .no-print, dialog { display: none !important; }
  #screen-results { display: block !important; }
  .gift-card { break-inside: avoid; }
  .bar-row { break-inside: avoid; }
  .bar-track, .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
