/* Portfolio (work.html) — index rail + stacked panes on one page.
   Replaces the 3-across card grid, which cost a page load per product to read
   anything. Every write-up already existed inside each card's hover overlay;
   this surfaces it instead of hiding it. */

.pf { max-width: 84rem; margin: 0 auto; padding: 2.6rem var(--gutter) 4rem;
      display: grid; grid-template-columns: 15rem 1fr; gap: clamp(1.5rem, 4vw, 3rem);
      align-items: start; }

/* ---- index rail ---- */
.pf-rail { position: sticky; top: 5rem; max-height: calc(100vh - 7rem);
        overflow-y: auto; padding-right: 0.4rem; }
.pf-rail__group { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.18em;
        text-transform: uppercase; color: var(--phosphor); margin: 1.3rem 0 0.5rem;
        display: flex; justify-content: space-between; align-items: baseline; }
.pf-rail__group:first-child { margin-top: 0; }
.pf-rail__group span { color: var(--bone-2); }
.pf-rail__list { list-style: none; margin: 0; padding: 0; }
.pf-rail__list a { display: block; text-decoration: none; padding: 0.32rem 0 0.32rem 0.7rem;
        border-left: 2px solid var(--edge); color: var(--bone-1);
        font-family: var(--f-body); font-size: 0.96rem; line-height: 1.3;
        transition: color .15s ease, border-color .15s ease; }
.pf-rail__list a:hover { color: var(--bone-0); border-left-color: var(--tape, var(--caution)); }
/* Scrollspy state, set by portfolio.js */
.pf-rail__list a.is-current { color: var(--ink-0); background: var(--tape, var(--caution));
        border-left-color: var(--tape, var(--caution)); font-weight: 600; }

/* ---- panes ---- */
.grp { margin-bottom: 2.6rem; }
.grp__head { padding-bottom: 0.6rem; border-bottom: 1px solid var(--edge); margin-bottom: 1.2rem; }
.grp__h { font-family: var(--f-display); font-weight: 700; font-size: 1.4rem;
        color: var(--bone-0); margin: 0; }
.grp__d { font-family: var(--f-body); font-size: 0.98rem; color: var(--bone-2); margin: 0.3rem 0 0; }

.prod { background: var(--ink-2); border: 1px solid var(--edge);
        border-left: 3px solid var(--tape, var(--caution));
        padding: 1.4rem 1.6rem; margin-bottom: 1rem;
        /* clears the fixed nav when an anchor jumps here */
        scroll-margin-top: 5.5rem; }
.prod__title { font-family: var(--f-display); font-weight: 700; font-size: 1.5rem;
        color: var(--bone-0); margin: 0; }
/* cards whose product has a real wordmark render it in place of the text title */
.prod__title img { display: block; height: 2.4rem; width: auto; max-width: 100%; }
.prod__hook { font-family: var(--f-body); font-size: 1.06rem; line-height: 1.45;
        color: var(--tape, var(--caution)); margin: 0.4rem 0 0; }
.prod__body { margin-top: 0.9rem; }
.prod__body p { font-family: var(--f-body); font-size: 1rem; line-height: 1.6;
        color: var(--bone-1); margin: 0.75rem 0 0; }
.prod__body p strong { color: var(--bone-0); font-weight: 600; }
.prod__ctas { margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--edge);
        display: flex; flex-wrap: wrap; gap: 1.2rem; }
.prod__cta { font-family: var(--f-mono); font-size: 0.74rem; letter-spacing: 0.1em;
        text-transform: uppercase; color: var(--bone-2); text-decoration: none; }
.prod__cta:hover { color: var(--caution); }
.prod__cta--go { color: var(--phosphor); }

@media (max-width: 900px) {
  .pf { grid-template-columns: 1fr; }
  /* The rail becomes a horizontal chip strip rather than 15 stacked links. */
  .pf-rail { position: static; max-height: none; overflow-x: auto; overflow-y: hidden;
          white-space: nowrap; padding-bottom: 0.6rem;
          border-bottom: 1px solid var(--edge); margin-bottom: 1.4rem; }
  .pf-rail__group { display: none; }
  .pf-rail__list { display: inline-flex; gap: 0.4rem; }
  .pf-rail__list a { border: 1px solid var(--edge); border-left-width: 3px;
          padding: 0.35rem 0.7rem; font-size: 0.88rem; }
}

/* ---- cards move in, the window stays put ----
   Two implementations. Where the browser supports scroll-driven animations the
   movement is tied to scroll POSITION, so scrolling back up runs it backwards --
   that is the parallax feel, and it needs no JavaScript at all. Everywhere else
   falls back to a one-shot reveal driven by IntersectionObserver.

   The fallback's hidden start state is scoped to .pf-js, set by an inline script
   in the head. Without that guard, a visitor with JS disabled and no
   scroll-timeline support would get a page of invisible cards -- the failure
   mode where a decorative effect eats the content. */
