/*
 * Act III — the reading, over a dimmed board.
 *
 * The second thing in this client allowed a ground of its own (the Attunement is the
 * other), and for the same reason: the board paints furniture for cards, coins, wards and
 * a shelf, and nowhere at all for a paragraph. Everything here floats, so it carries its
 * own surface — unbacked prose over candlelight and painted ivy is unreadable.
 *
 * Laid out as headline / portrait / paragraph on purpose. That is the shape a shared
 * reading has to have, so Phase 10 photographs this instead of laying it out again.
 */

.reading {
    position: absolute;
    inset: 0;
    /* Above the Attunement (60), because a reading can only exist after one. */
    z-index: 70;

    background:
        radial-gradient(ellipse at 50% 45%,
            color-mix(in srgb, var(--colour-table-deep) 86%, transparent) 0%,
            color-mix(in srgb, black 94%, transparent) 72%);
    backdrop-filter: blur(3px);
}

/*
 * `[hidden]` is `!important` in reset.css so nothing can leave a hidden element on
 * screen; the grid therefore goes on a selector that only matches when it is not.
 */
/*
 * Three children — sheet, controls, door — sized to their content and centred as one
 * block.
 *
 * The sheet used to take `1fr`, which meant it absorbed every spare pixel on the stage
 * and the two rows under it were pushed to the floor. The prose and the portrait are
 * centred *inside* that stretched box, so the space came out as a gap between the bottom
 * of the card and the buttons, and the door ended up sitting on the bottom edge reading
 * like a footer — which is the one thing this control must not look like, since it is the
 * whole reason the game exists (D5).
 *
 * `minmax(0, auto)` rather than plain `auto` so a long reading can still shrink rather
 * than overflow the stage; `min-height: 0` on the sheet is what lets that reach the prose.
 */
.reading:not([hidden]) {
    display: grid;
    grid-template-rows: minmax(0, auto);
    justify-items: center;
    align-content: center;
    gap: 2.4cqh;
    padding: 4cqh 5cqw 3cqh;
}

/* --- The sheet ------------------------------------------------------------ */

.reading__sheet {
    display: grid;
    /*
     * The prose column is bounded rather than elastic, because the constraint here is
     * the *measure* and not the space. Given `1fr` the paragraph filled the stage and
     * ran to about ninety-five characters a line, which is roughly half as long again as
     * anything anyone reads comfortably — and the failure is invisible in a check, since
     * a line that is too long is still a line that fits.
     */
    grid-template-columns: auto minmax(0, 40cqw);
    justify-content: center;
    align-items: center;
    gap: 3.5cqw;
    min-height: 0;

    /*
     * Arrives by fading and rising — NOT by scaling.
     *
     * The portrait's text is fitted the moment it mounts, and the fitter compares a
     * measured box against the declared `--seat-scale`. An arrival that scaled an
     * ancestor would hand it a box a few per cent wrong and it would pick a title size to
     * match, which is precisely how THE REVENANT lost the serifs off both its T's in
     * Phase 7. `translate` and `opacity` move the sheet without resizing anything in it.
     */
    animation: reading-arrive 460ms var(--ease-deal) both;
}

@keyframes reading-arrive {
    0% { translate: 0 2.5cqh; opacity: 0; }
    100% { translate: 0 0; opacity: 1; }
}

/*
 * The Destiny, at a size worth looking at. Sized and scaled exactly as a table seat and
 * the board's own panel are — laid out at reading size, scaled down by a mount — so the
 * card never knows it is being shown small (see "Rendered large, shown small").
 */
.reading__portrait {
    position: relative;
    --seat-cqh: 40;
    --seat-scale: calc(var(--seat-cqh) / var(--render-cqh));
    width: calc(var(--seat-cqh) * 1cqh);
    aspect-ratio: var(--card-aspect);
    filter: drop-shadow(0 1.6cqh 2.6cqh rgb(0 0 0 / 70%))
            drop-shadow(0 0 2cqh color-mix(in srgb, var(--colour-gold) 26%, transparent));
}

.reading__mount {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    width: calc(var(--render-cqh) * 1cqh);
    aspect-ratio: var(--card-aspect);
    transform: translate(-50%, -50%) scale(var(--seat-scale));
}

/*
 * The card fills its mount, and this rule is not optional.
 *
 * `.card` carries no size of its own — every place that shows one gives it a box, and a
 * mount without this rule leaves the card at whatever its content happens to measure.
 * It renders, it composites, its text fits, and it is simply the wrong size: which is
 * exactly what happened here, and looked like a deliberately small card rather than a
 * missing declaration.
 */
.reading__portrait .card {
    position: absolute;
    inset: 0;
    width: 100%;
}

.reading__column {
    display: grid;
    gap: 1.6cqh;
    min-width: 0;
    min-height: 0;
}

.reading__title {
    font-family: var(--font-display);
    font-size: 3.1cqh;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    line-height: 1.1;

    /*
     * The same lettering the cards carry: a gradient clipped to the glyphs over a shadow
     * straight down. The shadow must be a `drop-shadow` filter and not a `text-shadow` —
     * with `color: transparent` a text-shadow paints behind a fill that is not there.
     */
    background: linear-gradient(180deg,
        var(--colour-gold-bright) 0%, var(--colour-gold) 55%, var(--colour-gold-deep) 100%);
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0.25cqh 0.5cqh rgb(0 0 0 / 85%));
}

