/* ============================================================
   The Journal of Implausible Causal Inference — Styles
   Academic journal parody aesthetic with slot-machine reels
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --bg-section: #f3f4f6;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --text-light: #9ca3af;
  --accent: #1a56db;
  --accent-dark: #1e3a8a;
  --accent-light: #dbeafe;
  --red: #dc2626;
  --green: #059669;
  --gold: #d97706;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  --reel-bg: #fff;
  --reel-border: #d1d5db;
  --shadow: rgba(0, 0, 0, 0.08);
  --font-sans: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Playfair Display', 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Sound toggle --- */
.sound-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
}
.sound-toggle:hover {
  background: var(--bg);
  box-shadow: 0 1px 4px var(--shadow);
}

/* --- Header / Journal Bar --- */
header {
  width: 100%;
  border-bottom: 3px solid var(--accent-dark);
}

.journal-bar {
  background: var(--accent-dark);
  color: #fff;
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 6px 16px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  flex-wrap: wrap;
}

.journal-access {
  background: var(--green);
  color: #fff;
  padding: 1px 8px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.journal-header {
  text-align: center;
  padding: 28px 16px 16px;
  max-width: 800px;
  margin: 0 auto;
}

.journal-title {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: var(--accent-dark);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.journal-subtitle {
  font-family: var(--font-sans);
  font-size: clamp(0.85rem, 2vw, 1rem);
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 400;
  font-style: italic;
}

.journal-note {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 2px;
}

.journal-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  flex-wrap: wrap;
}

.nav-item {
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: default;
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --- Main --- */
main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  padding: 0 16px 40px;
}

.article-container {
  margin-top: 28px;
}

.article-type {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 12px;
  border-radius: 3px;
  margin-bottom: 12px;
}

.article-instructions {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* --- Reels (styled as form fields) --- */
.reels-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 24px 0;
  flex-wrap: nowrap;
}

.reel-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex: 1;
  max-width: 280px;
}

.reel-label {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.reel-window {
  width: 100%;
  height: 80px;
  overflow: hidden;
  background: var(--reel-bg);
  border: 1px solid var(--reel-border);
  border-radius: 6px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.reel-window:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

/* Gradient fade at top/bottom edges */
.reel-window::before,
.reel-window::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  z-index: 2;
  pointer-events: none;
}
.reel-window::before {
  top: 0;
  background: linear-gradient(to bottom, var(--reel-bg), transparent);
}
.reel-window::after {
  bottom: 0;
  background: linear-gradient(to top, var(--reel-bg), transparent);
}

.reel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

.reel-item {
  min-height: 80px;
  height: 80px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  flex-shrink: 0;
  color: var(--text);
}

.reel-item.placeholder {
  color: var(--text-light);
  font-style: normal;
  font-weight: 400;
}

.reel-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  margin-bottom: 18px;
}

.connector-arrow {
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
  line-height: 1;
}

.connector-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-style: italic;
}

/* --- Spin button --- */
.spin-container {
  text-align: center;
  margin: 24px 0;
}

.spin-btn {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 36px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 1px 3px var(--shadow);
}

.spin-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}

.spin-btn:active:not(:disabled) {
  transform: translateY(0);
}

.spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spin-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 8px;
}

.spin-hint kbd {
  display: inline-block;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* --- Computing panel --- */
.computing-panel {
  text-align: center;
  padding: 28px;
  margin: 16px 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.computing-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.computing-text {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.computing-subtext {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* --- Results panel (structured abstract) --- */
.results-panel {
  margin: 24px 0;
  text-align: left;
  animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Article title area */
.results-ticker {
  padding: 24px 28px;
  border-left: 4px solid var(--accent);
  background: var(--bg-alt);
  margin-bottom: 0;
  border-radius: 0 8px 0 0;
}

.headline-text {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

/* Significant result styling */
.results-ticker.significant {
  border-left-color: var(--green);
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.results-ticker.significant .headline-text {
  color: #065f46;
}

.results-ticker.not-significant {
  border-left-color: var(--text-light);
  background: var(--bg-section);
}

.results-ticker.not-significant .headline-text {
  color: var(--text-muted);
}

/* Article metadata */
.article-meta {
  padding: 14px 28px;
  background: var(--bg-alt);
  border-left: 4px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.meta-authors {
  margin-bottom: 6px;
}

.author {
  color: var(--accent);
  font-weight: 500;
}

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

.meta-sep {
  color: var(--border-dark);
}

/* Structured abstract */
.structured-abstract {
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.abstract-section {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}

.abstract-section:last-child {
  border-bottom: none;
}

.abstract-heading {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.abstract-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

/* Results table */
.results-table-container {
  overflow-x: auto;
  margin-top: 8px;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

.results-table thead {
  background: var(--bg-section);
}

.results-table th {
  padding: 8px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-dark);
}

.results-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.results-table td:first-child {
  font-family: var(--font-sans);
  font-weight: 500;
}

/* Significant p-value highlight */
.results-table td.p-significant {
  color: var(--red);
  font-weight: 700;
}

/* Editor's note */
.editors-note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 16px 24px;
  margin: 16px 0;
}

.editors-note-heading {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 6px;
}

.editors-note-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #92400e;
  font-style: italic;
}

.results-disclaimer {
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 8px;
  text-align: center;
}

/* --- Share --- */
.share-container {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.share-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.share-icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
}

.share-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--shadow);
}

.share-btn-x {
  color: #2c2c2c;
}
.share-btn-x:hover {
  background: #2c2c2c;
  color: #fff;
  border-color: #2c2c2c;
}

.share-btn-bsky {
  color: #0085ff;
}
.share-btn-bsky:hover {
  background: #0085ff;
  color: #fff;
  border-color: #0085ff;
}

/* --- Footer --- */
footer {
  width: 100%;
  background: var(--bg-section);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-journal {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px;
  text-align: center;
}

.footer-copyright {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.footer-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-text a {
  color: var(--accent);
  text-decoration: none;
}
.footer-text a:hover {
  text-decoration: underline;
}

.footer-credit {
  font-size: 0.72rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 6px;
  display: block;
}

.github-link {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  color: var(--text-muted) !important;
  transition: color 0.2s;
}
.github-link:hover {
  color: var(--text) !important;
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}

/* --- Responsive --- */
@media (max-width: 960px) {
  .reels-container {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .reel-group {
    max-width: 360px;
    width: 100%;
  }

  .reel-connector {
    flex-direction: row;
    gap: 6px;
    margin-bottom: 0;
    padding: 4px 0;
  }

  .connector-arrow {
    transform: rotate(90deg);
  }

  .reel-window {
    width: 100%;
  }

  .results-stats {
    gap: 16px;
  }

  .meta-details {
    flex-direction: column;
    gap: 2px;
  }

  .meta-sep {
    display: none;
  }
}

@media (max-width: 480px) {
  .reel-group {
    max-width: 300px;
  }

  .spin-btn {
    font-size: 0.95rem;
    padding: 11px 28px;
  }

  .results-ticker {
    padding: 18px 16px;
  }

  .abstract-section {
    padding: 12px 16px;
  }

  .article-meta {
    padding: 10px 16px;
  }

  .journal-bar {
    gap: 12px;
  }

  .nav-item {
    padding: 8px 12px;
    font-size: 0.75rem;
  }
}
