/* ==================================================================
   March2Wolf — Portfolio
   Only portfolio.html loads this file, and everything in it is
   prefixed `pf-`, so it cannot reach another page. It leans on the
   tokens in base.css for colour, spacing and easing rather than
   inventing its own, which is why there are so few numbers here.

   The open/close animation is the same trick the projects page uses:
   a grid whose single row goes from 0fr to 1fr. It animates to the
   content's real height without anyone having to measure it first,
   and it does not break when the text inside changes length.
   ================================================================== */

/* --- the category bar --------------------------------------------- */

.pf-cat {
  border-top: 1px solid var(--line);
}

.pf-cat:last-of-type {
  border-bottom: 1px solid var(--line);
}

.pf-bar-head {
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
}

.pf-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md) var(--space-xs);
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s var(--ease);
}

.pf-bar:hover,
.pf-bar:focus-visible {
  background: rgba(255, 255, 255, 0.035);
}

/* A plus that becomes a minus. Two bars, one of which turns. */
.pf-bar-icon {
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
  flex: none;
}

.pf-bar-icon::before,
.pf-bar-icon::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto 0;
  height: 1px;
  background: var(--bronze);
  transform: translateY(-50%);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.pf-bar-icon::after {
  transform: translateY(-50%) rotate(90deg);
}

.pf-cat.is-open .pf-bar-icon::after {
  transform: translateY(-50%) rotate(0deg);
  opacity: 0;
}

.pf-bar-label {
  font-family: var(--font-display);
  font-size: var(--step-h3);
  line-height: 1.2;
}

/* The blurb rides along on the same line on a wide screen and drops
   out entirely on a narrow one, where the bar has to stay a bar. */
.pf-bar-blurb {
  display: none;
  color: var(--fog-500);
  font-size: 0.9rem;
}

.pf-bar-count {
  font-variant-numeric: tabular-nums;
  color: var(--fog-500);
  font-size: 0.9rem;
}

@media (min-width: 46rem) {
  .pf-bar {
    grid-template-columns: auto auto 1fr auto;
  }

  .pf-bar-blurb {
    display: block;
  }
}

/* --- the panel the bar opens -------------------------------------- */

.pf-panel-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s var(--ease);
}

.pf-cat.is-open .pf-panel-wrap {
  grid-template-rows: 1fr;
}

.pf-panel {
  overflow: hidden;
}

.pf-grid {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-xs) var(--space-lg);
}

@media (min-width: 40rem) {
  .pf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .pf-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --- a piece, closed ----------------------------------------------- */

/* A column, so that a card with a longer title still ends level with
   its neighbours and every "Open" sits on the same line across the
   row. Without this the row reads as four different-sized things. */
.pf-piece {
  display: flex;
  flex-direction: column;
  scroll-margin-top: 6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--ink-700), var(--ink-800));
  overflow: hidden;
  transition: border-color 0.25s var(--ease);
}

.pf-piece-head {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.pf-piece:hover {
  border-color: var(--line-strong);
}

.pf-piece-head {
  cursor: pointer;
}

.pf-piece-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

/* Pushed to the floor of the card, so the buttons line up no matter
   how many lines the title above them took. */
.pf-toggle {
  margin-top: auto;
}

.pf-shot {
  display: block;
  aspect-ratio: 800 / 430;
  overflow: hidden;
  background: var(--ink-900);
}

.pf-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.pf-shot-empty {
  display: block;
  width: 100%;
  height: 100%;
}

.pf-piece-body {
  padding: var(--space-sm) var(--space-sm) var(--space-md);
}

.pf-piece-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fog-500);
}

/* Said on the card, not only inside it. A visitor who never opens a
   piece still learns which businesses are invented. */
.pf-flag {
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--fog-500);
}

.pf-piece-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--step-h3);
  line-height: 1.25;
}

.pf-toggle {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  background: none;
  border: 0;
  color: var(--bronze);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.pf-toggle-icon {
  position: relative;
  width: 0.8rem;
  height: 0.8rem;
}

.pf-toggle-icon::before,
.pf-toggle-icon::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto 0;
  height: 1px;
  background: currentColor;
  transform: translateY(-50%);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.pf-toggle-icon::after {
  transform: translateY(-50%) rotate(90deg);
}

.pf-piece.is-open .pf-toggle-icon::after {
  transform: translateY(-50%) rotate(0deg);
  opacity: 0;
}

/* --- a piece, open -------------------------------------------------- */

/* An opened piece takes the whole row. Anything narrower turns the
   write-up into a column of two-word lines, and the screenshots are
   the point of opening it in the first place. */
.pf-piece.is-open {
  grid-column: 1 / -1;
  border-color: var(--line-strong);
}

.pf-detail-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.45s var(--ease);
}

