/* Bionic Reader - Dark, minimal, reading-focused */

:root {
  --bg: #1a1a1a;
  --bg-secondary: #242424;
  --bg-hover: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #888;
  --text-read: #555;
  --accent: #6b9fff;
  --star: #f5c518;
  --border: #333;
  --success: #34c759;
  --read-later: #5856d6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Categories */
.categories {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.categories::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.cat-btn:hover {
  background: var(--bg-hover);
}

.cat-btn.active {
  color: var(--text);
  background: var(--bg-secondary);
}

/* Main content */
main {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  position: relative;
}

/* Pull to refresh */
.pull-indicator {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 14px;
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  transition: top 0.2s;
}

.pull-indicator.visible {
  top: 0;
  position: relative;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  display: none;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* Items */
.item {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: border-color 0.2s ease-out;
}

/* When swipe-wrapped, content moves to inner div */
.item:has(.item-content) {
  padding: 0;
}

.item-content {
  padding: 16px;
  background: var(--bg);
  transition: transform 0.2s ease-out;
  position: relative;
  z-index: 1;
}

.item:active .item-content {
  background: var(--bg-hover);
}

/* Swipe action backgrounds */
.swipe-action-right,
.swipe-action-left {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.swipe-action-right {
  left: 0;
  background: var(--success);
  justify-content: flex-start;
  padding-left: 24px;
}

.swipe-action-left {
  right: 0;
  background: var(--star);
  justify-content: flex-end;
  padding-right: 24px;
}

.swipe-action-right.visible,
.swipe-action-left.visible {
  opacity: 1;
}

.swipe-icon {
  font-size: 24px;
  color: #fff;
}

/* Visual states */
.item:not(.read) {
  border-left-color: var(--accent);
}

.item.read {
  opacity: 0.6;
}

.item.read .item-content {
  background: rgba(0, 0, 0, 0.15);
}

.item.read .summary {
  color: var(--text-read);
}

.item.starred {
  border-left-color: var(--star);
}

.item.read-later {
  border-left-color: var(--read-later);
}

.item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.source {
  color: var(--accent);
  font-weight: 500;
}

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

.star-btn {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.star-btn.starred {
  color: var(--star);
}

.title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 8px;
}

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

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

.summary {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
}

/* Bionic bold styling - weight only, no color change */
.summary b {
  font-weight: 600;
}

.tweet-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.tweet-link:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  header h1 {
    text-align: center;
  }

  .filters {
    justify-content: center;
  }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  main {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Context Menu */
.context-menu {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s;
}

.context-menu.visible {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s, opacity 0.3s;
}

.context-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.context-menu-sheet {
  position: relative;
  background: var(--bg-secondary);
  border-radius: 12px 12px 0 0;
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
}

.context-menu.visible .context-menu-sheet {
  transform: translateY(0);
}

.context-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.context-action:active {
  background: var(--bg-hover);
}

.context-action.cancel {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  justify-content: center;
  color: var(--accent);
  font-weight: 500;
}

.action-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.action-label {
  flex: 1;
}

/* Gesture Onboarding */
.onboarding-hint {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

.onboarding-hint.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s, visibility 0s;
}

.onboarding-content {
  text-align: center;
  padding: 32px;
}

.onboarding-hand {
  font-size: 48px;
  animation: swipe-hint 1.5s ease-in-out infinite;
}

@keyframes swipe-hint {
  0%, 100% {
    transform: translateX(-20px);
    opacity: 0.5;
  }
  50% {
    transform: translateX(40px);
    opacity: 1;
  }
}

.onboarding-text {
  margin-top: 16px;
  font-size: 18px;
  color: var(--text);
  font-weight: 500;
}

.onboarding-dismiss {
  margin-top: 24px;
  padding: 12px 32px;
  background: var(--accent);
  border: none;
  border-radius: 24px;
  color: #000;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

/* Update Toast */
.update-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: #000;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s;
}

.update-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.update-toast button {
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 12px;
  color: #000;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .update-toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
