/* buidlers — canales
 *
 * Tokens are verbatim from buidlers-ai-standards
 * `ai-consultancy-research/deck/08-brand-direction-for-design.md`, which is the
 * authoritative brand spec. Two rules from it drive most of what follows:
 *
 *   1. Yellow is an ACCENT, not a fill — ≤20% of the surface, and never body text.
 *      It marks section numbers, the cursor, and the thing the eye must find first.
 *   2. "When in doubt, reduce the element until it looks like documentation."
 *      Hence: hairlines over cards, numbered sections, monospace metadata, no shadows.
 *
 * Never bare #000000 for the background; #0c0c0c is the token. Never #ffffff for text.
 */

:root {
  --bg: #0c0c0c;
  --surface: #1a1a1a;
  --border: #2f2f2f;
  --muted: #6a6a6a;
  --body: #f1f1f8;
  --accent: #f1e65d;
  --accent-press: #c9bf35;

  --ok: #7aa37a;
  --warn: #c9a94a;
  --down: #a35a5a;

  --font-display: 'Inter Tight', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 46rem;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
  --rule: 1px solid var(--border);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Atmosphere ───────────────────────────────────────────────────────────────
 * Two fixed layers behind everything: an engineering-paper grid and a grain wash.
 * Both are pure CSS/SVG — no image requests, nothing to 404 in an air-gapped pod.
 * The grid is what makes the page read as a spec sheet rather than a landing page.
 */

.grid-field,
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.grid-field {
  background-image:
    linear-gradient(to right, rgba(241, 230, 93, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(241, 230, 93, 0.035) 1px, transparent 1px);
  background-size: 4.5rem 4.5rem;
  /* Fade the grid out at the edges so it reads as texture, not as a table. */
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 78%);
}

.grain {
  opacity: 0.035;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Status bar ───────────────────────────────────────────────────────────────
 * A terminal statusline pinned to the top. Carries the honest freshness signal:
 * when the feed last synced, and whether the last sync actually worked.
 */

.statusbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem var(--gutter);
  border-bottom: var(--rule);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(12, 12, 12, 0.86);
  backdrop-filter: blur(8px);
}

/* Keeps the statusline to exactly one line. Measured at 320–1440px: without this the
 * status text simply WRAPS to a second row (it never overflowed the document), so this
 * is a deliberate look — a terminal statusline that grows taller is not one — not a
 * fix for a layout bug. min-width:0 + nowrap + ellipsis is what makes truncation,
 * rather than wrapping, the overflow behaviour. */
.statusbar__left {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.statusbar__left > [data-status-text] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusbar__right {
  flex: none;
}

.dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 currentColor;
}

.dot[data-state='ok'] {
  background: var(--ok);
}
.dot[data-state='stale'] {
  background: var(--warn);
}
.dot[data-state='down'] {
  background: var(--down);
}

/* ── Shell ────────────────────────────────────────────────────────────────── */

.shell {
  position: relative;
  z-index: 1;
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 12vh, 6rem) var(--gutter) 4rem;
}

/* ── Masthead ─────────────────────────────────────────────────────────────── */

.masthead {
  padding-bottom: clamp(2.5rem, 7vh, 4rem);
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(3.25rem, 13vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.035em;
  color: var(--body);
}

/* The cursor block is the brand's own device (`buidlers|`) and it is the single
 * loudest yellow moment on the page — which is exactly the accent rule's intent. */
.cursor {
  display: inline-block;
  /* Sized to a terminal caret, not a slab: roughly one stroke-width wide and
   * cap-height tall. Wider than ~0.3em and it stops reading as a cursor. */
  width: 0.22em;
  height: 0.72em;
  margin-left: 0.1em;
  vertical-align: baseline;
  background: var(--accent);
  animation: blink 1.15s steps(1, end) infinite;
}

.cursor--sm {
  width: 0.36em;
  height: 0.85em;
  margin-left: 0.08em;
  vertical-align: -0.06em;
}

@keyframes blink {
  0%,
  48% {
    opacity: 1;
  }
  49%,
  100% {
    opacity: 0;
  }
}

.tagline {
  max-width: 34rem;
  margin: 1.75rem 0 0;
  font-size: clamp(1rem, 2.4vw, 1.125rem);
  line-height: 1.5;
  color: var(--body);
  text-wrap: balance;
}

.tagline--sub {
  margin-top: 0.35rem;
  color: var(--muted);
}

/* ── Channel section ──────────────────────────────────────────────────────────
 * Each channel is a numbered spec-sheet entry: hairline rule, `[01]` index in
 * mono yellow, the profile link as the row's primary target, posts stacked below.
 */

.channel {
  border-top: var(--rule);
  padding-top: 1.5rem;
  margin-bottom: 3.25rem;
}

.channel__head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
  padding-bottom: 1.25rem;
}

