/* Hub landing page: bento grid and tile visuals. */
.bento {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: auto;
  grid-auto-flow: dense; gap: var(--gap); padding: 24px 0 40px;
}
.tile {
  position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 200px;
  padding: 20px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-tile);
  transition: border-color 0.2s;
}
.tile:hover { border-color: var(--border-strong); }
/* Cursor spotlight, shared by every tile */
.tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s;
  background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 65%);
}
.tile:hover::after { opacity: 1; }
.t-hero { grid-column: span 2; grid-row: span 2; padding: 28px; }
.t-xref, .t-retail, .t-projects { grid-column: span 2; }
.t-notes .badge { position: relative; z-index: 2; }
.list small { font-size: 12px; color: var(--faint); }
.t-stack { grid-column: span 4; min-height: 0; flex-direction: row; align-items: center; gap: 20px; }
.t-stack .marquee { flex: 1; min-width: 0; margin-top: 0; }
.t-projects, .t-notes, .t-links { min-height: 0; }
.t-projects .badge { position: relative; z-index: 2; }
.proj-list a { justify-content: flex-start; gap: 12px; }
.proj-list a > span { display: grid; flex: 1; min-width: 0; }
.proj-list b { font-weight: 500; transition: color 0.15s; }
.proj-list small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-list a:hover b { color: var(--accent); }
.list.proj-list a:hover span { color: inherit; }
.list.proj-list .app-logo { width: 32px; height: 32px; color: var(--text); }

.tile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tile h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.tile p { margin: 2px 0 0; color: var(--muted); font-size: 14px; max-width: 46ch; }

/* Hero */
.t-hero { justify-content: center; }
.t-hero h1 {
  margin: 0; max-width: 15ch;
  font-size: clamp(2.1rem, 1.2rem + 3.4vw, 3.5rem); line-height: 1.03; font-weight: 600; letter-spacing: -0.04em;
}
.t-hero .lede { margin: 16px 0 0; font-size: 16px; max-width: 44ch; }
.t-hero .foot { padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }

/* XrefCodes mini search */
.mock { border: 1px solid var(--border); border-radius: var(--r-inner); background: var(--bg-2); padding: 10px; margin-top: auto; }
.search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-family: var(--font-mono); font-size: 13px; }
.search svg { width: 14px; height: 14px; color: var(--faint); flex: none; }
.caret { display: inline-block; width: 1px; height: 1.05em; margin-left: 1px; background: var(--text); vertical-align: -2px; }
.results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.results li { display: flex; gap: 12px; align-items: baseline; padding: 6px 8px; border-radius: 6px; font-size: 13px; min-width: 0; }
.results li:first-child { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.results code { color: var(--accent); flex: none; min-width: 64px; }
.results span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Retail bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 72px; margin-top: auto; }
.bars i { flex: 1; height: 100%; border-radius: 5px 5px 2px 2px; background: var(--border-strong); transform-origin: bottom; transform: scaleY(var(--h)); }
.bars i:last-child { background: var(--accent); }

/* Link lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; transition: color 0.15s; }
.list li:first-child a { border-top: 0; }
.list a:hover span { color: var(--accent); }
.list svg { width: 14px; height: 14px; color: var(--faint); flex: none; }

/* Stack marquee */
.marquee { overflow: hidden; margin-top: auto; -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.track { display: flex; gap: 8px; width: max-content; }
.chipset { display: flex; gap: 8px; }
.chipset[aria-hidden="true"] { display: none; }
.tech { font-size: 13px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg-2); color: var(--muted); white-space: nowrap; }

/* Projects: one block per app below the bento, copy beside a small demo */
.projects { padding: 40px 0 8px; }
.projects-page { padding-top: 48px; }
.section-head { max-width: 620px; margin-bottom: 8px; }
.section-head h1, .section-head h2 { margin: 0; font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.4rem); line-height: 1.08; font-weight: 600; letter-spacing: -0.035em; }
.section-head p { margin: 12px 0 0; font-size: 16px; color: var(--muted); }

