/* =========================================================
   Posts module — minimal, icon-led layout (V1 pass B)
   - pixel icon is the only visual anchor; everything else neutral
   - GRID / LIST view toggle preserved
   ========================================================= */

/* ---------- Window header: matches the terminal header grammar ----------
   left = identity ( ~/posts ),  right = SORT via the three Bauhaus shapes  */
.posts-section .window {
  background: rgba(255, 255, 255, 0.8);
}

.win-path {
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
body.dark .win-path { color: var(--text-dark); }

/* Sort control — three Bauhaus primitives.
   Kandinsky's colour–shape theory: circle=blue, square=red, triangle=yellow.
   Inactive = neutral outline; active = filled with its colour. */
.win-sort {
  display: flex;
  align-items: center;
  gap: 11px;
}
.win-sort-label {
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-secondary);
  opacity: 0.7;
  margin-right: 0.15rem;
  user-select: none;
}

.win-shape {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: block;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.win-shape:hover { opacity: 0.9; transform: scale(1.15); }
.win-shape.active { opacity: 1; }

/* Circle — outline neutral → filled blue when active */
.win-circle {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-secondary);
}
.win-circle.active {
  border-color: var(--bauhaus-blue);
  background: var(--bauhaus-blue);
}

/* Square — outline neutral → filled red when active */
.win-square {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--accent-secondary);
}
.win-square.active {
  border-color: var(--orange);
  background: var(--orange);
}

/* Triangle — outline neutral → filled yellow when active */
.win-triangle {
  width: 0;
  height: 0;
  position: relative;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid var(--accent-secondary);
}
.win-triangle::after {
  content: '';
  position: absolute;
  left: -3.5px;
  top: 3.5px;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 6.5px solid var(--bg-light);
}
body.dark .win-triangle::after { border-bottom-color: var(--bg-dark); }
.win-triangle.active {
  border-bottom-color: var(--bauhaus-yellow);
}
.win-triangle.active::after { display: none; }


/* ---------- Toolbar: filter + view switch ---------- */
.posts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
body.dark .posts-toolbar { border-bottom-color: var(--border-dark); }

.posts-toolbar .filters {
  padding: 0;
  border-bottom: none;
  flex-wrap: wrap;
  gap: 1.5rem;
}

/* ---------- Category filters — editorial text tabs ----------
   lowercase mono tokens; active = darkened text + 2px underline (neutral) */
