/* Project cards. Tokens from styles.css, each with a fallback. */

.project-list {
  --pj-bg: var(--bg, #0d1014);
  --pj-bg-2: var(--bg-2, #141920);
  --pj-surface: var(--surface, #181e26);
  --pj-line: var(--line, #29313c);
  --pj-text: var(--text, #e6ebf0);
  --pj-muted: var(--text-muted, #9aa6b2);
  --pj-mint: var(--mint, #7fe0c0);
  --pj-mint-ink: var(--mint-ink, #7fe0c0);
  --pj-focus: var(--focus, #ffffff);
  --pj-slate: #6b7a90;
  --pj-slate-hi: #8795a9;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-5, 1.5rem);
  container-type: inline-size;
  container-name: projects;
}

/* ---- card ---- */
.project-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  margin: 0;
  background: var(--pj-surface);
  border: 1px solid var(--pj-line);
  border-radius: var(--radius, 14px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
  overflow: hidden;
}
.project-card:focus-within { border-color: rgb(127 224 192 / 0.6); }

/* ---- art ---- */
.project-art {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 13rem;
  padding: var(--s-4, 1rem);
  background:
    radial-gradient(ellipse 70% 65% at 50% 45%, rgb(127 224 192 / 0.08), transparent 72%),
    var(--pj-bg-2);
  border-bottom: 1px solid var(--pj-line);
}
.project-art svg { display: block; width: 100%; height: auto; max-height: 15rem; }

/* ---- body ---- */
.project-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3, 0.75rem);
  min-width: 0;
  padding: clamp(1.25rem, 4cqi, 2.25rem);
}
.project-meta {
  margin: 0;
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pj-mint-ink);
  font-variant-numeric: tabular-nums;
}
.project-title {
  margin: 0;
  font-family: var(--font-display, system-ui, "Segoe UI", sans-serif);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--pj-text);
  text-wrap: balance;
}
.project-summary { margin: 0; font-size: 1.0625rem; line-height: 1.55; color: var(--pj-text); max-width: 38rem; }

.project-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; max-width: 38rem; }
.project-points li {
  position: relative;
  padding-left: 1.25rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--pj-muted);
}
.project-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.78em;
  width: 0.7rem;
  height: 1px;
  background: var(--pj-mint);
}
.project-body .tag-list { margin: var(--s-1, 0.25rem) 0 0; }

.project-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: var(--s-2, 0.5rem);
  padding: 0 0.1rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--pj-mint-ink);
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 calc(50% + 0.85em) / 100% 1px no-repeat;
}
.project-link:hover { color: var(--pj-text); }
.project-link:focus-visible { outline: 3px solid var(--pj-focus); outline-offset: 3px; border-radius: 3px; }

/* ---- side card (smaller) ---- */
.project-card--side .project-art { min-height: 9.5rem; padding: var(--s-3, 0.75rem); }
.project-card--side .project-art svg { max-height: 10rem; }
.project-card--side .project-body { padding: clamp(1.1rem, 3cqi, 1.5rem); gap: var(--s-2, 0.5rem); }
.project-card--side .project-title { font-size: clamp(1.25rem, 1rem + 1vw, 1.5rem); }
.project-card--side .project-summary { font-size: 1rem; }

/* ---- wide: art beside the body, alternating ---- */
@container projects (min-width: 44rem) {
  .project-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  .project-art { min-height: 100%; padding: var(--s-5, 1.5rem); border-bottom: 0; border-right: 1px solid var(--pj-line); }
  .project-card:nth-child(even):not(.project-card--side) .project-art { order: 2; border-right: 0; border-left: 1px solid var(--pj-line); }
  .project-card--side { grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); }
  .project-card--side .project-art { padding: var(--s-3, 0.75rem); }
}

/* ---- hover: border brightens and lifts 2px (pointer devices, motion allowed) ---- */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .project-card { transition: transform 200ms var(--ease, ease), border-color 200ms var(--ease, ease); }
  .project-card:hover { transform: translateY(-2px); border-color: rgb(127 224 192 / 0.5); }
  .project-link { transition: color 160ms ease; }
}

/* ---- art drawing ---- */
.project-art svg .draw { stroke-dasharray: 1; stroke-dashoffset: 0; }

.art-area { fill: var(--pj-text); fill-opacity: 0.05; stroke: none; }
.art-guide { fill: none; stroke: var(--pj-text); stroke-opacity: 0.12; stroke-width: 1; stroke-dasharray: 2 5; }
.art-axis { fill: none; stroke: var(--pj-text); stroke-opacity: 0.1; stroke-width: 1; }
.art-price { fill: none; stroke: var(--pj-text); stroke-opacity: 0.75; stroke-width: 1.6; stroke-linejoin: round; }
.art-slow { fill: none; stroke: var(--pj-slate-hi); stroke-width: 1.8; stroke-linejoin: round; }
.art-fast { fill: none; stroke: var(--pj-mint); stroke-width: 2; stroke-linejoin: round; }
.art-rsi { fill: none; stroke: var(--pj-slate-hi); stroke-width: 1.5; stroke-linejoin: round; }

.art-node rect { fill: var(--pj-bg); stroke: var(--pj-text); stroke-opacity: 0.35; stroke-width: 1.2; }
.art-node text { fill: var(--pj-text); font-family: var(--font-body, system-ui, "Segoe UI", sans-serif); font-size: 15px; font-weight: 600; }
.art-node.is-end rect { stroke: var(--pj-mint); stroke-opacity: 1; }
.art-link, .art-head { fill: none; stroke: var(--pj-mint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.ra-tile { fill: #1a212a; stroke: var(--pj-text); stroke-opacity: 0.12; stroke-width: 0.75; stroke-linejoin: round; }
.ra-cube polygon { stroke: var(--pj-text); stroke-opacity: 0.4; stroke-width: 0.9; stroke-linejoin: round; }
.ra-block .ra-t { fill: var(--pj-slate-hi); }
.ra-block .ra-l { fill: var(--pj-slate); }
.ra-block .ra-r { fill: #4d5a6d; }
.ra-plate .ra-t { fill: var(--pj-mint); }
.ra-plate .ra-l { fill: #2c6b5a; }
.ra-plate .ra-r { fill: #235547; }
.ra-ped .ra-t { fill: #3d495a; }
.ra-ped .ra-l { fill: #2c3541; }
.ra-ped .ra-r { fill: #232b35; }
.ra-wire { fill: none; stroke: var(--pj-mint); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.ra-bulb { fill: var(--pj-mint); stroke: var(--pj-mint); }

/* Draw-in: only when JS marked the art pending (never under reduced motion). */
@media (prefers-reduced-motion: no-preference) {
  .project-art[data-state="pending"] .draw { stroke-dashoffset: 1; }
  .project-art[data-state="pending"] .fade { opacity: 0; }
  .project-art[data-state="drawn"] .draw {
    transition: stroke-dashoffset 1.1s var(--ease, ease) calc(var(--i, 0) * 110ms);
  }
  .project-art[data-state="drawn"] .fade {
    transition: opacity 600ms var(--ease, ease) calc(var(--i, 0) * 110ms);
  }
}