.reading__prose {
    font-family: var(--font-body);
    font-size: 2.35cqh;
    line-height: 1.52;
    color: var(--colour-text);
    text-shadow: 0 0.2cqh 1cqh rgb(0 0 0 / 85%);

    /*
     * Tall enough for a deeper reading, which is the case that decides this number.
     *
     * At 46cqh it clipped the last two lines of the third stanza — and a premise that
     * stops mid-sentence looks exactly like a premise that ends there, which is the one
     * way this screen fails without appearing to. The cap is still here because on a
     * short window something has to give, and it scrolls rather than shrinking: prose
     * sized down to fit is prose nobody reads, the same rule the copy budgets follow.
     */
    max-height: 62cqh;
    overflow-y: auto;
    padding-inline-end: 1cqw;
}

.reading__stanza + .reading__stanza {
    margin-block-start: 1.4cqh;
}

/* The Destiny framing. Set apart, because it is about the reader and the rest is not. */
.reading__stanza--invocation {
    font-style: italic;
    color: color-mix(in srgb, var(--colour-gold-bright) 78%, var(--colour-text));
}

/*
 * There is deliberately no rule here for a clause, a live element or a hover state.
 *
 * The first version underlined every card-derived fragment and made it clickable — spend
 * a Fate, wander that card, watch the sentence rewrite. It went, and the marking went with
 * it (D23): five underlined phrases in a paragraph *teach the reader how the paragraph was
 * built*, and a player who has worked out that each card is a phrase is no longer reading
 * a story. The prose is prose.
 */

.reading__note {
    font-family: var(--font-display);
    font-size: 1.5cqh;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--colour-gold) 85%, transparent);
    text-shadow: 0 0.2cqh 0.8cqh rgb(0 0 0 / 90%);
    transition: opacity 200ms ease;
}

/* Nothing to say about a reading that has not finished arriving. */
.reading[data-phase='typing'] .reading__note {
    opacity: 0;
}

/* --- The controls --------------------------------------------------------- */

.reading__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5cqw;
}

/*
 * No purse here either. Fate buys nothing on this screen, and a supply drawn where it
 * cannot be spent is an invitation to look for the thing that spends it.
 */

/*
 * The payoff control on the shelf. Filled rather than outlined, because it is the one
 * button on that strip that is the *point* of the four beside it — and it only ever
 * appears once every card is face up, so it never has to compete with Deal.
 */
.table__button--payoff {
    border-color: var(--colour-gold);
    background: color-mix(in srgb, var(--colour-gold) 22%, transparent);
}

.table__button--payoff:hover:not(:disabled) {
    background: color-mix(in srgb, var(--colour-gold) 34%, transparent);
}

/* --- The Verse Draft door (D5) ------------------------------------------- */

/*
 * The CTA, under the reading's own controls.
 *
 * Deliberately *not* a fifth button in the row above. The three minor controls and the
 * payoff are all things you do to this reading; this is the one thing that leaves, and a
 * link off the site sitting in a row of in-page actions reads as an advertisement wearing
 * the interface's clothes. Given its own line and its own mark, it reads as a door.
 *
 * The mark carries the invitation and the words underneath state it plainly, because the
 * logo alone assumes a visitor who already knows what Verse Draft is — and the whole
 * point of this door is the visitor who does not.
 */
.reading__door {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Tight, because the three parts are one sentence. Loose enough to be three lines
       and they stop reading as a phrase and start reading as a stack of labels. */
    gap: 0.25cqh;
    /*
     * No margin above it. The grid already puts `2.4cqh` between every row, and this
     * added the same again on top — so the door sat twice as far from the controls as the
     * controls sit from the sheet, for no reason anyone chose. Two mechanisms spacing the
     * same seam is how a gap ends up a number nobody meant.
     */
    padding: 1.4cqh 2.4cqw;
    border-radius: 0.5rem;
    border: 1px solid color-mix(in srgb, var(--colour-gold) 26%, transparent);
    background: color-mix(in srgb, var(--colour-table-deep) 70%, transparent);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 200ms var(--ease-deal), background-color 200ms var(--ease-deal);
}

/* The promise, first and largest. */
.reading__door-line {
    font-family: var(--font-display);
    font-size: 1.7cqh;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--colour-gold);
}

/*
 * The hinge. Small, quiet and lowercase on purpose: it is a word doing grammar rather
 * than a word doing work, and at the same weight as the line above it the whole control
 * would read as three competing labels instead of one sentence.
 */
.reading__door-with {
    font-family: var(--font-display);
    font-size: 1.15cqh;
    letter-spacing: 0.24em;
    /* Capitals like the line above it. Lowercase read as a different voice cutting in
       between the promise and the mark, which is exactly what it is not. */
    text-transform: uppercase;
    color: var(--colour-text-muted);
}

.reading__door-mark {
    border-radius: 0.25rem;
    width: 14cqw;
    max-width: 20rem;
    height: auto;
}

/*
 * The maker's mark, at half the product's width.
 *
 * Half of every value above it rather than a size of its own, so the two stay in
 * proportion at any viewport — the door is sized in `cqw` and a fixed width here would
 * drift away from the logo it sits under as the stage changes.
 *
 * The column already puts `0.25cqh` between its children, which is about 2px at a 900px
 * stage; this tops that up to roughly five. Stated as the *difference* rather than as the
 * whole gap, because the flex gap is still there and writing 5px here would silently mean
 * seven — the same double-spacing that had the door itself sitting twice as far from the
 * controls as anything intended.
 */
.reading__door-company {
    width: 7cqw;
    max-width: 10rem;
    height: auto;
    margin-block-start: 0.3cqh;
    /* It is a signature, not a second call to action. */
    opacity: 0.75;
}

.reading__door:hover,
.reading__door:focus-visible {
    border-color: var(--colour-gold);
    background: color-mix(in srgb, var(--colour-table-raised) 80%, transparent);
}

.reading__door:hover .reading__door-line,
.reading__door:focus-visible .reading__door-line {
    color: var(--colour-gold-bright);
}