.posts-toolbar .filter-btn {
  padding: 0 0 0.4rem !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  color: var(--accent-secondary);
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: none;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.posts-toolbar .filter-btn:hover { color: var(--text-light); }
body.dark .posts-toolbar .filter-btn:hover { color: var(--text-dark); }

.posts-toolbar .filter-btn.active {
  color: var(--text-light);
  border-bottom-color: var(--text-light) !important;
}
body.dark .posts-toolbar .filter-btn.active {
  color: var(--text-dark);
  border-bottom-color: var(--text-dark) !important;
}

/* ---------- GRID / LIST switch — one square, two subdivisions ----------
   grid = quartered square (4 cells) · list = square split into 3 rows.
   Frameless; active = full ink, inactive = muted. */
.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.view-switch button {
  background: transparent;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--accent-secondary);
  opacity: 0.55;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.view-switch button:hover { opacity: 1; color: var(--text-light); }
body.dark .view-switch button:hover { opacity: 1; color: var(--text-dark); }

.view-switch button.active { opacity: 1; color: var(--text-light); }
body.dark .view-switch button.active { color: var(--text-dark); }

/* GRID icon — a square quartered by a cross (4 panes) */
.ic-grid {
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 1px solid currentColor;
  position: relative;
}
.ic-grid::before {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: currentColor;
  transform: translateX(-50%);
}
.ic-grid::after {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: currentColor;
  transform: translateY(-50%);
}

/* LIST icon — the same square split into three horizontal rows */
.ic-list {
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 1px solid currentColor;
  position: relative;
}
.ic-list::before {
  content: '';
  position: absolute;
  top: 33.3%; left: 0; right: 0;
  height: 1px;
  background: currentColor;
  transform: translateY(-50%);
}
.ic-list::after {
  content: '';
  position: absolute;
  top: 66.6%; left: 0; right: 0;
  height: 1px;
  background: currentColor;
  transform: translateY(-50%);
}

/* Active view fills ONE module — terminal orange (--orange / --term-accent) */
.view-switch button.active .ic-grid {
  background-image: linear-gradient(var(--orange), var(--orange));
  background-size: 50% 50%;
  background-position: 0% 0%;
  background-repeat: no-repeat;
}
.view-switch button.active .ic-list {
  background-image: linear-gradient(var(--orange), var(--orange));
  background-size: 100% 33.3%;
  background-position: 0% 0%;
  background-repeat: no-repeat;
}

/* Click = one uniform slot-machine cycle of the filled module,
   landing back on the first cell. step-end = discrete jumps. */
.view-switch button.spin .ic-grid { animation: vs-spin-grid 0.6s step-end; }
.view-switch button.spin .ic-list { animation: vs-spin-list 0.45s step-end; }
@keyframes vs-spin-grid {
  0%   { background-position: 0% 0%; }
  25%  { background-position: 100% 0%; }
  50%  { background-position: 100% 100%; }
  75%  { background-position: 0% 100%; }
  100% { background-position: 0% 0%; }
}
@keyframes vs-spin-list {
  0%    { background-position: 0% 0%; }
  33.3% { background-position: 0% 50%; }
  66.6% { background-position: 0% 100%; }
  100%  { background-position: 0% 0%; }
}

/* =========================================================
   Posts grid — overrides home.css cards. Icon-led, neutral.
   ========================================================= */
.posts-grid {
  padding: 2rem 1.5rem 2.25rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.75rem;
  border-top: 0;
}

@media (max-width: 1100px) { .posts-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .posts-grid { grid-template-columns: 1fr; } }

a.post-card {
  background: transparent !important;
  border: 1px solid var(--border-light) !important;
  border-radius: 0 !important;
  padding: 1.5rem 1.4rem 1.6rem;
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0.75rem;
  min-height: 200px;
  box-shadow: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
}
body.dark a.post-card {
  border-color: var(--border-dark) !important;
}

a.post-card:hover {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: rgba(0, 0, 0, 0.18) !important;
}
body.dark a.post-card:hover {
  background: rgba(255, 255, 255, 0.025) !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
}

/* The pixel icon — restored, top-anchored */
.post-card .post-icon {
  display: block !important;
  width: 40px;
  height: 40px;
  margin: 0 0 0.25rem;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  opacity: 0.9;
}

.post-card .post-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.post-card .post-title {
  font-family: 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  margin: 0;
  color: var(--text-light);
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
body.dark .post-card .post-title { color: var(--text-dark); }
a.post-card:hover .post-title { color: var(--text-light); }
body.dark a.post-card:hover .post-title { color: var(--text-dark); }

.post-card .post-meta {
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.5;
  margin: 0;
}

.post-card .post-excerpt {
  font-size: 0.82rem;
  line-height: 1.65;
  opacity: 0.78;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card .post-tags {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.post-card .tag {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 0;
  padding: 0.15rem 0.5rem;
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  color: var(--accent-secondary);
}
body.dark .post-card .tag { border-color: var(--border-dark); }

/* =========================================================
   Pager — window footer bar. Same grammar as the toolbar:
   mono tokens, hairline top rule; left = range readout,
   right = ‹ prev · page numbers · next ›. Active page gets
   the terminal-orange underline (same accent as view switch).
   ========================================================= */
.posts-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem 1.2rem;
  border-top: 1px solid var(--border-light);
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
}
body.dark .posts-pager { border-top-color: var(--border-dark); }

.pager-range {
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-secondary);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.pager-nav { display: flex; align-items: center; gap: 1.4rem; }
.pager-nums { display: flex; gap: 1rem; }

.posts-pager button {
  background: transparent;
  border: none;
  padding: 0 0 0.35rem;
  cursor: pointer;
  font-family: 'DM Mono', 'IBM Plex Mono', 'Noto Sans SC', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent-secondary);
  border-bottom: 2px solid transparent;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.posts-pager button:hover { color: var(--text-light); }
body.dark .posts-pager button:hover { color: var(--text-dark); }

.pager-num.active {
  color: var(--text-light);
  border-bottom-color: var(--orange);
  cursor: default;
}
body.dark .pager-num.active { color: var(--text-dark); }

.pager-arrow:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

@media (max-width: 640px) {
  .posts-pager { flex-direction: column-reverse; gap: 0.9rem; }
}

/* =========================================================
   LIST view — single column rows, icon · title · excerpt · tags
   ========================================================= */
.posts-grid.view-list {
  grid-template-columns: 1fr;
  padding: 0.5rem 1.5rem 1.5rem;
  gap: 0;
}

.posts-grid.view-list a.post-card {
  display: grid;
  grid-template-columns: 32px minmax(180px, 1.1fr) minmax(220px, 1.6fr) auto;
  grid-template-rows: auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 0.5rem;
  min-height: 0;
  border: none !important;
  border-bottom: 1px solid var(--border-light) !important;
}
body.dark .posts-grid.view-list a.post-card {
  border-bottom-color: var(--border-dark) !important;
}
.posts-grid.view-list a.post-card:last-child {
  border-bottom: none !important;
}
.posts-grid.view-list a.post-card:hover {
  background: rgba(0, 0, 0, 0.02) !important;
  border-bottom-color: rgba(0, 0, 0, 0.18) !important;
}
body.dark .posts-grid.view-list a.post-card:hover {
  background: rgba(255, 255, 255, 0.025) !important;
  border-bottom-color: rgba(255, 255, 255, 0.22) !important;
}

.posts-grid.view-list .post-card .post-icon {
  width: 28px;
  height: 28px;
  margin: 0;
}

.posts-grid.view-list .post-card .post-title {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.posts-grid.view-list .post-card .post-meta {
  font-size: 0.62rem;
  opacity: 0.45;
}

.posts-grid.view-list .post-card .post-excerpt {
  font-size: 0.78rem;
  -webkit-line-clamp: 1;
  opacity: 0.65;
  margin: 0;
}

.posts-grid.view-list .post-card .post-tags {
  justify-content: flex-end;
  flex-wrap: nowrap;
  max-width: 240px;
  overflow: hidden;
}
.posts-grid.view-list .post-card .post-tags .tag { flex-shrink: 0; }

@media (max-width: 900px) {
  .posts-grid.view-list a.post-card {
    grid-template-columns: 28px 1fr;
    grid-template-rows: auto auto;
    gap: 0.4rem 1rem;
  }
  .posts-grid.view-list .post-card .post-excerpt { display: none; }
  .posts-grid.view-list .post-card .post-tags {
    grid-column: 1 / -1;
    padding-left: 44px;
    justify-content: flex-start;
  }
}
