/* ============================================================
   CARDS — an interactive encyclopaedia, not an admin panel

   Layout: compact toolbar, optional picker, then the selected
   card as the protagonist with every meaning laid out in full.
   ============================================================ */

.deck {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

/* ------------------------------------------------------------
   HEADER — tight, no large vertical gap before the content
   ------------------------------------------------------------ */

.deck-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.deck-header h1 {
    margin: 0;
    font-size: clamp(1.45rem, 5.5vw, 2.6rem);
}

.deck-header__subtitle {
    max-width: 58ch;
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin: 0;
    text-wrap: pretty;
}

/* ------------------------------------------------------------
   TOOLBAR — search, filters, picker toggle
   ------------------------------------------------------------ */

.deck-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    /* An indigo-tinted panel, not a plain white strip. */
    background: var(--surface-celestial);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: var(--border-width) solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.deck-toolbar__search {
    flex: 1 1 240px;
    min-width: 0;
}

.deck-toolbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Filter chips: a single row that scrolls sideways on narrow screens
   instead of wrapping into a tall block. */
.deck-filters {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    scrollbar-width: thin;
    /* Room for the focus ring, which the scroll container would clip. */
    padding: 3px;
    margin: -3px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.deck-filters::-webkit-scrollbar {
    height: 4px;
}

.deck-filters::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
}

.deck-filters .chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

@media (min-width: 768px) {
    .deck-filters {
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

/* ------------------------------------------------------------
   PICKER — the whole deck, filtered client-side
   ------------------------------------------------------------ */

.deck-picker {
    padding: var(--space-4);
    background: var(--bg-surface-sunken);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
}

.deck-picker__grid {
    display: grid;
    gap: var(--space-2);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.375rem), 1fr));
    max-height: min(52vh, 420px);
    overflow-y: auto;
    padding-right: var(--space-1);
}

.deck-picker__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg-surface);
    border: var(--border-width) solid transparent;
    border-radius: var(--radius-md);
    transition: color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}

.deck-picker__item:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.deck-picker__item.is-current {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
    border-color: var(--accent-ink);
}

.deck-picker__thumb {
    flex-shrink: 0;
    width: 28px;
    height: 48px;
    object-fit: cover;
    border-radius: 3px;
    background: var(--bg-surface-sunken);
}

.deck-picker__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deck-picker__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ------------------------------------------------------------
   VIEWER — the card is the protagonist
   ------------------------------------------------------------ */

.card-viewer {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
    align-items: start;
}

@media (min-width: 900px) {
    .card-viewer {
        /* Sized to the image, not stretched, and narrower than the artwork
           needs so the meanings column holds everything comfortably. */
        grid-template-columns: minmax(15.625rem, 20rem) 1fr;
        gap: var(--space-7);
    }
}

/* --- Artwork ------------------------------------------------- */

.card-stage {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    /* Keeps the artwork in view while the meanings are read on desktop. */
    position: static;
}

@media (min-width: 900px) {
    .card-stage {
        position: sticky;
        top: calc(var(--nav-height) + var(--space-4));
    }
}

.card-stage__frame {
    position: relative;
    /* Rider-Waite proportion: the image keeps its own aspect ratio. */
    max-width: 340px;
    margin-inline: auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: var(--border-width) solid var(--border);
    box-shadow: var(--shadow-lg);
    background: var(--bg-surface-sunken);
    /* Sin transicion mientras sigue al puntero y con ella al volver:
       interpolar hacia un objetivo que cambia cada fotograma es lo que
       hacia que las cartas de la tirada fueran medio segundo por detras
       del raton. */
    transition: transform var(--duration-base) var(--ease-out),
                box-shadow var(--duration-base) var(--ease-out);
}

/* Natural height: the viewer adapts to whatever proportion the artwork
   has, so nothing is cropped while the deck is being redrawn. */
.card-stage__frame img {
    display: block;
    width: 100%;
    height: auto;
}

/* A thin gilded edge, drawn over the image without resizing it. */
/* El filete dorado, y tambien el reflejo que recorre la carta siguiendo
   al puntero. Van en el mismo pseudoelemento porque `::before` ya lleva
   el resplandor exterior y no quedan mas: anadir un `<span>` solo para un
   adorno seria meter un nodo en la plantilla por un efecto. */
