/* The projects panel: filters, view toggle, rail and grid, and project cards. */

/* Projects: a full-bleed rail of cards, newest at left */
.projects-panel {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding-left: 0;
  padding-right: 0;
}

.project-filter {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.5rem var(--gutter) 1.5rem;
  opacity: 0;
  transition: opacity var(--filter-fade-out) ease;
}

.filter-group {
  grid-column: 2;
  display: flex;
  justify-content: center;
  gap: 2rem;
}

/* Where the rail is: the card at its leading edge (or the open card) out of
   the cards shown, with steps either way. The grid shows every card at once,
   so it needs none. */
.rail-position {
  grid-column: 1;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--text-sm);
  letter-spacing: 0.12em;
  color: var(--dim);
}

.projects-panel.grid-view .rail-position {
  visibility: hidden;
}

.rail-count {
  font-variant-numeric: tabular-nums;
}

.rail-step {
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--hover) ease;
}

/* Hover feedback only where a pointer hovers: on a touch screen a tap leaves
   :hover on what it touched, so the look would stick. */
@media (hover: hover) {
  .rail-step:hover:not([aria-disabled='true']) {
    color: var(--ink);
  }
}

.rail-step[aria-disabled='true'] {
  opacity: 0.35;
  cursor: default;
}

/* The count after each filter's name */
.filter-count {
  font-weight: 400;
}

.view-toggle {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 0.5rem;
}

/* On a touch screen each toggle's hit area reaches 12px past its icon
   (css/controls.css), so the two sit 24px apart and their areas meet, and the
   filters keep 12px clear of them on a narrow phone. */
@media (hover: none) {
  .view-toggle {
    gap: 1.5rem;
  }

  .project-filter {
    column-gap: 0.75rem;
  }
}

/* Narrow phones: the filters, each label and count on one line, take a row
   of their own, centered; the rail position and the view toggle share the
   row below, so the position a swipe reaches shows here too. The rows are
   28px apart, the filters' 16px hit reach below plus the toggles' 12px above
   (css/controls.css), so the tap areas meet without overlapping. */
@media (max-width: 480px) {
  .project-filter {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'filters filters'
      'position toggle';
    row-gap: 1.75rem;
  }

  .filter-group {
    grid-area: filters;
    justify-content: center;
    gap: 1.25rem;
  }

  .filter-btn {
    white-space: nowrap;
  }

  .filter-count {
    font-size: var(--text-xs);
  }

  .rail-position {
    grid-area: position;
  }

  .view-toggle {
    grid-area: toggle;
  }
}

.view-btn {
  display: inline-flex;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dim);
  transition: color var(--hover) ease;
}

.view-btn[aria-pressed='true'] {
  color: var(--ink);
}

@media (hover: hover) {
  .view-btn:hover {
    color: var(--ink);
  }
}

.view-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* The filters arrive after the projects settle, and leave before they do */
.bar.active .projects-panel.shown .project-filter {
  opacity: 1;
  transition: opacity var(--filter-fade-in) ease var(--filter-delay);
}

.filter-btn {
  font-family: inherit;
  font-size: var(--text-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--hover) ease;
}

@media (hover: hover) {
  .filter-btn:hover {
    color: var(--ink);
  }
}

.filter-btn[aria-pressed='true'] {
  color: var(--ink);
  font-weight: 700;
}

.panel-inner.projects {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: var(--rail-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-padding-left: var(--gutter);
  padding: 0 0 0 var(--gutter);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-on-paper) transparent;
}

/* On a touch screen a swipe always comes to rest on a card; proximity
   snapping could leave the rail between two. */
@media (hover: none) {
  .panel-inner.projects {
    scroll-snap-type: x mandatory;
  }
}

/* While a card is open, snapping is off: snapping to card starts would pull
   the open card off center. */
.projects-panel.expanded .panel-inner.projects {
  scroll-snap-type: none;
}

