.folio-folders {
  --folder-depth: 0;
  display: flex;
  gap: 6px;
  margin-top: 14px;
  padding: 0 0 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.folio-folders button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--muted);
  font:700 var(--text-2xs) system-ui;
  letter-spacing: .05em;
  cursor: pointer;
}

.folio-folders button:hover,
.folio-folders button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.folio-folders button small {
  min-width: 18px;
  padding: 2px 5px;
  background: var(--surface);
  color: inherit;
  text-align: center;
}

/* The fan's stage is sized from its own width, because everything inside it is.
 *
 * A card is 38% of the stage's width and 5:7, and the outer cards sit 62px down and turned 14deg,
 * so the fan's lowest point is 62px + 0.57 of the width (measured: 0.569 at 428px and at 745px).
 * The stage used to be `height: clamp(365px, 32vw, 440px)` while the cards grew with no limit, so
 * wherever the stage was wide the fan ran out of the bottom of it and over the index: 121px on a
 * phone held sideways, 175px on a 2560px monitor.
 *
 * Now the height follows the width. 74px of top padding covers the 62px offset plus room for
 * the hover lift, and `aspect-ratio` on the content box covers the 0.57. The width is capped
 * twice: at 700px, about the size it reached on a 1920px screen, so a wide monitor gets a fan
 * rather than a billboard; and by the viewport's height, so on a short screen such as a phone
 * held sideways the whole fan fits beneath the topbar. It is centred in whatever space is left.
 *
 * Both selectors are spelled out, with and without folder tabs, because between them they match
 * every stage, and their :has() specificity is what outranks the fixed heights in homepage.css. */
.curator-visual:has(.folio-folders:not(.hidden)) .folio-cards,
.curator-visual:not(:has(.folio-folders:not(.hidden))) .folio-cards {
  box-sizing: content-box;
  width: min(100%, 700px, calc((100svh - 170px) / .57));
  height: auto;
  aspect-ratio: 100 / 57;
  margin-inline: auto;
  padding-top: 74px;
}

.curator-visual:has(.folio-folders:not(.hidden)) .folio-cards {
  margin-top: 12px;
}

.folio-card {
  /* Commander art cards replace this inline with their colour-identity glow. Declaring a default
     keeps the box-shadow declarations valid for any card that has no art to glow from. */
  --folio-glow-shadow: 0 0 0 0 transparent;
  color: inherit;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}

.folio-card.has-card-art {
  border-color: transparent;
  background: var(--paper);
  color: var(--ink);
}

.folio-card.has-card-art::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 30% 0 0;
  background: linear-gradient(transparent 0, var(--paper) 72%, var(--paper) 100%);
  pointer-events: none;
}

.folio-card-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* A partner pair: the second commander lies over the first and fades in and out. */
.folio-card-art-partner {
  opacity: 0;
  transition: opacity .9s ease;
}

.folio-card.showing-partner .folio-card-art-partner { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .folio-card-art-partner { transition-duration: .01s; }
}

.folio-card.has-card-art > span,
.folio-card.has-card-art > strong,
.folio-card.has-card-art > small {
  z-index: 2;
  color: var(--ink);
  text-shadow: none;
}

.folio-card:hover,
.folio-card:focus-visible {
  z-index: 5;
  border-color: var(--accent);
  box-shadow: 0 24px 52px var(--shadow-tint);
  outline: none;
}

.folio-card-back:hover,
.folio-card-back:focus-visible { transform: rotate(-7deg) translateY(-10px); }
.folio-card-middle:hover,
.folio-card-middle:focus-visible { transform: rotate(1deg) translateY(-12px); }
.folio-card-front:hover,
.folio-card-front:focus-visible { transform: rotate(7deg) translateY(-10px); }

.folio-cards .folio-card {
  right: auto;
  width: 38%;
  /* Explicit, not left to the default: without it a card's automatic minimum height is its
     content, so a long deck name or label made that one card taller than its 5:7 neighbours —
     and the commander art, set to cover the card, zoomed in to fill the extra height. Seen on
     iOS Safari, where the phone-width cards are narrow enough for the text to outgrow them. */
  min-height: 0;
  transition: left .28s ease, top .28s ease, transform .28s ease, opacity .22s ease, box-shadow .2s, border-color .2s;
}