.card-stage__frame::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    border-radius: var(--radius-md);
    pointer-events: none;
    background: radial-gradient(
        circle at var(--shine-x, 50%) var(--shine-y, 50%),
        color-mix(in srgb, var(--gold-bright) 34%, transparent),
        transparent 55%
    );
    /* Apagado hasta que el puntero entra: si no, la carta llevaria una
       mancha dorada fija en el centro. */
    background-size: 0 0;
    transition: background-size var(--duration-base) var(--ease-out);
}

.card-stage__frame.is-tilting::after {
    background-size: 100% 100%;
}

/* --- Previous / next ------------------------------------------ */

.card-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    max-width: 340px;
    margin-inline: auto;
    width: 100%;
}

.card-nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 40px;
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    text-decoration: none;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-pill);
    transition: all var(--duration-fast) var(--ease-out);
    max-width: 45%;
}

.card-nav__link:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.card-nav__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-nav__position {
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

/* --- Identity column ------------------------------------------ */

.card-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.card-meta__group {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--accent-ink);
}

.card-meta__name {
    font-size: clamp(1.4rem, 6vw, 2.75rem);
    line-height: 1.05;
    margin: 0;
}

.card-meta__keywords {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.card-meta__summary {
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-secondary);
    margin: 0;
    text-wrap: pretty;
}

/* ------------------------------------------------------------
   YUNA'S ADVICE
   ------------------------------------------------------------ */

.yuna-note {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    overflow: hidden;
    background: var(--surface-celestial-strong);
    border: var(--border-width) solid var(--border-accent);
    border-radius: var(--radius-lg);
    animation: note-enter var(--duration-slow) var(--ease-out) both;
}

@keyframes note-enter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* A faint moon in the corner, purely atmospheric. */
.yuna-note::after {
    content: "";
    position: absolute;
    top: -34px;
    right: -34px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 35% 35%,
        color-mix(in srgb, var(--gold) 26%, transparent),
        transparent 68%
    );
    pointer-events: none;
}

.yuna-note__avatar {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    object-fit: contain;
    filter: drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 35%, transparent));
}

.yuna-note__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.yuna-note__name {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.yuna-note__text {
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--text-secondary);
    margin: 0;
    text-wrap: pretty;
}

@media (prefers-reduced-motion: reduce) {
    .yuna-note { animation: none; }
}

/* --- Blocks inside a panel ------------------------------------ */

.block {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
    /* Hides the corner arc where it passes the rounded edge; without it the
       arc bled past as a grey smudge. */
    overflow: hidden;
    background: var(--surface-celestial);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--duration-base) var(--ease-out),
                box-shadow var(--duration-base) var(--ease-out);
}

.block__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--secondary-contrast);
    margin: 0;
}

.block__text {
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--text-secondary);
    margin: 0;
    text-wrap: pretty;
}

/* Compact fact grid for the correspondences. */
/* Flex y no grid, a proposito.
 *
 * Con `grid` y `auto-fill`, las siete fichas cortas caian en columnas
 * fijas y la septima se quedaba sola en su fila con un hueco al lado.
 * Una rejilla no puede saber cuantas columnas le han tocado, asi que no
 * hay forma de decirle a la ultima que ocupe lo que sobra.
 *
 * En flex si: la ultima fila reparte el ancho entre lo que haya. Siete
 * fichas quedan en cuatro y tres, o en tres y cuatro, pero nunca con un
 * hueco. Y a la de «Fechas», que es la del texto mas largo, estirarse le
 * viene bien.
 */
.fact-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.fact-grid > * {
    flex: 1 1 10rem;
    min-width: 0;
}

.fact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-celestial);
    border-radius: var(--radius-md);
    box-shadow: var(--ring-gold);
}

/* Shared with `.trait` on the horoscope: one micro-label for the whole app,
   so a correspondence here and a correspondence there look alike. */
.fact__label {
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--accent-ink);
}

/* Mismo tamano que el texto de los demas bloques de la carta (`.block__text`).
   A --text-lg en seminegrita, las correspondencias largas eran un bloque de
   letra grande y pesada que no parecia de la misma pagina. El peso medio y
   el color primario bastan para que el dato destaque sobre su etiqueta. */
.fact__value {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    /* Sans, no la serif de titulares.
     *
     * La serif es para nombrar: una carta, un signo, Yuna. Un dato no se
     * nombra, se lee —«Aire», «Urano», «Luna creciente»— y puesto en
     * serif junto a su etiqueta en sans el panel suena a dos voces y
     * parece pegado de otra pagina.
     *
     * Es el mismo criterio que ya se aplico a la cita de Yuna cuando la
     * serif a --text-lg hacia que la lectura conjunta no pareciera del
     * mismo sitio que los parrafos de al lado. */
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    text-wrap: pretty;
}

