/* ============================================================
   VeritasCheck — Academic Integrity Engine
   Design: Dark editorial with amber/gold accents, DM Serif Display
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0c0c0f;
  --bg2:        #131318;
  --bg3:        #1a1a22;
  --border:     #2a2a38;
  --border2:    #3a3a50;
  --text:       #e8e8f0;
  --text-dim:   #8888aa;
  --text-faint: #44445a;
  --gold:       #d4a843;
  --gold-light: #f0c96a;
  --gold-dim:   #7a6020;
  --red:        #e05454;
  --red-dim:    #5a2222;
  --green:      #4ec994;
  --green-dim:  #1e5a3a;
  --blue:       #5494e0;
  --blue-dim:   #1e3a5a;
  --amber:      #e0843c;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 8px 40px rgba(0,0,0,0.6);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 15px;
  line-height: 1.6;
}

/* Background effects */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(212,168,67,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,168,67,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
}
.bg-glow {
  position: fixed; top: -200px; right: -200px; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(212,168,67,0.06) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* Header */
header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 48px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  background: rgba(12,12,15,0.8);
  position: sticky; top: 0;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; color: var(--gold); }
.logo-text {
  font-family: 'DM Serif Display', serif;
  font-size: 20px; font-weight: 400;
  color: var(--text); letter-spacing: 0.02em;
}
.nav-tag {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--gold);
  background: rgba(212,168,67,0.1);
  border: 1px solid rgba(212,168,67,0.2);
  padding: 4px 12px; border-radius: 99px;
  letter-spacing: 0.1em; text-transform: uppercase;
}

/* Main layout */
main {
  position: relative; z-index: 1;
  max-width: 820px; margin: 0 auto;
  padding: 64px 24px 80px;
}

/* Hero */
.hero { text-align: center; margin-bottom: 56px; }
.hero-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px; letter-spacing: 0.2em;
  color: var(--gold); margin-bottom: 20px;
  display: inline-block;
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 6px;
}
h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1.1; color: var(--text);
  margin-bottom: 20px; font-weight: 400;
}
h1 em { color: var(--gold); font-style: italic; }
.hero-sub {
  font-size: 17px; color: var(--text-dim);
  max-width: 520px; margin: 0 auto;
  line-height: 1.7;
}

/* Checker card */
.checker-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 16px;
  border: none; background: transparent;
  color: var(--text-dim); font-family: 'Outfit', sans-serif;
  font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s ease;
}
.tab:hover { color: var(--text); background: var(--bg3); }
.tab.active { background: var(--bg3); color: var(--gold); border: 1px solid var(--border2); }
.tab span { font-size: 16px; }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Textarea */
textarea {
  width: 100%; min-height: 220px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: 'Outfit', sans-serif;
  font-size: 14px; line-height: 1.7;
  padding: 16px; resize: vertical;
  outline: none; transition: border-color 0.2s;
}
textarea:focus { border-color: var(--gold-dim); }
textarea::placeholder { color: var(--text-faint); }
.char-count {
  text-align: right; font-size: 12px;
  color: var(--text-faint); margin-top: 6px;
  font-family: 'DM Mono', monospace;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-sm);
  padding: 48px 24px; text-align: center;
  cursor: pointer; transition: all 0.2s;
  background: var(--bg);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold-dim);
  background: rgba(212,168,67,0.04);
}
.upload-icon { font-size: 36px; margin-bottom: 12px; color: var(--text-dim); }
.upload-zone p { color: var(--text-dim); font-size: 15px; }
.upload-link { color: var(--gold); cursor: pointer; text-decoration: underline; }
.upload-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.file-preview {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.file-icon { font-size: 22px; }
#file-name { flex: 1; font-size: 14px; color: var(--text); }
.remove-file {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; padding: 2px 6px;
  border-radius: 4px; transition: all 0.2s;
}
.remove-file:hover { background: var(--bg3); color: var(--red); }

/* Options */
.check-options {
  display: flex; gap: 24px; margin: 24px 0;
  flex-wrap: wrap;
}
.option-toggle {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 14px; color: var(--text-dim);
  user-select: none;
}
.option-toggle input { display: none; }
.toggle-track {
  width: 42px; height: 24px; background: var(--bg3);
  border: 1px solid var(--border2); border-radius: 99px;
  position: relative; transition: all 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-faint); transition: all 0.2s;
}
.option-toggle input:checked + .toggle-track {
  background: rgba(212,168,67,0.15);
  border-color: var(--gold-dim);
}
.option-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--gold);
}

/* Check button */
.btn-check {
  width: 100%; padding: 16px 32px;
  background: var(--gold);
  color: #0c0c0f; font-family: 'Outfit', sans-serif;
  font-size: 16px; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 10px;
  transition: all 0.2s; letter-spacing: 0.02em;
}
.btn-check:hover { background: var(--gold-light); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(212,168,67,0.3); }
.btn-check:active { transform: translateY(0); }
.btn-check:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-arrow { font-size: 18px; transition: transform 0.2s; }
.btn-check:hover .btn-arrow { transform: translateX(4px); }

