/* The text tile on the static pages (public/static/card-tile.js): the card drawn from its
   data where its picture cannot be had, the same tile the app draws
   (apps/frontend/src/ui/cards/card_tile.rs; docs/reference/card-tiles.md, "The static pages").

   Two parts, as card-preview.css copies the app's rules:

   1. The app's tokens the tile reads, which the static pages do not define (or define for
      their own surfaces): the mana colors, the on-media ink pair, the frame palette
      (--frame-*), the radii and spacing. The values are styles/variables.css's and
      Midnight's (the template's shared values), scoped to the tile so nothing else on the
      page changes. The tile is one picture on every theme, as in the app, so these never
      follow the page. The app's body face is set too: the tile's small print (the printing,
      the notice) is in the app's face, not the article's.
   2. styles/card-tile.css, copied whole and unchanged below the marker line. Do not edit it
      here: change styles/card-tile.css and copy it again. static_pages::card_tile fails when
      the copy and the app's file differ.

   The tile is `position: absolute; inset: 0` and fills its parent, as in the app; the
   parent is a positioned box with a card's proportions. `.amx-tile-host` is one
   (AMXCardTile.render(card, { host: true })). */

.card-tile,
.card-constellation {
    --mtg-white-mana: #F0EFD8;
    --mtg-blue-mana: #4a90d9;
    --mtg-black-mana: #20242a;
    --mtg-red-mana: #e05c4b;
    --mtg-green-mana: #5cb85c;
    --mtg-generic-mana: #706e6eff;
    --mtg-multicolor: #CFB53B;
    --on-media-ink: #ffffff;
    --on-media-scrim: #000000;
    --frame-classic-surface: #161b22;
    --frame-classic-deep: #0d1117;
    --frame-classic-line: #30363d;
    --frame-classic-line-soft: #30363dcc;
    --frame-classic-text: #e6edf3;
    --frame-classic-text-muted: #8b949e;
    --frame-light-surface: #ffffff;
    --frame-light-deep: #e9edf4;
    --frame-light-line: #d5dbe6;
    --frame-light-line-soft: #d5dbe6cc;
    --frame-light-text: #131a26;
    --frame-light-text-muted: #3f4a5c;
    --frame-sky: #05070d;
    --frame-rarity-uncommon: #BBC5D5;
    --frame-rarity-rare: #FFE182;
    --frame-rarity-mythic: #FF9550;
    --frame-rarity-special: #A77BD6;
    --frame-rarity-bonus: #5CC8C0;
    --radius-pill: 999px;
    --radius-round: 50%;
    --radius-card: 4.75% / 3.5%;
    --space-px: 1px;
    --space-1: 0.25rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-style: normal;
    letter-spacing: normal;
}

/* A box with a card's proportions for the tile to fill. */
.amx-tile-host {
    position: relative;
    width: 100%;
    aspect-ratio: 63 / 88;
}

/* ── styles/card-tile.css, unchanged ─────────────────────────────────────── */
/* Alegreya by Huerta Tipografica, SIL OFL 1.1; self-hosted for preview and PNG export. */
@font-face {
    font-family: "Alegreya";
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url("/public/assets/fonts/alegreya/Alegreya-Regular.ttf") format("truetype");
}
@font-face {
    font-family: "Alegreya";
    font-style: italic;
    font-weight: 400 900;
    font-display: swap;
    src: url("/public/assets/fonts/alegreya/Alegreya-Italic.ttf") format("truetype");
}
/* Grenze by Omnibus-Type, SIL OFL 1.1: the title face (name, type line, corner
   box). A Roman cut with blackletter's bite, engraved rather than printed, and
   narrower than Alegreya's bold, so a name the fitter sized for Alegreya fits. */
@font-face {
    font-family: "Grenze";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("/public/assets/fonts/grenze/Grenze-Variable.ttf") format("truetype");
}

/* The text tile (ui/cards/card_tile.rs): a card drawn from its data where its
   picture cannot be had, and the frame a custom card will be drawn in.

   A card's reading order (name and cost, art, type line, rules, the corner
   box, then the printing) in ArcaneMetriX's own frame, which copies no part
   of a printed card: a black border, wide on the left; on that side a spine
   in the card's colors (the app's graph; the Genome's deck column) with a
   node beside each thing the card says (the name, the type line, where the
   color indicator sits, the start of the rules, and the printing); a framed
   title, embellished on a legendary card; a constellation over a dot grid for
   art; the X mark in the rarity's color where a set symbol would sit; a
   hexagonal seal set into the frame's bottom edge; and, on the border under
   the frame, the printing and a line saying what the tile is. Tokens only.

   Every size is in container units against the tile's own width, so one tile
   is the same tile at every size, as a card's picture is. The tile is the
   container; an element cannot query itself, so the sizes live on the body
   and below.

   Nothing wraps or runs off. CSS cannot fit text to a box, so the code works
   the sizes out from the text and sets them inline: --name-size and
   --type-size (each fitted to one line), --rules-size and --art-height (how
   the rules text and the art box share the tile; the code also decides what
   of a long card's rules is drawn). The
   geometry below and the constants in card_tile.rs are the same numbers:
   change one, change the other. Also inline: the framing's color --tile-trim,
   the frame's ground --tile-wash-a / -m / -b and the rules plate's tint
   --tile-box-a / -m / -b (each left to right), a texture layer's --weave, a band's
   --band-label / --band-stats, the indicator's fill --tile-indicator, the
   mark's --tile-rarity, a hand-drawn pip's --pip-a / --pip-b / --pip-ink, and a
   Fuse card's --fuse-size. A card whose faces share a side, and a Battle's
   front, sets each face's frame on the tile as the printed card does (see
   the section at the end).

   Color is never the only thing that says a card's color: each color,
   colorless, gold and the land frame has a texture of its own on the ground
   (.card-tile-weave--*). */

/* The frame style (TileFrame, card-tile--frame-*): a card is one picture, the
   same on every theme of the app, so the tile does not read the theme's
   surfaces and text. It sets the names the rules below read to a fixed
   palette of its own (styles/variables.css, --frame-*): Classic, dark plates
   and ground; Classic Light, light ones. Constellation Borderless (at the end)
   is the classic palette, see-through, over a night sky. The art crop
   (.card-constellation) draws in the classic palette too. */
.card-tile,
.card-constellation {
    --text-color: var(--frame-classic-text);
    --text-secondary: var(--frame-classic-text-muted);
    --panel-bg-opaque: var(--frame-classic-surface);
    --bg-tertiary: var(--frame-classic-deep);
    --border-primary: var(--frame-classic-line);
    --border-color: var(--frame-classic-line-soft);
    --rarity-uncommon: var(--frame-rarity-uncommon);
    --rarity-rare: var(--frame-rarity-rare);
    --rarity-mythic: var(--frame-rarity-mythic);
    --rarity-special: var(--frame-rarity-special);
    --rarity-bonus: var(--frame-rarity-bonus);
}

.card-tile--frame-light {
    --text-color: var(--frame-light-text);
    --text-secondary: var(--frame-light-text-muted);
    --panel-bg-opaque: var(--frame-light-surface);
    --bg-tertiary: var(--frame-light-deep);
    --border-primary: var(--frame-light-line);
    --border-color: var(--frame-light-line-soft);
}

.card-tile {
    /* The border (TileBorder, card-tile--border-*): its fill, the one color of it for
       rings and lines drawn in it, the ink printed on it (the printing, the notice, the
       fuse line), and the spine's black and white as they show on it. Black by default;
       the light borders below switch the ink to dark, so what is printed on a border is
       always readable whatever the border. The fill is always an image (a flat
       gradient on black), so it can be a layer under the fuse bar's outline. */
    --tile-border-fill: linear-gradient(var(--on-media-scrim), var(--on-media-scrim));
    --tile-border-solid: var(--on-media-scrim);
    --tile-on-border: var(--on-media-ink);
    --tile-seal-shine: var(--on-media-ink);
    --tile-side-black: color-mix(in srgb, var(--mtg-black-mana) 55%, var(--on-media-ink));
    --tile-side-white: var(--mtg-white-mana);
    --tile-side-gold: var(--mtg-multicolor);
    position: absolute;
    inset: 0;
    container-type: inline-size;
    /* The body's corners, so a ring a host puts on the tile follows them. */
    border-radius: var(--radius-card);
}

/* The light borders: dark ink on them, black drawn as itself and white pulled toward
   the dark ink. Silver and gold catch the light across the card, as metal does. */
.card-tile--border-white,
.card-tile--border-silver,
.card-tile--border-gold {
    --tile-on-border: var(--on-media-scrim);
    --tile-seal-shine: color-mix(in srgb, var(--on-media-scrim) 22%, var(--on-media-ink));
    --tile-side-black: var(--mtg-black-mana);
    --tile-side-white: color-mix(in srgb, var(--mtg-white-mana) 40%, var(--on-media-scrim));
}

.card-tile--border-white {
    --tile-border-fill: linear-gradient(135deg, var(--on-media-ink), color-mix(in srgb, var(--on-media-ink) 90%, var(--mtg-generic-mana)));
    --tile-border-solid: var(--on-media-ink);
}

