/* =====================================================
   PassageFinder — GradePerfect Design System
   ===================================================== */

/* ----- Design Tokens ----- */
:root {
  /* GradePerfect brand palette */
  --gp-dark:        #054156;
  --gp-dark-mid:    #0a6b8a;
  --gp-teal:        #00d6b7;
  --gp-yellow:      #ffde59;
  --gp-bg:          #fffdfa;
  --gp-surface:     #ffffff;
  --gp-text:        #1a1a1a;
  --gp-muted:       #527a87;
  --gp-border:      #daeee9;
  --gp-teal-faint:  rgba(0, 214, 183, 0.08);
  --gp-error:       #dc2626;
  --gp-success:     #059669;

  /* Gradients */
  --gradient-cta:   linear-gradient(90deg, #00d6b7 0%, #ffde59 100%);
  --gradient-dark:  linear-gradient(135deg, #054156 0%, #0a6b8a 100%);

  /* Typography */
  --font-ui:      'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-passage: Georgia, 'Times New Roman', Times, serif;
  --font-size-base: 16px;
  --line-height-passage: 1.85;

  /* Geometry */
  --radius-sm:   6px;
  --radius:      12px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-pill: 9999px;

  /* Shadows (teal-tinted depth) */
  --shadow-xs: 0 1px 3px rgba(5,65,86,0.06);
  --shadow:    0 2px 8px rgba(5,65,86,0.08), 0 1px 3px rgba(5,65,86,0.04);
  --shadow-md: 0 4px 16px rgba(5,65,86,0.10), 0 2px 6px rgba(5,65,86,0.05);
  --shadow-lg: 0 8px 32px rgba(5,65,86,0.14), 0 4px 12px rgba(5,65,86,0.07);
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--font-size-base); scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--gp-bg);
  color: var(--gp-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- Accessibility: focus ring ----- */
:focus-visible {
  outline: 3px solid var(--gp-teal);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =====================================================
   Header
   ===================================================== */

.app-header {
  background: var(--gp-surface);
  border-bottom: 1px solid var(--gp-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.gp-logo-mark {
  width: 38px;
  height: 38px;
  background: var(--gradient-dark);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 13px;
  color: #ffffff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-brand-name {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gp-teal);
}

.header-product-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gp-dark);
  letter-spacing: -0.015em;
}

.app-version {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gp-muted);
  background: rgba(0,214,183,0.10);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0,214,183,0.20);
}

/* =====================================================
   Layout
   ===================================================== */

.app-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.screen { width: 100%; }

/* =====================================================
   Loading & Error States
   ===================================================== */

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 100px 24px 80px;
  gap: 20px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 214, 183, 0.18);
  border-top-color: var(--gp-teal);
  border-radius: 50%;
  animation: gp-spin 0.8s linear infinite;
}

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

.loading-logo {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gp-teal);
  margin-bottom: -8px;
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gp-dark);
}

.loading-sub {
  font-size: 0.85rem;
  color: var(--gp-muted);
  margin-top: -8px;
}

.error-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 24px;
  gap: 10px;
  text-align: center;
}

.error-wrap-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gp-error);
}

.error-wrap-body {
  font-size: 0.9rem;
  color: var(--gp-muted);
  max-width: 420px;
  line-height: 1.6;
}

/* =====================================================
   Filter Screen
   ===================================================== */

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Hero ─────────────────────────── */

.filter-hero {
  background: var(--gradient-dark);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Decorative radial glows */
.filter-hero::before {
  content: '';
  position: absolute;
  top: -70px; right: -40px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(0,214,183,0.22) 0%, transparent 65%);
  pointer-events: none;
}

.filter-hero::after {
  content: '';
  position: absolute;
  bottom: -50px; left: -20px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,222,89,0.14) 0%, transparent 65%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gp-teal);
  margin-bottom: 14px;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
  margin-bottom: 12px;
  letter-spacing: -0.025em;
}

.hero-subtitle {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.60);
  font-weight: 400;
  line-height: 1.6;
}

