/* ============================================
   My Stack — Dedicated stack page styling
   Uses existing palette from styles.css
   ============================================ */

.stack-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.2rem 1.25rem 4rem;
}

/* --- Hero -------------------------------- */
.stack-hero {
  text-align: left;
  padding: 1.4rem 0 2.6rem;
  border-bottom: 1px solid var(--border);
}

.stack-hero-title {
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.stack-hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 0.95rem;
}

.stack-stats-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.stack-stats {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.stack-sort-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.stack-clear-all-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.stack-clear-all-btn:hover {
  color: #c82333;
  border-color: rgba(200, 35, 51, 0.4);
}

.stack-sort {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}

.stack-sort:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stack-stat strong {
  color: var(--accent);
  font-weight: 700;
}

.stack-stat-sep {
  margin: 0 0.5rem;
  opacity: 0.6;
}

.stack-empty-msg {
  margin: 1rem 0 0;
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.92rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  line-height: 1.5;
}

.stack-empty-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.stack-empty-msg a {
  color: var(--accent);
  font-weight: 600;
}

/* --- Section ----------------------------- */
.stack-section {
  padding: 2.2rem 0;
  border-bottom: 1px solid var(--border);
}

.stack-section:last-of-type {
  border-bottom: none;
}

.stack-section-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.stack-section-icon {
  font-size: 1.35rem;
  opacity: 0.95;
}

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

.stack-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.stack-card.hidden {
  display: none;
}

.stack-card:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: var(--shadow-hover);
}

.stack-card-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stack-visit-btn {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  min-width: 44px;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stack-visit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.stack-share-btn {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  min-width: 44px;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stack-share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.stack-remove-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.stack-remove-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.stack-card-link {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.stack-card-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

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

.stack-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: var(--text);
}

.stack-card-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stack-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.stack-card-tag {
  font-size: 0.63rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.stack-card-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border-radius: 4px;
  border: 1px solid var(--border-light);
}

/* --- Responsive -------------------------- */
@media (max-width: 640px) {
  .stack-main {
    padding: 1.5rem calc(0.75rem + env(safe-area-inset-right, 0px)) calc(3rem + env(safe-area-inset-bottom, 0px)) calc(0.75rem + env(safe-area-inset-left, 0px));
  }

  .stack-hero {
    padding: 2rem 0 3rem;
  }

  .stack-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stack-card {
    padding: 0.9rem 1rem;
  }
}