.card-tile--border-silver {
    --tile-border-fill: linear-gradient(135deg,
        color-mix(in srgb, var(--on-media-ink) 80%, var(--mtg-generic-mana)),
        color-mix(in srgb, var(--on-media-ink) 52%, var(--mtg-generic-mana)) 45%,
        color-mix(in srgb, var(--on-media-ink) 74%, var(--mtg-generic-mana)) 70%,
        color-mix(in srgb, var(--on-media-ink) 50%, var(--mtg-generic-mana)));
    --tile-border-solid: color-mix(in srgb, var(--on-media-ink) 64%, var(--mtg-generic-mana));
}

.card-tile--border-gold {
    --tile-border-fill: linear-gradient(135deg,
        color-mix(in srgb, var(--mtg-multicolor) 72%, var(--on-media-ink)),
        var(--mtg-multicolor) 40%,
        color-mix(in srgb, var(--mtg-multicolor) 84%, var(--on-media-scrim)) 70%,
        color-mix(in srgb, var(--mtg-multicolor) 80%, var(--on-media-ink)));
    --tile-border-solid: var(--mtg-multicolor);
    /* Gold on gold would not show: a gold card's spine is darkened on it. */
    --tile-side-gold: color-mix(in srgb, var(--mtg-multicolor) 45%, var(--on-media-scrim));
}

/* The border: black on every theme, as a card's is, so the frame reads as a
   card against any surface and the small print under it has full contrast.
   It is wide on the left, where the spine runs: the spine's colors show best
   on black. */
.card-tile-body {
    /* The frame color pulled toward the text color, so lines drawn in it
       show on every theme, the black frame on a dark one included. */
    --tile-ink: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 45%, var(--text-color));
    --tile-edge: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 64%, var(--border-primary));
    /* The same for what is drawn on the border, which is black on every
       theme: pulled toward the border's own light ink, not the theme's text
       color, which is dark on a light theme. */
    --tile-border-ink: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 45%, var(--tile-on-border));
    /* Print grain: fractal noise in greys about the middle, laid over a plate's
       color with background-blend-mode: overlay, so it lightens and darkens the
       plate alike on a dark theme or a light one and never changes its hue. Its
       size is in the tile's units, so the grain is the same at every size. The
       plates take the full grain; the frame's ground, under its texture, the
       soft one. Far below the contrast of the printed words. */
    --tile-paper-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27g%27%20color-interpolation-filters%3D%27sRGB%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%270.8%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270.55%200%200%200%200.225%200.55%200%200%200%200.225%200.55%200%200%200%200.225%200%200%200%200%201%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27180%27%20height%3D%27180%27%20filter%3D%27url%28%23g%29%27%2F%3E%3C%2Fsvg%3E") 0 0 / 36cqw 36cqw;
    --tile-ground-grain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27180%27%20height%3D%27180%27%3E%3Cfilter%20id%3D%27g%27%20color-interpolation-filters%3D%27sRGB%27%3E%3CfeTurbulence%20type%3D%27fractalNoise%27%20baseFrequency%3D%270.7%27%20numOctaves%3D%272%27%20stitchTiles%3D%27stitch%27%2F%3E%3CfeColorMatrix%20values%3D%270.45%200%200%200%200.275%200.45%200%200%200%200.275%200.45%200%200%200%200.275%200%200%200%200%201%27%2F%3E%3C%2Ffilter%3E%3Crect%20width%3D%27180%27%20height%3D%27180%27%20filter%3D%27url%28%23g%29%27%2F%3E%3C%2Fsvg%3E") 0 0 / 44cqw 44cqw;
    /* The trim: the band every plate and the frame are edged in, the framing's
       color at near full strength, and the light that catches it. Lit from
       above: a highlight on a band's top edge, a dark groove inside it; plates
       that stand on the frame (the title, the type line, the corner box) cast a
       shadow down onto it, and the rules plate and the art window are sunk into
       it. All of it is drawn as shadows, so none of it takes room the fitting
       counted. */
    --tile-trim-band: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 82%, var(--border-primary));
    --tile-bevel-light: color-mix(in srgb, var(--on-media-ink) 34%, transparent);
    --tile-bevel-dark: color-mix(in srgb, var(--on-media-scrim) 55%, transparent);
    --tile-lift: color-mix(in srgb, var(--on-media-scrim) 50%, transparent);
    /* The border's left side, the spine in the middle of it, and how far a
       row's content sits in from the frame's own edges. */
    /* The rules plate's own surface, and how much of the card's colors it
       takes: little on a spell, more on a land, whose plate says what it
       makes. */
    --tile-plate: color-mix(in srgb, var(--text-color) 5%, var(--panel-bg-opaque));
    --tile-box-share: 9%;
    --tile-side: 8cqw;
    --tile-spine-x: 4.1cqw;
    --tile-inset: 3.4cqw;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
    padding: 2.4cqw 2.4cqw 0 var(--tile-side);
    overflow: hidden;
    background: var(--tile-border-fill);
    border-radius: var(--radius-card);
    color: var(--text-color);
    font-size: 4.6cqw;
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
}

/* The frame: everything but the small print. Nothing in it is clipped by it,
   so the nodes its rows hang on the spine can sit outside it. */
.card-tile-frame {
    position: relative;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
    /* Its own stacking context, so the texture can sit under its rows. */
    isolation: isolate;
    /* The ground: the card's color; two or three blend across it from left to
       right; four or five are gold (tone_style). */
    /* Over it, the soft grain and the light: brighter toward the top left,
       falling off toward the bottom right, as a card held under a lamp. */
    background:
        var(--tile-ground-grain),
        linear-gradient(160deg, color-mix(in srgb, var(--on-media-ink) 8%, transparent), transparent 40%, transparent 60%, color-mix(in srgb, var(--on-media-scrim) 22%, transparent)),
        linear-gradient(to right,
            color-mix(in srgb, var(--tile-wash-a, var(--mtg-generic-mana)) 24%, var(--panel-bg-opaque)),
            color-mix(in srgb, var(--tile-wash-m, var(--mtg-generic-mana)) 24%, var(--panel-bg-opaque)),
            color-mix(in srgb, var(--tile-wash-b, var(--mtg-generic-mana)) 24%, var(--panel-bg-opaque)));
    background-blend-mode: overlay, normal, normal;
    border: 1px solid var(--tile-edge);
    /* The trim band, its highlight and shade, the groove inside it, and the
       ground sunk under it. */
    box-shadow:
        inset 0 0.25cqw 0 var(--tile-bevel-light),
        inset 0 -0.25cqw 0 var(--tile-bevel-dark),
        inset 0 0 0 1cqw var(--tile-trim-band),
        inset 0 0 0 1.25cqw var(--tile-bevel-dark),
        inset 0 0.6cqw 2.4cqw 1.25cqw color-mix(in srgb, var(--on-media-scrim) 30%, transparent);
    border-radius: 3cqw;
}

/* The texture over the frame's ground: one layer for
   each of the card's colors, so color is not told by hue alone. A card of two
   or three colors has each color's texture where its ground is that color,
   one fading into the next as the ground blends. */
.card-tile-weave {
    position: absolute;
    /* Inside the trim band, which is painted under it. */
    inset: 1.25cqw;
    z-index: -1;
    overflow: hidden;
    border-radius: 1.75cqw;
    pointer-events: none;
}

.card-tile-weave-layer {
    /* The layer's color pulled toward the text color, as the frame's lines
       are, and thinned well into the ground: a texture, not a drawing. */
    --weave-ink: color-mix(in srgb, color-mix(in srgb, var(--weave, var(--mtg-generic-mana)) 55%, var(--text-color)) 11%, transparent);
    position: absolute;
    inset: 0;
}

.card-tile-weave[data-layers="2"] > :nth-child(1) {
    -webkit-mask-image: linear-gradient(to right, var(--on-media-scrim) 36%, transparent 64%);
    mask-image: linear-gradient(to right, var(--on-media-scrim) 36%, transparent 64%);
}

.card-tile-weave[data-layers="2"] > :nth-child(2) {
    -webkit-mask-image: linear-gradient(to right, transparent 36%, var(--on-media-scrim) 64%);
    mask-image: linear-gradient(to right, transparent 36%, var(--on-media-scrim) 64%);
}

.card-tile-weave[data-layers="3"] > :nth-child(1) {
    -webkit-mask-image: linear-gradient(to right, var(--on-media-scrim) 22%, transparent 42%);
    mask-image: linear-gradient(to right, var(--on-media-scrim) 22%, transparent 42%);
}

.card-tile-weave[data-layers="3"] > :nth-child(2) {
    -webkit-mask-image: linear-gradient(to right, transparent 22%, var(--on-media-scrim) 42%, var(--on-media-scrim) 58%, transparent 78%);
    mask-image: linear-gradient(to right, transparent 22%, var(--on-media-scrim) 42%, var(--on-media-scrim) 58%, transparent 78%);
}

.card-tile-weave[data-layers="3"] > :nth-child(3) {
    -webkit-mask-image: linear-gradient(to right, transparent 58%, var(--on-media-scrim) 78%);
    mask-image: linear-gradient(to right, transparent 58%, var(--on-media-scrim) 78%);
}