.project {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(24px, 4vw, 56px); align-items: center;
  padding: 48px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 64px;
}
.project:last-child { border-bottom: 0; }
.project.flip .project-visual { order: -1; }
.project h3 { margin: 0 0 6px; font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.project-lede { margin: 20px 0 0; font-size: 17px; line-height: 1.55; max-width: 52ch; }
.features { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 12px; }
.features li { position: relative; padding-left: 22px; font-size: 14.5px; color: var(--muted); max-width: 58ch; }
.features li::before { content: ""; position: absolute; left: 1px; top: 0.5em; width: 8px; height: 8px; border: 1.5px solid var(--accent); border-radius: 2px; }
.features strong { font-weight: 500; color: var(--text); }
.note { display: flex; gap: 8px; align-items: flex-start; margin: 20px 0 0; font-size: 13px; color: var(--faint); max-width: 58ch; }
.note svg { width: 14px; height: 14px; flex: none; margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.chips .tech { font-size: 12px; padding: 4px 10px; }

.project-visual {
  padding: 20px; border: 1px solid var(--border); border-radius: var(--r-tile);
  background: var(--bg-2) radial-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 16px 16px;
}
.visual-label { margin: 0 0 14px; font-family: var(--font-mono); font-size: 12px; color: var(--faint); }

/* XrefCodes: how it works, steps run in order */
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.flow li {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-inner);
  transition: border-color 0.3s;
}
.flow li + li::before { content: ""; position: absolute; left: 17px; top: -9px; height: 8px; border-left: 1px dashed var(--border-strong); }
.flow li div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; flex: 1; min-width: 0; }
.flow b { font-size: 14px; font-weight: 500; }
.flow span:not(.step-dot) { font-size: 12.5px; color: var(--muted); }
.flow code { color: var(--accent); }
.step-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; border: 1.5px solid var(--border-strong); transition: background 0.3s, border-color 0.3s, box-shadow 0.3s; }
.flow li.run { border-color: var(--accent); }
.flow li.run .step-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--run-bg); }
.flow li.done .step-dot { background: var(--ok); border-color: var(--ok); }
.sql {
  margin: 12px 0 0; padding: 12px 14px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-inner);
  font-size: 12.5px; line-height: 1.65; color: var(--muted); opacity: 0.45; transition: opacity 0.4s;
}
.sql.on { opacity: 1; }
.sql .k { color: var(--text); font-weight: 500; }
.sql .s { color: var(--accent); }

/* Retail: a stock ledger that documents move */
.ledger { padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-inner); }
.ledger-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.ledger-head div { display: grid; }
.ledger-head span { font-size: 12.5px; color: var(--muted); }
.ledger-head b { font-weight: 500; }
.ledger-qty { text-align: right; }
.ledger-qty b { font-family: var(--font-mono); font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.meter { height: 6px; margin: 12px 0 6px; border-radius: var(--r-pill); background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.meter i { display: block; height: 100%; width: calc(var(--v) * 100%); border-radius: inherit; background: var(--accent); transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.ledger-rows { list-style: none; margin: 0; padding: 0; }
.ledger-rows li { display: flex; align-items: baseline; gap: 12px; padding: 9px 0 0; margin-top: 9px; border-top: 1px solid var(--border); font-size: 13px; min-width: 0; }
.ledger-rows code { flex: none; min-width: 64px; color: var(--muted); }
.ledger-rows span { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger-rows em { flex: none; font-style: normal; font-family: var(--font-mono); color: var(--faint); }
.ledger-rows em.in { color: var(--ok); }
.ledger-rows em.out { color: var(--text); }

/* Closing call to action */
.cta { min-height: 0; margin: 24px 0 56px; padding: 32px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 32px; }
.cta h2 { font-size: clamp(1.35rem, 1rem + 1.1vw, 1.7rem); line-height: 1.15; letter-spacing: -0.03em; }
.cta p { margin-top: 6px; font-size: 15px; }
.cta .actions { margin-top: 0; }

/* Responsive */
@media (max-width: 980px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .t-hero { grid-column: span 2; grid-row: auto; }
  .t-stack { grid-column: span 2; }
}
@media (max-width: 860px) {
  .project { grid-template-columns: minmax(0, 1fr); padding: 36px 0; }
  .project.flip .project-visual { order: 0; }
}
@media (max-width: 560px) {
  .bento { grid-template-columns: 1fr; }
  .bento > .tile { grid-column: auto; grid-row: auto; }
  .t-hero { padding: 22px; }
  .t-stack { flex-direction: column; align-items: stretch; }
  .project-visual { padding: 14px; }
  .cta { padding: 22px; }
}

/* Motion: everything below is skipped for reduced-motion users */
@media (prefers-reduced-motion: no-preference) {
  /* Tiles settle in once on load */
  .tile { animation: enter 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
  @keyframes enter { from { opacity: 0; transform: translateY(10px); } }

  .caret { animation: blink 1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }

  .results li { transition: opacity 0.35s, transform 0.35s; }
  .results:not(.show) li { opacity: 0; transform: translateY(4px); }
  .results li:nth-child(2) { transition-delay: 0.08s; }
  .results li:nth-child(3) { transition-delay: 0.16s; }

  .bars i { animation: bar 3.4s ease-in-out infinite; animation-delay: calc(var(--d) * 0.22s); }
  @keyframes bar { 50% { transform: scaleY(calc(var(--h) * 0.55 + 0.3)); } }

  /* Projects fade up once as they scroll in (hub.js adds .reveal-on, then .in) */
  .reveal { transition: opacity 0.7s, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .reveal-on .reveal:not(.in) { opacity: 0; transform: translateY(16px); }

  .ledger-rows li { transition: opacity 0.35s, transform 0.35s; }
  .ledger-rows li:not(.show) { opacity: 0; transform: translateY(4px); }

  .track { animation: scroll 28s linear infinite; }
  .chipset[aria-hidden="true"] { display: flex; }
  .marquee:hover .track { animation-play-state: paused; }
  @keyframes scroll { to { transform: translateX(calc(-50% - 4px)); } }
}
@media (prefers-reduced-motion: reduce) {
  .marquee { -webkit-mask-image: none; mask-image: none; }
  .chipset { flex-wrap: wrap; }
  .track { width: auto; }
}
