/* The /plugins directory. Its own stylesheet: the home page has a .plugin-list
   of its own, and nothing here should reach it. */

#plugin-directory {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 20px 90px;
}

/* ----------------------------------------------------------------- header */

/* the site-wide `header` rule dresses every header element as the masthead;
   this one is a heading inside the page, so that is undone */
.directory-header {
  position: static;
  z-index: auto;
  background: none;
  box-shadow: none;
  border: 0;
  margin-bottom: 34px;
  text-align: center;
}

#content .directory-header h1 {
  margin-bottom: 16px;
}


/* the category pills are in category-pills.css, which the front page shares */

/* the line under the categories; it holds one line's height even when the
   chosen category has nothing written about it */
.directory-descriptions {
  max-width: 640px;
  min-height: 1.5em;
  margin: 18px auto 16px;
  border-top: 1px solid var(--lv4);
  border-bottom: 1px solid var(--lv4);
  padding: 8px;
}

#content .directory-category-about {
  margin: 0;
  color: var(--lv13);
  font-size: 16px;
  line-height: 1.5;
  /* even lines rather than a word left alone on the last */
  text-wrap: balance;
  font-variation-settings: "wght" 400, "ital" 1;
}

#content .directory-category-about[hidden] {
  display: none;
}

#content .plugin-cards > li[hidden] {
  display: none;
}

/* the order and light/dark switches are in view-switches.css, which
   /collections shares */

/* ------------------------------------------------------------------ grid */

#content .plugin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 420px) {
  #content .plugin-cards {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

#content .plugin-card-item {
  margin: 0;
  padding: 0;
  background: none;
}

/* ------------------------------------------------------------------ card */

#content .plugin-card {
  /* The card is measured against itself, not the window: the same card is
     three to a row on a collection's page and two on the directory, so what
     fits is a question about the card. */
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--lv5);
  border-radius: 10px;
  background: var(--lv0);
  color: inherit;
  box-shadow: 0 1px 3px rgba(var(--shade-rgb), 0.05);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

/* Everything above the buttons is the link to the plugin, and it takes what
   room is going so the buttons sit at the foot of every card in a row however
   long the taglines run. focus-within rather than focus-visible now that the
   card is a div: what takes focus is something inside it. */
#content .plugin-card-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

#content .plugin-card:hover,
#content .plugin-card:focus-within {
  border-color: var(--theme);
  box-shadow: 0 10px 30px rgba(var(--shade-rgb), 0.12);
  transform: translateY(-2px);
}

/* ------------------------------------------------------- ways to buy it */

/* The pair from a plugin's own page, in the foot of the card: the green one
   to press and the quiet one for a cart being built. */
#content .plugin-card-buy {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

/* Side by side and sharing the width evenly, whatever is written in them —
   min-width: 0 because a flex item will not shrink below its content
   otherwise, and "Buy Now — $199.00" is wider than half a card. */
#content .plugin-card-buy-now,
#content .plugin-card-cart,
#content .plugin-card-buy-note {
  flex: 1 1 0;
  min-width: 0;
}

#content .plugin-card-buy-now,
#content .plugin-card-cart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  padding: 7px 12px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 100px;
  font-size: 14px;
  line-height: 1.25;
  text-decoration: none;
  transition: filter 0.15s, border-color 0.15s, color 0.15s;
}

/* the plugin's own colour here rather than the green a single product page
   uses: on a wall of cards it is what tells one from the next */
#content .plugin-card-buy-now {
  border-color: var(--theme);
  background: var(--theme);
  color: var(--slab-ink);
  font-variation-settings: "wght" 700, "ital" 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 1px 2px rgba(var(--shade-rgb), 0.18);
}

#content .plugin-card-buy-now:hover {
  filter: brightness(1.12);
}

#content .plugin-card-cart {
  border-color: var(--lv6);
  background: var(--lv0);
  color: var(--lv16);
  font-variation-settings: "wght" 600, "ital" 0;
}

#content .plugin-card-cart:hover {
  border-color: var(--theme);
  color: var(--theme);
}

/* the glyph is hidden by default and shown by whatever carries it */
#content .plugin-card-cart .nav-cart {
  display: flex;
  margin: 0;
}

/* nothing to press — free, or not out yet — said in the same space */
#content .plugin-card-buy-note {
  padding: 7px 12px;
  border: 1px dashed var(--lv6);
  border-radius: 100px;
  color: var(--lv12);
  font-size: 14px;
  line-height: 1.25;
  font-variation-settings: "wght" 600, "ital" 0;
  text-align: center;
}

