/* Construct Blog Theme — matches construct.space sidebar pattern */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700&display=swap');

/* ─── Tokens (vs-dark default, overridden by JS theme switcher) ─── */
:root {
  --app-background: #1e1e1e;
  --app-foreground: #d4d4d4;
  --app-muted: #6b7280;
  --app-accent: #34C759;
  --app-accent-foreground: #ffffff;
  --app-border: #3c3c3c;
  --app-surface: #282828;
  --app-card: #2e2e2e;
  --app-input-bg: #363636;
}

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

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

body {
  font-family: 'Rubik', sans-serif;
  color: var(--app-foreground);
  background: var(--app-background);
  line-height: 1.6;
}

a { color: var(--app-accent); text-decoration: none; transition: color 0.2s; }
a:hover { opacity: 0.85; }
img { max-width: 100%; height: auto; }

/* ─── Layout ─── */

.site-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ─── Icon-only Sidebar (60px, matches construct.space) ─── */

.site-sidebar {
  width: 60px;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  gap: 0.25rem;
  z-index: 200;
  overflow: hidden;
}

/* 3D entrance animation (from construct.space) */
.sidebar-3d {
  overflow: hidden;
}

.sidebar-3d-panel {
  animation: sidebarCubeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0.75rem 0;
  gap: 0.25rem;
}

@keyframes sidebarCubeIn {
  from { transform: perspective(600px) rotateY(-90deg); opacity: 0; }
  to   { transform: perspective(600px) rotateY(0deg); opacity: 1; }
}

.sidebar-3d-panel nav > a {
  opacity: 0;
  animation: sidebarItemIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.sidebar-3d-panel nav > a:nth-child(1) { animation-delay: 0.05s; }
.sidebar-3d-panel nav > a:nth-child(2) { animation-delay: 0.08s; }
.sidebar-3d-panel nav > a:nth-child(3) { animation-delay: 0.11s; }
.sidebar-3d-panel nav > a:nth-child(4) { animation-delay: 0.14s; }
.sidebar-3d-panel nav > a:nth-child(5) { animation-delay: 0.17s; }
.sidebar-3d-panel nav > a:nth-child(6) { animation-delay: 0.20s; }
.sidebar-3d-panel nav > a:nth-child(7) { animation-delay: 0.23s; }

@keyframes sidebarItemIn {
  from { opacity: 0; transform: perspective(600px) rotateY(-45deg) scale(0.8); }
  to   { opacity: 1; transform: perspective(600px) rotateY(0deg) scale(1); }
}

.sidebar-3d-panel > div:first-child {
  animation: sidebarLogoIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sidebarLogoIn {
  from { opacity: 0; transform: perspective(600px) scale(0.5) rotateY(-90deg); }
  to   { opacity: 1; transform: perspective(600px) scale(1) rotateY(0deg); }
}

/* Sidebar logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 0.5rem;
  color: var(--app-accent);
}

.sidebar-logo svg {
  width: 28px;
  height: 28px;
}

/* Sidebar divider */
.sidebar-divider {
  width: 32px;
  border: none;
  border-top: 1px solid var(--app-border);
  margin: 0.375rem 0;
}

/* Sidebar icon button */
.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  color: var(--app-muted);
  border: none;
  background: none;
  font-family: inherit;
}

.sidebar-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-icon:hover {
  background: var(--app-input-bg);
  color: var(--app-foreground);
}

.sidebar-icon.active {
  background: color-mix(in srgb, var(--app-accent) 15%, transparent);
  color: var(--app-accent);
}

/* Tooltip */
.sidebar-icon .tooltip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 300;
  background: var(--app-foreground);
  color: var(--app-background);
}

.sidebar-icon:hover .tooltip {
  opacity: 1;
}

/* Sidebar spacer */
.sidebar-spacer {
  flex: 1;
}

/* ─── Theme Picker (popover from sidebar) ─── */

.theme-popover {
  display: none;
  position: fixed;
  left: 68px;
  bottom: 60px;
  width: 200px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  padding: 0.375rem;
  z-index: 400;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.theme-popover.open {
  display: block;
}

.theme-popover-title {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--app-muted);
  padding: 0.375rem 0.5rem 0.25rem;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--app-muted);
  transition: background 0.15s;
  text-align: left;
}

