/* ---------- Collection pages (shared by Apps, Code, Art + Talks) ----------
   Page-agnostic structure: container width, responsive grid, card shell +
   hover, detail two-column layout, the detail header (name/tagline/media/links),
   and the JS swap fade. Page-specific card internals live in apps.css /
   code.css / art.css / talks.css. The Tech-Specs key/value list the detail
   sidebars use is the shared .spec-list component in site.css. */

/* Container width: every collection page widens the content column (and the
   footer, via the shared --page-width mechanism in site.css); grids widen
   further at the 3-col tier (see the min-width rule at the bottom). */
body:has(.collection) {
    --page-width: 1100px;
}

/* Detail pages read a touch wider than the 1100px base (the prose + sidebar
   want a little more room). They're excluded from the grid's wide tier below,
   so this is their fixed width at all sizes. (Same specificity as the rule
   above - being later in the file is what makes it win.) */
body:has(.collection-detail) {
    --page-width: 1250px;
    /* Ceiling for the detail hero media's height: full viewport minus the room the
       header takes plus a peek of the description below. On tall screens this term
       never binds (media keeps its natural, content-width height); on short ones
       (e.g. an iPad) the media caps here and narrows to keep its ratio, so the
       header and a sliver of prose stay on screen. */
    --detail-media-max-h: calc(100vh - 25rem);
}

.collection {
    margin-top: 40px;
}

/* Plain text links in collection prose (descriptions, section blurbs) read in
   the text colour with a quiet underline and only turn red on hover, like the
   sidebar and Contact links. The red link colour is for the blog. Classed
   anchors (cards, badges, filters) keep their own styling. */
.collection a:not([class]) {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--text-tertiary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.collection a:not([class]):hover {
    color: var(--link);
    text-decoration-color: currentColor;
}

/* On short viewports the whole detail column narrows (centred) so its aspect-ratio
   hero fits vertically with the header and a peek of prose still on screen - the
   column moves as one, not just the media. Width is driven off the hero's ratio
   (16:10 for an empty app stage, 16:9 for the shot everywhere else); on tall
   screens --detail-media-max-h is large, so neither term binds and the column
   keeps its full width. The 850px floor stops the two-column body from collapsing
   when the window gets very short - past that the hero just overflows and scrolls. */
.collection-detail:has(.collection-detail-shot) {
    max-width: min(100%, max(850px, calc(var(--detail-media-max-h) * 16 / 9)));
    margin-inline: auto;
}

/* Centered page title + subtitle. Size/weight/alignment/colour come from the
   global .page-title / .page-subtitle rules; this only adjusts spacing,
   size and measure. */
.collection .page-title {
    margin: 0 0 0.3em;
}

.collection .page-subtitle {
    font-size: 1.15em;
    /* Clamp the page tagline to a comfortable measure, centered, on every
       collection subpage (Apps / Code / Art). balance evens the wrapped lines
       so it reads well on both wide and narrow screens (no manual <br>). */
    max-width: 850px;
    margin: 0 auto 3em;
    line-height: 1.5;
    text-wrap: balance;
}

/* When jump-nav chips follow the tagline (Art page), pull them up close to it
   - the full 3em gap reads as dead space between them. */
.collection .page-subtitle:has(+ .section-chips) {
    margin-bottom: 1em;
}

/* Card grid - fluid columns: 2 default, 3 at the wide tier, 1 on mobile.
   Generous gap so the cardless tiles breathe; the card padding (below) adds
   further inset, and the hover surface fits within it. */
.collection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 64px 44px;
}

/* Cardless at rest - transparent surface, so only the imagery (rounded) shows
   against the page. Constant padding + rounding are always present so the card
   surface can fade IN on hover with no layout shift: the rounded rectangle
   quickly appears behind the content as the hover state. */
.collection-card {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 16px;
    border-radius: 18px;
    corner-shape: squircle;
    background: transparent;
    transition: background 0.2s ease,
                transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
    will-change: transform;
}

/* Whole-surface links (cards + the Talks featured hero) - never inherit the
   content-link red/underline on hover (the global a:hover would otherwise
   out-specify text-decoration: none). */
.collection-card:hover,
.talks-featured:hover {
    color: inherit;
    text-decoration: none;
}

@media (hover: hover) {
    .collection-card:hover {
        background: var(--bg-secondary);
        transform: scale(1.02);
    }
}

/* Reduced motion: keep the surface fade, drop the zoom. */
@media (prefers-reduced-motion: reduce) {
    .collection-card {
        transition: background 0.2s ease;
    }
    .collection-card:hover {
        transform: none;
    }
}

/* ----- Detail page ----- */

.collection-back {
    display: inline-block;
    font-size: 0.85em;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 1.5em;
}

.collection-back:hover {
    color: var(--text);
}

.collection-detail-body {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 3em;
    align-items: start;
}

.collection-detail-prose {
    color: var(--text);
    line-height: 1.7;
}