/* Masks provide shape only; their alpha is tinted by the theme-derived ink.
   The parent keeps the multicolor fade, independently of the repeating motif. */
.card-tile-weave-layer::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--weave-ink);
    -webkit-mask-image: var(--weave-pattern);
    mask-image: var(--weave-pattern);
    -webkit-mask-size: var(--weave-size);
    mask-size: var(--weave-size);
    mask-mode: alpha;
    pointer-events: none;
}

/* Woven ivory lozenges, offset by half a repeat; no radiating light. */
.card-tile-weave--white {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2040%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M10%201l9%209-9%209-9-9zM30%2021l9%209-9%209-9-9z%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 12cqw 12cqw;
}

/* Overlapping waves in alternating rows. */
.card-tile-weave--blue {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2040%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M-10%202Q0%2020%2010%202T30%202T50%202M-20%2022Q-10%2040%200%2022T20%2022T40%2022%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 12cqw 12cqw;
}

/* Irregular mineral flecks, with several sizes and bearings. */
.card-tile-weave--black {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2040%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cg%20fill%3D%22black%22%20stroke%3D%22none%22%3E%3Cellipse%20cx%3D%228%22%20cy%3D%2211%22%20rx%3D%224%22%20ry%3D%222%22%20transform%3D%22rotate%28-24%208%2011%29%22%2F%3E%3Cellipse%20cx%3D%2229%22%20cy%3D%2230%22%20rx%3D%223%22%20ry%3D%225%22%20transform%3D%22rotate%2831%2029%2030%29%22%2F%3E%3Ccircle%20cx%3D%2230%22%20cy%3D%227%22%20r%3D%221.3%22%2F%3E%3Cellipse%20cx%3D%229%22%20cy%3D%2232%22%20rx%3D%222%22%20ry%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    --weave-size: 12cqw 12cqw;
}

/* Broken flint chevrons in staggered rows. */
.card-tile-weave--red {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2040%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M2%2014l8-9%208%209M22%2034l8-9%208%209%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 12cqw 12cqw;
}

/* Paired growth rings, offset rather than arranged in a square grid. */
.card-tile-weave--green {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2048%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cellipse%20cx%3D%2212%22%20cy%3D%2212%22%20rx%3D%228%22%20ry%3D%226%22%2F%3E%3Cellipse%20cx%3D%2212%22%20cy%3D%2212%22%20rx%3D%224%22%20ry%3D%223%22%2F%3E%3Cellipse%20cx%3D%2236%22%20cy%3D%2236%22%20rx%3D%228%22%20ry%3D%226%22%2F%3E%3Cellipse%20cx%3D%2236%22%20cy%3D%2236%22%20rx%3D%224%22%20ry%3D%223%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 14cqw 14cqw;
}

/* Quiet pinpricks in offset rows. */
.card-tile-weave--colorless {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cg%20fill%3D%22black%22%20stroke%3D%22none%22%3E%3Ccircle%20cx%3D%226%22%20cy%3D%226%22%20r%3D%221%22%2F%3E%3Ccircle%20cx%3D%2218%22%20cy%3D%2218%22%20r%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
    --weave-size: 8.6cqw 8.6cqw;
}

/* Etched metal plates in a running bond, with alternating seams. */
.card-tile-weave--artifact {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2040%2040%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M0%200h40M0%2020h40M0%2040h40M0%200v20M40%200v20M20%2020v20%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 11cqw 11cqw;
}

/* Fine diagonal metal engraving. */
.card-tile-weave--gold {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M-8%208L8-8M0%2032L32%200M24%2040L40%2024M8%2016l4%204M24%200l4%204%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 10cqw 10cqw;
}

/* Sediment contours with a small organic rise and fall. */
.card-tile-weave--land {
    --weave-pattern: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2032%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%221.2%22%3E%3Cpath%20d%3D%22M-4%208C12%202%2024%2014%2052%207M-4%2021C13%2027%2030%2014%2052%2021M-4%2026C14%2032%2032%2020%2052%2027%22%2F%3E%3C%2Fsvg%3E");
    --weave-size: 15cqw 10cqw;
}

/* The spine: one line down the border's wide side, from the name's node to
   the printing's, running from the card's first color to its last. */
.card-tile-spine {
    position: absolute;
    top: 9.4cqw;
    bottom: 6.3cqw;
    left: var(--tile-spine-x);
    width: 0.8cqw;
    /* The card's colors as they show on black (--tile-side-a / -b): black
       itself is drawn toward the border's light ink there. */
    background: linear-gradient(to bottom, var(--tile-side-a, var(--mtg-generic-mana)), var(--tile-side-m, var(--mtg-generic-mana)), var(--tile-side-b, var(--mtg-generic-mana)));
    border-radius: var(--radius-pill);
    transform: translateX(-50%);
}

/* A row the spine marks: a ring on the spine, level with the row. The row
   starts inside the frame's left edge and its 1px line, so the ring is that
   far back from it. */
.card-tile-node {
    position: relative;
}

.card-tile-node::before {
    content: "";
    position: absolute;
    top: 50%;
    left: calc(var(--tile-spine-x) - var(--tile-side) - 1px);
    box-sizing: border-box;
    width: 3cqw;
    height: 3cqw;
    background: var(--tile-border-solid);
    border: 0.7cqw solid var(--tile-border-ink);
    border-radius: var(--radius-round);
    transform: translate(-50%, -50%);
}

/* The type line's node is the color indicator: a disc in the card's colors
   (one fills it, more share it in slices), ringed dark and then light so
   every color, black included, shows. It is how a card with no cost, or the
   back of a double-faced one, says what color it is. */
.card-tile-indicator::before {
    width: 4.8cqw;
    height: 4.8cqw;
    background: var(--tile-indicator, var(--mtg-generic-mana));
    border: 0.5cqw solid var(--tile-border-solid);
    box-shadow: 0 0 0 0.35cqw var(--tile-border-ink);
}

/* Under it, level with the first line of the rules: a tick, a different mark
   for a different thing. It hangs from the type line's row because the rules'
   plate clips what is in it. */
.card-tile-indicator::after {
    content: "";
    position: absolute;
    top: calc(100% + 2.2cqw + var(--rules-size, 4.6cqw) * 0.65);
    left: calc(var(--tile-spine-x) - var(--tile-side) - 1px);
    width: 2.2cqw;
    height: 2.2cqw;
    background: var(--tile-border-ink);
    border: 0.4cqw solid var(--tile-border-solid);
    box-sizing: border-box;
    transform: translate(-50%, -50%) rotate(45deg);
}

.card-tile--bare .card-tile-indicator::after {
    display: none;
}

/* The printing's node, on the border under the frame. Its row starts where
   the frame does, with no line to step back over. */
.card-tile-set.card-tile-node::before {
    left: calc(var(--tile-spine-x) - var(--tile-side));
}

/* The name's row. Its node is the spine's first. The plate fills the row to
   its foot and the row laps 1.2 over the art box below it (and is raised
   over it), so the name and its
   cost have a taller plate than the row takes from the tile. */
.card-tile-head {
    z-index: 1;
    flex: 0 0 auto;
    box-sizing: border-box;
    height: 12.4cqw;
    margin-bottom: -1.2cqw;
    padding: 1.6cqw 2.2cqw 0;
}

/* Level with the plate's middle, not the row's. */
.card-tile-head.card-tile-node::before {
    top: 7cqw;
}

/* The title plate: the name and its cost, framed. Cut at two corners like the
   corner box, edged in the card's color. */
.card-tile-plate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2cqw;
    box-sizing: border-box;
    height: 100%;
    padding: 0 2.2cqw;
    /* The grain, a sheen down the plate, the plate's color. */
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 9%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 16%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 24%, var(--bg-tertiary));
    background-blend-mode: overlay, normal, normal;
    border: 1px solid var(--tile-edge);
    border-radius: 2.4cqw 0.6cqw;
    /* Raised: the trim band lit on its top edge, a groove inside it, and a
       shadow cast down onto the art. */
    box-shadow:
        inset 0 0.22cqw 0 var(--tile-bevel-light),
        inset 0 0 0 0.6cqw var(--tile-trim-band),
        inset 0 0 0 0.8cqw var(--tile-bevel-dark),
        0 0.5cqw 0.9cqw var(--tile-lift);
}

/* A legendary card's plate: edged in the ink, a second line inside the first,
   and a crest of three points on its top edge. */
.card-tile--legendary .card-tile-plate {
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 9%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 16%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 30%, var(--bg-tertiary));
    background-blend-mode: overlay, normal, normal;
    border-color: var(--tile-ink);
    box-shadow:
        inset 0 0.22cqw 0 var(--tile-bevel-light),
        inset 0 0 0 0.6cqw var(--tile-ink),
        inset 0 0 0 0.85cqw var(--panel-bg-opaque),
        inset 0 0 0 1.1cqw var(--tile-ink),
        0 0.5cqw 0.9cqw var(--tile-lift);
}