.theme-option:hover {
  background: var(--app-input-bg);
}

.theme-option.active {
  color: var(--app-accent);
}

.theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--app-border);
}

.theme-option.active .theme-dot {
  outline: 2px solid var(--app-accent);
  outline-offset: 1px;
}

/* ─── Main Content ─── */

.site-main {
  margin-left: 60px;
  flex: 1;
  min-width: 0;
}

.main-content {
  max-width: 920px;
  margin: 0 auto;
  padding: 3rem 2.5rem;
}

/* ─── Section Label (uppercase, small, like Construct dashboard) ─── */

.section-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--app-muted);
  margin-bottom: 1rem;
}

/* ─── Hero (featured post, text-only, spacious) ─── */

.hero {
  padding-bottom: 2.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--app-border);
}

.hero-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.hero-title a {
  color: var(--app-foreground);
  transition: color 0.15s;
}

.hero-title a:hover {
  color: var(--app-accent);
  opacity: 1;
}

.hero-excerpt {
  font-size: 1rem;
  color: var(--app-muted);
  line-height: 1.6;
  max-width: 600px;
  margin-bottom: 1rem;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--app-muted);
}

.meta-dot {
  opacity: 0.4;
}

.meta-tag {
  color: var(--app-accent);
  font-weight: 500;
}

/* ─── Feed Section ─── */

.feed-section {
  margin-bottom: 2.5rem;
}

/* ─── Post List (clean rows, no cards) ─── */

.post-list {
  display: flex;
  flex-direction: column;
}

.post-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--app-border);
  color: var(--app-foreground);
  transition: background 0.1s;
  text-decoration: none;
}

.post-row:first-child {
  border-top: 1px solid var(--app-border);
}

.post-row:hover {
  background: var(--app-surface);
  opacity: 1;
}

.post-row-date {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--app-muted);
  width: 52px;
  flex-shrink: 0;
}

.post-row-tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--app-accent);
  width: 80px;
  flex-shrink: 0;
}

.post-row-title {
  font-size: 0.9375rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-row-reading {
  font-size: 0.75rem;
  color: var(--app-muted);
  flex-shrink: 0;
}

/* ─── Topic Grid (small, flat pills) ─── */

.topic-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.topic-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--app-border);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--app-muted);
  transition: border-color 0.15s, color 0.15s;
  text-decoration: none;
}

.topic-item:hover {
  border-color: var(--app-accent);
  color: var(--app-foreground);
  opacity: 1;
}

.topic-name {
  font-weight: 500;
}

.topic-count {
  font-family: monospace;
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ─── Post Card (used on tag/author pages) ─── */

.post-feed {
  display: flex;
  flex-direction: column;
}

.post-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--app-border);
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}

.post-card:first-child {
  border-top: 1px solid var(--app-border);
}

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

.post-card-image { display: none; }

.post-card-content {
  flex: 1;
  min-width: 0;
}

.post-card-tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--app-accent);
  margin-bottom: 0.125rem;
}

.post-card-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--app-foreground);
  line-height: 1.3;
}

.post-card-title a { color: inherit; }

.post-card-excerpt {
  font-size: 0.8125rem;
  color: var(--app-muted);
  line-height: 1.4;
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-meta {
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--app-muted);
}

.post-card-author-avatar { display: none; }

/* ─── Single Post ─── */

.post-full {
  max-width: 720px;
  margin: 0 auto;
}

.post-full-header { margin-bottom: 2rem; }

.post-full-tag {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--app-accent);
  margin-bottom: 0.75rem;
}

.post-full-title {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.post-full-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  color: var(--app-muted);
}

.post-full-meta img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.post-full-image {
  width: 100%;
  border-radius: 0.75rem;
  margin-bottom: 2rem;
}

/* ─── Post Content ─── */

.post-content {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--app-foreground);
}

.post-content h1, .post-content h2, .post-content h3, .post-content h4 {
  font-weight: 600;
  margin: 2rem 0 1rem;
  line-height: 1.3;
}

.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.25rem; }
.post-content h4 { font-size: 1.125rem; }
.post-content p { margin-bottom: 1.25rem; }

