/* ═══════════════════════════════════════════════════════════════ */
/* Home Page Styles — Hero, treemap, paper list, teaser, footer     */
/* ═══════════════════════════════════════════════════════════════ */

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Hero / center stage ── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10vh 24px 32px;
}

.brand {
  text-align: center;
  margin-bottom: 24px;
}

.brand-name {
  font-size: 34px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.2px;
  line-height: 1;
}

.brand-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  margin-top: 6px;
  letter-spacing: 0;
}

/* ── Search ── */
.search {
  width: 100%;
  max-width: 616px;
  position: relative;
  margin-bottom: 6px;
  z-index: 100;
}

.search-wrapper {
  position: relative;
  border-radius: 6px;
}

/* When dropdown is open, accent outline wraps input + dropdown as one unit */
.search-wrapper:has(.search-results.active) {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 46px 0 42px;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  position: relative;
  z-index: 102;
}

.search input:focus {
  border-color: var(--accent);
}

.search input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}

/* LHS magnifying glass icon */
.search-wrapper > svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  z-index: 103;
}

/* RHS paper plane "go" button — always visible, active on hover */
.search-go {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0 5px 5px 0;
  background: var(--bg);
  color: var(--text-3);
  cursor: default;
  z-index: 103;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

/* Hover only activates when there's text in the input */
.search-wrapper:has(input:not(:placeholder-shown)) .search-go {
  cursor: pointer;
}

.search-wrapper:has(input:not(:placeholder-shown)) .search-go:hover {
  background: rgba(0, 86, 179, 0.06);
  color: var(--accent);
}

.search-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 0;
  margin-top: 8px;
}

.search-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
}

/* ── Home-specific search result overrides ── */
.search-results {
  max-height: 400px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  z-index: 101;
}

.search-result-item {
  padding: 6px 16px;
}

.search-concept-row {
  padding: 8px 16px;
}

/* ── Content area ── */
.content {
  max-width: 790px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 44px;
  flex: 1;
}

/* ── Treemap section ── */
.treemap-section {
  margin-bottom: 16px;
  min-height: 264px; /* header + chart + info line; keeps paper section from shifting on view toggle */
}

.section-head {
  display: flex;
  align-items: center;
  height: 16px;
  margin-bottom: 10px;
  min-height: 16px;
  position: relative;
}

.section-head .toggle {
  margin-left: auto;
}
.view-toggle + .toggle {
  margin-left: -4px;
}

.section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ── Toggle (plain text with divider) ── */
.toggle {
  display: flex;
  align-items: center;
  gap: 0;
}

.toggle-btn {
  padding: 2px 8px;
  font-size: 10px;
  font-family: var(--font);
  font-weight: 600;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.12s;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.toggle-btn.active {
  color: var(--accent);
}

.toggle-btn:not(.active):hover {
  color: var(--text-2);
}

.toggle-btn:last-child {
  padding-right: 0;
}

.toggle-sep {
  width: 1px;
  height: 12px;
  background: var(--border);
}

/* ── View toggle (chart ↔ treemap) ── */
.view-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px 2px 0;
  margin-left: auto;
  color: var(--text-3);
  transition: color 0.15s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 16px;
}
.view-toggle:hover { color: var(--accent); }
.view-toggle:focus, .view-toggle:focus-visible { outline: none; box-shadow: none; }
.view-toggle:disabled,
.view-toggle.is-loading {
  color: var(--text-3);
  cursor: default;
  opacity: 0.36;
}
.view-toggle:disabled:hover,
.view-toggle.is-loading:hover {
  color: var(--text-3);
}
.view-toggle .view-icon,
.view-toggle .view-icon-tree {
  filter: none !important;
  -webkit-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}
.view-toggle .view-icon-tree,
.view-toggle .view-icon-tree * {
  shape-rendering: crispEdges;
  filter: none !important;
  -webkit-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

/* ── Treemap container ── */
#treemap {
  width: 100%;
  height: 220px;
}

/* ── Trend chart container ── */
#trendView {
  width: 100%;
  height: 220px;
}

/* Hover info line below treemap */
.tm-info {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-3);
  height: 18px;
  line-height: 18px;
  margin-top: 0;
  pointer-events: none;
  text-align: left;
}
.tm-info-name {
  font-weight: 400;
}
.tm-info-count {
  margin-left: 4px;
  font-weight: 400;
}

#treemap rect {
  stroke: var(--bg);
  stroke-width: 1.5;
  cursor: pointer;
  transition: opacity 0.12s;
}

#treemap rect:hover {
  opacity: 0.85;
}

#treemap text {
  font-family: var(--font);
  fill: #fff;
  pointer-events: none;
  font-weight: 500;
}

/* ── Paper list section ── */
.paper-section {
  position: relative;
  margin-bottom: 38px;
}

.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.col-head a {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}

.col-head a:hover {
  text-decoration: underline;
}

/* ── Paper list scroll container ──
   Show exactly 6 full rows, no partial. Hidden scrollbar,
   still scrollable via wheel/touch. Snaps to row boundaries. */
.paper-scroll-wrap {
  position: relative;
}
#papers-added,
#papers-viewed {
  min-height: 246px;
  max-height: 246px;
  overflow-y: auto;
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* IE/Edge */
  scroll-snap-type: y mandatory;
}
#papers-added::-webkit-scrollbar,
#papers-viewed::-webkit-scrollbar {
  display: none;                    /* Chrome/Safari */
}