.card-tile--legendary .card-tile-plate::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 9cqw;
    height: 2.4cqw;
    background: var(--tile-ink);
    /* Three points in a row, the middle one the tallest, as one outline: the
       stretches between them run along the middle and enclose nothing. */
    clip-path: polygon(
        5% 50%, 17% 18%, 29% 50%,
        37% 50%, 50% 0%, 63% 50%,
        71% 50%, 83% 18%, 95% 50%,
        83% 82%, 71% 50%,
        63% 50%, 50% 100%, 37% 50%,
        29% 50%, 17% 82%);
    transform: translate(-50%, -50%);
}

/* One line, always: the size is fitted to the name in code (name_size), as a
   printed card shrinks a long name. */
.card-tile-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: var(--name-size, 6.4cqw);
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-tile-cost {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.6cqw;
    font-size: 5.6cqw;
}

/* The tile's own images (symbols, a loyalty badge, a custom card's picture)
   are not the card's picture. Hosts style that picture with rules as broad as
   "every image in this card" (a stack card, a fan, a hand); this puts the
   tile's images back to plain inline images whatever the host said, and the
   rules below, written at the same weight, size each kind. */
.card-tile .card-tile-body img[class] {
    position: static;
    display: inline-block;
    flex: 0 0 auto;
    width: auto;
    height: auto;
    min-width: 0;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
    opacity: 1;
    transform: none;
    transition: none;
}

/* A card symbol: the official one, from the app's own copy. */
.card-tile .card-tile-body img.card-tile-symbol {
    width: 1.05em;
    height: 1.05em;
    vertical-align: -0.14em;
}

/* A few official symbols are a bare black glyph with no disc of their own
   (chaos, a ticket, the planeswalker mark): a light disc goes under them, or
   they would not show on a dark surface. */
.card-tile .card-tile-body img.card-tile-symbol--bare {
    box-sizing: border-box;
    padding: 0.6cqw;
    background: var(--on-media-ink);
    border-radius: var(--radius-round);
}

.card-tile .card-tile-rule img.card-tile-symbol {
    margin: 0 var(--space-px);
}

/* A loyalty cost's badge runs taller than a mana symbol, as it does in the
   Oracle text. */
.card-tile .card-tile-body img.card-tile-loyalty {
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.38em;
}

/* A symbol the copy does not hold, drawn: a disc in the mana color with its
   letter or number. A hybrid is split corner to corner. */
.card-tile-pip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 1.5em;
    height: 1.5em;
    margin: 0 var(--space-px);
    background: linear-gradient(135deg,
        var(--pip-a, var(--mtg-generic-mana)) 50%,
        var(--pip-b, var(--mtg-generic-mana)) 50%);
    border-radius: var(--radius-round);
    /* A ring in the ink, so the black and generic discs show on a dark surface. */
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pip-ink, var(--on-media-ink)) 45%, transparent);
    color: var(--pip-ink, var(--on-media-ink));
    font-size: 0.72em;
    font-weight: 700;
    line-height: 1;
    vertical-align: 0.1em;
}

.card-tile-pip--wide {
    width: auto;
    min-width: 1.5em;
    padding: 0 0.5cqw;
    border-radius: var(--radius-pill);
    letter-spacing: -0.04em;
}

/* A generic number the copy has no file for ({23}): the official generic
   disc (pip_style's GENERIC_DISC under a dark numeral), at the official
   symbol's size and place (1.05em of the text, 0.14em down), so {1}{23}
   reads as one cost. The numeral is 0.8 of the text; two digits are set
   narrower (0.72) and the disc measured against that. */
.card-tile-pip--generic {
    width: 1.3125em;
    height: 1.3125em;
    margin: 0;
    box-shadow: none;
    font-size: 0.8em;
    font-weight: 800;
    vertical-align: -0.175em;
}

.card-tile-pip--digits {
    width: 1.4583em;
    height: 1.4583em;
    font-size: 0.72em;
    letter-spacing: -0.08em;
    vertical-align: -0.1944em;
}

.card-tile-rule .card-tile-pip--generic {
    margin: 0 var(--space-px);
}

/* The art box: the constellation over a far field of faint stars (far_stars,
   seeded by the card), in a void. The card's colors and textures are the
   frame's, never the art's: only the stars and the figure take the framing's
   ink. Its height is the code's
   (fit_rules): a full figure over a short ability, a strip of one over a
   wall of text. */
.card-tile-art {
    position: relative;
    flex: 0 0 auto;
    box-sizing: border-box;
    height: var(--art-height, 36cqw);
    margin: 0 var(--tile-inset);
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--tile-edge);
    border-radius: 2cqw;
    /* A window sunk into the frame: ringed in the trim band, shaded from its
       top edge. A custom card's picture covers the shade, not the ring. */
    box-shadow:
        0 0 0 0.45cqw var(--tile-trim-band),
        0 0 0 0.65cqw var(--tile-bevel-dark),
        inset 0 0.8cqw 1.8cqw color-mix(in srgb, var(--on-media-scrim) 55%, transparent);
}

.card-tile-sky,
.card-tile .card-tile-body img.card-tile-picture {
    display: block;
    width: 100%;
    height: 100%;
}

/* The figure over the far field, drawn whole (preserveAspectRatio meet). */
.card-tile-sky--figure {
    position: absolute;
    inset: 0;
}

/* An art crop keeps the tile's exact constellation and palette, without its frame. */
.card-image-art-only { container-type: inline-size; }

.card-tile-art.card-constellation {
    --tile-ink: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 45%, var(--text-color));
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: inherit;
    container-type: inline-size;
}

.card-tile .card-tile-body img.card-tile-picture {
    object-fit: cover;
}

.card-tile-link {
    stroke: var(--tile-ink);
    stroke-width: 0.5;
    opacity: 0.6;
}

/* The far field: points too faint to read as a pattern, the farthest stars. */
.card-tile-far {
    fill: var(--tile-ink);
    opacity: 0.22;
}

/* A star as light: a wide faint halo, a nearer one and a bright core
   (star_view), which twinkle together, ever so slightly. Each star's own
   delay and pace come from the code (--twinkle-delay, --twinkle-time), so no
   two neighbors pulse together. They twinkle on a card the reader can turn
   (the Custom Creator, a published card's page) while it is on screen
   (card-tilt--seen, an IntersectionObserver), and on a tile under the
   pointer; a page of tiles (Search, a deck in an image outage) holds still,
   since dozens of blurred, pulsing skies would cost frames. */
.card-tilt--seen .card-tile-glow,
.card-tilt--seen .card-tile-far--twinkle,
.card-tile:hover .card-tile-glow,
.card-tile:hover .card-tile-far--twinkle {
    animation: card-tile-twinkle var(--twinkle-time, 3s) ease-in-out var(--twinkle-delay, 0s) infinite;
}

@keyframes card-tile-twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.66; }
}

.card-tilt--seen .card-tile-far--twinkle,
.card-tile:hover .card-tile-far--twinkle {
    animation-name: card-tile-twinkle-far;
}

@keyframes card-tile-twinkle-far {
    0%, 100% { opacity: 0.22; }
    50% { opacity: 0.5; }
}

/* Softened, so a star is a blur of light, not a ring of discs. A CSS blur on
   the circle itself: no gradient defs, whose ids would repeat on a page of
   tiles. Its lengths are the art's own units (100 across). */
.card-tile-halo {
    fill: var(--tile-ink);
    opacity: 0.13;
    filter: blur(1.1px);
}

.card-tile-halo--inner {
    opacity: 0.2;
    filter: blur(0.5px);
}

.card-tile-star {
    fill: var(--tile-ink);
}

/* The card's own star: tinted by the framing, with streaks of light. */
.card-tile-glow--hub {
    --tile-hub: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 70%, var(--tile-ink));
}

.card-tile-glow--hub .card-tile-halo {
    fill: var(--tile-hub);
    opacity: 0.14;
}

.card-tile-glow--hub .card-tile-halo--inner {
    opacity: 0.32;
}

.card-tile-star--hub {
    fill: var(--tile-hub);
}

.card-tile-streak {
    stroke: var(--tile-hub);
    stroke-width: 0.22;
    stroke-linecap: round;
    opacity: 0.55;
}

.card-tile-streak--short {
    stroke-width: 0.14;
    opacity: 0.4;
}

/* Twinkling is opacity only, which reduced motion keeps; nothing here moves. */

.card-tile-type {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 2cqw;
    box-sizing: border-box;
    height: 9.2cqw;
    padding: 0 var(--tile-inset);
    color: var(--text-secondary);
    font-weight: 600;
}

/* The type line's plate: the title plate's shape, lower, so the ground's
   texture does not run under the words. Its padding is the fitting's
   (TYPE_PLATE_PADDING). */
.card-tile-type-plate {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-between;
    gap: 2cqw;
    box-sizing: border-box;
    min-width: 0;
    height: 6.8cqw;
    padding: 0 1.6cqw;
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 7%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 14%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 16%, var(--bg-tertiary));
    background-blend-mode: overlay, normal, normal;
    border-radius: 2.4cqw 0.6cqw;
    /* Raised, as the title plate is, on a thinner band. */
    box-shadow:
        inset 0 0.2cqw 0 var(--tile-bevel-light),
        inset 0 0 0 0.5cqw var(--tile-trim-band),
        inset 0 0 0 0.68cqw var(--tile-bevel-dark),
        0 0.4cqw 0.7cqw var(--tile-lift);
}

