*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; font-family: "Times New Roman", Times, serif; }

:root {
  --bg:           #15181f;
  --surface:      #1e2233;
  --surface-2:    #252a3d;
  --border:       #2e3450;
  --text:         #f8f9fa;
  --text-muted:   #a2a9b1;
  --accent:       #3b6bc4;
  --accent-hover: #2a5aad;
  --accent-glow:  rgba(59, 107, 196, 0.2);
  --green:        #27ae60;
  --green-dim:    rgba(39, 174, 96, 0.15);
  --amber:        #c97c2a;
  --amber-dim:    rgba(201, 124, 42, 0.15);
  --red:          #c0392b;
}

body {
  font-family: "Times New Roman", Times, serif;
  background-color: var(--bg);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 28px,
    rgba(255, 255, 255, 0.03) 28px,
    rgba(255, 255, 255, 0.03) 30px
  );
  color: var(--text);
  padding: 2rem;
  min-height: 100vh;
}

/* ── Splash screen ── */

#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.6s ease;
}

#splash.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash-img {
  width: 320px;
  height: 320px;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#splash-img.visible {
  opacity: 1;
  transform: scale(1);
}

#splash-title {
  font-family: Georgia, "Linux Libertine", serif;
  font-size: 2rem;
  font-weight: normal;
  letter-spacing: 0.04em;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}

#splash-title.visible {
  opacity: 1;
  transform: translateY(0);
}

#main-content {
  opacity: 0;
  transition: opacity 0.5s ease;
}

#main-content.visible {
  opacity: 1;
}

/* ── Header ── */

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-family: Georgia, "Linux Libertine", serif;
  font-size: 2.4rem;
  font-weight: normal;
  letter-spacing: 0.04em;
  color: var(--text);
}

.tagline {
  color: var(--text-muted);
  margin-top: 0.4rem;
  font-size: 0.95rem;
}

.about-btn {
  margin-top: 1.5rem;
  padding: 0.3rem 1rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 0.85rem;
  border-radius: 6px;
}

.about-btn:hover { background: var(--accent-glow); }

/* ── About panel ── */

.about-panel {
  max-width: 760px;
  margin: 0 auto 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.about-content h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: var(--text);
}

.about-content p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.6rem;
}

.about-content p:last-child { margin-bottom: 0; }

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

/* ── Main layout ── */

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 760px;
  margin: 0 auto;
}

/* ── Cards ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.card h2 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.card-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.card-heading h2 { margin-bottom: 0; }

.info-btn {
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  line-height: 1.4rem;
  text-align: center;
  flex-shrink: 0;
  cursor: pointer;
}

.info-btn:hover { background: var(--border); color: var(--text); }

/* ── Inputs & controls ── */

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-row input {
  flex: 1;
  min-width: 140px;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-row input::placeholder { color: var(--text-muted); }

.input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.arrow { color: var(--text-muted); font-size: 1.2rem; }

select {
  padding: 0.55rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

select:focus { border-color: var(--accent); }

button {
  padding: 0.55rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

button:hover    { background: var(--accent-hover); }
button:disabled { background: #2a3a5e; color: #5a6a8e; cursor: wait; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover    { background: var(--border); color: var(--text); }
.btn-secondary:disabled { background: var(--surface); color: #3a4060; cursor: wait; }

/* ── Algo description ── */

.algo-desc {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  min-height: 1.2em;
}

/* ── Info bubble (Article Rank description) ── */

.info-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.info-bubble[hidden] { display: none; }

.info-bubble strong { font-weight: 600; color: var(--text); }

.info-bubble p { margin-bottom: 0.5rem; }
.info-bubble p:last-child { margin-bottom: 0; }

/* ── Result area ── */

.result {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

.result.error { color: var(--red); }

/* ── Animated path chain ── */

.path-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.path-node {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  opacity: 0;
  transform: scale(0.75) translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.path-node.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.path-node.first { background: var(--green-dim);  border-color: var(--green); }
.path-node.last  { background: var(--amber-dim);  border-color: var(--amber); }

.path-node a         { color: var(--accent); text-decoration: none; font-weight: 500; }
.path-node.first a   { color: var(--green); }
.path-node.last  a   { color: var(--amber); }
.path-node a:hover   { text-decoration: underline; }

.path-connector {
  color: var(--text-muted);
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.25s ease;
  flex-shrink: 0;
}

.path-connector.visible { opacity: 1; }

/* ── Hops / badge row ── */

.hops-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.algo-badge {
  display: inline-block;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(59, 107, 196, 0.4);
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.8rem;
}

.time-badge {
  display: inline-block;
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(39, 174, 96, 0.35);
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.8rem;
}

/* ── Rank card ── */

.rank-details p { margin: 0.25rem 0; color: var(--text); }
.rank-details a { color: var(--accent); text-decoration: none; }
.rank-details a:hover { text-decoration: underline; }
.rank-score { font-size: 0.85rem; color: var(--text-muted); }