/* Trailing spacer: the rail's end inset, as a pseudo-element so it needs no
   markup. It grows instantly when a card opens, so the last card can scroll
   to center, and eases back on close. */
.panel-inner.projects::after {
  content: '';
  flex: 0 0 var(--gutter);
  transition: flex-basis var(--card-resize) ease;
}

/* Room to center the last card: (rail width − open card width) / 2 − gap. The
   rail is this 100% (its content box) plus one gutter of left padding, so half
   the rail is 50% + gutter / 2. Sized in CSS, so it follows a resize. */
.projects-panel.expanded .panel-inner.projects::after {
  flex-basis: max(
    var(--gutter),
    calc(50% + var(--gutter) / 2 - var(--card-w-expanded) / 2 - var(--rail-gap))
  );
  transition: none;
}

.panel-inner.projects::-webkit-scrollbar {
  height: 8px;
}

.panel-inner.projects::-webkit-scrollbar-thumb {
  background: var(--scrollbar-on-paper);
  border-radius: 4px;
}

/* Grid view: compact cards in a responsive grid that scrolls vertically */
/* Rows take their tallest card, and the cards in a row stretch to match. A
   plain auto row would size to the cards' min-height alone, since each card
   clips its overflow. */
.projects-panel.grid-view .panel-inner.projects {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-items: stretch;
  align-content: start;
  gap: 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.25rem var(--gutter) 1rem;
}