.collection-detail-prose p {
    margin: 0 0 1.25em;
}

/* Sidebar section header ("Links"). The tight bottom margin tucks the first
   row up under the heading, which does the grouping on its own (a heading
   hairline was tried and dropped). */
.collection-eyebrow {
    display: block;
    font-size: 1.2em;
    font-weight: 700;
    color: var(--heading);
    margin: 0 0 0.35em;
}

.collection-eyebrow:not(:first-child) {
    margin-top: 2em;
}

/* The detail sidebar's Details list sits on the same rounded card as the
   About page's Colophon and the Contact details: grey surface, squircle
   corners, its .card-heading above it. Badges and Links stay outside the
   card, beneath it. */
.collection-details-card {
    padding: 20px 28px;
    background: var(--bg-secondary);
    border-radius: 24px;
    corner-shape: squircle;
}

/* ----- Detail header - shared by App/Code/Art/Talk detail pages. -----
   (The key/value details table beside it is .spec-list in site.css.) */
.collection-detail-name {
    font-size: 2.7em;
    line-height: 1.0;
    color: var(--heading);
    margin: 0;
}

.collection-detail-tagline {
    font-size: 1.3em;
    color: var(--text-secondary);
    margin: 0.3em 0 1.5em;
}

/* Large detail media (screenshot / video) in a bordered surface. */
.collection-detail-shot {
    border-radius: 18px;
    corner-shape: squircle;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 2.5em;
}

/* Sidebar links list (text links with a trailing arrow). */
.collection-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.collection-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    font-size: 0.95em;
    padding: 0.5em 0;
    border-top: 1px solid var(--border);
}

.collection-links li:first-child .collection-link {
    border-top: none;
}

.collection-link:hover {
    color: var(--link);
}

.collection-link-arrow {
    color: var(--text-tertiary);
}

/* --- "get it" store badges (App Store / YouTube / Dribbble / GitHub) -------
   Each badge ships as a light and a dark pre-coloured SVG <img> (see
   Badge.swift); the one matching the page's data-color-scheme shows, so the
   badge follows the manual theme toggle. Centred, with room above whatever
   sidebar block precedes it. */
.store-badge {
    display: block;
    width: fit-content;
    margin: 2.0em auto 0;
}
.store-badge img {
    display: block;
    width: 200px;
    max-width: 100%;
    height: auto;
}
.store-badge .store-badge-dark,
[data-color-scheme="dark"] .store-badge .store-badge-light {
    display: none;
}
[data-color-scheme="dark"] .store-badge .store-badge-dark {
    display: block;
}

/* Cardless card body - text sits flush-left beneath standalone imagery
   (no card surface or side padding). Talks adds its own 2px-inset variant. */
.code-body,
.art-body {
    padding: 14px 0 0;
}

@media (max-width: 720px) {
    /* Same phone padding as the About page's Colophon card. */
    .collection-details-card {
        padding: 16px 20px;
    }
    .collection-detail-name {
        font-size: 2.1em;
    }
}

/* One-word names (Code repos: "TOPasscodeViewController") shrink to fit the
   column instead of wrapping mid-word. --fit-chars is set per page at build
   time; 0.6em is a little over the widest measured glyph average (0.574em).
   On wider screens the cap is far above the normal size, so it never applies. */
.collection-detail-name[style*="--fit-chars"] {
    font-size: min(2.7em, (100vw - 40px) / (var(--fit-chars) * 0.6));
}
@media (max-width: 720px) {
    .collection-detail-name[style*="--fit-chars"] {
        font-size: min(2.1em, (100vw - 40px) / (var(--fit-chars) * 0.6));
    }
}

/* Swap transition - applied by the JS content swap only (via .collection-swapped),
   so it fires on in-place navigation but NOT on a fresh page load. */
@media (prefers-reduced-motion: no-preference) {
    .collection-swapped {
        animation: collection-fade-in 0.25s ease;
    }
}

@keyframes collection-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile - single column. */
/* Tablet band: at iPad-portrait widths the fixed 360px sidebar plus the 3em
   gap left the prose barely wider than the Details table. Narrow both so the
   prose clearly leads. */
@media (min-width: 720.02px) and (max-width: 1000px) {
    /* Same move as the About page: pull the 35px page gutter in to the phone
       value so the freed margin goes to the prose. The footer follows via
       --container-pad. */
    body:has(.collection-detail) {
        --container-pad: 20px;
    }
    /* 260px keeps every Details row on one line at 18px (longest value today:
       "Senior iOS Engineer"). Recheck all detail pages if a longer value is
       added - the table has no room to wrap gracefully. */
    .collection-detail-body {
        grid-template-columns: minmax(0, 1fr) 260px;
        gap: 2em;
    }
}

@media (max-width: 720px) {
    .collection-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    /* No hover surface on phones, so the card's side padding would only push
       the imagery in from the page gutter. Drop it so cards line up with the
       page title and the header capsule; keep the vertical padding as the
       spacing between cards. */
    .collection-card {
        padding-inline: 0;
    }
    .collection-detail-body {
        grid-template-columns: 1fr;
        gap: 2em;
    }
}

