/* ============================================================
   jjw.sh — featured work panels and /work/<slug>/ pages
   Loaded after /styles.css. Visual modules draw with the same
   CSS variables so the dark palette carries through.
   ============================================================ */

/* ---------- homepage panels ---------- */

.work-grid {
  display: grid;
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.work-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem 1.4rem;
  padding: 1.1rem 1.2rem 1.15rem;
  border: 1px solid color-mix(in srgb, var(--accent-2) 28%, var(--border));
  border-radius: 4px;
  background: var(--bg-raised);
}

@media (min-width: 760px) {
  .work-panel {
    grid-template-columns: minmax(0, 3fr) minmax(220px, 2fr);
    align-items: start;
  }
  .work-panel .work-visual { grid-row: 1 / span 2; }
}

.work-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.work-title {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
}
.work-title a { color: inherit; }
.work-title a:hover { text-decoration: none; color: var(--text); }

.work-contribution {
  margin: 0 0 0.75rem;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

.work-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}
.work-stats li { font-size: 0.8rem; color: var(--text-dim); }
.work-stats strong { display: block; color: var(--text); font-weight: 600; font-size: 1.05rem; }

.work-links { font-size: 0.82rem; }
.work-links a { margin-right: 0.75rem; }

/* ---------- the visual host ---------- */

.work-visual {
  position: relative;
  min-width: 0;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
}
.work-visual[data-state="loading"]::after {
  content: "loading…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.work-visual > svg,
.work-visual > canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.work-visual-desc {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.work-visual-controls {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  gap: 0.35rem;
}
.work-visual-controls button,
.work-visual button {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  color: var(--text-dim);
  cursor: pointer;
}
.work-visual button:hover,
.work-visual button[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.work-visual button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.work-fallback { margin: 0; padding: 1rem; font-size: 0.85rem; }

/* ---------- /work/<slug>/ pages ---------- */

.work-page main {
  max-width: 860px;
  margin: 0 auto;
  padding: 6.5rem 1.25rem 3rem;
}
.work-page .work-visual { aspect-ratio: 16 / 9; margin: 1.75rem 0; }
.work-page h1 {
  margin: 0.4rem 0 1rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.work-page .work-contribution { max-width: 65ch; font-size: 1rem; }
.work-captions {
  display: grid;
  gap: 1.1rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
  counter-reset: caption;
}
.work-captions li {
  max-width: 65ch;
  padding-left: 2.2rem;
  position: relative;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  line-height: 1.65;
}
.work-captions li::before {
  counter-increment: caption;
  content: counter(caption, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.15rem;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
}
.work-provenance { font-size: 0.78rem; color: var(--text-dim); }

/* Modules may set host.dataset.layout = "stacked" when the host is under ~480px wide
   and needs vertical room (any viewport); clear it again when wider. */
.work-visual[data-layout="stacked"],
.work-page .work-visual[data-layout="stacked"] { aspect-ratio: auto; min-height: 520px; }

@media (max-width: 640px) {
  .work-page main { padding-top: 5.5rem; }
  .work-visual,
  .work-page .work-visual { aspect-ratio: auto; min-height: 320px; }
  .work-visual[data-layout="stacked"],
  .work-page .work-visual[data-layout="stacked"] { min-height: 520px; }
}
