/* ============================================
   Ideas Dashboard — Newsfeed Redesign
   Apple/Anthropic aesthetic
   ============================================ */

:root {
  /* ---- palette: clean paper ---- */
  --bg:           #FAFAFA;
  --surface:      #FFFFFF;
  --surface-card: #FFFFFF;
  --surface-hover: #F5F5F5;
  --surface-selected: #FDF8F6;
  --ink:          #1D1D1F;
  --ink-2:        #424245;
  --ink-3:        #86868B;
  --line:         #E8E8ED;
  --line-soft:    #F2F2F7;

  /* ---- accent ---- */
  --accent:       #E10909;
  --accent-ink:   #FFFFFF;
  --accent-soft:  rgba(225, 9, 9, 0.08);

  /* ---- semantic ---- */
  --high:    #E10909;
  --medium:  #BF5700;
  --watch:   #5856D6;

  /* ---- typography ---- */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-editorial: Georgia, "Iowan Old Style", "Times New Roman", serif;

  /* ---- geometry ---- */
  --r-sm:   8px;
  --r-md:   12px;

  /* ---- motion ---- */
  --ease:  cubic-bezier(0.22, 1, 0.36, 1);
  --dur-1: 150ms;
  --dur-2: 250ms;

  /* ---- elevation ---- */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);

  /* ---- layout ---- */
  --sidebar-width: 200px;
  --content-max: 720px;
}

/* ---- dark mode ---- */
.dark {
  --bg:           #000000;
  --surface:      #1C1C1E;
  --surface-card: #1C1C1E;
  --surface-hover: #2C2C2E;
  --surface-selected: #2A2420;
  --ink:          #F5F5F7;
  --ink-2:        #A1A1A6;
  --ink-3:        #6E6E73;
  --line:         #38383A;
  --line-soft:    #2C2C2E;
  --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.dark {
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================
   App Shell
   ============================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  padding: 0 12px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.sidebar-logo-icon {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo-icon svg {
  width: 14px;
  height: 14px;
  color: var(--accent-ink);
  stroke-width: 2;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.sidebar-link:hover {
  color: var(--ink-2);
  background: var(--surface-hover);
}

.sidebar-link.active {
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-selected);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-spacer {
  flex: 1;
  min-height: 24px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- Main Column ---- */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---- Top Bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.page-title {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.page-meta {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.theme-toggle:hover {
  color: var(--ink);
  background: var(--surface-hover);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Filter Bar ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-link {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-3);
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.filter-link:hover {
  color: var(--ink-2);
}

.filter-link.active {
  font-weight: 500;
  color: var(--ink);
  background: var(--surface-selected);
}

.filter-sep {
  color: var(--line);
  font-size: 14px;
  user-select: none;
}

.filter-spacer {
  flex: 1;
}

.feed-meta {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}

/* ============================================
   Newsfeed
   ============================================ */
.newsfeed {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.story-card {
  background: var(--surface-card);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}

.story-card:hover {
  background: var(--surface-hover);
}

.story-card.expanded {
  background: var(--surface-card);
  cursor: default;
}

.story-collapsed {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.story-type {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface-hover);
  color: var(--ink-2);
}

.story-type[data-type="idea"] {
  background: rgba(88, 86, 214, 0.1);
  color: #5856D6;
}

.story-type[data-type="pulse"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.story-interest {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.story-interest[data-interest="high"] {
  color: var(--high);
}

.story-interest[data-interest="medium"] {
  color: var(--medium);
}

.story-interest[data-interest="watch"] {
  color: var(--watch);
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-3);
  opacity: 0.5;
}

.story-date {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}

.story-headline {
  font-family: var(--font-editorial);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.story-lede {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---- Expanded Story ---- */
.story-expanded {
  display: none;
  padding: 0 24px 24px 24px;
  border-top: 1px solid var(--line-soft);
  margin-top: -1px;
}

.story-card.expanded .story-expanded {
  display: block;
}

.story-card.expanded .story-collapsed {
  padding-bottom: 16px;
}

.story-body {
  font-family: var(--font-editorial);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 24px;
}

.story-body p {
  margin-bottom: 1em;
}

.story-body p:last-child {
  margin-bottom: 0;
}

.story-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.story-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.section-content {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
}

.story-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.topic-tag {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--surface-hover);
  color: var(--ink-2);
}

.story-sources {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.sources-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.source-link {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--dur-1) var(--ease);
}

.source-link:hover {
  color: var(--accent);
}

.source-link::after {
  content: "↗";
  font-size: 12px;
  opacity: 0.5;
}

/* ---- Close button ---- */
.story-close {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-hover);
  color: var(--ink-3);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}

.story-close:hover {
  background: var(--line);
  color: var(--ink);
}

.story-close svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.story-card.expanded {
  position: relative;
}

.story-card.expanded .story-close {
  display: flex;
}

/* ============================================
   Topics View
   ============================================ */
.topics-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.topic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface-card);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}

.topic-row:hover {
  background: var(--surface-hover);
}

.topic-name {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.topic-count {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-3);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  padding: 64px 24px;
  text-align: center;
}

.empty-text {
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink-3);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 64px;
  }
  
  .sidebar-logo span,
  .sidebar-link span {
    display: none;
  }
  
  .sidebar-link {
    justify-content: center;
    padding: 12px;
  }
  
  .app-sidebar {
    padding: 24px 8px;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 640px) {
  .app-sidebar {
    display: none;
  }
  
  .main-content {
    padding: 16px;
  }
  
  .top-bar {
    padding: 12px 16px;
  }

  .story-collapsed {
    padding: 16px;
  }

  .story-expanded {
    padding: 0 16px 16px 16px;
  }

  .story-headline {
    font-size: 18px;
  }

  .story-body {
    font-size: 16px;
  }
}

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

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
}