/* Landscape phones have the width for two cards per row - which shrinks each
   card (and its imagery) down to a sensible size. Portrait stays single-column. */
@media (max-width: 720px) and (orientation: landscape) {
    .collection-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Wide tier → 3 columns. Threshold == the container's 3-col cap (1650px), so
   3 columns only appear once there's room for full-size cards - never shrunk.
   Below 1650px it's 2 columns shrinking fluidly down to the mobile 1-col break;
   the snap from 3→2 happens exactly as the cards would start to shrink. */
@media (min-width: 1650px) {
    /* Only the GRID pages widen - detail pages (.collection-detail) keep
       their reading width, so they don't go comically wide. */
    body:has(.collection:not(.collection-detail)) {
        --page-width: 1650px;
    }
    .collection-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Jump-nav chips (shared) - a row of pill links to in-page sections, reusing
   the Archive chip look. Used by the Art page; available to any long page.
   The Talks filter pills share the same capsule recipe (talks.css adds the
   button resets and the .is-active state). */
.section-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 3em;
}

.section-chip,
.talks-filter {
    padding: 4px 14px;
    border-radius: 999px;
    corner-shape: squircle;
    border: 1px solid var(--border);
    font-size: 0.85em;
    color: var(--text);
    text-decoration: none;
    line-height: 1.6;
}

.section-chip:hover,
.talks-filter:hover {
    background: var(--control-hover);
    color: var(--text);
    text-decoration: none;
}

/* ---------- Media slots with no image yet ----------
   A flat neutral surface holding the space until the real image lands. No
   gradient and no fake device chrome - the image simply hasn't arrived. Each
   media container (.app-icon, .app-hero, .code-shot, .talks-thumb, .art-shot)
   brings its own aspect ratio; this only paints the fill. */
.is-empty {
    background: var(--bg-secondary);
}

/* ---------- Shared media-surface treatment ----------
   Every collection's image container - Code's repo screenshot, Talks' poster,
   Art's poster - wears the same 14px squircle clip ("only images rounded"),
   so it's one design decision stated once. Aspect ratios, overlay positioning
   and Code's border stay with each page's own file; Apps' .app-icon keeps its
   own tighter 15px rounding in apps.css. */
.code-shot,
.talks-thumb,
.art-shot {
    border-radius: 14px;
    corner-shape: squircle;
    overflow: hidden;
}

/* A hairline drawn over the grid images' edge (same token as the app icons),
   so a white picture still separates from the white page. It's an inset
   overlay, not a border, so it adds no size and follows the squircle. Code's
   grid shot already has a border (code.css), and the detail frame has its own
   (.collection-detail-shot), so neither gets a second edge. */
.app-hero {
    position: relative;
}
.app-hero::after,
.talks-thumb::after,
.art-shot::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    corner-shape: inherit;
    box-shadow: inset 0 0 0 1px var(--image-stroke);
    pointer-events: none;
}
.collection-detail-shot .app-hero::after,
.collection-detail-shot .talks-thumb::after,
.collection-detail-shot .art-shot::after {
    content: none;
}

/* The image fills its container; the container's aspect ratio decides the
   crop. Shared by every clipped media surface, including the app icon tile. */
.app-icon img,
.app-hero img,
.code-shot img,
.talks-thumb img,
.art-shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Inside the bordered detail wrapper (.collection-detail-shot) the surface
   must not double the wrapper's rounding, and detail media is 16:9 across the
   collections. Code's border + hover-transition reset stays in code.css. */
.collection-detail-shot .code-shot,
.collection-detail-shot .talks-thumb,
.collection-detail-shot .art-shot {
    aspect-ratio: 16 / 9;
    border-radius: 0;
}

/* Detail images are lightbox triggers (Media.zoomable): the anchor is just a
   block wrapper, so the frame looks the same, with a zoom cursor. */
.collection-zoom {
    display: block;
    color: inherit;
    cursor: zoom-in;
}

/* Detail video (Talks and Art): the lite-youtube facade fills the bordered
   16:9 frame. lite-yt-embed.css caps the element at 720px, so lift that. */
.collection-detail-shot lite-youtube {
    display: block;
    width: 100%;
    max-width: none;
}

/* Art detail keeps each image's own ratio (`--ar`, set inline from the media
   manifest) so nothing is cropped. The frame narrows and centres to stay within
   the same viewport-height budget as the 16:9 heroes, with a floor so short
   landscape screens don't shrink it to a postage stamp. */
.collection-detail-shot--natural {
    width: min(100%, max(480px, calc(var(--detail-media-max-h) * var(--ar))));
    margin-inline: auto;
}
.collection-detail-shot--natural .art-shot,
.collection-detail-shot--natural .app-hero {
    aspect-ratio: var(--ar);
}
