/* /updates/attack-forms: the class attack forms, drawn cell by cell from the game's own captures.
   Builds on goldthread.css (night sky, lantern amber, Codex parchment). The loops are clear-backed
   pixel art, so each one stands on a small night stage and is only ever enlarged by whole pixels. */

.af-page { gap: 3.2rem; }
.af-page figure { margin: 0; }

/* ---- A stage: one loop at the art's own pixels ----
   The stage's content box is the art, with the border outside it, and its width is a whole number
   of steps. A step is one cell width over --sprite-loop-steps: two steps per device pixel, set here
   for the common screens and by sprite-loops.js for any other zoom or screen. A texel of the art is
   two captured pixels, so every texel then covers a whole number of screen pixels. */
:root { --sprite-loop-steps: 2; }
@media (resolution: 1.25dppx) { :root { --sprite-loop-steps: 2.5; } }
@media (resolution: 1.5dppx) { :root { --sprite-loop-steps: 3; } }
@media (resolution: 1.75dppx) { :root { --sprite-loop-steps: 3.5; } }
@media (resolution: 2dppx), (-webkit-device-pixel-ratio: 2) { :root { --sprite-loop-steps: 4; } }
@media (resolution: 2.5dppx) { :root { --sprite-loop-steps: 5; } }
@media (resolution: 2.625dppx) { :root { --sprite-loop-steps: 5.25; } }
@media (resolution: 2.75dppx) { :root { --sprite-loop-steps: 5.5; } }
@media (resolution: 3dppx), (-webkit-device-pixel-ratio: 3) { :root { --sprite-loop-steps: 6; } }
@media (resolution: 3.5dppx) { :root { --sprite-loop-steps: 7; } }
@media (resolution: 4dppx) { :root { --sprite-loop-steps: 8; } }

.af-stage {
    --af-cap: calc(var(--af-w) * var(--af-scale, 2) * 1px);
    position: relative;
    box-sizing: content-box;
    width: min(100% - 2px, var(--af-cap));
    margin-inline: auto;
    overflow: hidden;
    border: 1px solid rgba(43, 29, 18, .4);
    border-radius: 7px;
    background:
        radial-gradient(60% 48% at 50% 66%, rgba(232, 180, 90, .14), transparent 72%),
        linear-gradient(180deg, #0e1529 0%, var(--gt-night-0) 100%);
    aspect-ratio: var(--af-w) / var(--af-h);
}

/* Whole steps only; never less than one. The .05px keeps a width that is already a whole number
   of steps from losing a step to rounding. */
@supports (width: round(down, min(100% - 2px, 20px), 3px)) {
    .af-stage {
        --af-step: calc(var(--af-w) * 1px / var(--sprite-loop-steps, 2));
        width: max(var(--af-step), round(down, min(100% - 2px, var(--af-cap)) + .05px, var(--af-step)));
    }
}

.af-stage canvas,
.af-stage img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* The poster stays until the sheet's first cell is drawn; the cells are clear-backed, so it must go. */
.af-stage canvas { opacity: 0; }
.af-stage canvas.is-ready { opacity: 1; }
.af-stage canvas.is-ready + img { visibility: hidden; }

.af-stage .af-toggle {
    position: absolute;
    right: .35rem;
    bottom: .35rem;
    z-index: 1;
    width: 1.7rem;
    height: 1.7rem;
}

/* ---- Hero: the Flourish, at any speed ---- */
.af-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 1.8rem;
}

.af-hero-copy p { max-width: 62ch; color: var(--gt-text); font-size: 1.05rem; line-height: 1.7; }
.af-hero-copy .gt-note { font-size: .98rem; }
.af-hero-copy .gt-links { margin-top: 1rem; }

/* The plate holds the Flourish at three times its size and no wider. */
.af-feature { width: min(100%, 690px); justify-self: center; }
.af-feature .af-stage { --af-scale: 3; }
.af-feature figcaption { display: grid; gap: .25rem; }

.af-feature .af-rates {
    display: inline-flex;
    justify-self: start;
    margin-top: .55rem;
    overflow: hidden;
    border: 1px solid rgba(43, 29, 18, .5);
    border-radius: 999px;
}

.af-rates button {
    min-height: 2.5rem;
    padding: .35rem .95rem;
    border: 0;
    border-left: 1px solid rgba(43, 29, 18, .3);
    background: transparent;
    color: var(--gt-ink);
    font: inherit;
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
}

.af-rates button:first-child { border-left: 0; }
.af-rates button[aria-pressed="true"] { background: var(--gt-ink); color: var(--gt-parch); }
.af-rates button:focus-visible { outline: 2px solid var(--gt-rust); outline-offset: -3px; }

/* ---- One cast, laid out to scale ---- */
.af-timeline {
    display: flex;
    gap: 3px;
    margin: 1.3rem 0 0;
    padding: 0;
    list-style: none;
}

.af-timeline li {
    flex: var(--af-ms) 1 0;
    min-width: 0;
    padding: .7rem .65rem .8rem;
    border-top: 3px solid rgba(201, 168, 106, .55);
    background: var(--gt-night-1);
}

