/* ================================================================ forge
 *
 * The fused cards-and-factions page.
 *
 * Each faction is a section: a bar with its icon, name and six card-shaped slots,
 * then that faction's cards. NO FACTION is the same section under the grey folder.
 * Nothing here reaches the other pages; nothing there reaches this one.
 */

.forge-page {
  padding: 14px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------------ band */

.forge-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.forge-band {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  /*
   * Fill the bar. As a content-sized flex item the band ended at its last chip, so
   * there was no free space for the fold-all control's auto margin to claim and it sat
   * next to "Add faction" instead of at the far right.
   */
  flex: 1;
  width: 100%;
}

.forge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.forge-chip:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
/*
 * A chip that is switched off is half there, not outlined in amber.
 *
 * The pressed state used to carry an amber tint and border, which made "on" the loud
 * state in a band where most chips are on -- every chip shouted at once. What needs to
 * be visible is the exception: the faction you have hidden.
 */
.forge-chip[aria-pressed='true'] {
  color: var(--text);
}
.forge-chip[aria-pressed='false'] {
  opacity: 0.25;
}

.forge-status {
  margin-left: auto;
  color: var(--text-faint);
  font-family: var(--font);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}


/* nothing inside a mark may escape its box */

/* ------------------------------------------------------------ the strip */

.forge-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-left: 3px solid var(--faction-color, var(--line-hot));
  border-radius: 4px;
}
.forge-strip.is-nofaction {
  border-left-color: var(--gray);
}

.forge-strip__head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  min-width: 0;
}

.forge-strip__name {
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.forge-strip__count {
  color: var(--text-faint);
  font-family: var(--font);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.forge-strip__slots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* a slot is a card outline: upright, the proportion of a card */
.forge-slot {
  /* the card's own proportion, kept small so the bar stays band-height rather than
     growing to the size of a card */
  width: 30px;
  height: 45px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.25);
  position: relative;
  /* the symbol overhangs the picture, so the slot must not clip its own contents */
  overflow: visible;
}
/*
 * A filled slot is the card itself at slot size.
 *
 * The card is rendered into .forge-slot__card, which fills the slot; the information
 * layer is hidden so what remains is the body, the frame and the picture -- a card
 * before it says anything. The ramp colour arrives as an overlay above the artwork but
 * below nothing, recolouring it without flattening the frame.
 */
.forge-slot.is-full {
  border: 0;
  background: #14161a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
.forge-slot__card {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;   /* the card scales to the slot and sits centred in it */
}
.forge-slot__card .card-fit {
  margin: 0;
}
/* the information layer: everything the card would say */
.forge-slot__card .slot.text,
.forge-slot__card .slot.name,
.forge-slot__card .slot.value,
.forge-slot__card .slot.trigger,
.forge-slot__card .slot.faction,
.forge-slot__card .slot,
.forge-slot__card .toggles {
  display: none !important;
}

.forge-slot__cost {
  position: absolute;
  top: 1px;
  left: 3px;
  font-family: var(--font);
  font-size: 0.52rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.8);
}

.forge-slot__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  padding: 0 2px;
  font-family: var(--font);
  font-size: 0.44rem;
  font-weight: 700;
  line-height: 1.05;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ----------------------------------------------------------- the cards */

#forge-host > .forge-grid:last-child {
  margin-bottom: 6px;
}
/* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . dragging


/* the bar under the pointer: the whole strip lights up, because the whole strip
   is the drop target */
