/* ============ TickerWord ============ */

:root {
  --bg: #070b14;
  --panel: rgba(148, 163, 184, 0.055);
  --panel-2: rgba(148, 163, 184, 0.09);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);
  --text: #e7eef7;
  --muted: #8b96a8;
  --faint: #5b6678;
  --green: #3ddc97;
  --green-dim: rgba(61, 220, 151, 0.12);
  --green-line: rgba(61, 220, 151, 0.3);
  --amber: #fbbf24;
  --blue: #60a5fa;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: rgba(61, 220, 151, 0.28); }

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 620px at 72% -12%, rgba(61, 220, 151, 0.1), transparent 60%),
    radial-gradient(900px 520px at 8% -4%, rgba(96, 165, 250, 0.1), transparent 55%),
    linear-gradient(180deg, #0a1120 0%, var(--bg) 46%);
}

/* ---------- top bar ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 24px 0;
}

.logo { display: flex; align-items: center; gap: 10px; user-select: none; }

.logo-tile {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(180deg, #10243a, #0b1322);
  border: 1px solid var(--border-strong);
  color: var(--green);
  font-size: 15px;
  box-shadow: 0 0 24px -6px rgba(61, 220, 151, 0.55);
}

.logo-text { font-size: 1.18rem; font-weight: 700; letter-spacing: 0.01em; }
.logo-text em { font-style: normal; color: var(--green); }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.seg {
  display: flex;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 0.8rem var(--sans);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: var(--panel-2);
  color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green-line);
}

/* ---------- shared buttons ---------- */

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: 600 0.8rem var(--sans);
  padding: 9px 14px;
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}

.btn-ghost:hover { border-color: var(--border-strong); background: var(--panel-2); }
.btn-ghost:active { transform: scale(0.97); }

button:focus-visible, input:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ---------- hero / input ---------- */

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px 60px; }

.hero { text-align: center; padding: 58px 0 16px; }

.hero h1 {
  font-size: clamp(1.9rem, 4.6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

.grad {
  background: linear-gradient(92deg, var(--green) 10%, var(--blue) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.inputwrap {
  display: flex;
  gap: 9px;
  max-width: 540px;
  margin: 28px auto 0;
  padding: 9px;
  background: rgba(10, 16, 28, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.inputwrap:focus-within {
  border-color: var(--green-line);
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.08), 0 12px 40px -18px rgba(61, 220, 151, 0.35);
}

#letters {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 700 1.45rem var(--mono);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 0 10px 0.32em; /* offset trailing letter-spacing */
}

#letters::placeholder { color: var(--faint); }
#letters:focus { outline: none; }

.btn-go {
  border: 0;
  border-radius: 11px;
  padding: 0 22px;
  background: linear-gradient(180deg, #3ddc97, #16b07c);
  color: #04130c;
  font: 700 0.92rem var(--sans);
  cursor: pointer;
  transition: filter 0.18s, transform 0.12s;
}

.btn-go:hover { filter: brightness(1.08); }
.btn-go:active { transform: scale(0.97); }

.msg {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--amber);
  font-size: 0.86rem;
  opacity: 0;
  transition: opacity 0.25s;
}

.msg.show { opacity: 1; animation: nudge 0.3s; }

@keyframes nudge {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.hint {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.hint-label { color: var(--faint); font-size: 0.82rem; }

.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--green);
  font: 600 0.78rem var(--mono);
  letter-spacing: 0.08em;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}

.chip:hover { border-color: var(--green-line); background: var(--green-dim); }
.chip:active { transform: scale(0.95); }

.hint-rule { flex-basis: 100%; color: var(--faint); font-size: 0.78rem; }

/* ---------- how-to (empty state) ---------- */

.howto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 44px;
}

.how {
  padding: 22px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: rise 0.5s both;
}

.how:nth-child(2) { animation-delay: 80ms; }
.how:nth-child(3) { animation-delay: 160ms; }

.how-num { font: 700 0.8rem var(--mono); color: var(--green); letter-spacing: 0.12em; }
.how h3 { margin: 10px 0 6px; font-size: 1rem; }
.how p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

/* ---------- results ---------- */

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
  margin-top: 40px;
}

.hidden { display: none !important; }

.card {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 18px 44px -26px rgba(0, 0, 0, 0.85);
}

.card.enter { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: var(--d, 0ms); }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.card.primary {
  grid-column: 1 / -1;
  border-color: var(--green-line);
  background: linear-gradient(180deg, rgba(61, 220, 151, 0.07), var(--panel) 38%);
  box-shadow: 0 0 60px -28px rgba(61, 220, 151, 0.5);
}

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

.badge {
  font: 700 0.66rem var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}

.b-green { color: var(--green); border-color: var(--green-line); background: var(--green-dim); }
.b-amber { color: var(--amber); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.09); }
.b-blue  { color: var(--blue);  border-color: rgba(96, 165, 250, 0.35); background: rgba(96, 165, 250, 0.09); }
.b-ghost { color: var(--faint); border-color: var(--border); background: transparent; font-family: var(--mono); }

.card-actions { display: flex; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, transform 0.12s;
}

.icon-btn svg { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1); }
.icon-btn:hover { color: var(--green); border-color: var(--green-line); background: var(--green-dim); }
.act-swap:hover svg { transform: rotate(150deg); }
.act-cycle:hover svg { transform: scale(1.15); }
.icon-btn:active { transform: scale(0.92); }