@media (max-width: 1200px) {
  .projects-panel.grid-view .panel-inner.projects {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .projects-panel.grid-view .panel-inner.projects {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .projects-panel.grid-view .panel-inner.projects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.projects-panel.grid-view .panel-inner.projects::after {
  display: none;
}

/* Compact grid cards: tag, title, context, and the first three stack items
   (then +N) or the role. Each row is as tall as its tallest card, so
   nothing is cut off; the rest shows when a card opens. */
.projects-panel.grid-view .project-card {
  flex: none;
  width: auto;
  height: auto;
  min-height: 200px;
  padding: 1.4rem 1.4rem;
  scroll-snap-align: none;
}

.projects-panel.grid-view .project-card:not(.expanded) :is(.org, .desc),
.projects-panel.grid-view
  .project-card:not(.expanded)
  .stack-list
  li:nth-child(n + 4):not(.stack-more) {
  display: none;
}

.projects-panel.grid-view .project-card:not(.expanded) .stack-list .stack-more {
  display: block;
  color: var(--muted);
}

.projects-panel.grid-view .project-card:not(.expanded) .stack-list,
.projects-panel.grid-view .project-card:not(.expanded) .role {
  margin-bottom: 0;
}

.projects-panel.grid-view .card-marks {
  top: 1.4rem;
  right: 1.4rem;
}

/* A phone's two grid columns are too narrow for the tag and the marks on one
   line, so the marks take their own line under the tag. */
@media (max-width: 480px) {
  .projects-panel.grid-view .card-marks {
    position: static;
    margin-top: 0.5rem;
  }
}

/* No hover magnify in the grid, where it would overlap neighbors */
@media (hover: hover) {
  .projects-panel.grid-view .project-card:hover {
    transform: none;
    z-index: auto;
  }
}

/* An opened grid card spans its row; the others dim */
.projects-panel.grid-view .project-card.expanded {
  grid-column: 1 / -1;
  width: auto;
  height: auto;
  max-height: none;
  overflow: visible;
}

.project-card {
  /* One size for the open card's logo slot and the text clearance beside it, so
     the two stay in step. */
  --logo-size: 84px;
  /* Never wider than the screen less both gutters */
  flex: 0 0 min(var(--card-w), calc(100vw - 2 * var(--gutter)));
  box-sizing: border-box;
  height: 360px;
  overflow: hidden;
  scroll-snap-align: start;
  background: var(--ink);
  border-radius: var(--radius-surface);
  padding: 1.75rem 1.6rem;
  color: var(--white);
  display: flex;
  flex-direction: column;
  text-align: left;
  position: relative;
  cursor: pointer;
  transition:
    transform var(--card-lift) ease,
    filter var(--card-dim) ease,
    opacity var(--card-dim) ease,
    flex-basis var(--card-resize) ease,
    height var(--card-resize) ease;
  will-change: transform;
}

/* Short windows (landscape phones): shrink collapsed rail cards to the rail's
   height, so they lose description lines at the bottom instead of their
   titles off the top. */
.projects-panel:not(.grid-view) .project-card:not(.expanded) {
  max-height: 100%;
}

/* Cards the filter leaves out. Needed because .project-card sets display,
   which overrides the browser's own [hidden] rule. */
.project-card[hidden] {
  display: none;
}

/* Magnify only the hovered card, and only for a pointer that hovers: on a
   touch screen, :hover sticks to whatever was last tapped. */
@media (hover: hover) {
  .project-card:hover {
    transform: scale(1.1);
    z-index: 3;
  }

  .projects-panel.expanded .project-card:not(.expanded):hover {
    transform: scale(1);
  }
}

/* While a card is open, the others dim and shrink a touch */
.projects-panel.expanded .project-card:not(.expanded) {
  filter: grayscale(1) brightness(0.55);
  transform: scale(0.94);
}

/* Reduced motion: no zooming or shrinking cards */
@media (prefers-reduced-motion: reduce) {
  .project-card:hover,
  .projects-panel.expanded .project-card:not(.expanded) {
    transform: none;
  }
}

.project-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--muted);
}

.project-tag .dot {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  line-height: 1;
}

.project-card.technical .dot {
  color: var(--technical);
}

.project-card.creative .dot {
  color: var(--creative);
}

.project-card.technical .dot::before {
  content: '</>';
  font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Arial Unicode MS', sans-serif;
}

.project-card.creative .dot::before {
  content: '\2726';
  font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Arial Unicode MS', sans-serif;
}

/* The title is a button (it opens and closes the card) that reads as the
   heading text */
.card-title {
  display: block;
  width: fit-content; /* the focus ring hugs the title; long titles still wrap the same */
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.project-card h3 {
  margin: 0.85rem 0 0.2rem;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--white);
}

.project-card .context {
  margin: 0 0 0.55rem;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Credit line for creative cards (technical cards use .stack-list) */
.project-card .role {
  margin: 0 0 0.85rem;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--creative);
}

.project-card .stack-list {
  margin: 0 0 0.95rem;
  padding: 0;
  list-style: none;
}

.project-card .stack-list li {
  margin: 0.14rem 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--technical);
}

.project-card .org {
  margin: 0 0 0.85rem;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--white);
}

.project-card .desc {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--soft);
}

/* A collapsed card's description stops after the last whole line that fits,
   with an ellipsis (js/card-clamp.js counts the lines). */
.project-card:not(.expanded) .desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--desc-lines, none);
  overflow: hidden;
}

/* Marks for what the open card holds: code, a live site, a video. They sit
   on the tag's line, where the open card's close button goes. */
.card-marks {
  position: absolute;
  top: 1.75rem;
  right: 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: calc(var(--text-xs) * 1.6);
  font-size: var(--text-xs);
  line-height: 1;
  color: var(--muted);
}

.card-mark svg {
  display: block;
  width: 12px;
  height: 12px;
}

.project-card.expanded .card-marks {
  display: none;
}

/* "+N" stands in for the stack items a compact grid card leaves out */
.stack-more {
  display: none;
}

/* The clicked card expands in place, sandwiched by the dimmed neighbors.
   It opens to full width at once (no flex-basis transition here), so the
   rail can center it from its final box; closing eases back through the
   .project-card transition. */