.forge-strip.is-dragover {
  border-color: var(--amber);
  background: rgba(240, 144, 27, 0.1);
  box-shadow: inset 0 0 0 1px var(--amber-dim);
}
.forge-strip.is-dragover .forge-strip__slots .forge-slot {
  border-color: var(--amber-dim);
}
/* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . editing

/* the name and icon are controls, but should not look like buttons until hovered */
.forge-strip__name.is-editable,
.faction-mark.is-editable {
  cursor: pointer;
  border-radius: 2px;
}
.forge-strip__name.is-editable:hover {
  color: var(--amber-hi);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.faction-mark.is-editable:hover {
  filter: brightness(1.3);
}

/* the two colours, as dots between the name and the count */
.forge-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.forge-dot {
  width: 13px;
  height: 13px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.1s;
}
.forge-dot:hover {
  transform: scale(1.2);
}

/* a palette chip inside the colour dialog */
.forge-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sw, var(--gray));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/*
 * The card in hand.
 *
 * z-index only applies to a positioned element, and the tile is already relative from
 * the card DB's stylesheet. Without a z-index it sat in DOM order among its siblings,
 * so the cards after it drew over it -- the card looked like it was sliding underneath
 * the pile instead of being lifted off it.
 */
.card-tile.is-lifted {
  z-index: 5;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.65));
  /*
   * The dragged card sits under the pointer, so without this it is what
   * elementFromPoint reports -- and the group it belongs to is looked up from that
   * answer. Every drop then resolved to the card's own faction, which is why a card
   * could never be moved anywhere.
   */
  pointer-events: none;
}
/* the sections need room between them: a grid running straight into the next bar
   left the cards looking pressed against it */
/* tighter section spacing: 16px between every element read as a gap between
   things that belong together */
#forge-host {
  /*
   * The space between sections. A section is a ribbon, its effect and its cards -- one
   * unit -- so this is the only gap in play; the parts inside a section sit flush.
   */
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/*
 * A section is a ribbon, its effect and its cards, stacked with no space between the
 * ribbon and its own effect. The host's gap does the separating, between sections.
 */
.forge-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.forge-grid {
  margin-top: 6px;
  /* room above the next bar: the cards were sitting straight on it */
  margin-bottom: 8px;
}
/*
 * A layer is absolute, but card.css scopes that to `.card > .layer` -- which a slot is
 * not. Without this the two layers were static blocks of zero height, so a filled slot
 * showed only its own background: a coloured square with no frame.
 */
.forge-slot > .layer {
  position: absolute;
  inset: 0;
}

/* the picture is an svg at the card's coordinates, so it needs no percentages */
.forge-slot__picture {
  width: 100%;
  height: 100%;
}

/*
 * The faction's symbol on the picture: darkened like the window's lip, overhanging the
 * window's right and bottom edges by a quarter of its own size -- the folder mark's
 * treatment, rotated to the corner that has room.
 *
 * The container is the picture window and clips whatever falls outside it, so the part
 * of the mark that hangs over the edge is not drawn.
 */
.forge-slot__symbol {
  position: absolute;
  left: 11.464%;     /* the picture window */
  top: 7.637%;
  width: 77.066%;
  height: 55.539%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;   /* the part that hangs over the edge is not drawn */
  z-index: 2;
  pointer-events: none;
}

/*
 * The watermark itself: black and translucent, the same treatment as the window's lip,
 * and a quarter of its size past the right edge and down.
 *
 * Note the class: the mark is `.faction-mark` (shared with the bars and the table). The
 * darkening rules were still written against the old `.forge-mark`, so they matched
 * nothing and the watermark kept the faction's colours.
 */
.forge-slot__symbol .faction-mark {
  width: 85%;
  height: 85%;
  /* Font Awesome sizes from this while the SVG fills its box; 19px is 85% of the
     22.9px picture window in a 30px slot, so both kinds land on the same size. */
  font-size: 19px;
  transform: translate(25%, 25%);
  filter: brightness(0) opacity(0.45);
}
.forge-slot.is-empty .forge-slot__symbol {
  display: none;
}



/* ------------------------------------------------------ the section folding */

/* The whole bar is a handle: it folds its cards away and back. */
.forge-strip.is-handle {
  cursor: pointer;
  user-select: none;
}
.forge-strip.is-handle:hover {
  border-color: var(--line-hot);
}
/* ---------------------------------------------------- empty-section holders */

/* The empty places in a section: the slot outline at card size. They are grid
   children, so they land in the same columns as the cards. */
