/* ------------------------------
   One published system
   ------------------------------
   Shared by the public /explore/{id} page and the in-app /app/explore/{id}
   view. The listing and byline live in project-grid.css (shared with the
   SPA); this is only the read-only token document.

   Token PREVIEWS live in token-preview.css, same as the editor, so a
   published swatch and an owned one cannot drift. */

/* A flex column that grows, on BOTH addresses, so the token column below has
   a real height to fill rather than only the height of its own content. That
   is what lets a published preview reach the bottom of the screen the way the
   editor's does; without it the preview sat at its 40rem floor on a 1200px
   display and the space under it was simply empty.

   Nothing new is invented for the public page: `body` is already a flex
   column with `min-height: 100dvh` (see tokens.css, the sticky-footer rule
   every public page uses), so `flex: 1` here claims exactly the room between
   the header and the footer. */
.explore-project {
  max-width: var(--pf-width-container);
  margin: 0 auto;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.explore-project-page > .explore-project {
  min-width: 0;
  overflow: hidden;
}

/* In the app the scroll container is this, and it has to pass the height on
   rather than absorb it: a plain block would size __body to its content and
   the stretch would stop here. min-height: 0 is what lets it shrink inside
   the shell instead of pushing the page taller. */
.explore-project__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.explore-project__head {
  border-bottom: 1px solid var(--pf-color-border);
  padding: var(--pf-space-6) var(--pf-gutter);
}

.explore-project__head .eyebrow a {
  color: inherit;
  text-decoration: none;
}

.explore-project__head .eyebrow a:hover {
  text-decoration: underline;
}

.explore-project h1 {
  margin: 0 0 var(--pf-space-2);
}

.explore-project__desc {
  max-width: 46rem;
  margin: 0 0 var(--pf-space-2);
  color: var(--pf-color-muted);
  line-height: var(--pf-leading-body);
}

/* inline-flex, not a block: the byline inside it carries a 20px avatar, and
   on a text baseline that tile would sit off-centre from the words beside it. */
.explore-project__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--pf-space-2);
  margin: 0 0 var(--pf-space-5);
  font-size: var(--pf-text-xs);
  color: var(--pf-color-muted);
}

.explore-project__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pf-space-3);
}

/* On the detail page: a real button beside Duplicate. Height, padding, radius
   and font all come from .btn and .btn-ghost. Copied from site.css so the
   in-app view, which does not load that sheet, still matches. */
.like.is-liked {
  color: var(--pf-color-danger) !important;
}

.like--lg {
  gap: var(--pf-space-2);
  padding-inline: var(--pf-space-3);
}

.like--lg:hover,
.like--lg:focus-visible {
  border-color: var(--pf-color-primary);
}

.explore-project__body {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: var(--pf-space-7);
  /* start, so the sticky group column stays a short box that can stick.
     Stretching it would make it as tall as the row and `position: sticky`
     would have nothing left to do. The token column opts out below. */
  align-items: start;
  padding: var(--pf-space-6) var(--pf-gutter);
  /* Takes the rest of the column, which is what the preview then fills.
     `1 0 auto`, never `1`: a shrink factor would let this shrink BELOW its
     own content whenever the page is already taller than the screen, which
     is most pages — the first attempt did exactly that and cut the panel
     down to 388px. Grow into spare room, never give any back. */
  flex: 1 0 auto;
}

/* The one column that wants the whole line. A group page is a list and looks
   the same either way; a preview is a PAGE, and a page that stops two thirds
   of the way down reads as broken rather than as short. */
.explore-tokens {
  align-self: stretch;
}

.explore-groups {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--pf-space-5);
}

/* Mobile-only group bar. Desktop keeps the button column; the signed-in
   drawer keeps it too — a select inside that off-canvas list would be a
   second control for the same job. */
.explore-groups__picker {
  display: none;
}

/* Twin of .token-sidebar .sidebar-preview in the editor: first in the
   column, left-packed, no count. Only rendered when the project has a saved
   layout (explore.mjs); without one the entry is absent, not empty. */
.explore-groups .sidebar-preview {
  justify-content: flex-start;
  margin-bottom: var(--pf-space-2);
}

.explore-group {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--pf-space-3);
  padding: var(--pf-space-2) var(--pf-space-3);
  border: none;
  background: none;
  color: var(--pf-color-muted);
  font-family: var(--pf-font-body);
  font-size: var(--pf-text-sm);
  text-align: left;
  text-transform: capitalize;
  cursor: pointer;
}

