/* Source: npm run build → rank02/css/main.css, rank03/css/main.css */
:root {
  --bg: #0a0c12;
  --surface: #10131c;
  --surface2: #161a27;
  --border: rgba(255,255,255,0.07);
  --accent: #7c6ef7;
  --accent2: #5ee7b0;
  --text: #e8eaf6;
  /* Meets ~4.5:1 on --bg for WCAG AA body-sized text */
  --text-muted: #9ca3af;
  --code-bg: #0d1117;
  --radius: 14px;
  --shadow: 0 8px 40px rgba(0,0,0,0.6);
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .modal-backdrop,
  .modal {
    animation: none !important;
  }
  .modal {
    opacity: 1;
    transform: none;
  }
  .card {
    transition: none !important;
  }
  .card:hover {
    transform: none !important;
  }
  .lang-btn:active {
    transform: none !important;
  }
}

html { scroll-behavior: smooth; }

.page-i18n-root {
  transition:
    opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
    filter 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-i18n-root.is-lang-switching {
  opacity: 0;
  transform: translateY(10px) scale(0.992);
  filter: blur(4px);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .page-i18n-root {
    transition: none;
  }
  .page-i18n-root.is-lang-switching {
    transform: none;
    filter: none;
  }
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background grid */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(124,110,247,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,110,247,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}
body > *:not(.bg-grid):not(.modal-backdrop) { position: relative; z-index: 1; }

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,12,18,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 64px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  outline-offset: 4px;
}
.logo:focus-visible {
  outline: 2px solid var(--accent2);
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #4c3d9e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
  box-shadow: 0 4px 24px rgba(124, 110, 247, 0.35);
}

.logo-text-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  line-height: 1.2;
  min-width: 0;
}

.logo-brand {
  font-size: clamp(14px, 2.8vw, 17px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-b-42 {
  color: #fff;
}

.logo-b-exam {
  background: linear-gradient(135deg, #c4b5fd 0%, var(--accent) 50%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-b-rank {
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
}

.logo-sub {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 12px;
  background: rgba(22, 26, 39, 0.9);
  border: 1px solid var(--border);
  gap: 2px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.lang-btn {
  min-width: 38px;
  padding: 7px 9px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.lang-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.lang-btn.is-active {
  color: #fff;
  background: linear-gradient(145deg, rgba(124, 110, 247, 0.55), rgba(91, 79, 212, 0.45));
  box-shadow:
    0 0 0 1px rgba(124, 110, 247, 0.5),
    0 4px 16px rgba(124, 110, 247, 0.25);
}

.lang-btn:active {
  transform: scale(0.96);
}

.lang-btn:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Search */
#search {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 240px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#search::placeholder { color: var(--text-muted); }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,110,247,0.2);
}

/* Main */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 56px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  background: linear-gradient(135deg, #fff 35%, var(--accent) 70%, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}
.hero-sub {
  color: var(--text-muted);
  font-size: clamp(15px, 2.5vw, 17px);
  line-height: 1.6;
  max-width: 38rem;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 22px;
}
.stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--accent2);
  font-weight: 500;
}

/* Filters */
.filter-bar {
  max-width: 1100px;
  margin: 0 auto 36px;
  padding: 0 24px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-group-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  flex: 0 0 auto;
  min-width: 4.5rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.filter-chip {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: #adb5c9;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.filter-chip:hover {
  color: var(--text);
  border-color: rgba(124, 110, 247, 0.35);
}

.filter-chip.is-active {
  color: #fff;
  background: linear-gradient(145deg, rgba(124, 110, 247, 0.55), rgba(91, 79, 212, 0.45));
  border-color: rgba(124, 110, 247, 0.5);
  box-shadow: 0 0 0 1px rgba(124, 110, 247, 0.35);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .filter-chip {
    transition: none;
  }
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(124,110,247,0.4);
  box-shadow: 0 12px 40px rgba(124,110,247,0.15);
}
.card:hover::before { opacity: 1; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-num {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(124,110,247,0.12);
  border-radius: 6px;
  padding: 2px 8px;
  letter-spacing: 0.5px;
}

.diff-pill {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
  border: 1px solid transparent;
}

.diff-pill--easy {
  color: #6ee7b7;
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.28);
}

.diff-pill--medium {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.12);
  border-color: rgba(252, 211, 77, 0.28);
}

.diff-pill--hard {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.28);
}

.diff-pill--lv1 {
  color: #6ee7b7;
  background: rgba(110, 231, 183, 0.12);
  border-color: rgba(110, 231, 183, 0.28);
}

.diff-pill--lv2 {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.12);
  border-color: rgba(252, 211, 77, 0.28);
}

.diff-pill--lv3 {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.14);
  border-color: rgba(251, 146, 60, 0.35);
}

.diff-pill--lv4 {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.28);
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
}
.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-file {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent2);
  background: rgba(94,231,176,0.08);
  border-radius: 5px;
  padding: 2px 8px;
}
.card-arrow {
  color: var(--text-muted);
  font-size: 18px;
  transition: transform 0.2s, color 0.2s;
}
.card:hover .card-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

button.card {
  display: block;
  width: 100%;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* No results */
.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
  font-size: 16px;
}
.hidden { display: none !important; }

/* Modal — must stay position:fixed (do not add .modal-backdrop to body > * stacking rule) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: rgba(6, 8, 14, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  isolation: isolate;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid rgba(124,110,247,0.35);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: min(85vh, 100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 24px 80px rgba(0,0,0,0.45);
  animation: modalIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalIn {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  padding: 28px 28px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 1;
}
.modal-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(124,110,247,0.12);
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-block;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.modal-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-meta-row .modal-num {
  margin-bottom: 0;
}

.modal-header h2 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.modal-file {
  font-size: 12px;
  color: var(--accent2);
  background: rgba(94,231,176,0.08);
  border-radius: 5px;
  padding: 2px 8px;
}

.close-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 16px;
  transition: background 0.2s, color 0.2s;
}
.close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.modal-body { padding: 24px 28px 28px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  margin-top: 24px;
}
.section-label:first-child { margin-top: 0; }

#modal-desc {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.code-block {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  line-height: 1.7;
  background: var(--code-bg);
  border: 1px solid rgba(124,110,247,0.2);
  border-radius: 10px;
  padding: 16px;
  color: #c9d1d9;
  white-space: pre-wrap;
  overflow-x: auto;
}

.example-item {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
}
.example-item .ex-in { color: #7dd3fc; }
.example-item .ex-out { color: var(--accent2); }
.example-item .ex-label { color: var(--text-muted); font-size: 11px; }
.example-item .ex-label.ex-label-spaced { margin-top: 6px; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.footer-version {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  opacity: 0.9;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

@media (max-width: 600px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 64px;
    padding: 12px 0;
    gap: 12px;
  }
  .header-right {
    width: 100%;
    justify-content: flex-end;
  }
  #search { width: min(100%, 200px); flex: 1; min-width: 0; }
  .lang-switcher { justify-content: space-between; width: 100%; }
  .lang-btn { flex: 1; min-width: 0; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-group-label { min-width: 0; }
  .modal { max-height: 90vh; }
  .modal-header, .modal-body { padding: 20px; }
}