.forge-holder {
  padding: 0;
  font: inherit;
  width: var(--card-w, 164px);
  height: calc(var(--card-w, 164px) * 1.5066);   /* the card's own proportion */
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
}
/* only the one that adds a card behaves like a control */
.forge-holder--add {
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

/* ------------------------------------------------- add and delete controls */

/* The trash sits at the end of the bar, revealed on hover like the card DB's. It only
   appears where there is something to delete. */
.forge-strip .card-delete {
  position: absolute;
  right: 8px;
  bottom: 6px;
  top: auto;
  opacity: 0;
  transition: opacity 0.12s;
}

.forge-strip {
  position: relative;
}
.forge-strip:hover .card-delete,
.forge-strip .card-delete:focus-visible {
  opacity: 1;
}


/* "Add faction" reads as a chip but is an action, not a filter */
.forge-chip--add {
  border-style: dashed;
  color: var(--amber-dim);
}
.forge-chip--add:hover {
  color: var(--amber-hi);
  border-color: var(--amber);
}

/* ----------------------------------------------------------- the table view */

.forge-table-wrap {
  margin-top: 4px;
}
.forge-table-faction {
  white-space: nowrap;
}
.forge-table-faction .forge-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
  cursor: default;
}
/*
 * The faction's name, not "the last span in the row".
 *
 * It was written as `span:last-child`, which also matches the label inside every tag --
 * a tag's own label is a span and it is the last child of the tag. So every filled tag
 * in a faction row got the muted grey meant for the name, while the same tag on a card
 * row stayed white.
 */
.forge-table-faction .faction-chip__name {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--gray);
}
/* a cell is a button so it can be clicked, but should not look like one */
.cell-edit {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  text-align: left;
  cursor: text;
}
.cell-edit:hover {
  border-color: var(--line);
  background: var(--ink-800);
}
.cell-edit.is-blank::after {
  content: '—';
  color: var(--line-hot);
}
.forge-table-wrap .is-text .cell-edit {
  white-space: normal;
  line-height: 1.4;
}


/* the two fields in the notes dialog */
.forge-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.forge-field > span {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray);
}
.forge-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--ink-900);
  color: var(--paper);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.45;
  resize: vertical;
}
.forge-input:focus {
  outline: none;
  border-color: var(--amber-dim);
}

/* ------------------------------------------------- the function menu */

/* Forge uses the card DB's head; the only addition is that the band sits under it. */
.forge-head {
  margin-bottom: 10px;
}
.forge-bar {
  margin-bottom: 14px;
}


/*
 * The artwork fills the box on both axes, whatever its intrinsic size -- and as a
 * descendant rule, because iconElement wraps the svg rather than returning it. The
 * overflow guard is the belt to that braces: nothing inside a mark may escape it.
 */
.faction-mark svg,
.faction-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

/* ------------------------------------------------------ the faction's effect */

/*
 * A full-width bar directly under the ribbon, the width of the section rather than the
 * ribbon's own contents -- the faction's rule reads across the group it governs.
 */
.forge-effect {
  display: flex;
  /* the bar centres its line against its own height; nothing about the text changes */
  align-items: center;
  /*
   * The bar is as tall as its tallest line, which is a keyword tag -- not a fixed
   * height guessed from the text. A floor keeps a faction with no tags from collapsing
   * to the height of one short line.
   */
  min-height: 30px;
  padding: 8px 14px;
  /*
   * No negative margin. It was pulling the bar up under the ribbon to close the gap,
   * which buried the top of any tag taller than a line of text -- the tags were being
   * cut by the ribbon above them, and the words looked pressed against the top edge.
   */
  margin-top: 0;
  background: #000;
  border: 1px solid var(--line);
  border-left: 3px solid var(--faction-color, var(--line));
  border-radius: 0 0 4px 4px;
  cursor: text;
}
.forge-effect__text {
  /*
   * Inline flow, with the words and the tags in the same line box.
   *
   * Flex made each word fragment and each tag its own box, which dropped the spaces
   * around the tags -- the spacing had to be reintroduced as a gap, and a gap is not a
   * space: the effect here stopped matching the same effect on the factions table. The
   * tags now have a real height from their own stylesheet, so inline flow centres them
   * without any help.
   */
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--paper);
}
/* an empty effect invites the click instead of pretending to say something */
.forge-effect__text.is-empty {
  color: var(--gray);
  font-style: italic;
}
.forge-effect__text.is-empty:hover {
  color: var(--amber-dim);
}