.channel__index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.05em;
  flex: none;
}

.channel__id {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

/* Muted by default so the row reads "mark, then name" rather than as a stutter —
 * which is exactly what `𝕏` + the label "X" looks like when both are body-coloured
 * at the same weight. LinkedIn does not have this problem; X does, and one rule
 * fixes it for both without special-casing a channel. */
.channel__icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
  fill: currentColor;
  color: var(--muted);
  transition: color 0.25s ease;
}

.channel__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.375rem;
  letter-spacing: -0.015em;
  line-height: 1;
}

.channel__handle {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted);
  margin-left: auto;
  padding-left: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.channel__arrow {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--muted);
  flex: none;
  transition:
    transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1),
    color 0.25s ease;
}

.channel__head:hover .channel__handle,
.channel__head:focus-visible .channel__handle,
.channel__head:hover .channel__arrow,
.channel__head:focus-visible .channel__arrow,
.channel__head:hover .channel__icon,
.channel__head:focus-visible .channel__icon {
  color: var(--accent);
}

.channel__head:hover .channel__arrow,
.channel__head:focus-visible .channel__arrow {
  transform: translateX(0.35rem);
}

/* ── Posts ────────────────────────────────────────────────────────────────────
 * A post is a row with a hairline left edge that lights up on hover — the
 * cheapest possible affordance, and the one that keeps the page documentation-like.
 */

.posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.post {
  position: relative;
}

.post__link {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: var(--rule);
  border-left: 2px solid var(--border);
  transition:
    border-left-color 0.22s ease,
    border-color 0.22s ease,
    background-color 0.22s ease,
    transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.post__link:hover,
.post__link:focus-visible {
  border-left-color: var(--accent);
  border-color: #3a3a3a;
  background: #1e1e1e;
  transform: translateX(2px);
}

.post__meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.post__text {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--body);
  /* Clamp so one long post cannot dominate the column; the permalink has the rest. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.post__metrics {
  display: flex;
  gap: 1.1rem;
  margin-top: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.post__metric {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.post__metric svg {
  width: 0.75rem;
  height: 0.75rem;
  fill: currentColor;
  opacity: 0.7;
}

/* ── Non-ok states ────────────────────────────────────────────────────────────
 * An empty card and a broken card must never look the same. Both render as a
 * documentation-style note; only the left edge colour differs.
 */

.note {
  padding: 0.9rem 1.15rem;
  border: var(--rule);
  border-left: 2px solid var(--muted);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.note[data-kind='error'] {
  border-left-color: var(--down);
}

.note[data-kind='unconfigured'] {
  border-left-color: var(--warn);
}

.note__label {
  color: var(--body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 0.5rem;
}

/* Skeleton rows shown between first paint and the /api/feeds response. */
.skeleton {
  height: 4.75rem;
  border: var(--rule);
  border-left: 2px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 0%, #212121 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: sweep 1.4s ease-in-out infinite;
}

@keyframes sweep {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ── Colophon ─────────────────────────────────────────────────────────────── */

.colophon {
  border-top: var(--rule);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.colophon__link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}

.colophon__link:hover,
.colophon__link:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent-press);
}

.colophon__sep {
  opacity: 0.5;
}

/* ── Focus ────────────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── Entrance ─────────────────────────────────────────────────────────────────
 * One orchestrated load: the masthead, then each channel, staggered. Delays live
 * in CSS (not inline style attributes) so the page needs no `unsafe-inline` CSP.
 */

.masthead,
.channel,
.colophon {
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}

.masthead {
  animation-delay: 0.05s;
}
.channel:nth-of-type(1) {
  animation-delay: 0.18s;
}
.channel:nth-of-type(2) {
  animation-delay: 0.28s;
}
.channel:nth-of-type(3) {
  animation-delay: 0.38s;
}
.colophon {
  animation-delay: 0.46s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* The cursor must not be left mid-blink on opacity:0 by the override above. */
  .cursor {
    opacity: 1;
  }
}

@media (max-width: 32rem) {
  .channel__handle {
    display: none;
  }
}
