/* ============================================================
   Law Study Tool — Mobile Practice App
   Clean, native app feel. Dark navy + warm gold.
   ============================================================ */

:root {
  --bg:            #0a0e1a;
  --surface-0:     #0d1120;
  --surface-1:     #111827;
  --surface-2:     #18243a;
  --surface-3:     #1e2b45;

  --border:        rgba(255, 255, 255, 0.06);
  --border-mid:    rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent:        #c8a96e;
  --accent-light:  #d9be8c;
  --accent-dim:    rgba(200, 169, 110, 0.12);
  --accent-glow:   rgba(200, 169, 110, 0.22);

  --text-1:        #f1f5f9;
  --text-2:        #94a3b8;
  --text-3:        #64748b;

  --success:       #22c55e;
  --success-dim:   rgba(34, 197, 94, 0.13);
  --success-border:rgba(34, 197, 94, 0.35);
  --error:         #f87171;
  --error-dim:     rgba(248, 113, 113, 0.13);
  --error-border:  rgba(248, 113, 113, 0.35);

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --radius-pill:   999px;
}

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

html {
  color-scheme: dark;
  height: 100%;
  /* prevent overscroll bounce revealing white */
  overscroll-behavior: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* iOS safe areas */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ===== SCREEN SHELL ===== */
#app {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* screens slide in/out */
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.screen.slide-out {
  transform: translateX(-30%);
  opacity: 0;
  pointer-events: none;
}

/* ===== TOP BAR ===== */
.top-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
}

.top-bar-title {
  flex: 1;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: normal;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  padding: 8px 0;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  justify-content: flex-start;
}

.back-btn svg {
  flex-shrink: 0;
}

/* ===== SCROLLABLE CONTENT AREA ===== */
.screen-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  overscroll-behavior: contain;
}

/* ===== SCREEN: SELECT PAGE ===== */
#screen-select .screen-body {
  padding: 0;
}

.select-header {
  padding: 24px 20px 12px;
}

.select-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
}

.select-header p {
  font-size: 0.875rem;
  color: var(--text-2);
}

/* Page list */
.page-list {
  padding: 0 12px;
}

.page-row {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 2px;
}

.page-row-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 150ms ease;
  min-height: 48px;
}

.page-row-inner:active {
  background: var(--surface-2);
}

.page-row-inner.highlighted {
  background: var(--accent-dim);
  border: 1px solid rgba(200, 169, 110, 0.25);
}

.page-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  color: var(--text-3);
}

.page-row-inner.highlighted .page-icon {
  color: var(--accent);
}

.page-row-title {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-1);
  line-height: 1.4;
}

.page-expand-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms, background 150ms;
}

.page-expand-btn:active {
  background: var(--surface-2);
  color: var(--text-1);
}

.page-sub-list {
  padding-left: 0;
}

.page-sub-list.hidden { display: none; }

.page-loading,
.page-empty {
  padding: 20px;
  color: var(--text-3);
  font-size: 0.875rem;
  text-align: center;
}

/* ===== STICKY CONTINUE BAR ===== */
.continue-bar {
  flex-shrink: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding-top: 24px;
}

.primary-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #0a0e1a;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: opacity 200ms, transform 100ms;
  min-height: 52px;
}

.primary-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.primary-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ===== SCREEN: MODE SELECT ===== */
.mode-page-label {
  font-size: 0.8rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mode-page-name {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 28px;
  line-height: 1.3;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-card {
  background: var(--surface-1);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color 200ms, background 200ms, transform 100ms;
  position: relative;
  overflow: hidden;
}

.mode-card:active {
  transform: scale(0.99);
}

.mode-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.mode-card-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
  display: block;
}

.mode-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.mode-card p {
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.5;
}

.mode-card .mode-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-mid);
  transition: border-color 200ms, background 200ms;
}

.mode-card.selected .mode-badge {
  background: var(--accent);
  border-color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-card.selected .mode-badge::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid #0a0e1a;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

/* ===== SCREEN: MCQ QUIZ ===== */
#screen-mcq {
  background: var(--bg);
}

.quiz-stats {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.quiz-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.quiz-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
}

.quiz-stat-label {
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quiz-streak .quiz-stat-value {
  color: var(--accent);
}

.quiz-divider {
  width: 1px;
  height: 28px;
  background: var(--border-mid);
}

/* Question + options area */
.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.question-card {
  background: var(--surface-1);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
  flex-shrink: 0;
}

.question-text {
  font-size: 0.975rem;
  line-height: 1.65;
  color: var(--text-1);
}

.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-1);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 150ms, background 150ms, transform 80ms;
  min-height: 52px;
  color: var(--text-1);
}