.icon-btn.off { opacity: 0.32; cursor: default; }
.icon-btn.off:hover { color: var(--muted); border-color: var(--border); background: transparent; }
.icon-btn.off:hover svg { transform: none; }

/* the word, tile by tile */

.word { display: flex; flex-wrap: wrap; gap: 7px; }

.tile {
  display: grid;
  place-items: center;
  min-width: 1.62em;
  padding: 0.38em 0.18em;
  font: 700 1.32rem var(--mono);
  color: var(--green);
  background: linear-gradient(180deg, #101a2c, #0a1220);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 14px -8px rgba(0, 0, 0, 0.9);
  text-shadow: 0 0 14px rgba(61, 220, 151, 0.45);
}

.card.primary .tile { font-size: clamp(1.5rem, 4.2vw, 2.1rem); border-radius: 11px; }

.blurb { margin: -3px 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

/* per-letter company rows */

.picks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.card.primary .picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  column-gap: 18px;
}

.pick {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 11px;
  padding: 8px 9px;
  border-radius: 11px;
  transition: background 0.18s;
}

.pick:hover { background: rgba(148, 163, 184, 0.07); }

.pick.pulse { animation: flash 0.55s; }
.pick.pulse .pick-name, .pick.pulse .ticker { animation: drop 0.3s; }

@keyframes flash {
  0% { background: var(--green-dim); }
  100% { background: transparent; }
}

@keyframes drop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.pick-letter {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font: 700 0.82rem var(--mono);
  color: var(--green);
}

.pick-co { display: flex; flex-direction: column; min-width: 0; }

.pick-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pick-sector {
  color: var(--faint);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker {
  font: 600 0.78rem var(--mono);
  color: var(--green);
  background: var(--green-dim);
  border: 1px solid var(--green-line);
  padding: 3px 8px;
  border-radius: 7px;
  white-space: nowrap;
}

.card-meta {
  margin-top: auto;
  padding-top: 10px;
  color: var(--faint);
  font-size: 0.78rem;
  border-top: 1px dashed var(--border);
}

/* ---------- show more / footer / toast ---------- */

.more-wrap { text-align: center; margin-top: 22px; }

.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px 30px;
  color: var(--faint);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: #0e1a2e;
  border: 1px solid var(--green-line);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive & motion ---------- */

@media (max-width: 640px) {
  .hero { padding-top: 38px; }
  .inputwrap { flex-direction: column; }
  .btn-go { padding: 12px; }
  #letters { font-size: 1.25rem; }
  .results { grid-template-columns: 1fr; }
  .top { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