/* A fixed box, so the values start on the same line across a row however
   wide each mark happens to draw. */
.fact__icon,
.fact__glyphs,
.fact__swatch {
    flex-shrink: 0;
    width: 1.4rem;
    text-align: center;
}

.fact__value .material-symbols-rounded {
    font-size: 1rem;
    color: var(--card-accent, var(--accent));
}

.fact__swatch {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--card-accent, var(--accent));
    border: 1px solid var(--border-strong);
}

/* Without JavaScript the tab bar cannot work, so the bar is hidden and every
   panel is shown instead: all the information stays reachable. */

/* ============================================================
   MYSTICAL TREATMENT
   Alternating indigo and violet instead of gold everywhere, so
   the page reads like Yuna rather than like a gilded panel.
   ============================================================ */

/* Long correspondences take a full row; short ones stay as chips. */
/* Las de texto largo ocupan la fila entera. `100%` y no `1 1 100%`,
   porque con `flex-grow` compartirian linea con la anterior si cupiera. */
.fact--wide {
    flex-basis: 100%;
}

/* Each fact gets a hairline of the accent down its leading edge. */
.fact {
    position: relative;
    overflow: hidden;
    border: var(--border-width) solid var(--border);
    transition: border-color var(--duration-fast) var(--ease-out),
                background-color var(--duration-fast) var(--ease-out);
}

.fact::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 2px;
    background: linear-gradient(
        180deg,
        var(--secondary),
        color-mix(in srgb, var(--gold) 70%, transparent)
    );
    opacity: 0.6;
}

.fact:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-accent);
}

/* Alternate the icon hue so a long grid is not a wall of gold. */
/* `--secondary-contrast` y no `--secondary`: un icono cuenta como texto
   para el contraste, y el violeta medio se quedaba en 4.34 sobre la
   tarjeta, por debajo de AA. Para eso existe el token de contraste. */
.fact:nth-child(odd) .fact__value .material-symbols-rounded {
    color: var(--secondary-contrast);
}

.fact:nth-child(even) .fact__value .material-symbols-rounded {
    color: var(--accent);
}

/* --- Meaning blocks ------------------------------------------- */

.block:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
}

/* A thin crescent arc in the corner, in place of the large radial blob
   that used to smudge the edge. */
.block::after {
    content: "";
    position: absolute;
    top: -18px;
    right: -18px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1.5px solid color-mix(in srgb, var(--gold) 34%, transparent);
    border-right-color: transparent;
    border-bottom-color: transparent;
    opacity: 0.8;
    pointer-events: none;
}

/* Block headings alternate violet and indigo, gold reserved for the card. */
/* --- Tag colours ---------------------------------------------- */

/* Keywords alternate so the row is not a single gold band. */
.card-meta__keywords .tag:nth-child(3n + 1) {
    color: var(--accent-contrast);
    background: var(--accent-soft);
}

.card-meta__keywords .tag:nth-child(3n + 2) {
    color: var(--secondary-contrast);
    background: var(--secondary-soft);
}

.card-meta__keywords .tag:nth-child(3n) {
    color: var(--accent-ink);
    background: var(--gold-soft);
}

/* --- Card frame ------------------------------------------------ */

/* A violet halo behind the artwork, gold only on the inner edge. */
.card-stage__frame::before {
    content: "";
    position: absolute;
    inset: -14px;
    z-index: -1;
    border-radius: var(--radius-lg);
    background: radial-gradient(
        circle at 50% 40%,
        color-mix(in srgb, var(--secondary) 26%, transparent),
        transparent 70%
    );
}

/* ============================================================
   SEARCH — a scrying bar, not a form field

   It read as a plain input on a plain white strip. It now sits
   on an indigo-tinted panel with a gold hairline and a moon
   glow that answers to focus.
   ============================================================ */

.deck-toolbar {
    position: relative;
}

/* No gold hairline here: on a rounded panel it read as a stray orange
   streak crossing the corners. The violet tint and the border carry the
   treatment instead. */

.deck-toolbar .input {
    background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
    border-color: var(--border-accent);
    border-radius: var(--radius-pill);
    padding-left: calc(var(--space-5) + 1.1rem);
    transition: box-shadow var(--duration-base) var(--ease-out),
                border-color var(--duration-base) var(--ease-out),
                background-color var(--duration-base) var(--ease-out);
}

.deck-toolbar .input:focus {
    background: var(--bg-surface);
    border-color: var(--secondary);
    box-shadow: var(--glow-accent), 0 0 24px color-mix(in srgb, var(--secondary) 28%, transparent);
}