/* Results */
.results-section {
  margin-top: 48px;
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px;
}
.results-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; font-weight: 400;
}
.btn-new {
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text-dim); font-family: 'Outfit', sans-serif;
  font-size: 13px; padding: 8px 16px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s;
}
.btn-new:hover { color: var(--text); border-color: var(--border); background: var(--bg3); }

/* Score grid */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px; margin-bottom: 40px;
}
.score-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  text-align: center;
  animation: fadeUp 0.4s ease;
}
.score-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.15em;
  color: var(--text-faint); margin-bottom: 20px;
}
.score-ring-wrap {
  position: relative; width: 130px; height: 130px;
  margin: 0 auto 16px;
}
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg3); stroke-width: 10; }
.ring-fill {
  fill: none; stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.plagiarism-ring { stroke: var(--red); }
.ai-ring { stroke: var(--blue); }
.score-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-number {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; color: var(--text);
}
.score-status {
  font-size: 11px; color: var(--text-dim);
  margin-top: 2px; font-family: 'DM Mono', monospace;
}
.ai-verdict {
  font-size: 13px; color: var(--text-dim);
  margin-top: 8px; line-height: 1.5;
  font-style: italic;
}

/* Sources list */
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 20px; font-weight: 400;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); }

.sources-section, .ai-detail-section {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  margin-bottom: 24px;
  animation: fadeUp 0.5s ease;
}

.source-item {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  margin-bottom: 12px; transition: border-color 0.2s;
}
.source-item:hover { border-color: var(--border2); }
.source-rank {
  font-family: 'DM Mono', monospace;
  font-size: 13px; color: var(--text-faint);
  min-width: 24px; margin-top: 2px;
}
.source-body { flex: 1; min-width: 0; }
.source-title {
  font-size: 14px; font-weight: 500; color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.source-url {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--blue);
  text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; display: block;
  margin-bottom: 6px;
}
.source-url:hover { color: var(--gold); }
.source-snippet { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.source-match {
  font-family: 'DM Mono', monospace;
  font-size: 11px; padding: 3px 8px;
  border-radius: 4px; white-space: nowrap;
  align-self: flex-start;
  margin-top: 2px;
}
.match-high { background: rgba(224,84,84,0.15); color: var(--red); }
.match-med  { background: rgba(224,132,60,0.15); color: var(--amber); }
.match-low  { background: rgba(78,201,148,0.15); color: var(--green); }

/* No sources */
.no-sources {
  text-align: center; padding: 32px;
  color: var(--text-dim); font-size: 14px;
}
.no-sources .big { font-size: 32px; margin-bottom: 12px; }

/* AI detail */
.ai-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.ai-metric {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.ai-metric-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.1em;
  color: var(--text-faint); margin-bottom: 6px;
}
.ai-metric-bar {
  height: 4px; background: var(--bg3);
  border-radius: 2px; margin-bottom: 6px; overflow: hidden;
}
.ai-metric-fill {
  height: 100%; border-radius: 2px;
  background: var(--blue);
  transition: width 1s ease;
}
.ai-metric-val {
  font-family: 'DM Mono', monospace;
  font-size: 14px; color: var(--text);
}
.ai-summary {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  font-size: 14px; color: var(--text-dim);
  line-height: 1.7; border-left: 3px solid var(--blue);
}

/* Loading overlay */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(12,12,15,0.92);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.loading-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 48px 56px;
  text-align: center; min-width: 320px;
  box-shadow: var(--shadow);
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border2);
  border-top-color: var(--gold);
  border-radius: 50%; margin: 0 auto 24px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: 'DM Serif Display', serif;
  font-size: 20px; color: var(--text); margin-bottom: 20px;
}
.loading-steps { display: flex; flex-direction: column; gap: 6px; }
.loading-step {
  font-family: 'DM Mono', monospace;
  font-size: 12px; color: var(--text-faint);
  display: flex; align-items: center; gap: 8px;
  animation: fadeIn 0.3s ease;
}
.loading-step.done { color: var(--green); }
.loading-step.active { color: var(--gold); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Error toast */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg2); border: 1px solid var(--red-dim);
  color: var(--red); padding: 14px 24px;
  border-radius: var(--radius-sm); font-size: 14px;
  z-index: 200; white-space: nowrap;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Footer */
footer {
  position: relative; z-index: 1;
  text-align: center; padding: 32px 24px;
  color: var(--text-faint); font-size: 12px;
  border-top: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
}

@media (max-width: 600px) {
  header { padding: 16px 20px; }
  main { padding: 40px 16px 60px; }
  .checker-card { padding: 20px; }
  h1 { font-size: 36px; }
  .score-grid { grid-template-columns: 1fr; }
}