.option-btn:active:not(:disabled) {
  transform: scale(0.99);
  background: var(--surface-2);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1.5px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
  transition: all 150ms;
}

.option-text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.5;
  padding-top: 3px;
}

/* Answer states */
.option-btn.correct {
  background: var(--success-dim);
  border-color: var(--success-border);
}

.option-btn.correct .option-letter {
  background: var(--success);
  border-color: var(--success);
  color: #0a0e1a;
}

.option-btn.incorrect {
  background: var(--error-dim);
  border-color: var(--error-border);
}

.option-btn.incorrect .option-letter {
  background: var(--error);
  border-color: var(--error);
  color: #0a0e1a;
}

/* Feedback bar */
.feedback-bar {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  transition: background 200ms;
}

.feedback-bar.correct {
  background: var(--success-dim);
  border-top-color: var(--success-border);
}

.feedback-bar.incorrect {
  background: var(--error-dim);
  border-top-color: var(--error-border);
}

.feedback-msg {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
}

.feedback-bar.correct .feedback-msg { color: var(--success); }
.feedback-bar.incorrect .feedback-msg { color: var(--error); }

.next-btn {
  flex-shrink: 0;
  background: var(--accent);
  color: #0a0e1a;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 150ms, transform 100ms;
  min-height: 44px;
  white-space: nowrap;
}

.next-btn:active { transform: scale(0.97); }

.feedback-bar.hidden {
  display: none;
}

/* Loading state for next batch */
.quiz-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-2);
}

.quiz-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.quiz-loading p {
  font-size: 0.875rem;
  color: var(--text-2);
}

/* ===== SCREEN: PROBLEM QUESTIONS ===== */
#screen-problem {
  background: var(--bg);
}

.prob-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.prob-nav::-webkit-scrollbar { display: none; }

.prob-nav-btn {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 150ms;
  min-height: 36px;
  white-space: nowrap;
}

.prob-nav-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Problem body */
.prob-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px;
  padding-bottom: 100px; /* space for sticky bottom bar */
}

.prob-scenario-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.prob-scenario-text {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-1);
  background: var(--surface-1);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

/* Issues panel */
.issues-panel {
  display: none;
}

.issues-panel.visible {
  display: block;
  animation: fadeUp 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.issues-label {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.issue-card {
  background: var(--surface-1);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.issue-text {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-1);
  line-height: 1.4;
}

.issue-assess-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.assess-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border-mid);
  background: var(--surface-2);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
  color: var(--text-2);
}

.assess-btn:active {
  transform: scale(0.92);
}

.assess-btn.got-it {
  background: var(--success-dim);
  border-color: var(--success-border);
  color: var(--success);
}

.assess-btn.missed-it {
  background: var(--error-dim);
  border-color: var(--error-border);
  color: var(--error);
}

/* Score */
.prob-score {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  margin-top: 16px;
  animation: fadeUp 300ms ease both;
}

.prob-score.visible {
  display: block;
}

.prob-score-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.prob-score-label {
  font-size: 0.85rem;
  color: var(--text-2);
}

/* Sticky bottom reveal bar */
.prob-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  padding-top: 28px;
  pointer-events: none;
}

.prob-bottom-bar button {
  pointer-events: all;
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #0a0e1a;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 200ms, transform 100ms;
  min-height: 52px;
}

.prob-bottom-bar button:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.prob-bottom-bar button.hidden {
  display: none;
}

/* ===== LOADING SCREEN ===== */
#screen-loading {
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#screen-loading p {
  font-size: 0.9rem;
  color: var(--text-2);
  text-align: center;
  max-width: 260px;
  line-height: 1.5;
}

/* ===== GENERAL UTILITIES ===== */
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar          { width: 3px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: rgba(200,169,110,0.2); border-radius: 3px; }

/* ===== LOGIN OVERLAY ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border-mid);
  border-radius: 20px;
  padding: 48px 32px;
  text-align: center;
  max-width: 320px;
  width: 88%;
}
.login-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 8px;
}
.login-card p {
  color: var(--text-2);
  font-size: 0.95rem;
  margin: 0 0 28px;
}
.google-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #0a0e1a;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 10px;
  padding: 14px 28px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.google-signin-btn:hover { opacity: 0.85; }