/*
 * A tag inside the effect bar keeps its own width: as a flex item it would otherwise
 * shrink to fit the row and lose its pointed end, which is what was clipped.
 */

/* the one place in NO FACTION that is always empty, so a card can always be added */
.forge-holder--add {
  display: grid;
  place-items: center;
  color: var(--amber-dim);
  font-size: 1.1rem;
}
.forge-holder--add:hover {
  color: var(--amber-hi);
  border-color: var(--amber-dim);
  background: rgba(240, 144, 27, 0.06);
}

/* the faction's trash, at the right end of its effect bar */
.forge-effect__delete {
  position: static;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.12s;
}
.forge-effect:hover .forge-effect__delete,
.forge-effect__delete:focus-visible {
  opacity: 1;
}

/*
 * The open/close-all control reads as an action, like "Add faction", and sits at the
 * far right: it acts on the whole band rather than following the faction it is next to.
 */
.forge-chip--fold {
  margin-left: auto;
  border-style: dashed;
  color: var(--gray);
}
.forge-chip--fold:hover {
  color: var(--paper);
  border-color: var(--line-hot);
}

/* ------------------------------------------------- the table's faction rows */

/*
 * A faction's own line, above the cards that belong to it: the band's relationship of
 * ribbon to contents, carried into the table.
 */
.cards-table tr.forge-table-faction > td {
  /*
   * The card table gives every cell but the effect one `width: 1%` so the columns stay
   * narrow. A faction row spans them all, but it is still a first child, so it took that
   * 1% and the whole line -- name, effect and comment -- was squeezed into the width of
   * the name column. Forced here rather than merely set: the comment's place depends on
   * this cell being the full width of the table.
   */
  width: auto !important;
  white-space: normal !important;
  padding: 5px 10px 4px;
  background: var(--ink-850);
  border-top: 2px solid var(--faction-color, var(--line));
}
.forge-table-faction__line {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: text;
}
/*
 * The card's effect cell, in every respect that affects a tag.
 *
 * A tag's height is 1.75em, and that em resolves against the text it sits in -- so the
 * faction row's smaller type made its tags smaller too, and neither matched the other.
 * Matching the card cell's font-size and line-height is what makes the two rows render
 * the same tag the same size; the tag itself has no size of its own to set.
 */
.forge-table-faction__effect {
  padding: 4px 0;          /* the same clickable height as the comment beside it */
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--gray);
}
/*
 * The same tag size a card's effect cell uses, and only that.
 *
 * `.cards-table td.is-text .tag` sets --tag-h: 1.75em; the faction row was taking the
 * stylesheet's default 28px, so the identical tag came out larger here than two rows
 * above. Repeating the two declarations rather than borrowing the class keeps the
 * cell's font-size and colour out of it.
 */
/*
 * The card's rule, copied exactly.
 *
 * `--tag-h` defaults to 28px in the keywords stylesheet and the card's effect cell
 * overrides it to 1.75em. Without the override here the same tag drew at the default,
 * visibly larger than two rows above. I removed this once believing it was circular;
 * it is not -- it is the only thing that sets the tag's height.
 */


/* a grid with no ribbons still says which faction's cards these are */
.forge-label {
  margin: 4px 0 0;
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faction-color, var(--gray));
}

/* a chip being dragged: lifted off the band, following the pointer */
.forge-chip.is-dragging {
  position: relative;
  z-index: 5;
  opacity: 0.9;
  cursor: grabbing;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55);
}
.forge-chip[data-faction-id]:not([data-faction-id='']) {
  cursor: grab;
}