/* One line, always, like the name: fitted in code (type_size). */
.card-tile-type-text {
    min-width: 0;
    overflow: hidden;
    font-size: var(--type-size, 4.3cqw);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The X mark, in the rarity's color, where a set symbol would sit. The color
   is pulled toward the theme's text color: the pale rarities would not show
   on a light theme's surface. */
.card-tile-mark {
    flex: 0 0 auto;
    width: 5.4cqw;
    height: 5.4cqw;
}

.card-tile-mark-arm {
    stroke: color-mix(in srgb, var(--tile-rarity, var(--text-secondary)) 72%, var(--text-color));
    stroke-linecap: round;
    stroke-width: 7;
}

.card-tile-mark-node {
    fill: color-mix(in srgb, var(--tile-rarity, var(--text-secondary)) 72%, var(--text-color));
}

/* The rules take what is left, in a plate of their own, at the size the code
   fitted them to it (fit_rules). What a long card's rules lose to fit (their
   reminder text, then their end) the code leaves out, so nothing here fades
   or is clipped mid-line. */
.card-tile-rules {
    flex: 1 1 0;
    box-sizing: border-box;
    min-height: 0;
    margin: 0 var(--tile-inset);
    padding: 2.2cqw 2.6cqw;
    overflow: hidden;
    /* Opaque, so the ground's texture does not run under the text; tinted by
       the card's colors, left to right, as the ground is. */
    background: var(--tile-paper-grain), linear-gradient(to right,
        color-mix(in srgb, var(--tile-box-a, var(--mtg-generic-mana)) var(--tile-box-share), var(--tile-plate)),
        color-mix(in srgb, var(--tile-box-m, var(--mtg-generic-mana)) var(--tile-box-share), var(--tile-plate)),
        color-mix(in srgb, var(--tile-box-b, var(--mtg-generic-mana)) var(--tile-box-share), var(--tile-plate)));
    background-blend-mode: overlay, normal;
    border-radius: 2cqw;
    /* Edged in the trim band, as the title plate is, but sunk into the frame:
       a shadow falls into it from its top edge, and the light catches the lip
       under it. Shadows, so they take no room from the text. */
    box-shadow:
        inset 0 0 0 0.6cqw var(--tile-trim-band),
        inset 0 0 0 0.8cqw var(--tile-bevel-dark),
        inset 0 0.9cqw 1.4cqw 0.8cqw color-mix(in srgb, var(--on-media-scrim) 18%, transparent),
        0 0.22cqw 0 color-mix(in srgb, var(--on-media-ink) 16%, transparent);
    font-size: var(--rules-size, 4.6cqw);
}

/* The gaps in the rules are shares of the text's size, which the fitting
   counts on (RULES_GAP). */
.card-tile-rule {
    margin: 0 0 calc(var(--rules-size, 4.6cqw) * 0.34);
}

.card-tile-rule:last-child {
    margin-bottom: 0;
}

/* Flavor text: last, in italics, and under any rules a thin rule in the
   framing's ink with a little room on each side. The rule's margin and padding
   are the fitting's (FLAVOR_RULE: 0.5em over the gap every paragraph has). */
.card-tile-flavor {
    margin: 0;
    font-style: italic;
}

.card-tile-flavor:not(:first-child) {
    padding-top: calc(var(--rules-size, 4.6cqw) * 0.25);
    border-top: 1px solid color-mix(in srgb, var(--tile-ink) 55%, transparent);
}

/* Under rules, the flavor is pinned to the bottom of the box and grows up
   into whatever room the rules leave, as a printed card sets it. The rules
   keep a body of their own, so their margins collapse into one another as the
   fitting counted; the body's margin is the least room left above the rule,
   and the flavor's auto margin takes the rest. */
.card-tile-rules--flavored {
    display: flex;
    flex-direction: column;
}

.card-tile-rules-body {
    flex: none;
    margin-bottom: calc(var(--rules-size, 4.6cqw) * 0.59);
}

.card-tile-rules--flavored > .card-tile-flavor {
    margin-top: auto;
}

/* What a card prints in italics: reminder text and ability words. */
.card-tile-italic {
    font-style: italic;
}

/* A further face on the same side: its own name and cost, ruled off. */
.card-tile-face {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2cqw;
    margin-top: calc(var(--rules-size, 4.6cqw) * 0.5);
    padding-top: calc(var(--rules-size, 4.6cqw) * 0.4);
    border-top: 1px solid var(--border-color);
    font-weight: 700;
}

.card-tile-face:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.card-tile-face .card-tile-cost {
    font-size: 1em;
}

.card-tile-face-type {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 600;
}

/* A band: a stretch of the rules a card prints as a stripe of its own (a
   leveler's levels, a station's thresholds, a Class's levels, a Saga's
   chapters). Its marker on the left, its text, its power and toughness on the
   right; one stripe a little deeper than the next. Its measures are shares
   of the text's size, and the marker's and the box's widths are the code's
   (--band-label, --band-stats), because the fitting counts on all of them
   (BAND_* in card_tile.rs). */
.card-tile-band {
    display: flex;
    align-items: center;
    gap: calc(var(--rules-size, 4.6cqw) * 0.5);
    margin: 0 0 calc(var(--rules-size, 4.6cqw) * 0.34);
    padding: calc(var(--rules-size, 4.6cqw) * 0.25) calc(var(--rules-size, 4.6cqw) * 0.4);
    background: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 9%, transparent);
    border-radius: 1.4cqw;
}

.card-tile-band:nth-of-type(even) {
    background: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 20%, transparent);
}

.card-tile-band:last-child {
    margin-bottom: 0;
}

.card-tile-band-text {
    flex: 1 1 0;
    min-width: 0;
}

/* The marker: cut at two corners like the title plate, a small word over
   what it counts. Its line is a shadow, not a border, so it takes no room. */
.card-tile-band-label {
    display: flex;
    flex: 0 0 var(--band-label, 3em);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 2em;
    overflow: hidden;
    background: var(--tile-paper-grain), color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 26%, var(--bg-tertiary));
    background-blend-mode: overlay, normal;
    border-radius: 2.2cqw 0.6cqw;
    box-shadow: inset 0 0 0 1px var(--tile-ink);
    color: var(--text-color);
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
}

