/* css/hub.css — the Projects index (project cards) and each project's hub page:
   a tab per resource (demo, pitch, film, app, code), a preview stage that shows
   a screenshot and swaps in the live page on request (js/hub.js), and the
   write-up underneath. Layered on styles.css and css/notes.css. */

/* --- shared page width: hubs and the index run wide, the write-up stays narrow --- */
.hub-page .container {
  max-width: var(--container);
}

.hub-body {
  max-width: 44rem;
  margin-top: 3.5rem;
}

/* --- project cards (projects/index.html) --- */
.pgroup {
  margin-top: 3.5rem;
}

.pgroup:first-of-type {
  margin-top: 0;
}

.pgroup > .sub {
  margin: 0 0 1.25rem;
}

.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pcard {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  transition: border-color var(--dur-quick) var(--ease-out), transform var(--dur-quick) var(--ease-out);
}

.pcard:hover,
.pcard:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

@media (prefers-reduced-motion: no-preference) {
  .pcard:hover {
    transform: translateY(-2px);
  }

  .pcard:hover .pcard-shot img {
    transform: scale(1.02);
  }
}

.pcard-shot {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.pcard-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform var(--dur-scene) var(--ease-out);
}

/* Projects with no screenshot show a structure render, centred, not cropped. */
.pcard-shot.is-poster img {
  object-fit: contain;
  object-position: center;
  padding: 0.75rem;
}

.pcard-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.15rem 1.15rem;
}

.pcard-kicker {
  margin: 0;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pcard-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

/* The title link covers the whole card; the chips sit above it. */
.pcard-link {
  color: var(--ink);
  text-decoration: none;
}

.pcard-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.pcard-link:focus-visible {
  outline: none;
}

.pcard:has(.pcard-link:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pcard-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.pcard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: auto 0 0;
  padding: 0.6rem 0 0;
  list-style: none;
}

.chip {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color var(--dur-quick) var(--ease-out), border-color var(--dur-quick) var(--ease-out);
}

a.chip:hover {
  color: var(--ink);
  border-color: var(--accent);
}

/* A green dot marks a resource you can use live, right here. */
.chip.is-live::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}

/* --- hub page --- */
.hub-head {
  margin-bottom: 1.75rem;
}

/* Wrap between meta items, never inside one. */
.hub-head .note-meta {
  flex-wrap: wrap;
  row-gap: 0.25rem;
  white-space: nowrap;
}

.hub-head .note-lede {
  max-width: 44rem;
  margin-bottom: 1rem;
}

.hub {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  overflow: hidden;
}

.hub-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.hub-tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.4em;
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.hub-tab:hover {
  color: var(--ink);
}

.hub-tab[aria-selected="true"] {
  border-color: var(--line);
  background: var(--bg);
  color: var(--ink);
}

.hub-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hub-tab.is-live::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
}

.hub-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 78vh;
  background: var(--bg);
}

.hub-stage:fullscreen {
  max-height: none;
  aspect-ratio: auto;
}

.hub-stage > img,
.hub-stage > iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.hub-stage > img {
  object-fit: cover;
  object-position: top center;
}

.hub-stage > img.is-poster {
  object-fit: contain;
  object-position: center;
  padding: 1.5rem;
}

/* The call to action over a screenshot: load the live page, or open it. */
.hub-cta {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.6rem;
  padding: 3.5rem 1rem 1.25rem;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 92%, transparent), transparent);
}

.hub-cta[hidden] {
  display: none;
}

.hub-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
}

.hub-caption {
  flex: 1 1 18rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.hub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hub-actions .btn {
  min-height: 40px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
}

.hub-actions [hidden] {
  display: none;
}

/* Without JavaScript the tabs are plain links and only the first panel's screenshot shows. */
.hub-note {
  margin: 0.75rem 0 0;
  color: var(--faint);
  font-size: 0.85rem;
}

/* Related projects at the foot of a hub. */
.hub-related {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.hub-related .sub {
  margin: 0 0 1rem;
}

@media (max-width: 640px) {
  .hub-stage {
    aspect-ratio: 4 / 5;
  }

  .hub-stage > img {
    object-position: top left;
  }
}