/* ── Scroll hint chevrons (absolute overlays) ── */
.scroll-hint {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  cursor: pointer;
  z-index: 2;
}
.scroll-hint svg {
  width: 12px;
  height: 7px;
  stroke: var(--text-3);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scroll-hint.visible {
  opacity: 0;
  pointer-events: none;
}
/* Both chevrons: controlled by JS zone tracking */
.scroll-hint.zone-hover {
  opacity: 1;
  pointer-events: auto;
}
/* Up: vertically aligned with the section-head row */
.scroll-hint-up {
  top: 6px;
}
/* Down: at the bottom of the paper-section */
.scroll-hint-down {
  bottom: -14px;
}

/* ── Paper row ── */
.pr {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  scroll-snap-align: start;
}

.pr:last-child {
  border-bottom: none;
}

.pr:hover .pr-t {
  color: var(--accent);
}

.pr-id {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
  min-width: 80px;
  flex-shrink: 0;
}

.pr-body {
  flex: 1;
  min-width: 0;
}

.pr-t {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  transition: color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-a {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 9px;
  font-weight: 500;
  padding: 0 4px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-kg {
  color: var(--green);
  background: var(--green-bg);
}

.badge-cit {
  color: var(--text-2);
  background: var(--bg-3);
}

.pr-time {
  font-size: 9px;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ── Recently viewed: double-click → confirm remove ── */
#papers-viewed .pr {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.pr-confirm {
  font-size: 9px;
  color: var(--text-3);
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.12s;
}

.pr-confirm:hover {
  color: var(--text-1, #333);
}

/* ── Concept Map teaser (full width) ── */
.teaser {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  color: inherit;
  margin-bottom: 0;
}

.teaser:hover { border-color: var(--accent); }
.teaser:hover .teaser-title { color: var(--accent); }

.teaser-viz {
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.teaser-viz svg { width: 100%; height: 100%; }

.teaser-body { flex: 1; min-width: 0; }

.teaser-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.teaser-desc {
  font-size: 11.5px;
  color: var(--text-2);
  line-height: 1.45;
  margin-bottom: 22px;
}

.teaser-stats {
  font-size: 10px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 14px;
  align-items: baseline;
}

.teaser-stats strong {
  color: var(--text-2);
  font-weight: 600;
}

/* ── Feature cards (two-column below teaser) ── */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.feature-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.12s;
  text-decoration: none;
  color: inherit;
}

.feature-card:hover { border-color: var(--border); }
.feature-card:hover .feature-card-title { color: var(--text); }

.feature-card-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-top: 1px;
}

.feature-card-icon svg [stroke] {
  stroke: var(--text-3);
}

.feature-card-icon svg [fill]:not([fill="none"]) {
  fill: var(--text-3);
}

.feature-card-body {
  flex: 1;
  min-width: 0;
}

.feature-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  transition: color 0.12s;
  display: inline;
}

.feature-card-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.3;
  display: inline;
}

/* Construction badge — upper-right corner */
.feature-card-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--text-4);
}

/* Coming Soon card styling */
.feature-card.coming-soon {
  cursor: default;
}
.feature-card.coming-soon .feature-card-icon,
.feature-card.coming-soon .feature-card-body {
  opacity: 0.35;
}
.feature-card.coming-soon:hover {
  border-color: var(--border);
}
.feature-card.coming-soon:hover .feature-card-title {
  color: var(--text);
}
.feature-card.coming-soon::after {
  content: 'Coming Soon';
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.3px;
  opacity: 0;
  transition: opacity 0.15s;
}
.feature-card.coming-soon:hover::after {
  opacity: 1;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .hero {
    padding: 32px 16px 24px;
  }

  .brand-name {
    font-size: 28px;
  }

  .brand-sub {
    font-size: 12px;
  }

  .search input {
    height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .search-go {
    width: 44px;
  }

  .search-hint {
    display: none;
  }

  .content {
    padding: 0 16px 32px;
  }

  #treemap {
    height: 160px;
  }
  #trendView {
    height: 160px;
  }
  .treemap-section {
    min-height: 204px;
  }

  /* Paper rows: bigger touch targets */
  .pr {
    padding: 10px 0;
    min-height: 44px;
  }

  .pr-id {
    display: none;
  }

  .pr-t {
    font-size: 14px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .pr-a {
    font-size: 12px;
  }

  /* Toggle buttons: bigger touch targets */
  .toggle-btn {
    padding: 6px 10px;
    font-size: 11px;
    min-height: 44px;
  }

  /* Scroll hint chevrons: hide on touch (no hover zones) */
  .scroll-hint {
    display: none;
  }

  /* Feature cards: stack vertically on mobile, bigger targets */
  .feature-cards {
    grid-template-columns: 1fr;
  }

  .feature-card {
    padding: 16px;
    min-height: 60px;
  }

  .feature-card-title {
    font-size: 14px;
  }

  .feature-card-desc {
    font-size: 13px;
  }

  .feature-card-meta {
    flex-wrap: wrap;
  }

  /* Teaser: touch-friendly */
  .teaser {
    padding: 16px;
  }

  .teaser-title {
    font-size: 15px;
  }

  .teaser-desc {
    font-size: 13px;
  }

  .teaser-stats {
    gap: 8px 12px;
    min-height: 32px;
  }

  /* Search results: bigger touch targets */
  .search-result-item {
    padding: 10px 16px;
    min-height: 44px;
  }

  .search-concept-row {
    padding: 10px 16px;
  }

  .search-concept-row .fp-chip {
    padding: 4px 10px;
    font-size: 12px;
    min-height: 32px;
  }

  /* Footer */
  .footer {
    font-size: 10px;
    padding: 16px;
  }
}
