/* ============================================================
   VileSaint — Main Stylesheet
   Theme: Courtroom / Judgment / Archive
   Colors: Black (#0a0a0a), Red (#dc2626), Gold (#ca8a04)
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1a1a1a;
  --bg-card: #111111;
  --bg-elevated: #1c1c1c;
  --border-default: #2a2a2a;
  --border-accent: #3a3a3a;

  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #6b6b6b;
  --text-inverse: #0a0a0a;

  --red: #dc2626;
  --red-hover: #ef4444;
  --red-dim: #991b1b;
  --gold: #ca8a04;
  --gold-hover: #eab308;
  --gold-dim: #854d0e;
  --blue-accent: #3b82f6;
  --green-accent: #22c55e;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-cjk-sc: 'Noto Sans SC', sans-serif;
  --font-cjk-jp: 'Noto Sans JP', sans-serif;
  --font-cjk-kr: 'Noto Sans KR', sans-serif;
  --font-arabic: 'Noto Naskh Arabic', serif;
  --font-thai: 'Noto Sans Thai', sans-serif;
  --font-devanagari: 'Noto Sans Devanagari', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.6);

  --transition-fast: 150ms ease;
  --transition-default: 250ms ease;
  --transition-slow: 400ms ease;

  --max-width: 640px;
  --header-height: 56px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--text-secondary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--text-primary); }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
textarea { font-family: inherit; resize: vertical; }
ul, ol { list-style: none; }

/* RTL support */
[dir="rtl"] { direction: rtl; text-align: right; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-weight: 800; line-height: 1.2; }
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; }

.section-title {
  font-size: 1.15rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-default);
}

/* ---------- Layout ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.brand { cursor: pointer; user-select: none; display: flex; align-items: baseline; gap: 0; }
.brand-vile {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--red);
}
.brand-saint {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: all var(--transition-fast);
}
.lang-btn:hover { border-color: var(--border-accent); background: var(--bg-tertiary); }

/* ---------- Main Content ---------- */
main, section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

/* ---------- Match Card ---------- */
.match-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 0.75rem;
}
.match-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status-verified { background: var(--green-accent); color: #000; }
.status-live { background: var(--red); color: #fff; animation: pulse-badge 2s infinite; }
.status-developing { background: var(--gold-dim); color: var(--gold-hover); }
.match-stage { font-size: 0.75rem; color: var(--text-muted); }

.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.team { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.team-flag { font-size: 2rem; }
.team-name { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); text-align: center; }
.match-score { text-align: center; flex-shrink: 0; }
.score-number { font-size: 1.75rem; font-weight: 900; letter-spacing: 0.04em; }
.score-status { display: block; font-size: 0.7rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.08em; margin-top: 2px; }
.match-verified { margin-top: 0.75rem; font-size: 0.75rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.verified-icon { color: var(--green-accent); }

/* ---------- Judgment Section ---------- */
.judgment-section {
  margin-top: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--red);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.judgment-person {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.person-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red-dim), var(--gold-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--border-accent);
}
.person-name {
  font-size: 1.2rem;
  font-weight: 800;
  display: block;
}
.person-role {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.judgment-question {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  color: #fff;
}
.judgment-fact {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

/* ---------- Vote Section ---------- */
.vote-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}
.vote-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}
.vote-btn-side-a {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-accent);
}
.vote-btn-side-a:hover, .vote-btn-side-a.selected {
  background: var(--red-dim);
  border-color: var(--red);
  color: #fff;
}
.vote-btn-side-b {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-accent);
}
.vote-btn-side-b:hover, .vote-btn-side-b.selected {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: #fff;
}
.vote-vs {
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.vote-badge {
  font-size: 0.7rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: 0.7;
}
.vote-label { flex: 1; text-align: center; }

/* ---------- Vote Result ---------- */
.vote-result { margin-top: 1rem; }
.result-bar-container {
  position: relative;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.result-bar {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.result-bar-a { background: var(--red); }
.result-bar-b { background: var(--gold); }
.result-pct {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0 0.5rem;
}
.result-pct-a { right: 0.5rem; color: #fff; text-align: right; }
.result-pct-b { left: 0.5rem; color: #fff; }
.result-total {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-accent); }
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--text-muted); }
.btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border-default); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text-primary); }
.btn-share {
  width: 100%;
  background: linear-gradient(135deg, var(--red-dim), var(--gold-dim));
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: none;
}
.btn-share:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.78rem; }
.btn-load-more { width: 100%; margin-top: 1rem; }