/*
 * The comment, which only the table's faction row has room for.
 *
 * Pushed to the far right rather than following the effect: it is a note about the
 * faction, not the next clause of its rule, and a margin of auto is what separates the
 * two without a second row.
 */
/*
 * The comment takes the room the effect leaves, and its text sits at the right end of
 * that room.
 *
 * It was pushed there with `margin-left: auto`, which left a gap the width of the row
 * with nothing in it. Taking the space instead means the comment's own box runs from the
 * effect to the edge, and `text-align: right` puts the words where they were -- without
 * a hole between them.
 */
/*
 * The comment takes the room the effect leaves, and its text sits at the right end of
 * that room -- with enough height to aim at. It is small italic type with nothing else
 * around it, so as a click target it was a thin strip.
 */
.forge-table-faction__comment {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 0 4px 24px;
  text-align: right;
  font-size: 0.78rem;
  line-height: 1.6;
  font-style: italic;
  color: var(--text-dim);
}
.forge-table-faction__comment.is-empty {
  color: var(--line-hot);
  opacity: 0.8;
}
.forge-table-faction__comment:hover {
  color: var(--amber-dim);
}
.forge-table-faction__effect.is-empty {
  color: var(--line-hot);
}

/* ------------------------------------------- a miniature folder inside a chip */

/*
 * The chip IS the folder, drawn by the same renderer the factions page uses.
 *
 * The stage is 192.8 x 146.4; at 0.332 it is 64 x 49. Every chip is that size, so the
 * band is a row of equal folders rather than pills whose width depends on how long a
 * faction's name is. The scale came down once, when the name grew into the plate and
 * made 96px look top-heavy.
 */
.forge-chip__folder {
  position: relative;
  flex: none;
  width: 64px;
  height: 49px;
  overflow: hidden;
  border-radius: 3px;
}
.forge-chip__folder .folder-stage {
  transform: scale(0.332);
  transform-origin: top left;
  filter: none;              /* the band is already dense; the folder's shadow muddied it */
  pointer-events: none;      /* the chip is the control, not the artwork inside it */
}

/*
 * What the chip shows of its folder: the artwork, the three slashes and the faction's
 * symbol -- the parts that identify a folder at a glance.
 *
 * The name plate, the colour dots and the effect panel are its content, and inside a
 * chip they would repeat the label beside them, crowd a 31px mark, and drag the effect
 * text into the band. Those are hidden.
 */
/* the folders' name plate is the chip's label now */
.forge-chip__folder .folder-effect,
.forge-chip__folder .folder-dot {
  display: none;
}

/*
 * A chip that holds a folder has no pill of its own: the folder is the shape. The chip's
 * padding and border would only add a margin of empty space around artwork that already
 * has an outline of its own.
 */
.forge-chip:has(.forge-chip__folder) {
  /*
   * Positioned, so the ring is absolutely placed against the chip. Without this it was
   * placed against the page, which is why one chip's outline covered the whole window.
   */
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 3px;
  /* the folder clips its own contents; the chip must not clip the hover ring */
  overflow: visible;
}
.forge-chip:has(.forge-chip__folder):hover {
  background: none;
}
.forge-chip:has(.forge-chip__folder):hover .forge-chip__folder {
  filter: brightness(1.12);
}

/*
 * The chip's edge: the folder's own path, stroked.
 *
 * `edge` is always there and `ring` appears on hover. Two paths rather than a filter
 * chain: a stroke costs nothing after layout, where four drop-shadows meant every chip
 * was rasterised on every repaint.
 */
.forge-chip__edge,
.forge-chip__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /*
   * The stroke is centred on the path, so half of it falls outside the folder's edge.
   * `visible` lets it draw there instead of shrinking the box to fit it.
   */
  overflow: visible;
  z-index: 3;
  pointer-events: none;
}
.forge-chip__edge {
  color: rgba(0, 0, 0, 0.92);
}
.forge-chip__ring {
  color: var(--paper);
  opacity: 0;
  transition: opacity 0.12s;
}
.forge-chip:has(.forge-chip__folder):hover .forge-chip__ring {
  opacity: 1;
}