.card-tile-band-kicker {
    font-size: 0.5em;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.card-tile-band-value {
    font-size: 0.95em;
}

.card-tile-band-label .card-tile-cost {
    gap: 0.2cqw;
    font-size: 0.85em;
}

/* A Spree mode's marker: its plus before its additional cost, in one row, at
   the cost's size (SPREE_PLUS, SPREE_GAP), and one row high (BAND_BOX). */
.card-tile-band--spree .card-tile-band-label {
    flex-direction: row;
    gap: calc(var(--rules-size, 4.6cqw) * 0.15);
    min-height: 1.6em;
}

.card-tile-band--spree .card-tile-band-kicker {
    /* Grenze's plus is a small glyph: set larger, it stands as tall as the
       cost's symbols beside it. */
    font-size: 1.15em;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
}

/* A station's power and toughness sit in the band's bottom right corner and
   its text wraps around them, so every line above the box has the band's
   width (band_stats_seated). A float cannot be sent to the bottom, so a
   spacer floated above it pushes it down, by a height the code works out
   from the text (--band-seat: the text's height as fitted, less the box), not
   by a share of the band's height, which the wrapping itself decides. The
   box's height is the fitting's (BAND_BOX). */
.card-tile-band--seated .card-tile-band-text::before {
    content: "";
    float: right;
    height: var(--band-seat, 0);
}

.card-tile-band--seated .card-tile-band-stats {
    float: right;
    clear: right;
    width: var(--band-stats, 3em);
    height: calc(var(--rules-size, 4.6cqw) * 1.6);
    margin-left: calc(var(--rules-size, 4.6cqw) * 0.5);
    padding: 0;
    line-height: calc(var(--rules-size, 4.6cqw) * 1.6);
}

/* A Saga's chapter: the hexagon, the tile's own shape, in the frame's ink. A
   band for two chapters has two, one over the other (BAND_STACK apart). */
.card-tile-band--chapter .card-tile-band-label {
    gap: calc(var(--rules-size, 4.6cqw) * 0.2);
    min-height: 0;
    overflow: visible;
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.card-tile-band--chapter .card-tile-band-value {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 1.6em;
    background: color-mix(in srgb, var(--tile-ink) 70%, var(--text-color));
    clip-path: polygon(0.4em 0%, calc(100% - 0.4em) 0%, 100% 50%, calc(100% - 0.4em) 100%, 0.4em 100%, 0% 50%);
    color: var(--panel-bg-opaque);
    font-size: 0.9em;
}

/* A planeswalker's ability: its loyalty badge is the marker, bare. */
.card-tile-band--loyalty .card-tile-band-label {
    min-height: 0;
    overflow: visible;
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.card-tile .card-tile-body img.card-tile-band-badge {
    width: 2.1em;
    height: 2.1em;
}

/* A band's power and toughness: the corner box, small. */
.card-tile-band-stats {
    flex: 0 0 var(--band-stats, 3em);
    box-sizing: border-box;
    padding: 0.4cqw 0;
    background: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 22%, var(--bg-tertiary));
    border-radius: 2.2cqw 0.6cqw;
    box-shadow: inset 0 0 0 1px var(--tile-ink);
    color: var(--text-color);
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

/* The foot of the frame: the corner box, when the card has one, and room for
   the seal either way. The corner box sits on the frame's bottom edge and
   hangs 2.4 over it, into the border, so its row is shorter than it is. */
.card-tile-foot {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    justify-content: flex-end;
    box-sizing: border-box;
    min-height: 4.4cqw;
    padding: 0 var(--tile-inset);
}

.card-tile-foot:not(:empty) {
    height: 6.6cqw;
}

/* Power and toughness: a plate cut at two corners, edged in the card's color. */
.card-tile-corner {
    margin-bottom: -2.4cqw;
    /* Grenze's figures sit a little under the middle of its line (measured:
       0.033em at line-height 1.2, with lining figures), so 0.19cqw of the top
       padding (0.035em of the 5.4cqw text) moves to the bottom and the numbers
       center in the box. The box keeps its height. */
    padding: 0.21cqw 3cqw 0.59cqw;
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 9%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 16%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 26%, var(--bg-tertiary));
    background-blend-mode: overlay, normal, normal;
    border: 1px solid var(--tile-ink);
    border-radius: 2.4cqw 0.6cqw;
    /* Raised over the frame's edge it hangs from, as the title plate is. */
    box-shadow:
        inset 0 0.22cqw 0 var(--tile-bevel-light),
        inset 0 0 0 0.5cqw var(--tile-trim-band),
        0 0.5cqw 0.9cqw var(--tile-lift);
    color: var(--text-color);
    font-size: 5.4cqw;
    font-weight: 700;
    line-height: 1.2;
}

/* A Vehicle's power and toughness, reversed, as its printed card sets them
   apart (it is a creature only while crewed): the plate takes the theme's text
   color, tinted by the framing, and the figures the surface's, so it reads as
   the inverse of every other corner box on any theme. The same cut, edge and
   bevel as any corner box. */
.card-tile-corner--vehicle {
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 12%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 22%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 30%, var(--text-color));
    background-blend-mode: overlay, normal, normal;
    color: var(--bg-tertiary);
}

/* Starting loyalty: the loyalty badge. */
.card-tile .card-tile-body img.card-tile-corner-loyalty {
    width: 8.6cqw;
    height: 8.6cqw;
    margin-bottom: -2.4cqw;
}

/* The seal: a tile's own mark, where a printed card carries its stamp, and
   not that stamp's shape. A hexagon (the heart of the X mark) set into the
   middle of the frame's bottom edge: the frame's line goes around it, and its
   face catches the card's colors. Three hexagons, one inside the next: the
   frame's line, the border's black, the face. */
.card-tile-seal {
    position: absolute;
    bottom: 9cqw;
    /* The middle of the frame, which sits off the tile's own middle. */
    left: calc((var(--tile-side) + 100% - 2.4cqw) / 2);
    width: 7.4cqw;
    height: 6.4cqw;
    background: var(--tile-edge);
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    transform: translate(-50%, 50%);
}

.card-tile-seal::before,
.card-tile-seal::after {
    content: "";
    position: absolute;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.card-tile-seal::before {
    inset: 0.35cqw;
    background: var(--tile-border-solid);
}

.card-tile-seal::after {
    inset: 1.1cqw;
    background: linear-gradient(135deg,
        var(--tile-side-a, var(--mtg-generic-mana)),
        var(--tile-seal-shine) 48%,
        var(--tile-side-b, var(--mtg-generic-mana)));
}

/* Under the frame, on the border: the printing, and what the tile is. Light
   ink on the black border, the pair made for print over a dark ground. */
.card-tile-legal {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    gap: 0.4cqw;
    box-sizing: border-box;
    height: 9cqw;
    padding: 0 0 0.6cqw;
    color: var(--tile-on-border);
    line-height: 1.15;
}

.card-tile-set {
    min-height: 1em;
    font-size: 3cqw;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* The line under the printing: on the left, the artist of a custom card's
   picture (empty on a catalog card's tile, and kept for it); on the right,
   what the tile is. */
.card-tile-credit {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 2cqw;
    min-width: 0;
    font-size: 2.3cqw;
}

.card-tile-artist {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    opacity: 0.82;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-tile-notice {
    flex: 0 0 auto;
    font-style: italic;
    opacity: 0.82;
    white-space: nowrap;
}

/* A card with no rules text (a vanilla creature, a card known only by name)
   gives the room to its figure. */
.card-tile--bare .card-tile-rules {
    display: none;
}

.card-tile--bare .card-tile-art {
    flex: 1 1 0;
    height: auto;
    min-height: 0;
}

/* A basic land's mana, large in its rules plate, in the rules' place. */
.card-tile-rules--mark {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-tile .card-tile-body img.card-tile-watermark {
    width: 26cqw;
    height: 26cqw;
}

/* A land. Its ground is the land tone with the strata, whatever it makes
   (tone_style, frame_weaves), and a band of that tone runs inside the frame's
   line. Its framing says what it makes, as a spell's does: its one color,
   gold for more, and the land tone only when it makes none. Its rules plate
   is deep in those colors. */
.card-tile--land {
    --tile-box-share: 30%;
}

.card-tile--land .card-tile-frame {
    box-shadow: inset 0 0 0 0.8cqw color-mix(in srgb, var(--tile-wash-a, var(--mtg-generic-mana)) 62%, var(--panel-bg-opaque));
}

/* The strata stop at that band, which stays clean. */
.card-tile--land .card-tile-frame > .card-tile-weave {
    inset: 0.8cqw;
}

/* A Battle's defense: a shield, cut to its shape, its line the frame's ink
   (the shield itself) under a face inset from it. It is taller than the
   corner box and hangs 3.4 over the frame's edge, clear of the notice. */
.card-tile-corner--defense {
    position: relative;
    isolation: isolate;
    min-width: 8cqw;
    margin-bottom: -3.4cqw;
    padding: 0.6cqw 2.4cqw 2.6cqw;
    background: var(--tile-ink);
    border: 0;
    border-radius: 0;
    clip-path: polygon(0% 0%, 100% 0%, 100% 45%, 92% 70%, 75% 88%, 50% 100%, 25% 88%, 8% 70%, 0% 45%);
    text-align: center;
}

.card-tile-corner--defense::before {
    content: "";
    position: absolute;
    inset: 0.4cqw;
    z-index: -1;
    background: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 22%, var(--bg-tertiary));
    clip-path: polygon(0% 0%, 100% 0%, 100% 45%, 92% 70%, 75% 88%, 50% 100%, 25% 88%, 8% 70%, 0% 45%);
}

/* ── Cards whose faces share a side, and a Battle's front ─────────────────
   (TileLayout). Each face is a frame of its own, the same frame a card is,
   set on the tile as the printed card sets it, so that turning the whole
   tile as the Card Detail Modal turns the card's picture
   (card_image_rotation) shows the face upright. The tile is then a sheet:
   black, the frames on it. Positions are in the tile's units: it is 100
   wide and 139.68 tall; a frame turned a quarter is placed by its middle
   (its box upright, then turned about its center). */
.card-tile--sheet {
    overflow: hidden;
    background: var(--tile-border-fill);
}

/* A split card's half (and an aftermath card's sideways one): upright it is
   half the card's height wide (69.84) and the card's width tall (100), a
   small card. It is a size container of its own, so the frame inside it is
   the card's frame in its units, and SPLIT_SHAPE is the card's with the
   half's height (143.19 in those units). Turned a quarter counterclockwise,
   so a quarter clockwise reads it: the first face is the bottom half (the
   left, turned), the second the top (the right). */
.card-tile-half {
    position: absolute;
    left: 15.08cqw;
    width: 69.84cqw;
    height: 100cqw;
    container-type: inline-size;
}

.card-tile-half--first {
    top: 54.76cqw;
    transform: rotate(-90deg);
}

.card-tile-half--second {
    top: -15.08cqw;
    transform: rotate(-90deg);
}

/* A Fuse card's halves stand over the fuse bar (FUSE_BAR, 9): 91 tall, so
   130.3 in their own units (FUSED_SHAPE), their middles 45.5 from the edge
   the bar is not on. */
.card-tile--fused .card-tile-half {
    left: 10.58cqw;
    height: 91cqw;
}

.card-tile--fused .card-tile-half--first {
    top: 59.26cqw;
}

.card-tile--fused .card-tile-half--second {
    top: -10.58cqw;
}

/* The fuse bar, across the foot of both halves: the card's height long, 9
   deep, along the edge that is the bottom when the card is turned. Its
   margins are the halves' border (theirs, in the tile's units: 5.6 on the
   spine's side, 1.7 elsewhere); its text is fitted to one line in code
   (fuse_size, --fuse-size). It is the border's own, not a plate on it:
   filled with the border, outlined under each half in that half's colors as
   its spine shows them (fuse_style: --fuse-a1 / -m1 / -b1 on the left,
   --fuse-a2 / -m2 / -b2 on the right), its line in the border's ink. */
.card-tile-fuse {
    position: absolute;
    top: 65.34cqw;
    left: 25.66cqw;
    box-sizing: border-box;
    width: 139.68cqw;
    height: 9cqw;
    padding: 0.4cqw 1.7cqw 1.7cqw 5.6cqw;
    transform: rotate(-90deg);
}

.card-tile-fuse-plate {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 100%;
    padding: 0 2cqw;
    background:
        var(--tile-border-fill) padding-box,
        linear-gradient(to right,
            var(--fuse-a1, var(--mtg-generic-mana)),
            var(--fuse-m1, var(--mtg-generic-mana)) 25%,
            var(--fuse-b1, var(--mtg-generic-mana)) 50%,
            var(--fuse-a2, var(--mtg-generic-mana)) 50%,
            var(--fuse-m2, var(--mtg-generic-mana)) 75%,
            var(--fuse-b2, var(--mtg-generic-mana))) border-box;
    border: 0.5cqw solid transparent;
    border-radius: 2.4cqw 0.6cqw;
    color: var(--tile-on-border);
}

.card-tile-fuse-text {
    min-width: 0;
    overflow: hidden;
    font-size: var(--fuse-size, 3.6cqw);
    font-weight: 700;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A Room's doors: an arch and a handle over each half's art box, the two
   handles facing each other across the card. */
.card-tile--room .card-tile-art {
    position: relative;
}

.card-tile-door {
    position: absolute;
    bottom: 0;
    left: 50%;
    box-sizing: border-box;
    width: 38%;
    height: 84%;
    background: color-mix(in srgb, var(--tile-ink) 12%, transparent);
    border: 0.9cqw solid color-mix(in srgb, var(--tile-ink) 85%, transparent);
    border-bottom: 0;
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
    transform: translateX(-50%);
}

.card-tile-door-handle {
    position: absolute;
    top: 56%;
    right: 14%;
    width: 2.4cqw;
    height: 2.4cqw;
    background: var(--tile-ink);
    border-radius: var(--radius-round);
}

.card-tile-half--second .card-tile-door-handle {
    right: auto;
    left: 14%;
}

/* An aftermath card: the first face upright in the top half (TOP_SHAPE, in
   the tile's units: 100 by 69.84, no printing under it), the second a split
   half turned a quarter clockwise in the bottom half, so a quarter
   counterclockwise reads it. */
.card-tile-body--top {
    height: 69.84cqw;
}

.card-tile-half--aftermath {
    top: 54.76cqw;
    transform: rotate(90deg);
}

/* A frame with no printing under it: the border's own padding in its place,
   and the spine and the seal moved down to match. The seal is centered a
   little above the frame's edge rather than on it: half its height (3.2) is
   more than the padding under the edge, and the frame clips what leaves it. */
.card-tile-body--unprinted {
    padding-bottom: 2.4cqw;
}

.card-tile-body--unprinted .card-tile-spine {
    bottom: 4.4cqw;
}

.card-tile-body--unprinted .card-tile-seal {
    bottom: 3.5cqw;
}

/* An aftermath card's two spines are one line. The sideways half's spine
   runs across the card just under the top half, from its printing's node
   near the left edge (in the tile's units: 6.3 of the half's 100 across the
   card, so 4.4 in; 4.1 of them down, so 72.70 down). The top half's spine is
   moved over that node (4.4), runs to its frame's foot with a square end,
   and a join on the sheet carries it, in its own last color, across to the
   node's ring (its radius: 1.5 of the half's units, 1.05), where the line
   turns into the sideways half's colors. The top frame's lower corners are
   square so nothing of the line is clipped at any size. */
.card-tile-body--top {
    --tile-spine-x: 4.4cqw;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.card-tile-body--top .card-tile-spine {
    bottom: 0;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.card-tile-join {
    position: absolute;
    top: 69.84cqw;
    left: 4.4cqw;
    width: 0.8cqw;
    height: 1.82cqw;
    background: var(--tile-side-b, var(--mtg-generic-mana));
    transform: translateX(-50%);
}

/* A Battle's front: landscape (BATTLE_SHAPE), in the tile's own units, since
   its text is the size a card's is: 139.68 wide and 100 tall, turned a
   quarter counterclockwise so a quarter clockwise reads it. */
.card-tile-body--landscape {
    position: absolute;
    top: 19.84cqw;
    left: -19.84cqw;
    width: 139.68cqw;
    height: 100cqw;
    transform: rotate(-90deg);
}

/* A flip card: the first half upright on top, the art box shared in the
   middle (FLIP_ART), the second half upside down under it, and room under
   the frame's last row for the seal (FLIP_FOOT). A half is its name row, its
   rules and its type line with the corner box in it (FLIP_SHAPE). */
.card-tile-body--flip .card-tile-frame {
    padding-bottom: 3.4cqw;
}

.card-tile-body--flip .card-tile-art {
    height: 22cqw;
}

.card-tile-flip-half {
    /* A half is tinted by its own colors (tone_style on it), so the inks are
       worked out again from them. */
    --tile-ink: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 45%, var(--text-color));
    --tile-edge: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 64%, var(--border-primary));
    --tile-trim-band: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 82%, var(--border-primary));
    position: relative;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
}

.card-tile-flip-half--turned {
    transform: rotate(180deg);
}

.card-tile-flip-half .card-tile-head {
    margin-bottom: 0;
}

/* The tick that marks where the rules begin hangs under the type line,
   which on a flip card comes after its rules. */
.card-tile-body--flip .card-tile-indicator::after {
    display: none;
}

/* A flip card's power and toughness, in its type line: the corner box at
   the type line's full size. Its padding is the fitting's
   (TYPE_CORNER_PADDING). */
.card-tile-type-corner {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0 1.6cqw;
    background: color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 22%, var(--bg-tertiary));
    border-radius: 1.8cqw 0.5cqw;
    box-shadow: inset 0 0 0 1px var(--tile-ink);
    color: var(--text-color);
    font-size: 4.3cqw;
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

/* Bookish, open-source letterforms on the printed plates; branding and tiny
   legal copy retain the app face. The rules are set in Alegreya, made for
   reading at length; the title face, Grenze, is cut narrower, so the fitter's
   estimates (set against Alegreya, and conservative enough for Georgia) hold
   for it and its fallbacks alike. */
.card-tile-rules {
    font-family: "Alegreya", Georgia, serif;
}
.card-tile-name,
.card-tile-type-text,
.card-tile-corner,
.card-tile-type-corner,
.card-tile-band-label {
    font-family: "Grenze", "Alegreya", Georgia, serif;
    /* Grenze's default figures are old-style (a 3 or 4 drops below the line,
       a 1 is only x-high), which sat a power and toughness low in its box and
       ragged beside one another. Lining figures stand on the line at cap
       height, as a card's numbers do. */
    font-variant-numeric: lining-nums;
}
.card-tile-name { letter-spacing: 0.01em; }
.card-tile-type-text { font-weight: 600; }

/* ── Constellation Borderless (TileFrame::Borderless) ──────────────────────
   No border: the constellation's night sky runs to the card's edges, as a
   borderless printing's art does, and the frame's plates float over it,
   see-through and frosted. The same geometry as the classic frame (the
   fitting's numbers hold), the spine still down the left, over the sky. The
   sky is the card's colors as nebulae on a night deeper than the classic
   plates, with a far field of its own over the whole card (bleed_view); the
   figure stays where the art box was, its window gone. A custom picture
   fills the card instead. Only on a tile of one frame (TileFrame::class). */
.card-tile--frame-borderless {
    /* See-through plates: the surfaces the plates and the rules box are
       mixed from, thinned. */
    --bg-tertiary: color-mix(in srgb, var(--frame-classic-deep) 58%, transparent);
    --panel-bg-opaque: color-mix(in srgb, var(--frame-classic-surface) 64%, transparent);
    /* What is printed on the edge reads on the sky, whatever border the
       card would have had. */
    --tile-on-border: var(--on-media-ink);
    --tile-border-solid: var(--frame-sky);
    --tile-seal-shine: var(--on-media-ink);
    --tile-side-black: color-mix(in srgb, var(--mtg-black-mana) 55%, var(--on-media-ink));
    --tile-side-white: var(--mtg-white-mana);
    --tile-side-gold: var(--mtg-multicolor);
}

.card-tile--frame-borderless .card-tile-body {
    /* The dark glass the type line and the rules box are made of. */
    --tile-glass: color-mix(in srgb, var(--frame-sky) 66%, transparent);
    background:
        var(--tile-ground-grain),
        radial-gradient(ellipse 95% 50% at 50% 22%, color-mix(in srgb, var(--tile-wash-m, var(--mtg-generic-mana)) 30%, transparent), transparent 72%),
        radial-gradient(ellipse 85% 45% at 18% 78%, color-mix(in srgb, var(--tile-wash-a, var(--mtg-generic-mana)) 20%, transparent), transparent 70%),
        radial-gradient(ellipse 85% 45% at 86% 64%, color-mix(in srgb, var(--tile-wash-b, var(--mtg-generic-mana)) 20%, transparent), transparent 70%),
        var(--frame-sky);
    background-blend-mode: overlay, normal, normal, normal, normal;
}

.card-tile-bleed {
    display: none;
}

.card-tile--frame-borderless .card-tile-bleed {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.card-tile--frame-borderless .card-tile-far {
    opacity: 0.4;
}

/* The type line and the rules box as dark glass (--tile-glass, set on the
   body above), with the classic frame's print grain: the sky shows through,
   the words at full ink. */
.card-tile--frame-borderless .card-tile-type {
    color: var(--text-color);
}

.card-tile--frame-borderless .card-tile-type-plate {
    background:
        var(--tile-paper-grain),
        linear-gradient(to bottom, color-mix(in srgb, var(--on-media-ink) 7%, transparent), transparent 50%, color-mix(in srgb, var(--on-media-scrim) 14%, transparent)),
        color-mix(in srgb, var(--tile-trim, var(--mtg-generic-mana)) 18%, var(--tile-glass));
    background-blend-mode: overlay, normal, normal;
}

.card-tile--frame-borderless .card-tile-rules {
    background: var(--tile-paper-grain), linear-gradient(to right,
        color-mix(in srgb, var(--tile-box-a, var(--mtg-generic-mana)) 12%, var(--tile-glass)),
        color-mix(in srgb, var(--tile-box-m, var(--mtg-generic-mana)) 12%, var(--tile-glass)),
        color-mix(in srgb, var(--tile-box-b, var(--mtg-generic-mana)) 12%, var(--tile-glass)));
    background-blend-mode: overlay, normal;
}

/* The frame's ground, trim and texture give way to the sky. */
.card-tile--frame-borderless .card-tile-frame {
    background: none;
    border-color: transparent;
    box-shadow: none;
}

.card-tile--frame-borderless .card-tile-weave {
    display: none;
}

/* The art box is a place in the layout, not a window: the figure in it
   without the box's own far field (the card's is behind it), its glow free to
   spill past where the box was. */
.card-tile--frame-borderless .card-tile-art {
    overflow: visible;
    background: none;
    border-color: transparent;
    box-shadow: none;
}

/* Short rules show more sky: the rules box is only as tall as its text, and
   the art takes the rest, so the type line and the rules box sit low on the
   card. The art is never less than the fitting gave it (--art-height), so the
   text, sized for the box the fitting worked out, still fits. The type line's
   nodes on the spine (the color indicator, the tick where the rules begin)
   are its own, so they move down with it. */
.card-tile--frame-borderless .card-tile-art {
    flex: 1 1 auto;
    height: auto;
    min-height: var(--art-height, 36cqw);
}

.card-tile--frame-borderless .card-tile-rules {
    flex: 0 1 auto;
}

.card-tile--frame-borderless .card-tile-art .card-tile-sky-far {
    display: none;
}

.card-tile--frame-borderless .card-tile-sky {
    overflow: visible;
}

/* A custom picture fills the card in the sky's place (bleed_view), under
   everything on it. */
.card-tile.card-tile--frame-borderless .card-tile-body img.card-tile-bleed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* The hem: a black band along the bottom for the printing, as a borderless
   card keeps one, its top edge a line in the card's framing color that curves
   up into the card's two bottom corners, the seal sitting on it. Drawn as a
   window (::before, the sky's rounded bottom) whose shadow is the black, so
   the black fills the corners outside the curve. It sits under the spine, the
   frame and the printing (all drawn after it), so the spine's nodes stay over
   their line as on the classic frame. Its band is the printing's height
   (.card-tile-legal, 9cqw), on which the seal (bottom: 9cqw) is centered. */
.card-tile-hem {
    display: none;
}

.card-tile--frame-borderless .card-tile-hem {
    display: block;
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 16cqw;
    overflow: hidden;
    pointer-events: none;
}

.card-tile--frame-borderless .card-tile-hem::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    box-sizing: border-box;
    height: 7cqw;
    border-bottom: 0.9cqw solid var(--tile-trim-band);
    border-radius: 0 0 9cqw 9cqw / 0 0 6.5cqw 6.5cqw;
    box-shadow: 0 0 0 40cqw var(--on-media-scrim);
}

/* The printing, over the hem (drawn after it). */
.card-tile--frame-borderless .card-tile-legal {
    position: relative;
}

/* The plates frost what is behind them, so the words keep their contrast
   over a bright star. */
.card-tile--frame-borderless .card-tile-plate,
.card-tile--frame-borderless .card-tile-type-plate,
.card-tile--frame-borderless .card-tile-rules,
.card-tile--frame-borderless .card-tile-corner {
    -webkit-backdrop-filter: blur(0.9cqw);
    backdrop-filter: blur(0.9cqw);
}


/* ── A card the reader turns (card_tilt::CardTilt) ─────────────────────────
   The wrapper publishes the tilt (--tilt-rx, --tilt-ry in degrees; --tilt-x,
   --tilt-y in -1..1; --tilt-m, how far it is turned at all). They are
   registered so they transition: the spring back flat carries everything
   that moves with the tilt, not the card alone. Download PNG copies the tile
   without this wrapper, so none of it reaches a saved picture. */
@property --tilt-rx { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --tilt-ry { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --tilt-x { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --tilt-y { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --tilt-m { syntax: "<number>"; inherits: true; initial-value: 0; }

.card-tilt {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-card);
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    /* Let go, it springs back flat; held, it follows the pull closely. */
    transition:
        --tilt-rx 380ms cubic-bezier(0.2, 0.7, 0.3, 1),
        --tilt-ry 380ms cubic-bezier(0.2, 0.7, 0.3, 1),
        --tilt-x 380ms cubic-bezier(0.2, 0.7, 0.3, 1),
        --tilt-y 380ms cubic-bezier(0.2, 0.7, 0.3, 1),
        --tilt-m 380ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.card-tilt--held {
    cursor: grabbing;
    transition-duration: 60ms;
}

.card-tilt:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: var(--space-1);
}

.card-tilt-body {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transform: perspective(1100px) rotateX(var(--tilt-rx)) rotateY(var(--tilt-ry));
}

/* A glare that crosses the card as it turns, from nothing at rest. */
.card-tilt-glare {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        circle at calc(50% + var(--tilt-x) * 45%) calc(50% - var(--tilt-y) * 45%),
        color-mix(in srgb, var(--on-media-ink) 34%, transparent),
        transparent 58%);
    mix-blend-mode: soft-light;
    opacity: var(--tilt-m);
    pointer-events: none;
}

/* Parallax: the tile's layers part as it turns. The far stars sit deepest,
   the figure in front of them, the frame at the card's face, and its plates
   raised off it; a deeper layer slides against the turn, a raised one with
   it. SVG lengths are the art's own units (100 across). */
.card-tilt .card-tile-sky-far {
    transform: translate(calc(var(--tilt-x) * -3px), calc(var(--tilt-y) * 2px));
}

.card-tilt .card-tile-sky-near {
    transform: translate(calc(var(--tilt-x) * -1.3px), calc(var(--tilt-y) * 0.9px));
}

.card-tilt .card-tile-plate,
.card-tilt .card-tile-type-plate,
.card-tilt .card-tile-corner,
.card-tilt .card-tile-seal {
    translate: calc(var(--tilt-x) * 0.55cqw) calc(var(--tilt-y) * -0.55cqw);
}

.card-tilt .card-tile-rules {
    translate: calc(var(--tilt-x) * 0.22cqw) calc(var(--tilt-y) * -0.22cqw);
}

/* Moving, the stars flare: their halos brighten, and the card's own star's
   streaks swing and lengthen with the turn. */
.card-tilt .card-tile-halo {
    opacity: calc(0.13 + var(--tilt-m) * 0.14);
}

.card-tilt .card-tile-halo--inner {
    opacity: calc(0.2 + var(--tilt-m) * 0.22);
}

.card-tilt .card-tile-glow--hub .card-tile-halo {
    opacity: calc(0.14 + var(--tilt-m) * 0.18);
}

.card-tilt .card-tile-glow--hub .card-tile-halo--inner {
    opacity: calc(0.32 + var(--tilt-m) * 0.25);
}

.card-tilt .card-tile-streaks {
    transform: rotate(calc(var(--tilt-x) * 14deg)) scale(calc(1 + var(--tilt-m) * 0.4));
    transform-box: fill-box;
    transform-origin: center;
}

/* The seal's foil: a band of light in the card's own colors (its sides, as
   the face at rest) that sweeps across its face as the card turns. */
.card-tilt .card-tile-seal::after {
    background:
        linear-gradient(115deg,
            transparent 30%,
            color-mix(in srgb, var(--tile-side-a, var(--mtg-generic-mana)) 55%, var(--on-media-ink)) 42%,
            var(--on-media-ink) 50%,
            color-mix(in srgb, var(--tile-side-b, var(--mtg-generic-mana)) 55%, var(--on-media-ink)) 58%,
            transparent 70%)
            calc(50% + var(--tilt-x) * 90%) calc(50% - var(--tilt-y) * 90%) / 260% 260% no-repeat,
        linear-gradient(135deg,
            var(--tile-side-a, var(--mtg-generic-mana)),
            var(--tile-seal-shine) 48%,
            var(--tile-side-b, var(--mtg-generic-mana)));
    background-blend-mode: screen, normal;
}

@media (prefers-reduced-motion: reduce) {
    /* The card still turns with a pull, the reader's own movement, but does
       not spring or glide on its own. */
    .card-tilt {
        transition: none;
    }
}