@media (prefers-reduced-motion: no-preference) {

  @supports (animation-timeline: view()) {
    .prod {
      animation: prod-move-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
    @keyframes prod-move-in {
      from { opacity: 0; transform: translateY(52px) scale(0.985); }
      to   { opacity: 1; transform: none; }
    }
    /* Group headings drift in behind the cards, slightly slower, so the two
       layers separate rather than moving as one slab. */
    .grp__head {
      animation: grp-move-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
    @keyframes grp-move-in {
      from { opacity: 0; transform: translateY(24px); }
      to   { opacity: 1; transform: none; }
    }
  }

  @supports not (animation-timeline: view()) {
    .pf-js .prod {
      opacity: 0; transform: translateY(44px) scale(0.985);
      transition: opacity .55s ease, transform .55s cubic-bezier(.22,.61,.36,1);
    }
    .pf-js .prod.is-in { opacity: 1; transform: none; }
  }
}

/* ---- VIEWER MODE ----
   Kevin's actual concept: the frame stays fixed and clicking a name slides that
   card into it. Scroll-reveal (above) was my misreading of "the window stays
   fixed, the cards move in".

   Enabled by .pf-viewer, which portfolio.js sets only when it can drive the
   interaction. Without JS the page stays as a plain stacked list, which is why
   the default styles are the readable ones and this is the enhancement. Every
   pane stays in the DOM either way -- hidden panes are still crawlable, which a
   lazy-loading viewer would have cost. */
.pf-viewer .panes {
  position: relative;
  min-height: 34rem;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-top: 3px solid var(--caution);
  background: var(--ink-1);
}
/* Group headings are the rail's job in viewer mode. */
.pf-viewer .grp__head { display: none; }
.pf-viewer .grp { margin: 0; }

.pf-viewer .prod {
  position: absolute; inset: 0;
  margin: 0; border: 0;
  overflow-y: auto;
  padding: 1.6rem 1.8rem;
  /* Slide in from the side the rail is on. */
  transform: translateX(2.5rem);
  opacity: 0;
  visibility: hidden;
  transition: transform .38s cubic-bezier(.22,.61,.36,1), opacity .28s ease, visibility 0s linear .38s;
  /* the scroll-driven animation has no business running in here */
  animation: none !important;
}
.pf-viewer .prod.is-shown {
  transform: none; opacity: 1; visibility: visible;
  transition: transform .38s cubic-bezier(.22,.61,.36,1), opacity .28s ease, visibility 0s;
}
.pf-viewer .prod::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--tape, var(--caution));
}
@media (prefers-reduced-motion: reduce) {
  .pf-viewer .prod { transition: opacity .01s, visibility 0s; transform: none; }
}
@media (max-width: 900px) {
  /* A fixed frame on a phone is a small window inside a small window. Fall back
     to the stacked list, which is what a thumb wants anyway. */
  .pf-viewer .panes { position: static; min-height: 0; overflow: visible; border: 0; background: none; }
  .pf-viewer .prod { position: static; opacity: 1; visibility: visible; transform: none;
                     border: 1px solid var(--edge); border-left: 3px solid var(--tape, var(--caution));
                     margin-bottom: 1rem; overflow: visible; }
  .pf-viewer .grp__head { display: block; }
  .pf-viewer .prod::before { display: none; }
}

/* The point of a fixed frame is seeing the list and the card at once. The
   calling-card hero is built for pages you scroll, so on this one it is
   compressed to get the viewer above the fold. */
@media (min-width: 901px) {
  .pf-viewer-page .hero--callingcard { padding-top: 4.5rem; padding-bottom: 1rem; min-height: 0; }
  .pf-viewer-page .cc-page-heading { font-size: clamp(2.4rem, 5vw, 3.6rem); margin-bottom: 0.6rem; }
  .pf-viewer-page .cc-intake { margin-bottom: 0.8rem; }
  .pf-viewer-page .cc-intake__row { padding: 0.18rem 0; }
  .pf-viewer-page .hero__container .cc-bio { font-size: 0.98rem; line-height: 1.5; margin-top: 0.7rem !important; }
  .pf { padding-top: 1.4rem; }
  .pf-viewer .panes { min-height: 30rem; }
}

/* ---- terminal face inside the cards ----
   The cards sit on a dark panel, where the serif body face reads as an article
   pasted onto a console. Space Mono instead: it is already in the design
   system, and it is the readable monospace. VT323 (--f-term) is the truer
   terminal font but it is a display face -- legible for a prompt line, punishing
   for four paragraphs of product copy.

   Monospace runs wider and sits tighter, so size comes down and leading goes up;
   dropping in a mono face at the serif's metrics is how you get a wall. */
.prod__hook {
  font-family: var(--f-mono);
  font-size: 0.94rem;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
.prod__body p {
  font-family: var(--f-mono);
  font-size: 0.85rem;
  line-height: 1.72;
  letter-spacing: -0.005em;
  color: var(--bone-1);
}
.prod__body p strong { color: var(--bone-0); font-weight: 700; }
.prod__body em { color: var(--bone-0); font-style: normal; }

/* The frame matches the rail's height rather than guessing at one. Grid items
   stretch by default; .pf overrides that to `start` for the scroll layout, so
   viewer mode puts it back. The rail also stops being sticky here -- there is
   nothing to stick to when both columns are the same height and the page barely
   scrolls. */
@media (min-width: 901px) {
  .pf-viewer { align-items: stretch; }
  .pf-viewer .pf-rail { position: static; max-height: none; overflow: visible; }
  .pf-viewer .panes { min-height: 0; }
}
