/* Prediction Markets Overview — Dark Theme */
:root {
  --bg: #0c0e12;
  --bg-light: #12161c;
  --bg-elevated: #1e2329;
  --accent: #f0b90b;
  --green: #0ecb81;
  --red: #f6465d;
  --text: #eaecef;
  --text-muted: #848e9c;
  --border: #2b3139;
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: opacity .2s; }
a:hover { opacity: .8; }

/* --- Main Nav (unified) --- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 14, 18, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
}

.nav-logo { display: flex; align-items: center; flex-shrink: 0; margin-right: 12px; }
.nav-logo-img { height: 28px; width: auto; }

/* Main nav items (Forum / Markets / Events) */
.nav-main { display: flex; gap: 2px; list-style: none; align-items: center; margin-left: 4px; }

.nav-main-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.nav-main-btn--forum { color: rgba(255,255,255,.65); }
.nav-main-btn--forum:hover { background: rgba(255,255,255,.08); color: #fff; opacity: 1; }
.nav-main-btn--markets { color: #f0b90b; }
.nav-main-btn--markets:hover { background: rgba(240,185,11,.1); opacity: 1; }
.nav-main-btn--events { color: #0ecb81; }
.nav-main-btn--events:hover { background: rgba(14,203,129,.1); opacity: 1; }
.nav-main-btn.active { background: rgba(255,255,255,.08); }

/* Right side (socials + lang) */
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.nav-socials {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.65);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  transition: color .2s, background .2s;
}
.nav-socials a:hover { color: #fff; background: rgba(255,255,255,.1); opacity: 1; }

/* Sub-navigation (page-specific) */
.sub-nav {
  background: rgba(12, 14, 18, .95);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.sub-nav .nav-inner {
  height: 40px;
}

.sub-nav-links {
  display: flex;
  gap: 20px;
  list-style: none;
  align-items: center;
}

.sub-nav-links a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: color .2s;
}
.sub-nav-links a:hover { color: var(--text); opacity: 1; }

/* FIX-M2: Hamburger touch target — min 44×44px per WCAG 2.5.5 */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  touch-action: manipulation;
}

/* --- Language Switcher --- */
.lang-switcher {
  display: flex;
  align-items: center;
}

.lang-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  transition: border-color .2s, color .2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23848e9c'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 22px;
}

/* FIX-M3: Language select touch target — min 44px height on mobile, 16px prevents iOS zoom */
@media (max-width: 768px) {
  .lang-select {
    min-height: 44px;
    padding: 8px 28px 8px 12px;
    font-size: 16px;
  }
}

.lang-select:hover { border-color: var(--text-muted); color: var(--text); }
.lang-select:focus { border-color: var(--accent); }

.lang-select option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* --- Container --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  overflow-x: hidden;
}

/* Prevent any child from causing horizontal overflow */
section, .section { max-width: 100%; overflow-x: hidden; }

/* --- Hero --- */
.hero {
  padding: 64px 0 48px;
  text-align: center;
}

.hero h1 {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.hero h1 .accent { color: var(--accent); }

.hero .subtitle {
  color: var(--text-muted);
  font-size: 18px;
  max-width: 640px;
  margin: 0 auto 40px;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
}

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .value.loading {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent;
  display: inline-block;
  min-width: 80px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.stat-card .change {
  font-size: 13px;
  margin-top: 4px;
}

.change.positive { color: var(--green); }
.change.negative { color: var(--red); }

/* --- Sections --- */
.section {
  padding: 48px 0;
}

.section-header {
  margin-bottom: 32px;
}

.section-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-header p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 600px;
}

/* --- Charts --- */
.chart-container {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.chart-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.chart-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}

.chart-btn:hover { border-color: var(--text-muted); color: var(--text); }
.chart-btn.active { background: var(--accent); color: #0c0e12; border-color: var(--accent); }

.chart-wrap {
  position: relative;
  height: 400px;
  max-width: 100%;
  overflow: hidden;
}

/* --- Two-column layout for charts --- */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  max-width: 100%;
  overflow: hidden;
}

.doughnut-wrap {
  position: relative;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-legend {
  margin-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-name { flex: 1; color: var(--text-muted); }
.legend-value { font-weight: 600; }

/* --- Table --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}

.data-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.data-table th:hover { color: var(--text); }

.data-table th .sort-arrow {
  margin-left: 4px;
  opacity: 0.3;
}

.data-table th.sorted .sort-arrow { opacity: 1; color: var(--accent); }

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr:hover { background: var(--bg-elevated); }
.data-table tbody tr:last-child td { border-bottom: none; }

.platform-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.platform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chain-tags { display: flex; gap: 4px; flex-wrap: wrap; }

.chain-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.type-badge {
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.type-badge.crypto { background: rgba(46, 92, 255, .15); color: #6b8aff; }
.type-badge.regulated { background: rgba(77, 228, 178, .15); color: #4de4b2; }

/* --- Trending --- */
.trending-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.trending-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color .2s;
}

.trending-card:hover { border-color: var(--text-muted); }

.trending-card .market-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.trending-card .market-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.trending-card .market-meta span { display: flex; align-items: center; gap: 4px; }

.outcome-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.outcome-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}

.outcome-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 4px;
}

.outcome-labels .yes { color: var(--green); }
.outcome-labels .no { color: var(--red); }

/* --- Platform Profiles --- */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

.profile-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.profile-card .profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-card .profile-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.profile-card .profile-header .tier-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.tier-badge.tier-1 { background: rgba(240, 185, 11, .15); color: var(--accent); }
.tier-badge.tier-2 { background: rgba(14, 203, 129, .15); color: var(--green); }
.tier-badge.tier-3 { background: rgba(132, 142, 156, .15); color: var(--text-muted); }