.post-content blockquote {
  border-left: 3px solid var(--app-accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--app-muted);
  font-style: italic;
}

.post-content code {
  font-family: monospace;
  font-size: 0.875em;
  background: var(--app-input-bg);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
}

.post-content pre {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.post-content pre code { background: none; padding: 0; }

.post-content ul, .post-content ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.post-content li { margin-bottom: 0.5rem; }

.post-content img {
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--app-border);
  margin: 2rem 0;
}

.post-content a {
  color: var(--app-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content figcaption {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--app-muted);
  margin-top: 0.5rem;
}

/* Ghost Koenig editor width classes */
.post-content .kg-width-wide {
  margin-left: -4rem;
  margin-right: -4rem;
  max-width: calc(100% + 8rem);
}

.post-content .kg-width-full {
  margin-left: calc(-50vw + 50% + 30px);
  margin-right: calc(-50vw + 50% + 30px);
  max-width: none;
  width: calc(100vw - 60px);
}

@media (max-width: 768px) {
  .post-content .kg-width-wide {
    margin-left: -1rem;
    margin-right: -1rem;
    max-width: calc(100% + 2rem);
  }
}

/* Ghost content cards */
.post-content .kg-card { margin: 1.5rem 0; }
.post-content .kg-image-card img,
.post-content .kg-gallery-image img { border-radius: 0.5rem; }

.post-content .kg-bookmark-card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.post-content .kg-bookmark-container {
  display: flex;
  text-decoration: none;
  color: inherit;
}

.post-content .kg-bookmark-content { padding: 1rem; flex: 1; }

.post-content .kg-bookmark-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--app-foreground);
}

.post-content .kg-bookmark-description {
  font-size: 0.8125rem;
  color: var(--app-muted);
  margin-top: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-content .kg-bookmark-thumbnail img {
  width: 160px;
  height: 100%;
  object-fit: cover;
}

/* ─── Pagination ─── */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--app-border);
  font-size: 0.875rem;
}

.pagination a {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  color: var(--app-accent);
  font-weight: 500;
  border: 1px solid var(--app-border);
  transition: background 0.15s;
}

.pagination a:hover { background: var(--app-input-bg); opacity: 1; }

.pagination .page-number {
  color: var(--app-muted);
  font-size: 0.8125rem;
}

/* ─── Tag / Author headers ─── */

.tag-header { margin-bottom: 2rem; }
.tag-header h1 { font-size: 1.75rem; font-weight: 700; }
.tag-header p { color: var(--app-muted); font-size: 0.875rem; margin-top: 0.375rem; }

.author-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.author-header img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.author-header h1 { font-size: 1.5rem; font-weight: 700; }
.author-header p { color: var(--app-muted); font-size: 0.875rem; margin-top: 0.25rem; }


/* ─── Sidebar Avatar (logged-in state) ─── */

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar-avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-accent);
  color: var(--app-accent-foreground);
  font-size: 0.6875rem;
  font-weight: 600;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

/* ─── User Menu Popover ─── */

.user-menu {
  display: none;
  position: fixed;
  left: 68px;
  bottom: 100px;
  width: 220px;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  z-index: 400;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  overflow: hidden;
}

.user-menu.open {
  display: block;
}

.user-menu-header {
  padding: 0.875rem 1rem;
}

.user-menu-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-foreground);
}

.user-menu-email {
  font-size: 0.75rem;
  color: var(--app-muted);
  margin-top: 0.125rem;
}

.user-menu-divider {
  border-top: 1px solid var(--app-border);
}

.user-menu-item {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  color: var(--app-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.user-menu-item:hover {
  color: var(--app-foreground);
  background: var(--app-input-bg);
  opacity: 1;
}

.user-menu-logout:hover {
  color: var(--app-error, #f87171);
}

/* ─── Comments (Ghost native) ─── */

.post-comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--app-border);
}

/* ─── Mobile ─── */

@media (max-width: 768px) {
  .main-content { padding: 2rem 1rem; }
  .hero-title { font-size: 1.5rem; }
  .post-full-title { font-size: 1.5rem; }
  .post-row { gap: 0.625rem; }
  .post-row-tag { display: none; }
  .post-row-reading { display: none; }
}
