/* ===== Tokens ===== */
:root {
  --bg: #0b0f14;
  --bg-elevated: #12181f;
  --bg-card: #151c25;
  --bg-card-hover: #1a2330;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef6;
  --text-muted: #94a3b8;
  --text-soft: #64748b;
  --accent: #22d3ee;
  --accent-dim: #0ea5e9;
  --accent-glow: rgba(34, 211, 238, 0.15);
  --us: #38bdf8;
  --us-bg: rgba(56, 189, 248, 0.12);
  --hk: #fbbf24;
  --hk-bg: rgba(251, 191, 36, 0.12);
  --up: #34d399;
  --down: #f87171;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1080px;
  --header-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(14, 165, 233, 0.12), transparent),
    radial-gradient(ellipse 40% 30% at 90% 10%, rgba(34, 211, 238, 0.06), transparent),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: var(--accent);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #0b0f14;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(11, 15, 20, 0.82);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark svg {
  flex-shrink: 0;
}

.site-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.site-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.demo-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* ===== Hero ===== */
.hero {
  padding: 2.5rem 1.25rem 1.5rem;
}

.hero-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: block;
  padding: 2rem;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--mono);
}

.hero-copy h2 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.hero-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  max-width: 42em;
  font-size: 0.95rem;
}

.hero-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.chip-us {
  color: var(--us);
  background: var(--us-bg);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.chip-both {
  color: var(--accent);
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.28);
}

.chip-hk {
  color: var(--hk);
  background: var(--hk-bg);
  border: 1px solid rgba(251, 191, 36, 0.25);
}


/* ===== Feed ===== */
.feed-section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.filters {
  display: flex;
  gap: 0.4rem;
  padding: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.filter-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

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

.filter-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-btn.is-active {
  background: var(--accent-glow);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.3);
}

.date-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 9.5rem;
}

.date-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  text-transform: uppercase;
}

.date-toolbar select,
.date-toolbar input[type="date"] {
  appearance: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  color-scheme: dark;
  min-height: 2.4rem;
}

.date-toolbar select:focus-visible,
.date-toolbar input[type="date"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.date-clear {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  min-height: 2.4rem;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.date-clear:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-card);
}

.date-clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Cards ===== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
}

.post-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.35rem 1.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  transition:
    transform 0.25s var(--ease),
    border-color 0.25s var(--ease),
    background 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  width: 100%;
}

.post-card:hover {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.post-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.post-card.is-hidden {
  display: none;
}

.post-time {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.detail-time {
  margin: 0.4rem 0 0.75rem;
  color: var(--text-muted);
}

.market-asof {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.market-asof time {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.empty-filter {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.5rem;
  color: var(--text-muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.post-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-soft);
}

.post-badges {
  display: flex;
  gap: 0.35rem;
}

.post-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.post-excerpt {
  margin: 0 0 1rem;
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: gap 0.2s var(--ease);
}

.post-card:hover .post-cta {
  gap: 0.55rem;
}

/* ===== Detail ===== */
.post-detail {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
}

.post-detail[hidden] {
  display: none !important;
}

.detail-inner {
  animation: fadeUp 0.35s var(--ease);
}

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

.back-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.back-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-card);
}

.back-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.detail-article {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  box-shadow: var(--shadow);
}

.detail-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.detail-header .post-date {
  display: block;
  margin-bottom: 0.5rem;
}

.detail-header h2 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 700;
  line-height: 1.35;
  max-width: 22em;
}

.detail-disclaimer {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-soft);
  padding: 0.65rem 0.85rem;
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid var(--hk);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.market-section {
  margin-bottom: 2rem;
}

.market-section:last-child {
  margin-bottom: 0;
}

.market-section h3 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.market-section p {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  max-width: 40em;
  font-size: 0.95rem;
}

.ticker-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.ticker-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.ticker-sym {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--accent);
  min-width: 4.5em;
}

.ticker-note {
  color: var(--text-muted);
}

.ticker-chg {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
}

.ticker-chg.up {
  color: var(--up);
}

.ticker-chg.down {
  color: var(--down);
}

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
}

.theme-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  background: rgba(0, 0, 0, 0.25);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  text-align: center;
}

.footer-inner p {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-meta {
  font-size: 0.78rem !important;
  color: var(--text-soft) !important;
}

/* ===== List / detail mode ===== */
body.showing-detail .hero,
body.showing-detail .feed-section {
  display: none;
}

body.showing-detail .post-detail {
  padding-top: 1.5rem;
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
  .hero-inner {
    padding: 1.35rem;
  }

  .header-meta {
    display: none;
  }

  .site-title {
    font-size: 1.05rem;
  }

  .site-subtitle {
    font-size: 0.72rem;
  }
}

@media (max-width: 480px) {
  .filters {
    width: 100%;
    justify-content: stretch;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .ticker-list li {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .ticker-sym {
    grid-column: 1;
  }

  .ticker-chg {
    grid-column: 2;
    grid-row: 1;
  }

  .ticker-note {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

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