.profile-card .profile-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.profile-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.profile-stat .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profile-stat .stat-value {
  font-size: 16px;
  font-weight: 700;
}

.profile-card .profile-link {
  display: inline-block;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 32px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -29px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-item .year {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.timeline-item h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.timeline-item p {
  color: var(--text-muted);
  font-size: 14px;
}

/* --- Future --- */
.future-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.future-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color .2s;
}

.future-card:hover { border-color: var(--text-muted); }

.future-card .future-icon {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
  line-height: 1;
}

.future-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.future-card p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.future-card p a { text-decoration: underline; }

.future-card-highlight {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(240, 185, 11, .06), var(--bg-light));
  grid-column: 1 / -1;
}

.future-card-highlight h3 { color: var(--accent); }

/* --- FAQ --- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 20px 24px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font);
}

.faq-question:hover { background: var(--bg-elevated); }

.faq-question .icon {
  font-size: 20px;
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
  margin-left: 16px;
}

.faq-item.open .faq-question .icon { transform: rotate(45deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}

.faq-answer-inner {
  padding: 0 24px 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.7;
}

.faq-answer-inner a { text-decoration: underline; }

.faq-item.open .faq-answer {
  max-height: 500px;
}

/* --- CTA --- */
.cta-section {
  text-align: center;
  padding: 64px 0;
}

.cta-section h2 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 12px;
}

.cta-section p {
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 32px;
}

.cta-btn {
  display: inline-block;
  background: var(--accent);
  color: #0c0e12;
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  transition: transform .2s, box-shadow .2s;
}

.cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(240, 185, 11, .25);
  opacity: 1;
}

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

.site-footer a { color: var(--text-muted); text-decoration: underline; }

/* --- Updated badge --- */
.updated-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.updated-badge .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* --- Responsive --- */

/* Prevent overflow on mid-range screens */
@media (max-width: 1440px) {
  .chart-container { max-width: 100%; overflow: hidden; }
  .chart-wrap canvas { max-width: 100% !important; }
}

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

@media (max-width: 768px) {
  .nav-main { display: none; }
  .nav-toggle { display: flex; }
  .nav-main.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    gap: 4px;
    z-index: 101;
  }
  .nav-main.open .nav-main-btn { padding: 10px 12px; font-size: 14px; justify-content: flex-start; }
  .nav-socials { display: none; }
  .sub-nav-links { gap: 12px; overflow-x: auto; }
  .sub-nav-links a { font-size: 12px; white-space: nowrap; }

  .hero h1 { font-size: 28px; }
  .hero .subtitle { font-size: 15px; }

  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 22px; }

  .chart-wrap { height: 300px; }

  .section-header h2 { font-size: 22px; }

  .profiles-grid { grid-template-columns: 1fr; }
  .trending-grid { grid-template-columns: 1fr; }
  .future-grid { grid-template-columns: 1fr; }
  .future-card-highlight { grid-column: auto; }

  .profile-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .site-nav { padding: 0 16px; }
  .stat-cards { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .profile-stats { grid-template-columns: 1fr; gap: 8px; }
  .charts-grid { gap: 16px; }
  .chart-container { min-width: 0; max-width: 100%; overflow-x: auto; }
  .chart-wrap { height: 250px; min-width: 0; }
  .doughnut-wrap { height: 220px; min-width: 0; }
  .chart-controls { gap: 4px; }
  .chart-btn { padding: 4px 10px; font-size: 12px; }
}

/* ==========================================
   Task F: Horizontal Overflow Fixes
   Ensure no element causes horizontal scroll
   ========================================== */

/* Safety net: prevent any horizontal overflow at root level */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

/* Container: strict width constraint */
.container {
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
}

/* Charts grid: prevent overflow at all breakpoints */
.charts-grid {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Chart wrap: contain canvas within bounds */
.chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
}
.chart-wrap canvas {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
}

/* Table: always scrollable on narrow screens */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}
.data-table { min-width: 600px; }

/* Nav inner: prevent overflow */
.nav-inner { max-width: 100%; box-sizing: border-box; overflow: hidden; }

/* Site nav: strict width */
.site-nav { max-width: 100vw; box-sizing: border-box; overflow: hidden; }

/* All sections: prevent children from overflowing */
section { overflow-x: hidden; max-width: 100%; box-sizing: border-box; }

/* At 1280px–1440px: chart containers stay bounded */
@media (min-width: 1024px) and (max-width: 1440px) {
  .chart-container {
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }
  .charts-grid {
    overflow: hidden;
  }
}

/* 320px: everything must fit */
@media (max-width: 360px) {
  .site-nav { padding: 0 12px; }
  .container { padding: 0 12px; }
  .nav-logo-img { height: 22px; }
  .nav-main-btn { padding: 3px 6px; font-size: 11px; }
}

/* Breadcrumb navigation */
.breadcrumb-nav { background: transparent; border-bottom: 1px solid rgba(255,255,255,0.06); padding: 8px 0; }
.breadcrumb-list { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; font-size: 13px; flex-wrap: wrap; }
.breadcrumb-list li { color: rgba(255,255,255,0.5); }
.breadcrumb-list li + li::before { content: "›"; margin: 0 8px; color: rgba(255,255,255,0.3); }
.breadcrumb-list a { color: rgba(255,255,255,0.5); text-decoration: none; transition: color 0.2s; }
.breadcrumb-list a:hover { color: var(--accent, #f0b90b); }
.breadcrumb-list [aria-current="page"] { color: rgba(255,255,255,0.85); }
/* Footer links */
.footer-links { margin-top: 10px; font-size: 13px; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