/* ---------- Person Cards ---------- */
.person-cards { margin-top: 0.25rem; }
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.person-card:hover { border-color: var(--border-accent); background: var(--bg-elevated); }
.person-card.active { border-color: var(--red); border-left: 3px solid var(--red); }
.card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.9rem;
  flex-shrink: 0;
  border: 2px solid var(--border-accent);
}
.card-body { flex: 1; min-width: 0; }
.card-name { font-size: 0.95rem; font-weight: 700; }
.card-question { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-votes { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.card-arrow { color: var(--text-muted); font-size: 1.2rem; }

/* ---------- Comment Section ---------- */
.comment-section { margin-top: 0.25rem; }
.comment-sort {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.sort-btn {
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.sort-btn:hover { color: var(--text-secondary); }
.sort-btn.active { color: #fff; background: var(--bg-tertiary); border-color: var(--border-accent); }

.comment-composer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}
.composer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--text-muted);
}
.composer-input-wrapper { flex: 1; min-width: 0; }
.composer-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color var(--transition-fast);
  min-height: 44px;
}
.composer-textarea:focus { border-color: var(--red); }
.composer-textarea::placeholder { color: var(--text-muted); }
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}
.char-count { font-size: 0.7rem; color: var(--text-muted); }
.char-count.warning { color: var(--gold); }
.char-count.danger { color: var(--red); }

/* ---------- Comments List ---------- */
.comments-list { display: flex; flex-direction: column; gap: 0; }
.comment-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-default);
  transition: background 0.3s ease;
}
.comment-item:last-child { border-bottom: none; }
.comment-item.highlight {
  background: rgba(220, 38, 38, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.5rem;
  margin: 0 -0.5rem;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
}
.comment-author {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}
.comment-author-self { color: var(--gold); }
.comment-time { font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }
.comment-body {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
  margin-bottom: 0.4rem;
}
.comment-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
}
.comment-action {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.comment-action:hover { color: var(--text-secondary); }
.comment-action.liked { color: var(--red); }
.comment-action svg { width: 14px; height: 14px; }

/* Reply composer */
.reply-composer {
  margin-top: 0.5rem;
  margin-left: 2rem;
  display: none;
}
.reply-composer.active { display: block; }
.reply-composer textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.5rem 0.6rem;
  outline: none;
  min-height: 36px;
}
.reply-composer textarea:focus { border-color: var(--red); }
.reply-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.reply-actions .btn-sm { padding: 0.3rem 0.7rem; font-size: 0.72rem; }

/* Nested replies */
.comment-replies {
  margin-left: 2rem;
  margin-top: 0.5rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border-default);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn var(--transition-default) ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-default);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }

/* Language Modal */
.lang-modal { max-width: 560px; }
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  padding: 1rem 1.25rem;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  text-align: left;
}
.lang-option:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.lang-option.active { background: var(--red-dim); color: #fff; font-weight: 700; }

/* Share Modal */
.share-modal { max-width: 400px; }
.share-poster-container {
  padding: 1rem;
  display: flex;
  justify-content: center;
}
.share-canvas {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.share-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem 1.25rem;
}
.share-actions .btn { flex: 1; }

/* ---------- Manifesto ---------- */
.manifesto {
  text-align: center;
  padding: 3rem 1rem;
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}
.manifesto-bg-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-5deg);
  font-size: 4rem;
  font-weight: 900;
  color: rgba(255,255,255,0.03);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.1em;
}
.manifesto-tagline {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}
.manifesto-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  position: relative;
  z-index: 1;
}
.manifesto-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.5rem;
  position: relative;
  z-index: 1;
}
.manifesto-links a {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}
.manifesto-links a:hover { color: var(--text-secondary); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-default);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 0.6rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  pointer-events: auto;
  white-space: nowrap;
}
.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green-accent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ---------- Spinner ---------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-default);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Animations ---------- */
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  :root { --max-width: 680px; }
  h1 { font-size: 2rem; }
  .judgment-question { font-size: 1.75rem; }
  .cards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .vote-section { gap: 1rem; }
  .vote-btn { padding: 1rem 1.25rem; font-size: 0.95rem; }
}

@media (min-width: 1024px) {
  :root { --max-width: 720px; }
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
}

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

/* RTL overrides */
[dir="rtl"] .judgment-section { border-left: none; border-right: 3px solid var(--red); border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
[dir="rtl"] .person-card.active { border-left: none; border-right: 3px solid var(--red); }
[dir="rtl"] .comment-replies { margin-left: 0; margin-right: 2rem; padding-left: 0; padding-right: 0.75rem; border-left: none; border-right: 2px solid var(--border-default); }
[dir="rtl"] .reply-composer { margin-left: 0; margin-right: 2rem; }
