/* ============================================================
   VerseLock — identidade visual
   Paleta: pergaminho (#f4ecd8), tinta (#151221), vinho (#5c1a2b),
   selo dourado (#c9a44c), verde acerto (#3f6b4f), âmbar seta (#b8792f)
   Tipografia: display serifado (Fraunces) + corpo humanista (Source Serif)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,600;0,700;1,500&family=Source+Serif+4:wght@400;600&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --ink: #151221;
  --ink-soft: #2b2438;
  --parchment: #f4ecd8;
  --parchment-dim: #e8dcc0;
  --wine: #5c1a2b;
  --gold: #c9a44c;
  --gold-bright: #e0bd6a;
  --ok: #3f6b4f;
  --near: #b8792f;
  --bad: #8a3b3b;
  --shadow: 0 10px 30px rgba(21, 18, 33, 0.35);
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--parchment);
  font-family: 'Source Serif 4', Georgia, serif;
}

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(92, 26, 43, 0.35), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(201, 164, 76, 0.12), transparent 55%),
    var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 64px;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: 0.01em;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* -------------------- Header -------------------- */

.app-header {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-seal {
  width: 38px; height: 38px;
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  font-style: italic;
  margin: 0;
  color: var(--parchment);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(244, 236, 216, 0.06);
  border: 1px solid rgba(244, 236, 216, 0.18);
  color: var(--parchment);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.icon-btn:hover { background: rgba(244, 236, 216, 0.14); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* -------------------- Mode tabs -------------------- */

.mode-tabs {
  width: 100%;
  max-width: 640px;
  display: flex;
  gap: 6px;
  background: rgba(244, 236, 216, 0.05);
  border: 1px solid rgba(244, 236, 216, 0.1);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.mode-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(244, 236, 216, 0.65);
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.mode-tab[aria-selected="true"] {
  background: var(--gold);
  color: var(--ink);
}

/* -------------------- Card shell -------------------- */

.card {
  width: 100%;
  max-width: 640px;
  background: linear-gradient(180deg, rgba(244,236,216,0.04), rgba(244,236,216,0.02));
  border: 1px solid rgba(244, 236, 216, 0.12);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: rgba(244, 236, 216, 0.75);
}
.stat-pill {
  background: rgba(201, 164, 76, 0.12);
  border: 1px solid rgba(201, 164, 76, 0.3);
  border-radius: 999px;
  padding: 4px 10px;
}

/* -------------------- Verse display -------------------- */

.verse-quote {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--parchment);
  text-align: center;
  margin: 18px 0 6px;
  quotes: "“" "”";
}
.verse-quote::before { content: open-quote; color: var(--gold); margin-right: 2px; }
.verse-quote::after { content: close-quote; color: var(--gold); margin-left: 2px; }

.day-badge {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  margin-bottom: 4px;
}

/* -------------------- Guess form -------------------- */

.guess-form {
  display: grid;
  grid-template-columns: 1fr 90px 90px auto;
  gap: 8px;
  margin: 18px 0 10px;
}
@media (max-width: 480px) {
  .guess-form { grid-template-columns: 1fr 1fr; }
  .guess-form .submit-btn { grid-column: 1 / -1; }
}

.guess-form select,
.guess-form input {
  background: var(--parchment);
  color: var(--ink);
  border: none;
  border-radius: 9px;
  padding: 11px 10px;
  font-family: 'Source Serif 4', serif;
  font-size: 0.95rem;
}
.guess-form input::placeholder { color: rgba(21, 18, 33, 0.45); }

.submit-btn {
  background: var(--wine);
  color: var(--parchment);
  border: 1px solid rgba(244,236,216,0.2);
  border-radius: 9px;
  padding: 11px 18px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.submit-btn:hover { background: #712235; }
.submit-btn:active { transform: scale(0.97); }
.submit-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* -------------------- Attempts / feedback rows -------------------- */

.attempts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.attempt-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: stretch;
}

.chip {
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  min-width: 52px;
}
.chip-book { justify-content: flex-start; }
.chip.ok { background: rgba(63, 107, 79, 0.85); color: #eafff0; }
.chip.bad { background: rgba(138, 59, 59, 0.85); color: #ffe9e9; }
.chip.near { background: rgba(184, 121, 47, 0.85); color: #fff2df; }

.distance-note {
  font-size: 0.72rem;
  color: rgba(244,236,216,0.6);
  margin-top: 2px;
}

/* -------------------- Hints -------------------- */

.hints-box {
  margin-top: 14px;
  border-top: 1px dashed rgba(244,236,216,0.2);
  padding-top: 12px;
}
.hint-item {
  font-size: 0.88rem;
  color: rgba(244,236,216,0.85);
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.hint-item .pin { color: var(--gold-bright); }
.hint-btn {
  background: none;
  border: 1px solid rgba(244,236,216,0.25);
  color: var(--parchment);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.82rem;
}
.hint-btn:hover { background: rgba(244,236,216,0.08); }

/* -------------------- Stars & result -------------------- */

.stars {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 4px;
  color: var(--gold-bright);
  margin: 12px 0;
}
.star-dim { color: rgba(244,236,216,0.25); }

.result-box {
  text-align: center;
}
.result-box .verse-ref {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--gold-bright);
}

.share-grid {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  text-align: center;
  line-height: 1.6;
  margin: 12px 0;
  user-select: all;
}

.devotional-box {
  text-align: left;
  background: rgba(201, 164, 76, 0.08);
  border: 1px solid rgba(201, 164, 76, 0.25);
  border-radius: 11px;
  padding: 14px 16px;
  margin: 14px 0;
}
.devotional-box .devotional-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.devotional-box p {
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0 0 8px;
  color: rgba(244, 236, 216, 0.9);
}
.devotional-box .study-nudge {
  font-size: 0.84rem;
  color: rgba(244, 236, 216, 0.75);
  font-style: italic;
  margin: 0;
}

.actions-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.ghost-btn {
  background: transparent;
  border: 1px solid rgba(244,236,216,0.3);
  color: var(--parchment);
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
}
.ghost-btn:hover { background: rgba(244,236,216,0.08); }
.gold-btn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
}
.gold-btn:hover { background: var(--gold-bright); }

/* -------------------- Modal -------------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 8, 16, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--ink-soft);
  border: 1px solid rgba(244,236,216,0.15);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal h2 {
  margin-top: 0;
  font-size: 1.3rem;
  color: var(--gold-bright);
}
.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--parchment);
  font-size: 1.3rem;
  cursor: pointer;
}
.modal ol, .modal ul { padding-left: 20px; line-height: 1.6; font-size: 0.92rem; }
.modal .legend-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 0.88rem; }

.nickname-form {
  display: flex; gap: 8px; margin-top: 10px;
}
.nickname-form input {
  flex: 1;
  background: var(--parchment);
  color: var(--ink);
  border: none; border-radius: 8px;
  padding: 10px; font-family: inherit;
}
.nickname-form input::placeholder { color: rgba(21, 18, 33, 0.45); }

/* -------------------- Ranking -------------------- */

.ranking-tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.ranking-tab {
  border: 1px solid rgba(244,236,216,0.2);
  background: transparent;
  color: var(--parchment);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
}
.ranking-tab[aria-selected="true"] { background: var(--wine); border-color: var(--wine); }

.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(244,236,216,0.08);
  font-size: 0.9rem;
}
.rank-list li:last-child { border-bottom: none; }
.rank-pos {
  font-family: 'JetBrains Mono', monospace;
  width: 26px; color: var(--gold-bright); font-weight: 700;
}
.rank-name { flex: 1; }
.rank-pts { font-family: 'JetBrains Mono', monospace; color: rgba(244,236,216,0.7); }
.rank-you { background: rgba(201,164,76,0.1); border-radius: 8px; }

/* -------------------- Training grid -------------------- */

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.category-card {
  background: rgba(244,236,216,0.05);
  border: 1px solid rgba(244,236,216,0.14);
  border-radius: 11px;
  padding: 14px;
  text-align: left;
  color: var(--parchment);
  font-weight: 600;
  font-size: 0.9rem;
}
.category-card:hover { background: rgba(244,236,216,0.1); }

footer.app-footer {
  margin-top: 20px;
  font-size: 0.75rem;
  color: rgba(244,236,216,0.4);
  text-align: center;
}

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