/* ============================================================
   Vybtrail — connection chain feature for Vybpedia v0.1
   Inherits color tokens from vybpedia.css. Self-contained styles.
   ============================================================ */

#trail-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 70px 28px 96px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- HERO ---------- */
.trail-hero { text-align: center; margin-bottom: 56px; }

.trail-hero-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px -8px rgba(99, 102, 241, 0.6);
}

.trail-hero-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 60px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
}

.trail-hero-title .grad {
  background: linear-gradient(120deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-style: italic;
}

.trail-hero-sub {
  font-size: 18px;
  line-height: 1.55;
  color: var(--text-muted, #555);
  max-width: 620px;
  margin: 0 auto 38px;
}

body.dark .trail-hero-sub { color: #9ca3af; }

/* ---------- FORM ---------- */
.trail-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 14px;
  align-items: end;
  max-width: 880px;
  margin: 0 auto 18px;
  padding: 18px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 4px 24px -10px rgba(0,0,0,0.08);
}

body.dark .trail-form {
  background: #1a1d24;
  border-color: #2a2e38;
  box-shadow: 0 4px 24px -10px rgba(0,0,0,0.5);
}

.trail-input-group {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.trail-input-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  margin-bottom: 6px;
  padding-left: 14px;
}

body.dark .trail-input-group label { color: #9ca3af; }

.trail-input-group input {
  padding: 12px 14px;
  font-size: 16px;
  font-family: 'Source Serif 4', Georgia, serif;
  background: var(--input-bg, #f9fafb);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

body.dark .trail-input-group input {
  background: #0f1116;
  border-color: #2a2e38;
}

.trail-input-group input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.trail-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  margin-bottom: 0;
  color: #6366f1;
  opacity: 0.5;
}

.trail-go-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
  height: 42px;
  white-space: nowrap;
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.55);
}

.trail-go-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -6px rgba(99, 102, 241, 0.7); }
.trail-go-btn:disabled { opacity: 0.5; cursor: wait; transform: none; }

/* ---------- ACTION CHIPS ---------- */
.trail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.trail-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: var(--chip-bg, #f3f4f6);
  color: var(--text-muted, #4b5563);
  border: 1px solid transparent;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

body.dark .trail-action-btn {
  background: #1f2229;
  color: #cbd5e1;
}

.trail-action-btn:hover {
  background: var(--chip-hover, #e0e7ff);
  color: #4338ca;
  border-color: rgba(99, 102, 241, 0.3);
}

body.dark .trail-action-btn:hover {
  background: #2a2e38;
  color: #c7d2fe;
}

/* ---------- RESULT / STATUS ---------- */
.trail-result { margin-top: 60px; }

.trail-status {
  margin-bottom: 30px;
  text-align: center;
}

.trail-status-line {
  font-size: 14px;
  color: var(--text-muted, #6b7280);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 12px;
  min-height: 20px;
}

body.dark .trail-status-line { color: #9ca3af; }

.trail-progress {
  height: 3px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: 100px;
  overflow: hidden;
  max-width: 600px;
  margin: 0 auto;
}

.trail-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
  background-size: 200% 100%;
  border-radius: 100px;
  transition: width 0.5s ease;
  animation: shimmer 2s linear infinite;
}

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

/* ---------- CHAIN OF CARDS ---------- */
.trail-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 760px;
  margin: 0 auto;
  position: relative;
}

.trail-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  padding: 22px 26px;
  position: relative;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(14px);
  animation: cardIn 0.45s ease forwards;
  box-shadow: 0 2px 16px -8px rgba(0,0,0,0.07);
}

body.dark .trail-card {
  background: #1a1d24;
  border-color: #2a2e38;
  box-shadow: 0 2px 16px -8px rgba(0,0,0,0.4);
}

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

.trail-card-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 100px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, 0.5);
}

.trail-card.is-endpoint .trail-card-num {
  background: linear-gradient(135deg, #ec4899, #f59e0b);
  box-shadow: 0 4px 12px -4px rgba(236, 72, 153, 0.5);
}

.trail-card-body { flex: 1; min-width: 0; }

.trail-card-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  margin: 2px 0 8px;
  line-height: 1.2;
}

.trail-card-title a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s; }
.trail-card-title a:hover { border-bottom-color: #6366f1; }

.trail-card-snippet {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted, #4b5563);
}

body.dark .trail-card-snippet { color: #9ca3af; }

/* Inline-expanded article content shown when "Show more" is toggled */
.trail-card-expanded {
  margin-top: 12px;
  padding: 14px 16px;
  border-left: 3px solid #6366f1;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #1f2937);
  max-height: 420px;
  overflow-y: auto;
  animation: trailExpandIn .2s ease;
}
.trail-card-expanded p {
  margin: 0 0 10px 0;
}
.trail-card-expanded p:last-child { margin-bottom: 0; }
body.dark .trail-card-expanded {
  background: rgba(99, 102, 241, 0.1);
  color: #e5e7eb;
  border-left-color: #8b5cf6;
}
@keyframes trailExpandIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Action row under snippet: Show more + Open full article */
.trail-card-actions {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.trail-card-toggle,
.trail-card-open {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
}
.trail-card-toggle {
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
}
.trail-card-toggle:hover {
  background: rgba(99, 102, 241, 0.15);
}
.trail-card-open {
  color: var(--text-muted, #6b7280);
  border-color: transparent;
}
.trail-card-open:hover {
  color: #6366f1;
  text-decoration: underline;
}
body.dark .trail-card-toggle {
  color: #a5b4fc;
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.1);
}
body.dark .trail-card-toggle:hover {
  background: rgba(139, 92, 246, 0.2);
}
body.dark .trail-card-open { color: #9ca3af; }
body.dark .trail-card-open:hover { color: #a5b4fc; }
.trail-card.is-expanded { background: linear-gradient(180deg, rgba(99,102,241,0.02), transparent); }

/* Fallback connector — shown when we couldn't find a real link and had to bridge directly.
   Dashed instead of solid, amber tint, to signal "this is a semantic reach, not a confirmed connection". */
.trail-connector.trail-connector-fallback::before {
  background: repeating-linear-gradient(
    to bottom,
    #f59e0b 0px, #f59e0b 4px,
    transparent 4px, transparent 8px
  ) !important;
  opacity: 0.7;
}
.trail-connector-narration-fallback {
  background: rgba(245, 158, 11, 0.08) !important;
  border-color: rgba(245, 158, 11, 0.4) !important;
  color: #92400e !important;
  font-style: normal !important;
  font-weight: 500 !important;
}
body.dark .trail-connector-narration-fallback {
  background: rgba(245, 158, 11, 0.15) !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
  color: #fbbf24 !important;
}

/* Vertical animated connector between cards */
.trail-connector {
  height: 64px;
  width: 2px;
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
  margin-left: 44px;        /* aligns with card-num */
  position: relative;
  opacity: 0;
  animation: connectorIn 0.4s ease 0.15s forwards;
}

@keyframes connectorIn { to { opacity: 0.5; } }

.trail-connector::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, #ec4899 50%, transparent 100%);
  background-size: 100% 50%;
  background-repeat: no-repeat;
  background-position: 0 -50%;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%   { background-position: 0 -50%; }
  100% { background-position: 0 150%; }
}

.trail-connector-narration {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid #8b5cf6;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.45;
  color: var(--text, #1f2937);
  max-width: 540px;
  font-family: 'Source Serif 4', Georgia, serif;
  box-shadow: 0 4px 14px -6px rgba(0,0,0,0.08);
}

body.dark .trail-connector-narration {
  background: #1a1d24;
  border-color: #2a2e38;
  border-left-color: #8b5cf6;
  color: #e5e7eb;
}

.trail-connector-narration::before {
  content: '✨';
  margin-right: 8px;
  font-style: normal;
}

/* ---------- META FOOTER ---------- */
.trail-meta {
  margin-top: 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.trail-meta-stats {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  font-family: 'JetBrains Mono', monospace;
}

.trail-meta-actions { display: flex; gap: 8px; }

/* ---------- ERROR STATE ---------- */
.trail-error {
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
  color: var(--text-muted, #6b7280);
}

.trail-error strong { color: #ec4899; }

/* ---------- HOW IT WORKS ---------- */
.trail-how {
  margin-top: 96px;
  text-align: center;
}

.trail-how h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 28px;
}

.trail-how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 920px;
  margin: 0 auto;
}

.trail-how-card {
  padding: 26px 22px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 14px;
  text-align: left;
}

body.dark .trail-how-card {
  background: #1a1d24;
  border-color: #2a2e38;
}

.trail-how-num {
  width: 28px;
  height: 28px;
  border-radius: 100px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 12px;
}

.trail-how-card h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}

.trail-how-card p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted, #6b7280);
  margin: 0;
}

body.dark .trail-how-card p { color: #9ca3af; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 760px) {
  .trail-hero-title { font-size: 40px; }
  .trail-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .trail-arrow { transform: rotate(90deg); height: 24px; }
  .trail-how-grid { grid-template-columns: 1fr; }
  .trail-card { padding: 18px 18px; gap: 14px; }
  .trail-card-title { font-size: 19px; }
  .trail-connector { margin-left: 32px; height: 80px; }
  .trail-connector-narration {
    left: 18px;
    max-width: calc(100vw - 80px);
    font-size: 12.5px;
  }
}

.hidden { display: none !important; }