.project-card.expanded {
  flex: 0 0 var(--card-w-expanded);
  transition:
    transform var(--card-lift) ease,
    filter var(--card-dim) ease,
    opacity var(--card-dim) ease,
    height var(--card-resize) ease;
  height: auto;
  max-height: calc(100% - 1.5rem);
  overflow-y: auto;
  overflow-x: hidden;
  cursor: default;
  z-index: 4;
  filter: none;
  transform: none;
  padding: 2.5rem 2.5rem 2.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-on-ink) transparent;
}

/* The shared close button (controls.css) shows only while its card is open */
.project-card .close-button {
  display: none;
}

.project-card.expanded .close-button {
  display: flex;
}

/* A card's logo sits top-right in the expanded card, below the close (×)
   button, only while the card is open (collapsed cards are too small). It
   sits on a light tile, app-icon style, so transparent or dark artwork stays
   visible against the black card. */
.card-logo {
  display: none;
  position: absolute;
  top: 3.5rem;
  right: 2.5rem;
  width: var(--logo-size);
  height: var(--logo-size);
  box-sizing: border-box;
  border-radius: var(--radius-inset);
  overflow: hidden;
  z-index: 4;
  background: var(--paper);
  padding: 8px;
}

/* Creative logos, and any fullLogo card, show the full artwork: no app-icon
   tile, padding, or rounded corners. Other technical cards keep the icon look. */
.project-card.creative .card-logo,
.project-card.full-logo .card-logo {
  background: none;
  padding: 0;
  border-radius: 0;
  overflow: visible;
}

/* logoSize: 'large' in js/data.js. Bumping --logo-size grows the slot and
   its text-clearance padding together, so the text is never overlapped. */
.project-card.logo-large {
  --logo-size: 104px;
}

/* With a one-line stack, the description still starts beside the logo, so
   it needs the same right-side clearance as the header lines. */
.project-card.expanded:has(.card-logo):has(.stack-list > li:only-child) .desc {
  padding-right: calc(var(--logo-size) + 1.75rem);
}

.project-card.expanded .card-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The logo fills its slot without distortion, like .entry-logo. */
.card-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Keep the header lines (tag, title, context, stack, role, org) clear of the
   logo. The description sits below the logo, so it is left alone. */
.project-card.expanded .project-tag,
.project-card.expanded h3,
.project-card.expanded .context,
.project-card.expanded .stack-list,
.project-card.expanded .role,
.project-card.expanded .org {
  padding-right: calc(var(--logo-size) + 1.75rem);
}

.card-extra {
  display: none;
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--hairline);
}

.project-card.expanded .card-extra {
  display: block;
}

/* Narrow phones: the open card spends less on padding, sets its logo above
   the tag instead of beside a title column a third of the card wide, and
   grows to its full content. The rail then scrolls down to it, instead of
   the card scrolling inside itself. */
@media (max-width: 480px) {
  .project-card.expanded {
    max-height: none;
    overflow: visible;
    padding: 1.75rem 1.5rem 1.5rem;
  }

  .project-card.expanded .card-logo {
    position: static;
    order: -1;
    margin-bottom: 1.25rem;
  }

  .project-card.expanded :is(.project-tag, h3, .context, .stack-list, .role, .org),
  .project-card.expanded:has(.card-logo):has(.stack-list > li:only-child) .desc {
    padding-right: 0;
  }

  .projects-panel.expanded .panel-inner.projects {
    overflow-y: auto;
    align-items: flex-start;
  }
}

.card-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.card-media {
  border-radius: var(--radius-inset);
  overflow: hidden;
}

/* Responsive 16:9 player slot for an embedded video */
.card-media.has-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
}

.card-media.has-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* A compact click-out button for YouTube videos, which cannot be embedded.
   A .pill-button, left-aligned at its natural height rather than
   filling a 16:9 slot. */
.card-media.has-link {
  display: flex;
  overflow: visible; /* no fill to clip, and it would clip the button's focus ring */
}
.pill-button.watch-btn .yt-ico {
  color: var(--youtube);
}