.deck-toolbar .search__icon {
    left: var(--space-4);
    color: var(--secondary-contrast);
    transition: color var(--duration-fast) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
}

.deck-toolbar .search__field:focus-within .search__icon {
    color: var(--accent-ink);
    transform: translateY(-50%) scale(1.12);
}

/* The "all cards" control reads as the primary action of the bar. */
.deck-toolbar [data-picker-toggle] {
    border-color: var(--border-accent);
    background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
}

.deck-toolbar [data-picker-toggle]:hover,
.deck-toolbar [data-picker-toggle][aria-expanded="true"] {
    color: var(--text-on-accent);
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    border-color: transparent;
}

/* ============================================================
   KEYWORDS — tinted with the card's own dominant colour
   ============================================================ */

.card-meta__keywords .tag {
    position: relative;
    overflow: hidden;
    color: color-mix(in srgb, var(--card-accent, var(--accent)) 78%, var(--text-primary));
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--card-accent, var(--accent)) 30%, transparent);
    transition: transform var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-base) var(--ease-out),
                background-color var(--duration-base) var(--ease-out);
}

/* The alternating palette from before must not override the card tint. */
.card-meta__keywords .tag:nth-child(3n + 1),
.card-meta__keywords .tag:nth-child(3n + 2),
.card-meta__keywords .tag:nth-child(3n) {
    color: color-mix(in srgb, var(--card-accent, var(--accent)) 78%, var(--text-primary));
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 14%, var(--bg-surface));
}

.card-meta__keywords .tag:hover {
    transform: translateY(-2px);
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 24%, var(--bg-surface));
    box-shadow: 0 0 14px color-mix(in srgb, var(--card-accent, var(--accent)) 40%, transparent);
}

/* A sheen crosses the keyword on hover. */
.card-meta__keywords .tag::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        115deg,
        transparent 40%,
        color-mix(in srgb, #fff 55%, transparent) 50%,
        transparent 60%
    );
    background-size: 280% 100%;
    background-position: 170% 0;
    pointer-events: none;
}

.card-meta__keywords .tag:hover::after {
    transition: background-position 700ms var(--ease-out);
    background-position: -70% 0;
}

@media (prefers-reduced-motion: reduce) {
    .card-meta__keywords .tag,
    .card-meta__keywords .tag::after {
        transition: none;
    }

    .card-meta__keywords .tag:hover {
        transform: none;
    }
}

/* ============================================================
   MEANING GROUPS
   Tabs hid most of a card behind clicks. Everything is shown at
   once now, so the grouping has to carry the structure that the
   tab bar used to: a clear heading per group, and blocks that
   are pleasant to read one after another.
   ============================================================ */

.card-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    scroll-margin-top: calc(var(--nav-height) + var(--space-4));
}

.card-group__body {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}

@media (min-width: 640px) {
    .card-group__body {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.25rem), 1fr));
    }
}

.block--wide {
    grid-column: 1 / -1;
}

/* --- Block refinements for the stacked layout ----------------- */

.block__title .material-symbols-rounded {
    font-size: 1rem;
    color: var(--accent-ink);
}

/* Tags inside a card take the card's own colour, like the keywords. */
.tag-card {
    color: color-mix(in srgb, var(--card-accent, var(--accent)) 76%, var(--text-primary));
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 12%, var(--bg-surface));
    border: 1px solid color-mix(in srgb, var(--card-accent, var(--accent)) 26%, transparent);
    transition: transform var(--duration-fast) var(--ease-out),
                background-color var(--duration-fast) var(--ease-out);
}

.tag-card:hover {
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--card-accent, var(--accent)) 20%, var(--bg-surface));
}

@media (prefers-reduced-motion: reduce) {
    .tag-card:hover {
        transform: none;
    }
}

/* ============================================================
   COLLAPSIBLE GROUPS
   `<details>` carries the open state, so the arrow and spacing
   follow it without any script.
   ============================================================ */

.card-group {
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--bg-surface) 55%, transparent);
    overflow: hidden;
}

.card-group__summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color var(--duration-fast) var(--ease-out);
}

/* Hide the native marker in every engine. */
.card-group__summary::-webkit-details-marker {
    display: none;
}

.card-group__summary:hover {
    background: var(--bg-surface-hover);
}

.card-group__summary:focus-visible {
    outline: var(--border-width-thick) solid var(--secondary);
    outline-offset: -2px;
}