.af-timeline li.is-release {
    border-top-color: var(--gt-spark);
    background: rgba(232, 180, 90, .17);
}

.af-timeline b { display: block; color: #fff; font-family: Cinzel, Georgia, serif; font-size: 1rem; }
.af-ms { display: block; color: var(--gt-amber); font-size: .9rem; font-variant-numeric: tabular-nums; }
.af-beat-note { display: block; margin-top: .3rem; color: var(--gt-muted); font-size: .86rem; line-height: 1.4; }

/* ---- The three forms ---- */
.af-forms {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1.1rem;
    margin-top: 1.25rem;
}

.af-form { display: grid; gap: .7rem; }
.af-side .af-stage { --af-scale: 2; }

/* The front view sets the width of the column it sits in, so it cannot measure that column: it
   takes its own size, in whole steps. */
.af-front .af-stage { --af-scale: 1; width: var(--af-cap); }

@supports (width: round(down, min(100% - 2px, 20px), 3px)) {
    .af-front .af-stage { width: max(var(--af-step), round(down, var(--af-cap) + .05px, var(--af-step))); }
}

.af-form-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: .9rem;
    padding: 0 .35rem;
}

.af-front figcaption {
    margin-top: .3rem;
    color: var(--gt-ink-soft);
    font-size: .78rem;
    text-align: center;
}

.public-wrapper .af-form h3 {
    margin: .1rem 0 .35rem;
    color: var(--gt-rust);
    font-family: Cinzel, Georgia, serif;
    font-size: 1.12rem;
    letter-spacing: .01em;
}

.af-form p { margin: 0 0 .55rem; color: var(--gt-ink-soft); font-size: .95rem; line-height: 1.5; }
.af-form a { color: var(--gt-rust); font-weight: 700; text-underline-offset: .2em; }
.af-form a:focus-visible { outline: 2px solid var(--gt-rust); outline-offset: 3px; }

/* ---- The wand wall ---- */
.af-wall {
    --af-scale: 1;
    display: grid;
    /* One tile: a 140-pixel cell and its border. */
    grid-template-columns: repeat(auto-fill, calc(140px * var(--af-scale) + 2px));
    justify-content: center;
    gap: 1rem .7rem;
    margin-top: 1.25rem;
    padding: 1.1rem .8rem 1.2rem;
    border: 1px solid rgba(201, 168, 106, .32);
    border-radius: 12px;
    background: linear-gradient(180deg, #0d1326 0%, #090d1a 100%);
}

.af-wand .af-stage { border-color: rgba(201, 168, 106, .18); }

/* The cast's ground ring is wider than the tile: it fades out toward the edges it would cross
   instead of ending on them. */
.af-wand .af-stage canvas,
.af-wand .af-stage img {
    -webkit-mask-image:
        linear-gradient(180deg, #000 84%, transparent 100%),
        linear-gradient(90deg, transparent 0, #000 11%, #000 93%, transparent 100%);
    -webkit-mask-composite: source-in;
    mask-image:
        linear-gradient(180deg, #000 84%, transparent 100%),
        linear-gradient(90deg, transparent 0, #000 11%, #000 93%, transparent 100%);
    mask-composite: intersect;
}
.af-wand .af-toggle { width: 1.35rem; height: 1.35rem; right: .2rem; bottom: .2rem; }
.af-wand .af-toggle::before { width: .5rem; height: .5rem; }
.af-wand figcaption { margin-top: .35rem; text-align: center; line-height: 1.25; }
.af-wand figcaption b { color: var(--gt-text); font-size: .8rem; font-weight: 600; }

/* ---- Between attacks ---- */
.af-details {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.1rem;
    margin-top: 1.25rem;
}

/* A card's stage and caption sit on rows it shares with its neighbours, so the captions line up
   under stages of different heights. */
.af-detail {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    row-gap: 0;
}

.af-detail .af-stage { --af-scale: 2; align-self: end; }

@media (min-width: 700px) {
    .af-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1250px) {
    .af-details { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* The dark play button keeps its light label on the parchment call to action. */
.af-page .gt-cta-actions .hero-play-cta { color: var(--gt-spark); }

@media (min-width: 1000px) {
    .af-hero { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 2.4rem; }
    .af-forms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .af-wall { --af-scale: 2; padding: 1.4rem 1rem 1.5rem; }
    .af-wand figcaption b { font-size: .9rem; }
}

@media (max-width: 860px) {
    .af-timeline { flex-direction: column; }
    .af-timeline li {
        display: grid;
        grid-template-columns: 5.5rem 4rem minmax(0, 1fr);
        align-items: baseline;
        gap: .6rem;
        flex: none;
        padding: .55rem .7rem;
        border-top: 0;
        border-left: 3px solid rgba(201, 168, 106, .55);
    }
    .af-timeline li.is-release { border-left-color: var(--gt-spark); }
    .af-beat-note { margin-top: 0; }
}
