/* Pariksha v1.1 — design tokens
   Grounded in the OMR answer sheet / admit-card / mark-sheet world:
   ruled hairlines, bubble-style options, an "official stamp" blue,
   a mark-sheet red for wrong/violation, a pass-slip green for correct. */

:root {
  --ink: #151A3D;
  --ink-soft: #4A4F73;
  --ultra: #2438C9;
  --ultra-dark: #1B2B9C;
  --paper: #F5F6FA;
  --paper-raised: #FFFFFF;
  --line: rgba(21, 26, 61, 0.18);
  --line-strong: rgba(21, 26, 61, 0.32);
  --omr: #D8334A;
  --omr-soft: #FBE7EA;
  --pass: #178A5A;
  --pass-soft: #E4F4EC;
  --gold: #AD7E2E;
  --gold-soft: #F6EEDD;
  --focus: #2438C9;

  --font-display: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;

  --radius-sm: 3px;
  --radius-md: 6px;
  --shadow-panel: 0 1px 0 rgba(21, 26, 61, 0.06);
}

* { box-sizing: border-box; }

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { margin: 0; min-height: 100vh; }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

a { color: var(--ultra); }

::selection { background: var(--ultra); color: #fff; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- layout shells ---------- */

.rule-top    { border-top: 1px solid var(--line); }
.rule-bottom { border-bottom: 1px solid var(--line); }
.rule        { border: 1px solid var(--line); }

.masthead {
  border-bottom: 2px solid var(--ink);
  background: var(--paper-raised);
}

.masthead .brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.masthead .brand small {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.68rem;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-left: 0.5rem;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.62rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--ultra); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ultra-dark); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }

.btn-danger { background: var(--omr); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b62038; }

.btn-quiet { background: transparent; color: var(--ink-soft); padding: 0.4rem 0.6rem; font-weight: 500; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ---------- form fields ---------- */

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 0.76rem; color: var(--ink-soft); }
.field .err  { font-size: 0.78rem; color: var(--omr); min-height: 1.1em; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], select, textarea {
  font-family: var(--font-body);
  font-size: 0.94rem;
  padding: 0.6rem 0.7rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--ultra); }
textarea { resize: vertical; min-height: 5rem; font-family: var(--font-body); }

/* ---------- panels (flat, ruled — not the SaaS card kit) ---------- */

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
}
.panel-pad { padding: 1.4rem; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.badge-pending  { background: var(--gold-soft); color: var(--gold); }
.badge-approved { background: var(--pass-soft); color: var(--pass); }
.badge-rejected { background: var(--omr-soft); color: var(--omr); }
.badge-pass     { background: var(--pass-soft); color: var(--pass); }
.badge-fail     { background: var(--omr-soft); color: var(--omr); }
.badge-neutral  { background: #EEF0F7; color: var(--ink-soft); }

/* ---------- OMR-style option bubbles ---------- */

.omr-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.omr-row:last-child { border-bottom: none; }

.omr-num {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--ink-soft);
  width: 2.1rem;
  flex: none;
  padding-top: 0.1rem;
}
.omr-num.flagged { color: var(--gold); }

.omr-body { flex: 1; min-width: 0; }
.omr-q { font-size: 0.98rem; line-height: 1.5; margin-bottom: 0.65rem; }

.omr-options { display: grid; gap: 0.45rem; }

.omr-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  background: var(--paper-raised);
  transition: border-color 0.1s ease, background-color 0.1s ease;
}
.omr-option:hover { border-color: var(--line-strong); }
.omr-option input { display: none; }

.omr-bubble {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  flex: none;
  position: relative;
}
.omr-option.checked .omr-bubble { border-color: var(--ultra); }
.omr-option.checked .omr-bubble::after {
  content: '';
  position: absolute;
  inset: 2.5px;
  background: var(--ultra);
  border-radius: 50%;
}
.omr-option.checked { border-color: var(--ultra); background: #EEF0FD; }

.omr-option.reveal-correct { border-color: var(--pass); background: var(--pass-soft); }
.omr-option.reveal-correct .omr-bubble { border-color: var(--pass); }
.omr-option.reveal-correct .omr-bubble::after { background: var(--pass); }
.omr-option.reveal-wrong { border-color: var(--omr); background: var(--omr-soft); }
.omr-option.reveal-wrong .omr-bubble { border-color: var(--omr); }
.omr-option.reveal-wrong .omr-bubble::after { background: var(--omr); }

/* ---------- timer ---------- */

.timer {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.4rem 0.8rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.timer.low { border-color: var(--omr); color: var(--omr); background: var(--omr-soft); }

/* ---------- question navigator grid ---------- */

.qnav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr));
  gap: 0.4rem;
}
.qnav-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--paper-raised);
  color: var(--ink-soft);
}
.qnav-cell.answered { background: var(--pass-soft); border-color: var(--pass); color: var(--pass); }
.qnav-cell.marked   { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.qnav-cell.current  { outline: 2px solid var(--ultra); outline-offset: 1px; }

/* ---------- toast ---------- */

#toast-stack {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  max-width: min(24rem, calc(100vw - 2.4rem));
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(21, 26, 61, 0.25);
}
.toast.error { background: var(--omr); }
.toast.success { background: var(--pass); }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(21, 26, 61, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1.2rem; z-index: 150;
}
.modal-box {
  background: var(--paper-raised);
  border-radius: var(--radius-md);
  max-width: 30rem; width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(21, 26, 61, 0.3);
}

/* ---------- misc ---------- */

.container { max-width: 72rem; margin: 0 auto; padding: 0 1.5rem; }

.exam-grid {
  display: grid;
  grid-template-columns: 1fr 16rem;
  gap: 1.4rem;
  align-items: start;
}
@media (max-width: 760px) {
  .exam-grid { grid-template-columns: 1fr; }
  .exam-grid .qnav-side { order: -1; }
}
.skeleton { background: linear-gradient(90deg, #E9EBF2 25%, #F5F6FA 37%, #E9EBF2 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.violation-flash {
  animation: flash-border 0.6s ease;
}
@keyframes flash-border {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: inset 0 0 0 4px var(--omr); }
}

.seal {
  width: 5.5rem; height: 5.5rem; border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-family: var(--font-display); font-weight: 600;
  font-size: 0.7rem; text-align: center; line-height: 1.2;
  position: relative;
}
.seal::before {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid var(--gold);
  border-radius: 50%;
}