.card-group__label {
    flex: 1;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.card-group__chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--duration-base) var(--ease-out);
}

.card-group[open] .card-group__chevron {
    transform: rotate(180deg);
}

.card-group__body {
    padding: 0 var(--space-4) var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
    .card-group__chevron { transition: none; }
}

/* ============================================================
   CLICKABLE MEANING BLOCKS
   ============================================================ */

.block--open {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 100%;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.block--open .block__title,
.block--open .block__text {
    display: block;
}

.block--open .block__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Long passages are clipped in the grid; the dialog shows them whole. */
.block--open .block__text {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.block__more {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    display: inline-flex;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.block__more .material-symbols-rounded {
    font-size: 1rem;
}

.block--open:hover .block__more,
.block--open:focus-visible .block__more {
    opacity: 1;
}

.block--open:focus-visible {
    outline: var(--border-width-thick) solid var(--secondary);
    outline-offset: 2px;
}

/* ============================================================
   DETAIL DIALOG
   ============================================================ */

.detail-dialog {
    width: min(560px, calc(100vw - 2 * var(--space-4)));
    padding: 0;
    color: var(--text-primary);
    background: var(--bg-surface);
    border: var(--border-width) solid var(--border-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), var(--glow-moon);
}

.detail-dialog::backdrop {
    background: var(--overlay);
    backdrop-filter: blur(3px);
}

.detail-dialog__inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
}

.detail-dialog__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.detail-dialog__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--secondary-contrast);
    background: linear-gradient(140deg, var(--accent-soft), var(--secondary-soft));
    border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
    border-radius: var(--radius-pill);
}

.detail-dialog__title {
    flex: 1;
    margin: 0;
    font-size: var(--text-xl);
}

.detail-dialog__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    color: var(--text-secondary);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius-pill);
    transition: all var(--duration-fast) var(--ease-out);
}

.detail-dialog__close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.detail-dialog__text {
    margin: 0;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-secondary);
    text-wrap: pretty;
}

.detail-dialog__footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-top: var(--space-3);
    border-top: var(--border-width) solid var(--border);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.detail-dialog__footer img {
    border-radius: var(--radius-pill);
}

/* --- Marks inside a correspondence ------------------------------- */

/* The sign's own glyph, which carries more than a generic star. */
.fact__glyphs {
    width: auto;
    font-size: 1.3rem;
    line-height: 1;
    letter-spacing: 0.08em;
    color: var(--accent-ink);
    flex-shrink: 0;
}

/* An answer is a tick, a cross or a question mark, and each is read at a
   glance only if it is coloured like what it means. */
.fact__icon--check_circle {
    color: var(--success);
}

.fact__icon--cancel {
    color: var(--danger);
}

.fact__icon--help {
    color: var(--accent-ink);
}

/* El rastro de vuelta al catalogo, encima del nombre de la carta. */
.deck-header__eyebrow {
    margin: 0 0 var(--space-1);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--text-muted);
}

.deck-header__eyebrow a {
    color: inherit;
    text-decoration: none;
}

.deck-header__eyebrow a:hover,
.deck-header__eyebrow a:focus-visible {
    color: var(--accent-ink);
    text-decoration: underline;
}

/* El aviso de «esto es lo mas parecido», cuando la busqueda exacta no
   encuentra nada y se ensena una sugerencia en su lugar. */
.deck-suggestion {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--surface-celestial);
    border: var(--border-width) solid var(--border);
    border-left: 3px solid var(--gold);
    border-radius: var(--radius-md);
}

.deck-suggestion .material-symbols-rounded {
    font-size: 1.15rem;
    color: var(--accent-ink);
}

/* ============================================================
   LA CARTA GRANDE, HACIA EL PUNTERO

   El mismo giro que las de una tirada. `flourish.js` escribe
   las cuatro variables; el movimiento vive aqui, con la carta.
   ============================================================ */

/* `perspective()` como funcion y no como propiedad: la propiedad se
   aplica a los hijos, y aqui el que gira es el propio elemento. */
.card-stage__frame.is-tilting {
    transition: box-shadow var(--duration-base) var(--ease-out);
    transform: perspective(1100px)
               rotateX(var(--tilt-x, 0deg))
               rotateY(var(--tilt-y, 0deg))
               scale(1.02);
    box-shadow: var(--shadow-lg), var(--glow-card);
}


@media (prefers-reduced-motion: reduce) {
    .card-stage__frame,
    .card-stage__frame.is-tilting {
        transform: none;
        transition: none;
    }
}