.explore-group:hover {
  color: var(--pf-color-ink);
  background: var(--pf-color-surface-sunken);
}

/* Inverted only while the groups still sit in the page body — the public
   unsigned layout. Once they live in `.explore-sidebar`, app-chrome.css
   gives them the editor's raised row instead. */
.explore-project__body .explore-group.active {
  background: var(--pf-color-ink);
  border-radius: var(--pf-radius-sm);
  color: var(--pf-color-bg);
}

.explore-group .count {
  font-size: var(--pf-text-xs);
  opacity: 0.7;
}

/* The rows are read-only here, so the cells are text rather than inputs —
   nothing to type into, and prose wraps where an input would truncate. */
.explore-cell {
  font-family: var(--pf-font-mono);
  font-size: var(--pf-text-sm);
  color: var(--pf-color-ink);
  overflow-wrap: anywhere;
}

.explore-cell--value {
  color: var(--pf-color-muted);
}

.explore-cell--desc {
  font-family: var(--pf-font-body);
  color: var(--pf-color-muted);
}

#explore-toast {
  position: fixed;
  bottom: var(--pf-space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--pf-color-ink);
  color: var(--pf-color-bg);
  padding: var(--pf-space-3) var(--pf-space-5);
  font-size: var(--pf-text-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--pf-duration-slow) var(--pf-ease-out);
  z-index: 10;
}

#explore-toast.visible {
  opacity: 1;
}

@media (max-width: 720px) {
  .explore-project__body {
    grid-template-columns: 1fr;
  }

  /* Public unsigned layout only: groups still live in the page body, so
     a wrapping chip row used to crowd the top. One closed list instead.
     The signed-in shell moves .explore-groups into .explore-sidebar, which
     is the drawer below 45rem — that list stays buttons. */
  .explore-project__body > .explore-groups {
    position: static;
  }

  .explore-project__body > .explore-groups > .explore-group {
    display: none;
  }

  .explore-project__body > .explore-groups > .explore-groups__picker {
    display: block;
  }
}

/* The group heading and type badge, mirroring the editor's. Not imported
   from app.css for the reason token-preview.css exists: that sheet also
   lays out the app shell and would rearrange the public page. */
.explore-tokens .token-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pf-space-4);
  margin-bottom: var(--pf-space-1);
}

.explore-tokens h2 {
  margin: 0;
  font-size: var(--pf-text-xl);
  font-weight: var(--pf-weight-semibold);
  letter-spacing: -0.02em;
  text-transform: capitalize;
}

.explore-tokens .group-type {
  display: flex;
  align-items: center;
  gap: var(--pf-space-1);
  flex: none;
}

.explore-tokens .group-type__label {
  font-size: var(--pf-text-xs);
  color: var(--pf-color-muted);
  letter-spacing: var(--pf-tracking-loose);
}

.explore-tokens .group-type__value {
  padding: 2px var(--pf-space-2);
  background: var(--pf-color-surface-sunken);
  border: 1px solid var(--pf-color-border);
  font-size: var(--pf-text-xs);
  color: var(--pf-color-ink);
}

.explore-tokens .group-description--static {
  max-width: 68ch;
  margin: var(--pf-space-3) 0 var(--pf-space-6);
  color: var(--pf-color-muted);
  font-size: var(--pf-text-sm);
  line-height: var(--pf-leading-body);
  /* Matches the editor: line breaks the author typed are kept rather than
     collapsed, so a published system reads the way it was written. */
  white-space: pre-wrap;
}

/* The row grid comes from token-preview.css; these are the read-only cells
   that sit in it. Not cards: that layout carries its own padding and a
   full border, and restating the list-row divider here left them flush
   and left-aligned. */
.explore-tokens .token-list:not(.token-list--cards) .token-row {
  align-items: center;
  padding: var(--pf-space-2) 0;
  border-bottom: 1px solid var(--pf-color-border);
}

.explore-tokens .column-headers {
  font-size: var(--pf-text-xs);
  color: var(--pf-color-muted);
  letter-spacing: var(--pf-tracking-loose);
  padding-bottom: var(--pf-space-1);
  border-bottom: 1px solid var(--pf-color-border);
}