.pf-piece.is-open .pf-detail-wrap {
  grid-template-rows: 1fr;
}

.pf-detail {
  overflow: hidden;
}

.pf-detail-inner {
  display: grid;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--line);
}

@media (min-width: 56rem) {
  .pf-detail-inner {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* The open card already shows the desktop shot at the top, so hide
   the small one behind it rather than printing the same picture
   twice down the page. */
.pf-piece.is-open .pf-piece-head .pf-shot {
  display: none;
}

/* --- the two frames -------------------------------------------------- */

/* The window takes the whole column, with room underneath it for the
   line of text that says it scrolls. Nothing is laid beside it: at this
   width a second frame would shrink the website to a stamp, and the
   28rem window happens to stand almost exactly as tall as the words in
   the column next to it, which is what keeps the two sides level. */
.pf-screens {
  position: relative;
}

.pf-screen {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--ink-900);
}

.pf-screen img {
  display: block;
  width: 100%;
  height: auto;
}

/* Three dots where a browser's buttons would be. Enough to read as a
   window without drawing a whole piece of chrome nobody asked for. */
.pf-screen-bar {
  display: block;
  height: 1.15rem;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 0.65rem 50%, var(--fog-500) 2px, transparent 2.5px),
    radial-gradient(circle at 1.3rem 50%, var(--fog-500) 2px, transparent 2.5px),
    radial-gradient(circle at 1.95rem 50%, var(--fog-500) 2px, transparent 2.5px);
  opacity: 0.75;
}

.pf-desk {
  width: 100%;
}

/* --- the scrollable window ------------------------------------------- */

/* The frame holds a capture of the entire website, so the visitor can
   scroll through the real thing instead of judging it by one hero shot.
   A fixed height keeps the opened piece a sensible size; the picture
   inside is whatever height the site actually is.

   Scroll chaining is deliberately left alone. When the window reaches
   its end the page carries on scrolling by itself, so nobody can get
   stuck inside the frame. */
.pf-scroll {
  display: block;
  height: 28rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bronze-deep) transparent;
}

.pf-scroll img {
  display: block;
  width: 100%;
  height: auto;
}

/* A visible scrollbar is the whole affordance — without one the frame
   just looks like a cropped picture, and nobody thinks to drag it. */
.pf-scroll::-webkit-scrollbar {
  width: 10px;
}

.pf-scroll::-webkit-scrollbar-track {
  background: var(--ink-900);
}

.pf-scroll::-webkit-scrollbar-thumb {
  background: var(--bronze-deep);
  border: 3px solid var(--ink-900);
  border-radius: var(--r-pill);
}

.pf-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--bronze);
}

.pf-scroll:focus-visible {
  outline: 2px solid var(--bronze);
  outline-offset: -2px;
}

/* Said in words as well, because the scrollbar only appears on hover on
   some machines, and the whole point is that there is more to see. */
.pf-scroll-hint {
  display: block;
  margin-top: 0.6rem;
  color: var(--fog-500);
  font-size: 0.8rem;
}

/* A shorter window on a small screen, so the piece does not become a
   wall of screenshot before the writing is reached. */
@media (max-width: 34rem) {
  .pf-scroll {
    height: 20rem;
  }
}

/* --- the words ------------------------------------------------------- */

.pf-words > p {
  margin: 0 0 var(--space-sm);
}

.pf-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem var(--space-sm);
  margin: var(--space-md) 0;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.pf-facts dt {
  color: var(--fog-500);
}

.pf-facts dd {
  margin: 0;
}

.pf-visit {
  margin-top: var(--space-xs);
}

.pf-nolink {
  margin-top: var(--space-xs);
  font-size: 0.9rem;
}

/* --- people who would rather nothing moved --------------------------- */

@media (prefers-reduced-motion: reduce) {
  .pf-panel-wrap,
  .pf-detail-wrap,
  .pf-bar,
  .pf-bar-icon::before,
  .pf-bar-icon::after,
  .pf-toggle-icon::before,
  .pf-toggle-icon::after {
    transition: none;
  }
}
