/* ==========================================================================
   Hobby MD — Category-Grouped Layout
   ========================================================================== */

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --bg-primary: #0f1218;
  --bg-surface: #171b22;
  --bg-elevated: #1d2430;
  --bg-subtle: #202938;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text-primary: #f3f4f6;
  --text-secondary: rgba(243, 244, 246, 0.72);
  --text-tertiary: rgba(243, 244, 246, 0.5);
  --accent-gradient: linear-gradient(135deg, #7aa2ff 0%, #9f8cff 100%);
  --vote-up: #4ade80;
  --vote-down: #f87171;
  --cat-websites: #60a5fa;
  --cat-blogs: #f472b6;
  --cat-github: #34d399;
  --cat-applications: #fbbf24;
  --side-padding: 48px;
}

html.light-mode {
  --bg-primary: #f3f4f6;
  --bg-surface: #ffffff;
  --bg-elevated: #fafafa;
  --bg-subtle: #eceff3;
  --border-color: #e0e0e0;
  --border-strong: #d8d8d8;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent-gradient: linear-gradient(135deg, #4f7fd2 0%, #7f68c2 100%);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* --- Page-load anti-shift --- */
body.is-loading .spotlight,
body.is-loading .hero,
body.is-loading .category-grid {
  opacity: 0;
}

.spotlight,
.hero,
.category-grid {
  transition: opacity 0.25s ease;
}

/* ---------- Nav ---------- */
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 48px;
  background: transparent;
  border-bottom: none;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.nav__logo {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  transform: translateY(24px);
}

.nav__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.nav__links {
  display: flex;
  gap: 28px;
}

.nav__icon-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav__icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav__icon-btn:hover {
  color: var(--text-secondary);
  background: transparent;
}

.nav__link {
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav__link:hover {
  color: var(--text-secondary);
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 24px 32px;
}

.hero__title {
  font-family: 'ApocRevelations', Georgia, 'Times New Roman', serif;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.hero__subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ---------- Spotlight (Single Card + Shuffle) ---------- */
.spotlight {
  max-width: 100%;
  padding: 48px 0 0;
  margin-bottom: 32px;
}

.spotlight__header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.spotlight__controls {
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-left: 40px;
}

.spotlight__heading {
  margin: 0;
  text-align: center;
  font-family: 'ApocRevelations', Georgia, 'Times New Roman', serif;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.spotlight__prev-btn,
.spotlight__shuffle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 0.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast), transform 0.4s ease;
}

.spotlight__prev-btn svg {
  display: block;
  overflow: visible;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
}

.spotlight__filter-wrap {
  position: relative;
}

.spotlight__filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 0.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}

.spotlight__prev-btn:hover:not(:disabled),
.spotlight__shuffle:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.spotlight__prev-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.spotlight__filter-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.spotlight__filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  padding: 6px;
  border-radius: 10px;
  border: 0.5px solid var(--border-strong);
  background: var(--bg-surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.spotlight__filter-item[data-category="software"],
.spotlight__filter-item[data-category="applications"] { background: #ece9df; color: #111827; }
.spotlight__filter-item[data-category="websites"] { background: #d7e5ea; color: #111827; }
.spotlight__filter-item[data-category="blogs"] { background: #9aa5eb; color: #111827; }
.spotlight__filter-item[data-category="github"] { background: #f2d8d7; color: #111827; }
.spotlight__filter-item[data-category="creation"] { background: #dff1e5; color: #111827; }
.spotlight__filter-item[data-category="productivity"] { background: #e8e3f7; color: #111827; }

.spotlight__filter-menu.is-open {
  display: flex;
}

.spotlight__filter-item {
  width: 100%;
  text-align: center;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
}

.spotlight__filter-item[data-category="all"] {
  font-weight: 600;
}

.spotlight__filter-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.spotlight__filter-item.is-active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 600;
}

.spotlight__shuffle--spin {
  transform: rotate(360deg);
}

.spotlight__stage {
  position: relative;
  width: 520px;
  margin: 0 auto;
  padding: 20px 0;
}

.spotlight__card-wrapper {
  width: 100%;
}

/* --- Individual card --- */
.spotlight__card {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
}

/* --- Card header (category bar) --- */
.spotlight__card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px 10px;
  background: #ece9df;
}

.spotlight__card-header--software,
.spotlight__card-header--applications { background: #ece9df; }
.spotlight__card-header--websites { background: #d7e5ea; }
.spotlight__card-header--blogs { background: #9aa5eb; }
.spotlight__card-header--github { background: #f2d8d7; }
.spotlight__card-header--creation { background: #dff1e5; }
.spotlight__card-header--productivity { background: #e8e3f7; }

.spotlight__card-header-name {
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  font-weight: 700;
  line-height: 1;
  color: #111827;
  text-align: center;
}

/* --- Card body (row-like layout) --- */
.spotlight__card-body {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 0.5px solid var(--border-color);
}

.spotlight__card-body--empty {
  justify-content: center;
  min-height: 120px;
}

.spotlight__card-info {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.spotlight__card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotlight__card-desc {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotlight__card-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Card preview (expanded style) --- */
.spotlight__card-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-elevated);
}

.spotlight__card-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---------- Category Grid ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 0 48px 64px;
  max-width: 1200px;
  margin: 0 auto;
}

.category-grid__column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* ---------- Category Card ---------- */
.cat-card {
  background: var(--bg-surface);
  border: 0.5px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.cat-card__header {
  display: flex;
  align-items: center;
  padding: 20px 24px 16px;
  --header-name-color: #111827;
  --header-count-color: #111827;
}

.cat-card--software .cat-card__header { background: #ece9df; }
.cat-card--websites .cat-card__header { background: #d7e5ea; }
.cat-card--blogs .cat-card__header { background: #9aa5eb; }
.cat-card--github .cat-card__header { background: #f2d8d7; }
.cat-card--creation .cat-card__header { background: #dff1e5; }
.cat-card--productivity .cat-card__header { background: #e8e3f7; }

.cat-card__meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cat-card__name {
  font-size: clamp(1.4rem, 2.2vw, 2.05rem);
  font-weight: 700;
  line-height: 1;
  color: var(--header-name-color);
}

.cat-card__count {
  font-size: 0.75rem;
  color: var(--header-count-color);
}

.cat-card__header[data-contrast='light'] {
  --header-name-color: #f8fafc;
  --header-count-color: rgba(248, 250, 252, 0.92);
}

.cat-card__separator {
  height: 0.5px;
  background: var(--border-color);
  margin: 0 24px;
}

/* ---------- Project Row ---------- */
.project-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  padding: 12px 24px;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, padding 0.25s ease;
}

.project-row:not(:last-child) {
  border-bottom: 0.5px solid var(--border-color);
}

.project-row:hover {
  background: var(--bg-elevated);
}

.project-row:focus-visible {
  outline: 2px solid #9bbcf3;
  outline-offset: -2px;
}

.project-row.is-expanded {
  align-items: center;
  padding-bottom: 16px;
}

.project-row__rank {
  font-size: 0.65rem;
  font-weight: 700;
  color: #E65100;
  background: #FFF3E0;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  grid-row: 1 / span 2;
  align-self: center;
}

.project-row__info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.project-row__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.project-row__desc {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.45;
  max-height: 1.45em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  transition: max-height 0.25s ease, color 0.2s ease;
}

.project-row.is-expanded .project-row__desc {
  color: var(--text-secondary);
  max-height: 6.5em;
  white-space: normal;
  overflow-wrap: anywhere;
}

.project-row__actions {
  display: flex;
  align-items: center;
  gap: 5px;
  grid-column: 2;
  justify-self: center;
  justify-content: center;
  margin-top: 2px;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-width: 0;
}

.project-row__preview {
  grid-column: 1 / -1;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-10px);
  transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.35s ease, margin-top 0.35s ease;
  margin-top: 0;
}

.project-row.is-expanded .project-row__preview {
  max-height: 520px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 10px;
}

.project-row__preview-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 0.5px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.project-row__preview-gif {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---------- Action Buttons ---------- */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 5px;
  border: 0.5px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1;
  font-family: var(--font-sans);
}

.project-row .action-btn {
  cursor: pointer;
}

.action-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.action-btn--upvote:hover,
.action-btn--upvote.active {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2e7d32;
}

.action-btn--downvote:hover,
.action-btn--downvote.active {
  background: #ffebee;
  border-color: #ef9a9a;
  color: #c62828;
}

.action-btn--views {
  cursor: default;
}

.action-btn--visit:hover {
  background: #e3f2fd;
  border-color: #90caf9;
  color: #1565c0;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .nav { padding: 14px 24px; }
  .nav__right { gap: 12px; }
  .nav__links { gap: 20px; }
  .spotlight { padding: 0 24px; }
  .spotlight__stage {
    position: static;
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .spotlight__card-wrapper {
    width: 100%;
    max-width: 520px;
  }
  .spotlight__controls {
    position: static;
    transform: none;
    flex-direction: row;
    margin-left: 0;
    margin-bottom: 16px;
    order: -1;
  }
  .category-grid {
    grid-template-columns: 1fr;
    padding: 0 24px 48px;
  }
}

@media (max-width: 639px) {
  .nav { padding: 12px 16px; }
  .nav__right { gap: 8px; }
  .nav__links { gap: 12px; }
  .nav__icon-buttons { gap: 6px; }
  .nav__icon-btn {
    width: 30px;
    height: 30px;
  }
  .hero__title { font-size: 1.75rem; }
  .spotlight { padding: 0 16px; }
  .spotlight__header {
    margin-bottom: 16px;
  }
  .spotlight__controls { gap: 8px; }
  .spotlight__prev-btn,
  .spotlight__shuffle,
  .spotlight__filter-btn {
    width: 36px;
    height: 36px;
  }
  .spotlight__row { padding: 12px 14px; }
  .spotlight__preview { padding: 0 14px 14px; }
  .spotlight__name { font-size: 0.85rem; }
  .category-grid {
    grid-template-columns: 1fr;
    padding: 0 16px 40px;
  }
  .project-row {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 10px 16px;
    gap: 8px;
  }
  .project-row__actions { row-gap: 6px; }
  .cat-card__header { padding: 16px 16px 12px; }
  .cat-card__separator { margin: 0 16px; }
  .project-row__actions { gap: 4px; }
  .action-btn { font-size: 10px; padding: 2px 5px; }
}

/* ---------- Print ---------- */
@media print {
  body { background: white; }
  .cat-card { border: 1px solid #ddd; page-break-inside: avoid; }
  .action-btn--upvote, .action-btn--downvote { display: none; }
}