.folio-cards [data-folio-slot="0"] { left: 0; top: 62px; z-index: 1; transform: rotate(-14deg); }
.folio-cards [data-folio-slot="1"] { left: 15.5%; top: 32px; z-index: 2; transform: rotate(-7deg); }
.folio-cards [data-folio-slot="2"] { left: 31%; top: 18px; z-index: 3; transform: rotate(0); }
.folio-cards [data-folio-slot="3"] { left: 46.5%; top: 32px; z-index: 4; transform: rotate(7deg); }
.folio-cards [data-folio-slot="4"] { left: 62%; top: 62px; z-index: 5; transform: rotate(14deg); }
.folio-cards [data-folio-slot="0"]:hover,.folio-cards [data-folio-slot="0"]:focus-visible { z-index: 8; transform: rotate(-11deg) translateY(-10px); }
.folio-cards [data-folio-slot="1"]:hover,.folio-cards [data-folio-slot="1"]:focus-visible { z-index: 8; transform: rotate(-5deg) translateY(-12px); }
.folio-cards [data-folio-slot="2"]:hover,.folio-cards [data-folio-slot="2"]:focus-visible { z-index: 8; transform: translateY(-14px); }
.folio-cards [data-folio-slot="3"]:hover,.folio-cards [data-folio-slot="3"]:focus-visible { z-index: 8; transform: rotate(5deg) translateY(-12px); }
.folio-cards [data-folio-slot="4"]:hover,.folio-cards [data-folio-slot="4"]:focus-visible { z-index: 8; transform: rotate(11deg) translateY(-10px); }

.folio-cards.folio-moving-next [data-folio-slot="0"] { left: -15.5%; top: 88px; opacity: 0; transform: rotate(-20deg); }
.folio-cards.folio-moving-next [data-folio-slot="1"] { left: 0; top: 62px; transform: rotate(-14deg); }
.folio-cards.folio-moving-next [data-folio-slot="2"] { left: 15.5%; top: 32px; transform: rotate(-7deg); }
.folio-cards.folio-moving-next [data-folio-slot="3"] { left: 31%; top: 18px; transform: rotate(0); }
.folio-cards.folio-moving-next [data-folio-slot="4"] { left: 46.5%; top: 32px; transform: rotate(7deg); }
.folio-cards.folio-moving-previous [data-folio-slot="0"] { left: 15.5%; top: 32px; transform: rotate(-7deg); }
.folio-cards.folio-moving-previous [data-folio-slot="1"] { left: 31%; top: 18px; transform: rotate(0); }
.folio-cards.folio-moving-previous [data-folio-slot="2"] { left: 46.5%; top: 32px; transform: rotate(7deg); }
.folio-cards.folio-moving-previous [data-folio-slot="3"] { left: 62%; top: 62px; transform: rotate(14deg); }
.folio-cards.folio-moving-previous [data-folio-slot="4"] { left: 77.5%; top: 88px; opacity: 0; transform: rotate(20deg); }
.folio-cards.folio-resetting .folio-card { transition: none; }
.folio-cards.folio-arrive-next [data-folio-slot="4"] { animation: folio-arrive-right .22s ease both; }
.folio-cards.folio-arrive-previous [data-folio-slot="0"] { animation: folio-arrive-left .22s ease both; }
@keyframes folio-arrive-right { from { opacity: 0; transform: rotate(18deg) translateX(24px); } }
@keyframes folio-arrive-left { from { opacity: 0; transform: rotate(-18deg) translateX(-24px); } }
@media(prefers-reduced-motion:reduce) {
  .folio-cards .folio-card { transition: none; }
  .folio-cards.folio-arrive-next [data-folio-slot="4"],.folio-cards.folio-arrive-previous [data-folio-slot="0"] { animation: none; }
}

.folio-card-fourth,.folio-card-fifth {
  background: var(--surface-raised);
  color: var(--ink);
}

.folio-card-back[data-deck-id] {
  align-items: flex-start;
  justify-content: flex-end;
  text-align: left;
}

.folio-card-back[data-deck-id] span {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  font:800 var(--text-2xs) system-ui;
}

.folio-card.folio-folder-card {
  align-items: flex-start;
  justify-content: flex-end;
  border-color: var(--warning);
  background: var(--warning-soft);
  color: var(--ink);
  text-align: left;
}

.folio-card.folio-folder-card span {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  color: var(--warning);
  font:800 var(--text-2xs) system-ui;
}

.folio-card.folio-folder-card small {
  color: var(--muted);
}

.folio-card.folio-deck-card {
  align-items: flex-start;
  justify-content: flex-end;
  border-color: var(--accent-strong);
  background: var(--green);
  color: var(--on-inverse);
  text-align: left;
}

.folio-card.folio-deck-card.has-card-art {
  border-color: transparent;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--folio-glow-shadow), 0 18px 40px var(--shadow-tint);
}