/* ── Filter card ─────────────────── */

.filter-card {
  background: var(--gp-surface);
  border: 1px solid var(--gp-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.filter-section {
  padding: 24px 28px;
}

.filter-divider {
  height: 1px;
  background: var(--gp-border);
  margin: 0 28px;
}

.filter-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gp-dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.required-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gp-error);
  background: #fef2f2;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid #fecaca;
}

.optional-badge {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--gp-muted);
  font-style: italic;
}

/* ── Length radio cards ──────────── */

.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.radio-card {
  flex: 1;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 18px 14px;
  background: var(--gp-surface);
  border: 2px solid var(--gp-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  user-select: none;
  position: relative;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.radio-card:hover {
  border-color: var(--gp-teal);
  background: var(--gp-teal-faint);
}

.radio-card.checked,
.radio-card:has(input:checked) {
  border-color: var(--gp-teal);
  background: var(--gp-teal-faint);
  box-shadow: 0 0 0 4px rgba(0, 214, 183, 0.12);
}

.radio-label {
  font-weight: 700;
  font-size: 1rem;
  color: var(--gp-dark);
  letter-spacing: -0.01em;
}

.radio-sub {
  font-size: 0.72rem;
  color: var(--gp-muted);
  font-weight: 500;
}

/* Show a teal check dot when selected */
.radio-card.checked::after,
.radio-card:has(input:checked)::after {
  content: '';
  position: absolute;
  top: 10px; right: 10px;
  width: 10px; height: 10px;
  background: var(--gp-teal);
  border-radius: 50%;
}

/* ── Checkbox items ──────────────── */

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--gp-surface);
  border: 1.5px solid var(--gp-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gp-text);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}

.checkbox-item:hover {
  border-color: var(--gp-teal);
  background: var(--gp-teal-faint);
}

