/* The home page is a long glass table seen from below: one photo of the whole table (ceiling, glass and things
   rendered together), with each section's text in the gap the render leaves for it. Every size and place comes
   from table-layers.css, which scripts/table_assets.py writes from the render. Lengths there are percentages of
   the table's width, so they are multiplied by 1cqw (the table is the size container). */

@import url('/css/table-layers.css');

:root {
    --ink: #fff;
    --sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.5 var(--sans);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'ss01';
}

a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(255, 255, 255, 0.45);
    text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: currentColor; }

/* ---- The table ---- */

.table {
    position: relative;
    width: 100%;
    container-type: inline-size;
    /* Text size follows the table, within limits; a block that outgrows its zone grows downward. */
    --fs: clamp(13px, 1.46cqw, 28px);
}
/* The bare glass above the first section. */
.table::before { content: ''; display: block; height: calc(var(--top) * 1cqw); }

/* The photo lies under everything, at the page's own size. Where the text makes the page longer than the photo,
   the page carries on in the photo's last colour (--bg). */
.photo { position: absolute; top: 0; left: 0; width: 100%; height: calc(var(--page-h) * 1cqw); pointer-events: none; }
.photo img { display: block; width: 100%; height: 100%; }
/* The photo's last stretch melts into --bg, so a longer page shows no edge. */
.photo::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4cqw; background: linear-gradient(to bottom, transparent, var(--bg)); }

/* The travel frames lie exactly on the photo. Two show at a time: one solid, the next fading in over it. */
.travel { position: absolute; top: 0; left: 0; width: 100%; height: calc(var(--page-h) * 1cqw); pointer-events: none; overflow: hidden; }
.travel img { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; }
/* The ceiling plate is taller than the page by --pad of the page height at each end, so it can slide behind the things. */
.travel .ceil { top: calc(var(--pad) * -100%); bottom: auto; height: calc(100% + var(--pad) * 200%); will-change: transform; }
/* The things' last stretch melts into --bg as the photo's does, so the sliding ceiling shows no edge there. */
.travel::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4cqw; background: linear-gradient(to bottom, transparent, var(--bg)); }

/* The deep page (travel.js adds html.deep): the page scrolls inside <body>, <body> has a perspective, and the
   ceiling plate lies deeper than the page. A deeper layer moves slower when the page scrolls, so the browser's own
   scrolling slides the ceiling behind the things, with no script and no animation in between.
   travel.js sets the sky box's place and size, the perspective's centre and --k, the factor that scales the deep
   layer back to the page's size. */
.sky { display: none; }
@media (min-width: 901px) {
    html.deep { height: 100%; overflow: hidden; background: var(--bg); }
    html.deep body { position: relative; height: 100%; overflow-x: hidden; overflow-y: auto; perspective: 1px; outline: none; }
    html.deep .table { z-index: 1; }
    .sky {
        display: block;
        position: absolute;
        left: 0;
        overflow: hidden;
        pointer-events: none;
        transform-origin: 100% 100%;
        transform: translateZ(calc((1 - var(--k, 1)) * 1px)) scale(var(--k, 1));
    }
    .sky img { position: absolute; left: 0; width: 100%; }
    /* The sky lies behind the table, so the still photo steps aside once the plate and the frames are ready.
       Below the photo the page carries on in --bg, in front of the sky. */
    .table.live .photo { visibility: hidden; }
    .table.live::after { content: ''; position: absolute; left: 0; right: 0; top: calc(var(--page-h) * 1cqw); bottom: 0; background: var(--bg); }
}

/* Where the deep page does not fit, the plate stays among the frames and the browser ties its slide to the scroll
   where it can. travel.js sets the four lengths: the scroll range (--s0 to --s1) and the plate's offset at each
   end (--y0, --y1). */
@keyframes ceil-glide { from { transform: translate3d(0, var(--y0, 0px), 0); } to { transform: translate3d(0, var(--y1, 0px), 0); } }
@supports (animation-timeline: scroll()) {
    .travel .ceil.glide { animation: ceil-glide linear both; animation-timeline: scroll(root block); animation-range: var(--s0, 0px) var(--s1, 100%); }
}

/* The things drawn live in 3D on a canvas that lies where the frames lie (html.draw3d, static/live).
   The photo holds the things in an older arrangement, so it stays hidden and only the ceiling shows until the
   things are drawn. They fade in. */
html.draw3d .photo img { visibility: hidden; }
.travel .live3d { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.5s ease; }
.table.webgl .travel .live3d { opacity: 1; }
.table.webgl .travel img:not(.ceil):not(.ceil-phone) { display: none; }
/* On a phone the page photo holds the things, so it steps aside for the same photo without them. */
.travel .ceil-phone { visibility: visible; will-change: transform; }
/* The phone's ceiling slides behind the things as the desk's does. live.js sets the four lengths. */
@supports (animation-timeline: scroll()) {
    .travel .ceil-phone.glide { animation: ceil-glide linear both; animation-timeline: scroll(root block); animation-range: var(--s0, 0px) var(--s1, 100%); }
}
.table.webgl-phone .photo { visibility: hidden; }

.name {
    position: absolute;
    left: calc(var(--name-x) * 1cqw);
    top: calc(var(--name-y) * 1cqw);
    z-index: 2;
    margin: 0;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    /* A little under the body text, and it grows with the table as the text does. */
    font-size: max(15px, calc(var(--fs) * 0.88));
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.005em;
    text-shadow: 0 0 0.8em rgba(0, 0, 0, 0.4), 0 0 0.14em rgba(0, 0, 0, 0.3);
}

.sec {
    position: relative;
    min-height: calc(var(--h) * 1cqw);
    padding: calc(var(--ty) * 1cqw) 0 0 calc(var(--tx) * 1cqw);
}
/* ---- Text ---- */

.text {
    position: relative;
    z-index: 2;
    width: calc(var(--tw) * 1cqw);
    font-size: var(--fs);
    line-height: 1.4;
    /* A soft halo, so white text holds on the pale ceiling without a box behind it. */
    text-shadow: 0 0 0.8em rgba(0, 0, 0, 0.4), 0 0 0.14em rgba(0, 0, 0, 0.3);
}
.text h2 { margin: 0 0 0.7em; font-size: 1.15em; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.entries { margin: 0; padding: 0; list-style: none; }
.entries li { margin: 0 0 0.9em; }
.entries li:last-child { margin-bottom: 0; }
.text h3 { margin: 0; font-size: 1em; font-weight: 500; line-height: 1.4; }
.text p { margin: 0; }
.year { font: 400 max(12px, 0.92em)/1 var(--mono); margin-right: 0.3em; }
.label { display: block; font-weight: 500; }

/* ---- Credits ---- */

/* The credits close the last section, under its text, so the page ends where the photo ends when they fit. */
.credits {
    position: relative;
    z-index: 2;
    margin: 1.6em 0 1.2em;
    padding-right: 16px;
    font: 400 12px/1.6 var(--mono);
    text-shadow: 0 0 0.8em rgba(0, 0, 0, 0.4), 0 0 0.14em rgba(0, 0, 0, 0.3);
}
.credits summary { width: max-content; cursor: pointer; list-style: none; }
.credits summary::-webkit-details-marker { display: none; }
.credits ul { margin: 0.6em 0 0; padding: 0; list-style: none; max-width: 40rem; }
.credits li { margin: 0 0 0.2em; }

/* ---- Phone ---- */

@media (max-width: 900px) {
    .table { --fs: clamp(13.5px, 3.85cqw, 24px); }
    .name { font-size: max(14px, calc(var(--fs) * 1.08)); }
}
