/* ===== TrendPulse AI — styles ===== */
:root {
  --grad: linear-gradient(135deg, #7c3aed 0%, #ec4899 50%, #f59e0b 100%);
  --accent: #7c3aed;
  --accent-2: #ec4899;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --maxw: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0f1a;
  --bg-2: #121829;
  --card: #161d31;
  --card-2: #1d2640;
  --text: #e8ecf6;
  --muted: #9aa6c2;
  --border: #243049;
}

[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f3f4fb;
  --text: #1a2036;
  --muted: #5a6480;
  --border: #e4e7f2;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win, even over class display rules
   like .modal{display:flex} / .btn{display:inline-flex}. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 64px;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

a { color: inherit; text-decoration: none; }

/* ===== Splash ===== */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash.hidden { opacity: 0; visibility: hidden; }
.splash-logo { font-size: 72px; animation: pulse 1.4s ease-in-out infinite; }
.splash-name { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; }
.splash-name span {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.splash-bar { width: 180px; height: 5px; border-radius: 99px; background: var(--border); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--grad); animation: load 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ===== Ticker ===== */
.ticker {
  background: var(--grad); color: #fff; overflow: hidden; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 6px 0; position: relative;
}
.ticker-track { display: inline-block; padding-left: 100%; animation: scroll 90s linear infinite; }
.ticker-track span { margin: 0 26px; opacity: 0.95; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

/* ===== Header ===== */
.header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 20px; }
.brand-icon { font-size: 24px; }
.brand-name strong { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav-link {
  background: none; border: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 99px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.nav-link:hover { color: var(--text); background: var(--card); }
.nav-link.active { color: #fff; background: var(--accent); }
.saved-count {
  background: rgba(255,255,255,0.25); border-radius: 99px; padding: 1px 8px; font-size: 12px;
}
.nav-link:not(.active) .saved-count { background: var(--card-2); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .15s;
}
.icon-btn:hover { transform: translateY(-1px); }
.menu-toggle { display: none; }
.install-btn { animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ===== Buttons ===== */
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--border); cursor: pointer;
  padding: 9px 16px; border-radius: 12px; background: var(--card); color: var(--text);
  transition: transform .15s, filter .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { transform: translateY(-1px); }
.btn-accent { background: var(--grad); color: #fff; border: none; }
.btn-accent:hover { filter: brightness(1.07); }
.btn-ghost { background: transparent; }

/* ===== Layout ===== */
.main { padding-top: 22px; }
.layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.panel {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.section-head { margin: 6px 0 18px; }

/* ===== Sample-data banner ===== */
.sample-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fde68a; color: #7c2d12; border: 1px solid #f59e0b;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 16px;
  font-weight: 600; font-size: 14px;
}
.sample-banner .btn {
  background: rgba(124, 45, 18, 0.12); color: #7c2d12; border-color: rgba(124, 45, 18, 0.3);
}

/* ===== Toolbar (last-updated + refresh) ===== */
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-bottom: 16px; }
.last-updated { font-size: 12px; white-space: nowrap; }
.provider-badge { font-size: 12px; font-weight: 600; opacity: 0.85; }

/* ===== Controls ===== */
.controls { margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
.search-box { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .6; }
.search-box input {
  width: 100%; padding: 13px 14px 13px 40px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit;
}
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  padding: 8px 16px; border-radius: 99px; cursor: pointer; font: inherit; font-weight: 600; font-size: 14px;
  transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }
/* per-category accent colours when active */
.chip.active[data-category="World"]   { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.chip.active[data-category="Stocks"]  { background: linear-gradient(90deg, #16a34a, #22c55e); }
.chip.active[data-category="Crypto"]  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.chip.active[data-category="Cricket"] { background: linear-gradient(90deg, #0891b2, #06b6d4); }
.chip.active[data-category="Sports"]  { background: linear-gradient(90deg, #ea580c, #f97316); }
.chip.active[data-category="AI"]      { background: linear-gradient(90deg, #7c3aed, #a855f7); }

/* ===== Live market strip ===== */
.market-strip {
  display: flex; align-items: center; gap: 16px; flex-wrap: nowrap; overflow-x: auto;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 14px; margin-bottom: 16px; font-size: 13px;
}
.market-strip::-webkit-scrollbar { height: 0; }
.mk-label { font-weight: 800; white-space: nowrap; }
.mk-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.mk-sym { font-weight: 700; color: var(--muted); }
.mk-price { font-weight: 700; }
.mk-chg { font-weight: 700; font-size: 12px; }
.mk-chg.up { color: #22c55e; }
.mk-chg.down { color: #ef4444; }

/* ===== Live scores ===== */
.scores-head { display: flex; align-items: center; justify-content: space-between; }
.sc-group { margin-bottom: 20px; }
.sc-sport { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.sc-count { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--card-2); border-radius: 99px; padding: 1px 9px; }
.sc-list { display: grid; gap: 8px; }
.sc-row {
  display: grid; grid-template-columns: 1fr auto 1fr 62px; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.sc-row.live { border-color: color-mix(in srgb, #ef4444 45%, var(--border)); }
.sc-team { font-weight: 600; font-size: 14px; }
.sc-team.home { text-align: right; }
.sc-team.away { text-align: left; }
.sc-score { font-weight: 800; font-size: 16px; white-space: nowrap; min-width: 54px; text-align: center; }
.sc-badge { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; white-space: nowrap; text-align: center; justify-self: end; }
.sc-badge.live { background: #ef4444; color: #fff; animation: livePulse 1.6s ease-in-out infinite; }
.sc-badge.ft { background: var(--card-2); color: var(--muted); }
.sc-badge.up { background: var(--card-2); color: var(--text); }
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (max-width: 560px) {
  .sc-row { grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 10px 12px; }
  .sc-badge { grid-column: 1 / -1; justify-self: center; margin-top: 4px; }
}
.control-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.slider-label, .sort-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 600; }
.slider-label input[type="range"] { accent-color: var(--accent); width: 160px; }
.sort-label select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font: inherit;
}

/* ===== Card grid ===== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 11px; position: relative;
  border-left: 3px solid transparent; animation: fadeUp .45s ease both;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Severity accent: hard/high-score news stands out */
.card.tier-hot { border-left-color: #ef4444; }
.card.tier-rising { border-left-color: #f59e0b; }
.card.tier-emerging { border-left-color: #3b82f6; }

/* Featured hero card — the top trend spans the grid */
.card.featured { grid-column: 1 / -1; }
.card.featured .card-title { font-size: 22px; line-height: 1.25; }
.card.featured .card-summary { -webkit-line-clamp: 3; line-clamp: 3; font-size: 14px; }
.card.featured .spark { height: 52px; }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--card-2); color: var(--muted); }
.badge.cat { color: #fff; background: var(--grad); }
.badge.cat-world { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.badge.cat-tech { background: linear-gradient(90deg, #4f46e5, #6366f1); }
.badge.cat-business { background: linear-gradient(90deg, #0d9488, #14b8a6); }
.badge.cat-stocks { background: linear-gradient(90deg, #16a34a, #22c55e); }
.badge.cat-crypto { background: linear-gradient(90deg, #d97706, #fbbf24); }
.badge.cat-ai { background: linear-gradient(90deg, #7c3aed, #a855f7); }
.badge.cat-sports { background: linear-gradient(90deg, #ea580c, #f97316); }
.badge.cat-fashion { background: linear-gradient(90deg, #db2777, #ec4899); }
.badge.cat-food { background: linear-gradient(90deg, #dc2626, #f87171); }
.src-badge { font-size: 11px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }

.card-title { font-size: 16.5px; font-weight: 750; line-height: 1.3; margin: 0; letter-spacing: -0.2px; }
.card-title a:hover { color: var(--accent); }
.card-summary { font-size: 13px; color: var(--muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Score meter */
.score-row { display: flex; align-items: center; gap: 10px; }
.meter { flex: 1; height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px; transition: width .6s ease; }
.score-label { font-size: 12px; font-weight: 700; white-space: nowrap; }
.hot { color: #ef4444; } .hot-bar { background: linear-gradient(90deg,#f97316,#ef4444); }
.rising { color: #f59e0b; } .rising-bar { background: linear-gradient(90deg,#fbbf24,#f59e0b); }
.emerging { color: #3b82f6; } .emerging-bar { background: linear-gradient(90deg,#60a5fa,#3b82f6); }

.spark { width: 100%; height: 38px; display: block; }

/* Compact card footer */
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.btn-ideas { padding: 8px 14px; font-size: 13px; }
.card-foot-right { display: flex; align-items: center; gap: 6px; }
.card-time { font-size: 12px; color: var(--muted); margin-right: 2px; }
.icon-mini {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; transition: transform .15s;
}
.icon-mini:hover { transform: translateY(-1px); }
.icon-mini.active { background: var(--grad); color: #fff; border-color: transparent; }

/* ===== Skeletons ===== */
.skeleton {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.sk-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--card-2) 25%, var(--border) 37%, var(--card-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.sk-line.lg { height: 18px; width: 80%; }
.sk-line.sm { width: 40%; }
.sk-block { height: 40px; border-radius: 8px; background: linear-gradient(90deg, var(--card-2) 25%, var(--border) 37%, var(--card-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ===== Sidebar ===== */
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li {
  display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border);
  align-items: center;
}
.top-list li:last-child { border-bottom: none; }
.top-list li.rank-1 { border-left: 3px solid #ef4444; padding-left: 9px; }
.top-rank {
  font-weight: 800; font-size: 14px; width: 26px; height: 26px; color: #fff;
  display: flex; align-items: center; justify-content: center; border-radius: 8px; flex: 0 0 26px;
}
.top-rank.hot { background: linear-gradient(90deg, #f97316, #ef4444); }
.top-rank.rising { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.top-rank.emerging { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.top-item { flex: 1; min-width: 0; }
.top-item-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.top-item-meta { font-size: 11px; color: var(--muted); }
.top-score { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }

.signup .muted { font-size: 13px; margin: 0 0 12px; }
.alert-form { display: flex; flex-direction: column; gap: 8px; }
.alert-form input { padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; }

.muted { color: var(--muted); }
.accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-illustration { font-size: 64px; margin-bottom: 8px; }
.empty-state h3 { margin: 6px 0; color: var(--text); }
.empty-state .btn { margin-top: 14px; }

/* ===== About ===== */
.about h1 { font-size: 30px; margin-top: 0; }
.about h3 { margin-top: 22px; }
.about ul { padding-left: 18px; }
.about li { margin: 6px 0; }
.about code { background: var(--card-2); padding: 2px 7px; border-radius: 6px; font-size: 13px; }

/* ===== Footer ===== */
.footer { border-top: 1px solid var(--border); margin-top: 30px; padding: 20px 0; color: var(--muted); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-nav { display: flex; gap: 18px; }
.footer-nav button, .footer-nav a { background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; }
.footer-nav button:hover, .footer-nav a:hover { color: var(--text); }

/* ===== FAB ===== */
.fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-size: 22px; box-shadow: var(--shadow);
  transition: transform .15s;
}
.fab:hover { transform: scale(1.08); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); animation: fadeIn .25s ease; }
.modal-card {
  position: relative; background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px;
  width: 100%; max-width: 540px; max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow); animation: modalIn .3s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; }
.modal-sub { padding: 4px 20px 0; color: var(--muted); font-size: 14px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 20px 20px; }
.idea-html h1, .idea-html h2, .idea-html h3 { font-size: 16px; margin: 14px 0 4px; }
.idea-html ol, .idea-html ul { padding-left: 20px; }
.idea-html li { margin: 8px 0; }
.idea-html strong { color: var(--accent-2); }

.spinner-wrap { text-align: center; padding: 30px 0; color: var(--muted); }
.spinner {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 14px;
  border: 4px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 300;
  font-weight: 600; font-size: 14px; animation: toastIn .25s ease;
}
.toast.err { border-color: #ef4444; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}
@media (max-width: 680px) {
  .nav { display: none; position: absolute; top: 62px; left: 0; right: 0; flex-direction: column;
    background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 10px; margin: 0; }
  .nav.open { display: flex; }
  .menu-toggle { display: inline-flex; }
  .install-btn { display: none; }
  .control-row { flex-direction: column; align-items: stretch; }
  .slider-label input[type="range"] { flex: 1; width: auto; }
}

@media (max-width: 768px) {
  /* horizontal-scrolling category filters */
  .filters { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .filters::-webkit-scrollbar { height: 0; }
  .chip { flex: 0 0 auto; }

  /* 44px minimum tap targets */
  .btn, .icon-btn, .chip, .nav-link { min-height: 44px; }
  .icon-mini { width: 40px; height: 40px; }

  /* full-screen, bottom-aligned modal */
  .modal { align-items: flex-end; padding: 0; }
  .modal-card { max-width: 100%; width: 100%; height: 90vh; max-height: 90vh; border-radius: 20px 20px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
