/* Section grid: the wiki's top-level sections as photo cards, three to a row, inserted into a page
   as a sectionGrid block. The home page uses it to list every console. Also the sidebar's
   linked-page marker, because both arrived with the same restructure (15 November 2026). */

.section-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 24px 0;
}

/* Never below two across: on a phone one tall card per row is a scroll, not a menu. */
@media (max-width: 760px) {
    .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

/* The filter box above a grid: one search field in the house input style. */
.section-grid-block { margin: 24px 0; }
.section-grid-block .section-grid { margin-top: 14px; }

.section-grid-search {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-muted);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.section-grid-search:focus-within {
    border-color: color-mix(in oklab, var(--color-primary) 55%, var(--color-border));
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-primary) 18%, transparent);
    color: var(--color-text);
}

.section-grid-search input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--color-text);
    font: inherit;
    font-size: 1rem;
}

.section-grid-search input::-webkit-search-cancel-button { cursor: pointer; }

/* A square card with the cut-out console floating in the top two thirds and its name over the
   foot: big, bold, centred, on a gradient that fades up from the card surface. One border, and
   hovering lifts the card with the same soft accent glow the subscription panel has; every
   colour is a theme variable. */
.section-card,
.page-content a.section-card {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 100%, color-mix(in oklab, var(--color-primary) 9%, transparent), transparent 60%),
        var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

/* The filter hides cards with the hidden attribute. The display:block above (and the theme's
   own link rules) outrank the attribute selector, so this is the one place !important is right. */
.section-card[hidden],
.page-content a.section-card[hidden] { display: none !important; }

.section-card:hover,
.page-content a.section-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in oklab, var(--color-primary) 55%, var(--color-border));
    box-shadow: 0 28px 60px -36px color-mix(in oklab, var(--color-primary) 80%, transparent);
    text-decoration: none;
}

/* The photo is a transparent cut-out, so a drop-shadow follows the console's own outline: a
   soft dark one for depth and a faint accent-coloured one for the glow, stronger on hover. */
.section-card img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center 50%;
    padding: 7% 10% 38%;
    box-sizing: border-box;
    display: block;
    filter:
        drop-shadow(0 10px 18px rgba(var(--black-rgb),0.55))
        drop-shadow(0 0 10px color-mix(in oklab, var(--color-primary) 28%, transparent));
    transition: transform var(--transition), filter var(--transition);
}

.section-card:hover img {
    transform: scale(1.05);
    filter:
        drop-shadow(0 14px 22px rgba(var(--black-rgb),0.6))
        drop-shadow(0 0 16px color-mix(in oklab, var(--color-primary) 55%, transparent));
}

/* The theme frames every content image (1px border, hover ring and glow, scale) and that frame
   is what drew two extra rectangles inside each card: the cut-out's box is the card itself. The
   theme's selector outweighs any class here, so these few properties are forced off. */
.page-content .section-card img,
.page-content .section-card img:hover {
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
}

.section-card-glyph {
    position: absolute;
    inset: 0 0 26%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.2rem;
}

.section-card-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 34% 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
    background: linear-gradient(to top,
        var(--color-surface) 0%,
        color-mix(in srgb, var(--color-surface) 92%, transparent) 38%,
        transparent 100%);
    pointer-events: none;
}

.section-card-title {
    font-family: var(--font-heading, inherit);
    font-weight: 800;
    font-size: clamp(1.05rem, 1.6vw + 0.5rem, 1.45rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--color-text);
    text-shadow: 0 2px 10px rgba(var(--black-rgb),0.55);
}

.section-card-count {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

@media (max-width: 760px) {
    .section-card-title { font-size: 1rem; }
    .section-card-count { display: none; }
}

.section-grid-empty {
    grid-column: 1 / -1;
    color: var(--color-text-muted);
    font-size: var(--size-small);
}

/* Linked page in the sidebar: same row as any page, plus a small chain mark after the title. */
.tree-item.is-link .tree-link-mark {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    color: var(--color-text-muted);
    opacity: 0.8;
    flex-shrink: 0;
}

/* The block as the editor shows it: a labelled placeholder, since the cards need the live tree. */
.section-grid-editor {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 12px 0;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: var(--size-small);
    cursor: pointer;
    user-select: none;
}

.section-grid-editor strong { color: var(--color-text); }

.ProseMirror-selectednode.section-grid-editor { border-color: var(--color-primary); }

/* The linked-page picker's result list (sidebar "Add linked page"). */
.link-page-results {
    margin-top: 8px;
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.link-page-result {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
    font-size: var(--size-small);
}

.link-page-result:hover { background: var(--color-surface); }
.link-page-result.selected { border-color: var(--color-primary); background: var(--color-surface); }
.link-page-result-icon { flex-shrink: 0; }
.link-page-result-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-page-result-slug { color: var(--color-text-muted); font-size: 0.75rem; flex-shrink: 0; }

/* A console folder's page: its cut-out sits behind the title and intro as a hero, half visible
   at the top and gone by its own foot, so the picture is a backdrop rather than a figure. The
   first picture in the folder's own text is the same console, so it is not drawn twice. */
.wiki-page.has-hero { position: relative; }

.page-hero {
    position: absolute;
    top: 0;
    right: -24px;
    width: min(62%, 560px);
    aspect-ratio: 1 / 1;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: top right;
    opacity: 0.5;
    -webkit-mask-image: linear-gradient(to bottom, var(--mask-solid) 0%, rgba(var(--black-rgb),0.55) 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, var(--mask-solid) 0%, rgba(var(--black-rgb),0.55) 55%, transparent 100%);
    pointer-events: none;
    z-index: 0;
    filter: drop-shadow(0 0 24px color-mix(in oklab, var(--color-primary) 30%, transparent));
}

.wiki-page.has-hero > *:not(.page-hero) { position: relative; z-index: 1; }

.wiki-page.has-hero .page-content > img.wiki-img:first-of-type,
.wiki-page.has-hero .page-content > figure:first-of-type,
.wiki-page.has-hero .page-content > p:first-of-type > img.wiki-img:only-child { display: none; }

@media (max-width: 760px) {
    .page-hero { width: 80%; right: -10px; opacity: 0.35; }
}