.checkbox-item input[type="checkbox"] {
  accent-color: var(--gp-teal);
  width: 14px; height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-item:has(input:checked) {
  border-color: var(--gp-teal);
  background: rgba(0, 214, 183, 0.12);
  color: var(--gp-dark);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(0,214,183,0.12);
}

/* ── Filter footer ───────────────── */

.filter-footer {
  padding: 20px 28px 28px;
  border-top: 1px solid var(--gp-border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  background: rgba(0,214,183,0.02);
}

.passage-count {
  font-size: 1rem;
  color: var(--gp-dark);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.passage-count.count-zero { color: var(--gp-error); }

.count-sub {
  font-size: 0.82rem;
  color: var(--gp-muted);
  font-weight: 400;
  margin-left: 4px;
}

.inline-error {
  font-size: 0.9rem;
  color: var(--gp-error);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 12px 16px;
  width: 100%;
  line-height: 1.5;
}

/* =====================================================
   Buttons
   ===================================================== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 32px;
  background: var(--gradient-cta);
  color: var(--gp-dark);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 214, 183, 0.42);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 214, 183, 0.25);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-large { padding: 15px 40px; font-size: 1rem; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--gp-surface);
  color: var(--gp-dark);
  border: 1.5px solid var(--gp-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}

.btn-secondary:hover {
  border-color: var(--gp-teal);
  background: var(--gp-teal-faint);
  box-shadow: 0 2px 8px rgba(0,214,183,0.15);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: transparent;
  color: var(--gp-muted);
  border: 1.5px solid var(--gp-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.btn-ghost:hover {
  color: var(--gp-dark);
  background: var(--gp-teal-faint);
  border-color: var(--gp-teal);
}

.btn-link {
  background: none;
  border: none;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gp-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
  transition: color 0.12s;
}

.btn-link:hover { color: var(--gp-dark); }

/* =====================================================
   Passage Screen
   ===================================================== */

.passage-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
}

.passage-article {
  background: var(--gp-surface);
  border: 1px solid var(--gp-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Gradient accent bar */
.passage-article::before {
  content: '';
  display: block;
  height: 5px;
  background: var(--gradient-cta);
}

.passage-header {
  padding: 28px 36px 20px;
}

.passage-title {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gp-dark);
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}

.passage-byline {
  font-size: 0.9375rem;
  color: var(--gp-muted);
  margin-bottom: 10px;
  font-weight: 400;
}

.passage-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--gp-muted);
}

.passage-meta span { white-space: nowrap; }
.passage-meta .meta-sep {
  color: var(--gp-border);
  font-weight: 300;
  margin: 0 2px;
  opacity: 0.8;
}

.passage-divider {
  height: 1px;
  background: var(--gp-border);
  margin: 0 36px;
}

.passage-text {
  padding: 32px 36px 28px;
  font-family: var(--font-passage);
  font-size: 1.0625rem;
  line-height: var(--line-height-passage);
  color: var(--gp-text);
  word-break: break-word;
}

.passage-text p {
  margin-bottom: 1.25em;
}
.passage-text p:last-child { margin-bottom: 0; }

.passage-actions {
  padding: 20px 36px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: rgba(0,214,183,0.02);
  border-top: 1px solid var(--gp-border);
}

.copy-confirm {
  font-size: 0.85rem;
  color: var(--gp-success);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s;
}
.copy-confirm.visible { opacity: 1; }

/* Skip error */
.skip-error-msg {
  color: var(--gp-error);
  font-size: 0.9rem;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  line-height: 1.5;
}

/* =====================================================
   Print
   ===================================================== */

@media print {
  .app-header, .passage-nav, .passage-actions { display: none !important; }
  body { background: #fff; color: #000; font-family: Georgia, serif; }
  .passage-article {
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
  .passage-article::before { display: none; }
  .passage-header { padding: 0 0 16px; }
  .passage-text { padding: 20px 0; font-size: 12pt; line-height: 1.7; }
  .passage-title { font-size: 18pt; color: #000; }
  .passage-byline, .passage-meta { color: #444; font-size: 10pt; }
  .passage-divider { background: #ccc; margin: 0; }
}

/* =====================================================
   Responsive — Tablet
   ===================================================== */

@media (max-width: 720px) {
  .app-main { padding: 24px 20px 64px; }
  .filter-hero { padding: 32px 24px; }
  .filter-section { padding: 20px 22px; }
  .filter-divider { margin: 0 22px; }
  .filter-footer { padding: 18px 22px 24px; }
  .passage-header { padding: 24px 28px 18px; }
  .passage-divider { margin: 0 28px; }
  .passage-text { padding: 26px 28px 22px; }
  .passage-actions { padding: 18px 28px 24px; }
}

/* =====================================================
   Responsive — Mobile
   ===================================================== */

@media (max-width: 480px) {
  .app-main { padding: 16px 14px 60px; }

  .header-inner { padding: 10px 16px; }
  .gp-logo-mark { width: 34px; height: 34px; font-size: 12px; border-radius: 8px; }
  .header-product-name { font-size: 0.9rem; }
  .header-brand-name { display: none; }

  .filter-hero { padding: 28px 20px; border-radius: var(--radius-lg); }
  .hero-title { font-size: 1.5rem; }
  .hero-subtitle { font-size: 0.82rem; }

  .filter-card { border-radius: var(--radius); }
  .filter-section { padding: 18px 16px; }
  .filter-divider { margin: 0 16px; }
  .filter-footer { padding: 16px 16px 20px; }

  .radio-group { flex-direction: column; gap: 8px; }
  .radio-card { flex-direction: row; padding: 14px 16px; justify-content: flex-start; }
  .radio-card.checked::after,
  .radio-card:has(input:checked)::after { top: 12px; right: 12px; }

  .btn-primary.btn-large { width: 100%; padding: 14px 24px; }

  .passage-header { padding: 20px 18px 14px; }
  .passage-divider { margin: 0 18px; }
  .passage-text { padding: 22px 18px 18px; font-size: 1rem; }
  .passage-actions { padding: 14px 18px 20px; }
  .passage-title { font-size: 1.25rem; }
  .passage-nav { flex-wrap: wrap; }
}