/* ------------------------------------------------- an empty folder to add one */

/* The add control matches the chips either side of it: same footprint, folder-shaped */
.forge-chip--add {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 49px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--amber-dim);
  overflow: visible;
}
.forge-chip--add__outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.forge-chip--add i {
  position: relative;
  /*
   * Down and heavier. The folder's body starts below its tab, so the visual centre of the
   * shape is lower than the middle of its box -- a centred plus sat in the tab. The
   * weight is raised because a hairline plus on a dashed outline reads as part of the
   * drawing rather than as a control.
   */
  transform: translateY(14%);
  font-size: 0.95rem;
  font-weight: 900;
  -webkit-text-stroke: 1px currentColor;
}
.forge-chip--add:hover {
  color: var(--amber-hi);
  background: none;
}

/* ======================================================== column widths

   Forge loads cards.css, keywords.css and factions.css -- the last of which was written
   for the factions page, where column 4 is the effect rather than the trigger. Its table
   rules are scoped to that page now, but the card table's own widths still lost the
   argument somewhere: the Trigger column kept taking space it had no content for.

   Stated here, last and specific: the trigger column is as wide as its content and no
   wider, and the effect column takes the rest.
   ==================================================================== */

.cards-table th:nth-child(4),
.cards-table td.is-trigger {
  width: 1px !important;
  white-space: nowrap;
}
.cards-table th:not(:nth-child(6)),
.cards-table td:not(.is-text):not(.is-actions) {
  width: 1px !important;
  white-space: nowrap;
}
.cards-table th:nth-child(6),
.cards-table td.is-text {
  width: 100% !important;
  white-space: normal !important;
}

/*
 * A folded section: the bar stays, the cards go.
 *
 * Done with a class rather than by rebuilding the section, so folding and unfolding are
 * a style change instead of a redraw.
 */
/*
 * Folded: the bar stays, everything the section shows underneath it goes -- the cards and
 * the faction's effect bar, which was staying behind and reading as an open section.
 */
.forge-section.is-folded .forge-grid,
.forge-section.is-folded .forge-effect {
  display: none;
}

/*
 * Sections the browser may skip until they are scrolled near.
 *
 * The whole page is built at once, and a faction's section is a heavy subtree: a folder,
 * six slot previews, and a full card per card. `content-visibility: auto` lets the
 * browser leave the layout and paint of an off-screen section until it is needed, which
 * is most of the benefit of a virtual list with none of its risk -- every node is still
 * in the DOM, so find-in-page, search filtering and in-place editing all keep working.
 *
 * `contain-intrinsic-size` gives the skipped section a remembered height so the
 * scrollbar does not jump as they come into view.
 */
.forge-section {
  content-visibility: auto;
  contain-intrinsic-size: auto 260px;
}

/*
 * A card tile reserves its space before its card is drawn, so deferring the card does not
 * make the page jump as tiles fill in.
 */
.card-tile__stage {
  min-height: calc(var(--card-w) * 1.5066);
}

/* ============================================================ the sticky header

   The controls and the band stay at the top of the window while the cards scroll, so a
   filter, a faction or a row mode is always one click away -- scrolling to the bottom of
   a long collection used to mean scrolling back to reach them.
   ======================================================================== */

.forge-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  /*
   * A background is required, not decoration: the sections pass underneath it, and
   * without one the cards would scroll through the controls.
   */
  background: var(--ink-900);
  /*
   * The page's own padding is on `.forge-page` (14px 18px 40px), so the header cancels
   * the sides and adds them back: it spans the content width, not the window, and the
   * cards cannot show through the gap beside it.
   */
  margin: 0 -18px;
  padding: 0 18px;
  /* a hairline, so it reads as a layer over the list rather than part of it */
  box-shadow: 0 1px 0 var(--line);
}