.folio-card.folio-deck-card.has-card-art:hover,
.folio-card.folio-deck-card.has-card-art:focus-visible {
  border-color: transparent;
  box-shadow: var(--folio-glow-shadow), 0 24px 52px var(--shadow-tint);
}

.folio-card.folio-deck-card.has-card-art span,
.folio-card.folio-deck-card.has-card-art small {
  color: var(--muted);
}

.folio-card.folio-deck-card span {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  color: var(--mana-gold);
  font:800 var(--text-2xs) system-ui;
}

.folio-card.folio-deck-card small {
  color: var(--faint);
}

.folio-card.folio-back-card {
  align-items: flex-start;
  justify-content: flex-end;
  border-color: var(--inverse);
  background: var(--inverse);
  color: var(--on-inverse);
  text-align: left;
}

.folio-card.folio-back-card span {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  color: var(--mana-gold);
  font:800 var(--text-2xs) system-ui;
}

.folio-card.folio-back-card small {
  color: var(--faint);
}

@media(prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) .folio-card.folio-back-card {
    border-color: var(--on-inverse);
    background: var(--on-inverse);
    color: var(--inverse);
  }
}

:root[data-theme="dark"] .folio-card.folio-back-card {
  border-color: var(--on-inverse);
  background: var(--on-inverse);
  color: var(--inverse);
}

.folio-card.folio-empty {
  align-items: flex-start;
  justify-content: flex-end;
  background: var(--green);
  color: var(--on-inverse);
  text-align: left;
}

.folio-card.folio-empty span {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  color: var(--mana-gold);
  font:800 var(--text-2xs) system-ui;
}

.folio-card.folio-empty strong {
  color: var(--on-inverse);
}

.folio-card.folio-empty small {
  color: var(--faint);
}

.folio-paging {
  position: absolute;
  inset: 50% 14px auto;
  z-index: 3;
  display: block;
  height: 0;
  pointer-events: none;
}

.folio-paging button {
  position: absolute;
  top: 0;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
  font:700 var(--text-xl)/1 Georgia,serif;
  cursor: pointer;
  pointer-events: auto;
  transform: translateY(-50%);
  transition: transform .16s, border-color .16s, box-shadow .16s;
}

#folio-previous { left: 0; }
#folio-next { right: 0; }

.folio-paging button:hover,
.folio-paging button:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  outline: none;
  transform: translateY(-50%) scale(1.06);
}

.folio-paging button:disabled {
  color: var(--faint);
  cursor: default;
  opacity: .55;
}

@media(prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) .folio-paging button {
    background: var(--on-inverse);
    color: var(--inverse);
  }
}

:root[data-theme="dark"] .folio-paging button {
  background: var(--on-inverse);
  color: var(--inverse);
}

.folio-index {
  position: relative;
  z-index: 10;
  justify-content: space-between;
  margin-top: 12px;
  padding-right: 135px;
  background: transparent;
}

.folio-index span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media(max-width:650px) {
  .curator-visual:not(:has(.folio-folders:not(.hidden))) {
    min-height: 565px;
  }

  .curator-visual:has(.folio-folders:not(.hidden)) {
    min-height: 565px;
  }

  .folio-index {
    padding-right: 0;
  }

  .folio-index span:first-child {
    display: none;
  }

  .folio-paging { inset-inline: 6px; }
}

/* A card narrower than about 180px is too narrow for the desktop type: the label wrapped to three
   lines and names ran off the card. Smaller, tighter, and clamped to two lines each, so the text
   always fits inside the 5:7 card rather than stretching it.
   Keyed on the fan's own width rather than the viewport's, because the card size no longer
   tracks the screen: a phone held sideways and a 1280px desktop both give 150–160px cards. The
   stage can be a size container safely, since its width is set outright rather than by content.
   480px of stage is a 182px card. */
.folio-cards { container: folio / inline-size; }
@container folio (max-width: 480px) {
  .folio-cards .folio-card { padding: 12px; }
  .folio-cards .folio-card.folio-deck-card > span,
  .folio-cards .folio-card.folio-deck-card > small { letter-spacing: .06em; font-size: var(--text-2xs); line-height: 1.25; }
  .folio-cards .folio-card.folio-deck-card > strong { margin: 5px 0; font-size: var(--text-base); line-height: 1.1; }
  .folio-cards .folio-card.folio-deck-card > span,
  .folio-cards .folio-card.folio-deck-card > strong,
  .folio-cards .folio-card.folio-deck-card > small { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
}