/* the interface, sitting on a wash of the plugin's own colour */
.plugin-card-stage {
  position: relative;
  aspect-ratio: 5 / 4;
  /* Ruled in fine squares over the wash, the same paper the collection stages
     stand their windows on. Theirs washes between two tints; a plugin has the
     one, so the bottom layer is a flat gradient of it rather than a colour —
     background-image cannot take a plain colour, and every layer here has to
     be one of those for the squares to sit over it. */
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px, 100% 100%;
  background-image:
    linear-gradient(to right, rgba(var(--tint-rgb), 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(var(--tint-rgb), 0.05) 1px, transparent 1px),
    linear-gradient(to right, rgba(var(--tint-rgb), 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(var(--tint-rgb), 0.025) 1px, transparent 1px),
    linear-gradient(var(--tint), var(--tint));
  transition: background 0.25s;
}

/* laid over the stage rather than sized by it: a percentage max-height does
   not resolve against a height that only comes from aspect-ratio, so a squarer
   interface (Vulf Compressor, Midside) would stretch its card taller than the
   others in the row */
.plugin-card-interface {
  position: absolute;
  inset: 12px;
  display: block;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  object-fit: contain;
  transition: transform 0.3s;
}

#content .plugin-card:hover .plugin-card-interface {
  transform: scale(1.03);
}

/* dark screenshots want a dark stage */
/* the tint is a tenth of an opacity, so dark mode needs something opaque
   under it, and the squares are ruled in light rather than in dark */
#plugin-directory.is-dark .plugin-card-stage {
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px, 100% 100%, 100% 100%;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(var(--tint), var(--tint)),
    linear-gradient(var(--slab-stage), var(--slab-stage));
}

/* the fallback, for a plugin with no screenshot: its nameplate, as the old
   directory showed it */
.plugin-card-nameplate {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background-color: var(--theme);
  background-size: 260px auto;
}

.plugin-card-nameplate img {
  width: 72%;
  max-width: 340px;
}

.plugin-card-stage.no-interface .plugin-card-nameplate,
.plugin-card-stage.missing .plugin-card-nameplate {
  display: flex;
}

.plugin-card-stage.missing .plugin-card-interface {
  display: none;
}

.plugin-card-sale {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 2px 10px;
  border-radius: 100px;
  background: var(--theme);
  color: var(--slab-ink);
  font-size: 13px;
  font-variation-settings: "wght" 800, "ital" 0;
  box-shadow: 0 2px 6px rgba(var(--shade-rgb), 0.18);
}

/* logo, name and tagline, and the price */
.plugin-card-info {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: top;
  gap: 14px;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--lv3);
}

.plugin-card-logo {
  display: block;
  width: 52px;
  height: 52px;
}

.plugin-card-text {
  min-width: 0;
}

/* named with the element: #content h2:not(:first-child) would otherwise add
   60px above every name */
#content h2.plugin-card-name {
  margin: 0;
  color: var(--theme-reading, var(--theme));
  font-size: 1.2em;
  line-height: 1.15;
  font-variation-settings: "wght" 780, "opsz" 24;
}

#content .plugin-card-tagline {
  margin: 3px 0 0;
  color: var(--lv13);
  font-size: 14px;
  line-height: 1.35;
}

/* what comes with it, free: VCME Soft Clip with VCME */
#content .plugin-card-includes {
  margin: 4px 0 0;
  color: var(--lv9);
  font-size: 12px;
  line-height: 1.3;
  font-variation-settings: "wght" 500, "ital" 0;
}

/* Most of these are a price — four characters that always fit beside the
   name. A plugin that cannot be bought on its own says "Unlockable" there
   instead, which is a whole word and does not break, and on a narrow card
   it was taking more room than the name and the tagline together: 87px of
   price against 66px of everything else, the name over two lines and the
   tagline over six.

   The price keeps its corner. What moves is the tagline, out from between
   the logo and the price and onto a line of its own under all three, where
   it has the whole card to run in. Only the name has to share the top row,
   and a name is short. */
@container (max-width: 340px) {
  /* :has, so this only reaches a card that has a price to work around. The
     checkout's widget cards carry no price and set their own columns
     (checkout.css, .cart-popular); without this they were caught by it and
     given a column they had not asked for. */
  #content .plugin-card .plugin-card-info:has(.plugin-card-price) {
    row-gap: 0;
  }

  /* the wrapper steps aside so the name and the tagline can be placed on
     the grid apart from one another, which is the whole point of this */
  #content .plugin-card-info:has(.plugin-card-price) .plugin-card-text {
    display: contents;
  }

  #content .plugin-card-info:has(.plugin-card-price) .plugin-card-name {
    grid-column: 2;
    grid-row: 1;
  }

  #content .plugin-card-info:has(.plugin-card-price) .plugin-card-price {
    grid-column: 3;
    grid-row: 1;
  }

  /* across everything, logo included: under the logo there is nothing but
     white, and a tagline that starts there reads as the card's own line */
  #content .plugin-card-info:has(.plugin-card-price) .plugin-card-tagline {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 8px;
  }

  #content .plugin-card-info:has(.plugin-card-price) .plugin-card-includes {
    grid-column: 1 / -1;
    grid-row: 3;
  }
}

.plugin-card-price {
  align-self: start;
  padding-top: 2px;
  color: var(--lv17);
  font-size: 17px;
  white-space: nowrap;
  font-variation-settings: "wght" 750, "ital" 0;
}

.plugin-card-price s {
  display: block;
  color: lightpink;
  font-size: 13px;
  text-align: right;
}