/*
 * The filter is a long field: it takes lanes, keywords and several words at once, and the
 * placeholder that explains the syntax needs the room.
 */
.card-filter--wide {
  min-width: 420px;
}
.card-filter--wide input {
  width: 100%;
}

/*
 * Clear: the field is the only way back to the whole collection, so emptying it should not
 * mean selecting the text and deleting it.
 */
.card-filter__clear {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.7rem;
}
.card-filter__clear:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.08);
}
.card-filter__clear[hidden] {
  display: none;
}

/* ================================================================ selection

   A card is picked with a check at its top left, the delete button's opposite corner, so
   nothing moves and the two actions mirror each other.
   =================================================================== */

.card-pick {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(12, 14, 17, 0.82);
  color: var(--text-faint);
  cursor: pointer;
  /* the delete button's size and icon scale, on the other corner */
  font-size: 0.92rem;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}

/* visible on hover, and always when it is on -- a picked card says so at a glance */
.card-tile:hover .card-pick,
.card-tile:focus-within .card-pick,
.card-pick[aria-pressed='true'] {
  opacity: 1;
}

.card-pick[aria-pressed='true'] {
  color: var(--ink-900);
  background: var(--amber);
  border-color: var(--amber);
}

.card-pick:hover {
  color: var(--paper);
  border-color: var(--amber);
}

/* the tile itself, so a picked card reads as picked at card scale too */
.card-tile.is-picked .card-tile__stage {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 3px;
}

/* the ribbon's select-all */
.forge-strip__pick {
  margin-left: 6px;
  padding: 3px 5px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.62rem;
}
.forge-strip__pick:hover {
  color: var(--amber);
  background: rgba(255, 255, 255, 0.06);
}

/* the faction's card, next to its name in the ribbon */
.forge-strip__card {
  margin-left: 4px;
  padding: 3px 5px;
  border-radius: 3px;
  color: var(--text-faint);
  font-size: 0.62rem;
  text-decoration: none;
}
.forge-strip__card:hover {
  color: var(--amber);
  background: rgba(255, 255, 255, 0.06);
}

/* a picked faction says so, like a picked card does */
.forge-strip__card[aria-pressed='true'] {
  color: var(--ink-900);
  background: var(--amber);
}
.forge-strip__card[aria-pressed='true']:hover {
  color: var(--ink-900);
  background: var(--amber-hi);
}

/* the faction cards built for printing: they exist for the sheet, not for the page */
#forge-faction-sheet {
  display: none;
}

/* ============================================== a chip's two states

   Hovering lifts a chip a couple of pixels, which is a pointer affordance and nothing more.
   A chip whose faction is completely picked keeps the ring that hover shows, so the two
   states are distinct: one follows the pointer, the other stays.
   ================================================= */

.forge-chip:has(.forge-chip__folder) {
  transition: transform 0.12s;
}

.forge-chip:has(.forge-chip__folder):hover {
  transform: translateY(-2px);
}

/* fully picked: the ring stays on */
.forge-chip.is-picked .forge-chip__ring {
  opacity: 1;
}

/* the comment sits at the far end of the effect bar, as it does in the table */
.forge-effect {
  display: flex;
  align-items: center;
  gap: 18px;
}
/* the effect takes what it needs; the comment takes everything else */
.forge-effect__text {
  flex: 0 1 auto;
  min-width: 0;
}
.forge-effect__comment {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 0 0 18px;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: right;
  /*
   * One line, always: the bar is a single row the height of the ribbon's note line, and a
   * comment long enough to wrap would make one faction's section taller than its neighbours.
   * The ellipsis is the honest end of it -- the whole note is in the table's column, on the
   * folder's panel and on the back of the faction's card.
   */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.forge-effect__comment:hover {
  color: var(--amber-hi);
}
.forge-effect__comment.is-empty {
  color: var(--text-faint);
  font-style: italic;
}
