

/* fonts and variables */

@font-face {
    font-family: 'VIVI_LANG';
    src: url('VIVI_LANG.ttf') format('truetype');
    font-display: block;   /* wait for the font instead of flashing normal text first */
}

/* PROJECT FONTS ----------------------------------------------------------
   To give a project page its own font, add a rule like this, then use the
   name ("MyGameFont") as `font` in that project's theme in content.js:

   @font-face {
       font-family: 'MyGameFont';
       src: url('fonts/MyGameFont.woff2') format('woff2');
       font-display: swap;
   }
-------------------------------------------------------------------------- */

:root {
    --bg-color: #ffffff;
    --text-color: #0d0d0d;
    --accent-black: #111111;

    /* The site border */
    --frame-w: clamp(22px, 4vw, 56px);   /* how thick it is on screen */
    --frame-slice: 210;                  /* corner size in pixels of border.png (NOT screen pixels) */

    /* The ornament under (and a thin copy above) the big titles. Replace assets/ui/title-divider.png with your own.
       --divider-on-dark is the CSS filter used when the title sits on a dark page; "invert(1)" flips black art to
       white. If your art already has its own colours, set it to "none". */
    --title-divider: url('assets/ui/title-divider.png');
    --divider-on-dark: invert(1);

    /* Content that scrolls toward the border fades out over this distance (see "EDGE FADE" at the end) */
    --edge-fade: 34px;
}


/* page basics */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
}

button { font-family: inherit; }


/* the gate */

/* The canvas holder (Three.js draws in here) */
#webgl-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
}

#webgl-container:active {
    cursor: grabbing;
}

/* The text layer on top of the canvas. Clicks pass straight through it. */
.ui-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--frame-w) + 28px);
    padding-bottom: calc(var(--frame-w) + 12px);   /* keeps the hint low, clear of the labels */
}

/* The title and the hint start hidden; the intro adds body.show-title / body.show-hint during the intro. */
.header-title {
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

body.show-title .header-title {
    opacity: 1;
    transform: none;
}

/* Cube labels: one per cube, placed under it from JS */
.cube-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cube-label {
    --cell: 0.95em;                 /* fixed width per letter so swapping fonts never shifts the layout */
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 0.3s ease;
    will-change: transform, opacity;
}

.cube-label.visible {
    opacity: 1;
}

.cube-label .ch {
    display: inline-block;
    width: var(--cell);
    text-align: center;
    transition: color 0.25s ease;
}

/* A letter that has not been "translated" yet: shown in your VIVI_LANG font */
.cube-label .ch.rune {
    font-family: 'VIVI_LANG', monospace;
    font-weight: normal;
    color: #6a6a6a;
}

/* A name marked noTranslate in content.js (the door) stays in VIVI_LANG even when the others turn into normal letters */
.cube-label.keep-rune .ch,
.section-title.vivi {
    font-family: 'VIVI_LANG', monospace;
    font-weight: normal;
}
.cube-label.keep-rune .ch { color: #6a6a6a; }
body.inverted .cube-label.keep-rune .ch { color: #9a9a9a; }

/* Help line at the bottom. the gate cycles tips through it and turns the class `on` on and off. */
.nav-prompt {
    /* sits in the gap between the pyramid and the cubes; moved from JS */
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    max-width: min(88vw, 560px);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    color: #777;
    text-transform: uppercase;
    text-align: center;
    min-height: 1.4em;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.nav-prompt.on { opacity: 1; }


/* the border */

/* Hand-drawn border (9-slice)
   border.png is cut into 9 pieces by --frame-slice:
     - the 4 corners are drawn at their natural proportions (scaled evenly, never stretched)
     - the 4 edges are TILED along the side ("round" adjusts the tile count so none is cut off)
     - the middle stays empty
   To use your own drawing: replace border.png, then set --frame-slice (top of this file)
   to your corner size in image pixels, and --frame-w to the thickness you want on screen. */
.frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 60;                      /* above the pages, below the viewer */
    pointer-events: none;
    border: var(--frame-w) solid transparent;
    border-image-source: url('border.png');
    border-image-slice: var(--frame-slice);
    border-image-width: var(--frame-w);
    border-image-repeat: round;
    transition: filter 0.6s ease, opacity 0.4s ease;

    /* Entry animation: two "pens", one per side, start at mid-height and draw up and down together until
       they meet at the top and bottom centre. the intro animates --w (half-width of each wedge) and
       --s (softness of its leading edge). */
    --w: 0deg;
    --s: 0deg;
    -webkit-mask-image:
        conic-gradient(from calc(90deg - var(--w)) at 50% 50%, transparent 0deg, #000 var(--s), #000 calc(var(--w) * 2 - var(--s)), transparent calc(var(--w) * 2), transparent 360deg),
        conic-gradient(from calc(270deg - var(--w)) at 50% 50%, transparent 0deg, #000 var(--s), #000 calc(var(--w) * 2 - var(--s)), transparent calc(var(--w) * 2), transparent 360deg);
    mask-image:
        conic-gradient(from calc(90deg - var(--w)) at 50% 50%, transparent 0deg, #000 var(--s), #000 calc(var(--w) * 2 - var(--s)), transparent calc(var(--w) * 2), transparent 360deg),
        conic-gradient(from calc(270deg - var(--w)) at 50% 50%, transparent 0deg, #000 var(--s), #000 calc(var(--w) * 2 - var(--s)), transparent calc(var(--w) * 2), transparent 360deg);
}

.frame.invert {
    filter: none;              /* the border keeps its own colours on every page (it is no longer flipped) */
}

/* A project page that has its own border hides this one */
.frame.hidden {
    opacity: 0;
}


/* section pages */

/* The black page. Hidden until a cube is clicked. */
.content-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    background: #0d0d0d;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: calc(var(--frame-w) + 28px) calc(var(--frame-w) + 24px) calc(var(--frame-w) + 16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    user-select: text;
    -webkit-user-select: text;
}

.content-view.active {
    opacity: 1;
    pointer-events: auto;
}

/* Back button on the left, the section name in the middle (same spot and style as the gate's title) */
.section-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 16px;
    flex: none;
}

.section-title {
    font-size: 1.2rem;
    letter-spacing: 0.3em;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    align-self: start;
}

.back-btn {
    justify-self: start;
    background: none;
    border: 1px solid #ffffff;
    color: #ffffff;
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: background 0.2s, color 0.2s;
    margin-top: -10px;   /* lines the button's text up with the title's text */
}

.back-btn:hover {
    background: #ffffff;
    color: #0d0d0d;
}

.section-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-top: 36px;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

/* Artwork grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    padding-bottom: 40px;
}

.artwork-item {
    display: block;
    width: 100%;
    background: #1a1a1a;
    aspect-ratio: 1/1;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    border: 1px solid #333333;
    padding: 0;
    min-width: 0;
}

/* Every thumbnail is the same square: the picture is cropped to fill it (never stretched), and it is taken out of the
   layout (absolute) so a wide picture cannot push the grid wider than the screen. The real size shows in the viewer. */
.artwork-item img, .artwork-item video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.5s ease;
}

.artwork-item:hover img, .artwork-item:hover video {
    transform: scale(1.05);
}

.artwork-item.is-video::after {
    content: '▶';
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    font-size: 0.8rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid #fff;
    pointer-events: none;
}

/* Projects: tabs + cards */
.tabs {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #888888;
    font-weight: bold;
    letter-spacing: 0.25em;
    padding: 8px 4px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: #ffffff; }

.tab.is-active {
    color: #ffffff;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    padding-bottom: 40px;
}

.project-grid .empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #777777;
    letter-spacing: 0.15em;
    padding: 40px 0;
}

.project-card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0;
    border: 1px solid #333333;
    background: #1a1a1a;
    overflow: hidden;
    cursor: pointer;
    color: #ffffff;
    text-align: left;
}

.project-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.project-card:hover img { transform: scale(1.05); }

.project-card-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 56px 18px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88), rgba(0, 0, 0, 0));
}

.project-card-title {
    font-size: 1.15rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.project-card-tagline {
    font-size: 0.8rem;
    color: #bbbbbb;
    margin-top: 4px;
}

/* About (text only) */
.about {
    max-width: 680px;
    margin: 0 auto;
    padding: 12px 0 80px;
    color: #eeeeee;
}

.about-name {
    font-size: clamp(2.4rem, 2vw, 2.6rem);
    letter-spacing: 0em;
    margin-bottom: 8px;
}

.about-sub {
    color: #999999;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.85rem;
    margin-bottom: 48px;
}

.about-part { margin-bottom: 40px; }

.about-part h3 {
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #ffffff;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333333;
}

.about-part p {
    line-height: 1.8;
    color: #cccccc;
    margin-bottom: 1em;
}

.about a { color: #ffffff; }

.about-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 10px 28px;
    margin-bottom: 48px;
}

.about-facts dt {
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.8rem;
    padding-top: 2px;
}

.about-facts dd { color: #eeeeee; }

.social-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.social {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid #444444;
    color: #ffffff;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.about .social:hover {
    background: #ffffff;
    color: #0d0d0d;
}

.social-name {
    font-weight: bold;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.social-handle { opacity: 0.7; }


/* project pages
   Every colour, the font, the background picture, the border and the buttons come from CSS variables
   named --p-*. the page script sets them from the project's `theme` in content.js. When a project has no
   theme, the fallbacks after each comma below (the black site look) are used. */

.project-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 25;                                   /* above the black section page, below the site border */
    overflow: hidden;                              /* the scrolling is done by .p-scroll inside (so its edge fade doesn't fade the background) */
    background-color: var(--p-bg, #0d0d0d);
    background-image: var(--p-bg-image, none);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--p-text, #f2f2f2);
    font-family: var(--p-font, 'Courier New', Courier, monospace);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    user-select: text;
    -webkit-user-select: text;
}

.p-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: calc(var(--frame-w) + 20px) calc(var(--frame-w) + 20px) calc(var(--frame-w) + 60px);
}

.project-view.active {
    opacity: 1;
    pointer-events: auto;
}

/* A project with its own border (theme.frame) */
.project-view[data-frame] {
    padding: calc(var(--p-frame-w, 48px) + 20px) calc(var(--p-frame-w, 48px) + 20px) calc(var(--p-frame-w, 48px) + 60px);
}

.project-view[data-frame]::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border: var(--p-frame-w, 48px) solid transparent;
    border-image-source: var(--p-frame-src);
    border-image-slice: var(--p-frame-slice, 120);
    border-image-width: var(--p-frame-w, 48px);
    border-image-repeat: round;
}

.p-bar {
    max-width: 760px;
    margin: 0 auto;
}

/* Buttons (back button, link buttons). With theme.button they use your 9-slice button art instead. */
.p-btn {
    display: inline-block;
    color: inherit;
    background: none;
    border: 1px solid var(--p-accent, currentColor);
    padding: 10px 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.p-btn:hover {
    background: var(--p-accent, #ffffff);
    color: var(--p-bg, #0d0d0d);
}

.project-view[data-btn] .p-btn {
    border: var(--p-btn-w, 14px) solid transparent;
    border-image: var(--p-btn-src) var(--p-btn-slice, 24) fill / var(--p-btn-w, 14px) stretch;
    background: none;
    padding: 4px 14px;
}

.project-view[data-btn] .p-btn:hover {
    background: none;
    color: inherit;
    filter: brightness(1.2);
}

.p-article {
    max-width: 760px;
    margin: 28px auto 0;
}

.p-head { margin-bottom: 40px; }

.p-kicker {
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--p-muted, #8a8a8a);
    margin-bottom: 12px;
}

.p-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.1;
    margin-bottom: 14px;
}

.p-tagline {
    font-size: 1.15rem;
    line-height: 1.5;
    color: var(--p-muted, #8a8a8a);
    margin-bottom: 18px;
}

.p-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.p-tags li {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    border: 1px solid var(--p-muted, #8a8a8a);
    color: var(--p-muted, #8a8a8a);
}

.p-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
}

.p-h2 {
    font-size: 1.5rem;
    line-height: 1.25;
    margin: 48px 0 16px;
}

.p-text p {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-bottom: 1.1em;
}

.p-text a { color: var(--p-accent, #ffffff); }

.p-figure { margin: 28px 0; }

.p-figure img, .p-figure video {
    display: block;
    width: 100%;
    height: auto;
}

.p-figure img { cursor: zoom-in; }

.p-figure figcaption {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--p-muted, #8a8a8a);
}

.p-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 28px 0;
}

.p-gallery .p-figure { margin: 0; }

.p-embed {
    position: relative;
    aspect-ratio: 16 / 9;
}

.p-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.p-quote {
    margin: 32px 0;
    padding-left: 18px;
    border-left: 3px solid var(--p-accent, #ffffff);
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.6;
}

.p-quote cite {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    font-style: normal;
    color: var(--p-muted, #8a8a8a);
}


/* the zoomable viewer */

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

.lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-wrapper {
    position: absolute; inset: 0; padding-bottom: var(--dock, 0px); box-sizing: border-box;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.lightbox-content {
    max-width: 88vw;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
}

img.lightbox-content {
    cursor: grab;
    touch-action: none;         /* we handle drag and pinch ourselves */
    user-select: none;
    -webkit-user-drag: none;
}

img.lightbox-content:active { cursor: grabbing; }

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 2.5rem;
    cursor: pointer;
    z-index: 110;
    font-family: monospace;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-hint {
    position: absolute;
    bottom: 30px;
    color: #888888;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    pointer-events: none;
}


/* phones and small windows */

@media (max-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .ui-layer { padding: calc(var(--frame-w) + 14px); }

    .header-title,
    .section-title {
        font-size: 0.95rem;
        letter-spacing: 0.2em;
    }

    .cube-label {
        font-size: 0.78rem;
        letter-spacing: 0.04em;
        --cell: 0.9em;
    }

    .nav-prompt { font-size: 0.7rem; }

    .content-view { padding: calc(var(--frame-w) + 14px) calc(var(--frame-w) + 12px) calc(var(--frame-w) + 12px); }

    .back-btn { padding: 8px 12px; margin-top: -8px; }
    .back-btn .long { display: none; }          /* on a phone the button is just an arrow */

    .section-body { margin-top: 28px; padding-right: 4px; }

    .gallery-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .project-grid { grid-template-columns: 1fr; gap: 20px; }

    .p-scroll { padding: calc(var(--frame-w) + 14px) calc(var(--frame-w) + 12px) calc(var(--frame-w) + 40px); }
    .project-view[data-frame] .p-scroll { padding: calc(var(--p-frame-w, 48px) * 0.7 + 14px) calc(var(--p-frame-w, 48px) * 0.7 + 12px) calc(var(--p-frame-w, 48px) * 0.7 + 40px); }
    .project-view[data-frame]::after {
        border-width: calc(var(--p-frame-w, 48px) * 0.7);
        border-image-width: calc(var(--p-frame-w, 48px) * 0.7);
    }

    .social { grid-template-columns: auto 1fr auto; gap: 12px; }
    .about-facts { grid-template-columns: 1fr; gap: 2px 0; }
    .about-facts dd { margin-bottom: 12px; }

    .lightbox-hint { display: none; }
    .lightbox-close { top: 16px; right: 20px; }
}


/* animations, cursor, falling characters, light theme swap */

/* Projects: tab switch animation ---
   The underline is one element (.tab-indicator) that pages.js slides under the active tab.
   When the tab changes, the old cards get .leaving (fade and sink), then the new ones rise in one by one:
   each card has --i (0, 1, 2...) set by pages.js, which staggers the delay.                       */
.tab-indicator {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: #ffffff;
    transition: transform 0.35s cubic-bezier(0.65, 0, 0.25, 1), width 0.35s cubic-bezier(0.65, 0, 0.25, 1);
    pointer-events: none;
}

.project-grid {
    transition: opacity 0.17s ease, transform 0.17s ease;
}

.project-grid.leaving {
    opacity: 0;
    transform: translateY(10px);
}

.project-card {
    animation: card-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 80ms);
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(22px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .project-card { animation: none; }
    .tab-indicator, .project-grid { transition: none; }
}


/* Zoom viewer: arrows, counter, picture swap */
.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 64px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #ffffff;
    opacity: 0.55;
    cursor: pointer;
    z-index: 110;
    transition: opacity 0.2s, transform 0.2s;
}

.lightbox-arrow[hidden] { display: none; }
.lightbox-arrow.prev { left: 20px; }
.lightbox-arrow.next { right: 20px; }
.lightbox-arrow:hover { opacity: 1; }
.lightbox-arrow.prev:hover { transform: translateY(-50%) translateX(-4px); }
.lightbox-arrow.next:hover { transform: translateY(-50%) translateX(4px); }

.lightbox-count {
    position: absolute;
    top: 38px;
    left: 40px;
    color: #888888;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    pointer-events: none;
}

.lightbox-content.enter { animation: lb-in 0.25s ease both; }

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


/* Custom cursor (cursor.js). Only exists on devices with a real mouse. */
html.has-cursor,
html.has-cursor * {
    cursor: none !important;
}

#cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    z-index: 100000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#cursor.seen { opacity: 1; }

.cursor-img {
    position: absolute;
    display: block;
    opacity: 0;
    pointer-events: none;
    user-select: none;
}

.cursor-img.on { opacity: 1; }
@keyframes cursor-play { to { background-position: var(--end) 0; } }


/* Falling characters and the hand (rain.js) */
.rain-canvas {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;      /* clicks must reach the 3D canvas */
}

.rain-back  { z-index: 0; }    /* behind the pyramid and cubes */
.rain-front { z-index: 13; }   /* the character you are holding / the hand takes: in front of everything on the gate, hand included */

.hand-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 12;               /* above the gate text, under the section pages and the border */
    pointer-events: none;
    overflow: hidden;
}

.hand {
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    transform-origin: 0 0;
    pointer-events: none;      /* rain.js turns this on only while the papers are showing */
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

@media (hover: none), (max-width: 899px) {
    .rain-canvas, .hand-layer { display: none; }
}


/* Swapped colours at the gate (double-click the pyramid): dark page, light shapes, light border */
body { transition: color 0.6s ease; }

body.inverted {
    --text-color: #ececec;
}

body.inverted .cube-label .ch.rune { color: #9a9a9a; }
body.inverted .nav-prompt { color: #9a9a9a; }


/* Hollow-Knight-style title ornament: a divider under the title and a thinner one above it ---
   The picture is assets/ui/title-divider.png (--title-divider at the top of this file). */
.header-title,
.section-title {
    position: relative;
    padding: 0 0 24px;
}

.header-title::before,
.header-title::after,
.section-title::before,
.section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    width: clamp(180px, 30vw, 360px);
    transform: translateX(-50%);
    background: var(--title-divider) center / contain no-repeat;
    pointer-events: none;
}

.header-title::after,
.section-title::after { bottom: 0; height: 18px; }

.header-title::before,
.section-title::before {
    top: -16px;
    height: 12px;
    width: clamp(120px, 20vw, 240px);
    opacity: 0.55;
    transform: translateX(-50%) scaleY(-1);
}

.section-title::before,
.section-title::after,
body.inverted .header-title::before,
body.inverted .header-title::after { filter: var(--divider-on-dark); }


/* Brackets either side of the cube row ---
   Two little brackets with a chevron that nudges toward the cubes. Drawn as a mask so they take the text colour
   (black on the light theme, white on the dark one). Swap the `mask-image` for your own SVG / PNG if you like. */
.cube-rail {
    position: absolute;
    top: 0;
    left: 0;
    width: 26px;
    height: 76px;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
    pointer-events: none;
}

body.show-rails .cube-rail { opacity: 0.75; }

.cube-rail-inner {
    display: block;
    width: 100%;
    height: 100%;
    background: currentColor;
    -webkit-mask: var(--rail-img, url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 76'><path d='M20 3 H4 V73 H20' fill='none' stroke='black' stroke-width='2.4' stroke-linejoin='round'/><path d='M9 31 L18 38 L9 45' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/></svg>")) center / contain no-repeat;
    mask: var(--rail-img, url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 76'><path d='M20 3 H4 V73 H20' fill='none' stroke='black' stroke-width='2.4' stroke-linejoin='round'/><path d='M9 31 L18 38 L9 45' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/></svg>")) center / contain no-repeat;
    animation: rail-nudge 2.4s ease-in-out infinite;
}

.cube-rail.right .cube-rail-inner {
    transform: scaleX(-1);
    animation-name: rail-nudge-r;
}

@keyframes rail-nudge   { 0%, 100% { translate: 0 0; } 50% { translate: 5px 0; } }
@keyframes rail-nudge-r { 0%, 100% { translate: 0 0; } 50% { translate: 5px 0; } }

@media (prefers-reduced-motion: reduce) { .cube-rail-inner { animation: none; } }


/* EDGE FADE: content fades out as it scrolls toward the border instead of being cut off ---
   A mask makes the top and bottom of a scrolling area transparent. The scroll areas have a matching padding,
   so at rest nothing sits inside the faded strip. */
.section-body {
    padding-top: var(--edge-fade);
    padding-bottom: var(--edge-fade);
    margin-top: calc(36px - var(--edge-fade));
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--edge-fade), #000 calc(100% - var(--edge-fade)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--edge-fade), #000 calc(100% - var(--edge-fade)), transparent 100%);
}

/* The project page scrolls full screen, so the fade starts under the border: fully hidden behind it,
   then easing in. (A project with its own drawn border keeps the page unmasked.) */
.project-view:not([data-frame]) .p-scroll {
    padding-top: calc(var(--frame-w) + var(--edge-fade) + 14px);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
}

/* Falling characters fade in and out near the border instead of popping against it */
.rain-canvas {
    -webkit-mask-image:
        linear-gradient(to bottom, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%),
        linear-gradient(to right, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
    -webkit-mask-composite: source-in;
    mask-image:
        linear-gradient(to bottom, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%),
        linear-gradient(to right, transparent 0, transparent var(--frame-w), #000 calc(var(--frame-w) + var(--edge-fade)), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
    mask-composite: intersect;
}


/* The gate title, split into letters so the intro can turn runes into normal text */
.header-title .ch {
    display: inline-block;
    width: 0.9em;                  /* one fixed cell per letter, so swapping fonts never shifts the line */
    text-align: center;
    letter-spacing: 0;
}

.header-title .ch.rune {
    font-family: 'VIVI_LANG', monospace;
    font-weight: normal;
    color: #6a6a6a;
}

body.inverted .header-title .ch.rune { color: #9a9a9a; }

/* While the intro animates the title with GSAP, the CSS fade must not fight it */
.header-title.gsap {
    transition: none;
    transform: none;
}

/* During the intro the title rises BEHIND the pyramid: the whole text layer drops under the 3D canvas */
body.title-behind .ui-layer { z-index: 0; }

/* Visually hidden text and the keyboard menu (index.html: #sr-nav). It appears when it gets focus. */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.sr-nav {
    position: fixed;
    top: calc(var(--frame-w) + 8px);
    left: calc(var(--frame-w) + 8px);
    z-index: 70;
    display: flex;
    gap: 6px;
    padding: 6px;
    background: #fff;
    border: 1px solid #0d0d0d;
    transform: translateY(-300%);          /* parked off screen; still reachable by Tab */
}
.sr-nav:focus-within { transform: none; }
.sr-nav a {
    color: #0d0d0d;
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 6px 10px;
}
.sr-nav a:focus-visible { outline: 2px solid #0d0d0d; outline-offset: 1px; }
body.no-webgl .sr-nav { display: none; }

/* Bottom row of the gate: sound switch, replay, found counter */
.tools {
    position: absolute;
    left: calc(var(--frame-w) + 18px);
    bottom: calc(var(--frame-w) + 8px);
    display: flex;
    gap: 6px;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.8s ease;
}
.tools-right { left: auto; right: calc(var(--frame-w) + 18px); pointer-events: none; }
body.show-hint .tools { opacity: 1; }
body.in-page .tools { opacity: 0; pointer-events: none; transition-duration: 0.3s; }

.tool {
    font: inherit;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #777;
    background: none;
    border: 0;
    padding: 6px 4px;
    cursor: pointer;
    transition: color 0.25s ease;
}
button.tool:hover, button.tool:focus-visible { color: var(--text-color); }
button.tool:focus-visible { outline: 1px dashed currentColor; outline-offset: 2px; }
.tool-count { cursor: default; }
.tool-count[hidden] { display: none; }
body.inverted .tool { color: #9a9a9a; }

/* the speaker: black on the light page, white on the dark one, with a red line through it while off */
.tool-icon, button.tool-icon:hover, button.tool-icon:focus-visible { color: #0d0d0d; line-height: 0; }
body.inverted .tool-icon, body.inverted button.tool-icon:hover, body.inverted button.tool-icon:focus-visible { color: #f0f0f0; }
.tool-icon svg { display: block; }
.tool-icon .off-line { display: none; }
.tool-icon[aria-pressed="false"] .off-line { display: inline; }
.tool-icon[aria-pressed="false"] .waves { opacity: .35; }
body.inverted button.tool:hover, body.inverted button.tool:focus-visible { color: #fff; }

@media (max-width: 767px) {
    .tools { left: calc(var(--frame-w) + 8px); }
    .tool { font-size: 0.62rem; letter-spacing: 0.12em; }
}

/* No WebGL: the plain menu (fallback.js) */
body.no-webgl #plain-menu {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: calc(var(--frame-w) + 24px);
    text-align: center;
}
body.no-webgl #plain-menu[hidden] { display: none; }
body.no-webgl #plain-menu h1 { font-size: 1.2rem; letter-spacing: 0.3em; }
body.no-webgl #plain-menu p { color: #666; max-width: 32em; }
body.no-webgl #plain-menu nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 28px; }
body.no-webgl #plain-menu a {
    color: var(--text-color);
    text-decoration: none;
    letter-spacing: 0.2em;
    font-weight: bold;
    padding: 10px 6px;
    border-bottom: 1px solid currentColor;
}
body.no-webgl #plain-menu a:hover, body.no-webgl #plain-menu a:focus-visible { opacity: 0.6; }
body.no-webgl #webgl-container,
body.no-webgl .ui-layer,
body.no-webgl .rain-canvas,
body.no-webgl .hand-layer { display: none; }
.about .plain-link { text-decoration: underline; }

/* Returning visitors: the title fades in quickly (body.quick during the short intro) */
body.quick .header-title { transition-duration: 0.5s; }


/* The secret door's page (type: 'diagram'): pure black, one big picture */
.content-view.pitch { background: #000; }

.diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding-bottom: 40px;
    text-align: center;
}
.diagram p { max-width: 36em; color: #cfcfcf; }
.diagram-img {
    width: min(100%, 78vh, 550px);
    height: auto;
    cursor: zoom-in;
    opacity: 0;
    animation: diagram-in 1.6s ease 0.3s forwards;
    -webkit-user-drag: none;
}
@keyframes diagram-in { to { opacity: 1; } }
.diagram .diagram-hint { font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: #777; }
@media (prefers-reduced-motion: reduce) { .diagram-img { animation: none; opacity: 1; } }

/* Phones: the buttons stack in a column with the label to the right of each  */
body.vertical .cube-label { text-align: left; }


/* 3D character viewer (model block, model-viewer.js) */
.p-model {
    position: relative;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    aspect-ratio: 1 / 0.85;
    border: 1px solid color-mix(in srgb, var(--p-muted, #8a8a8a) 45%, transparent);
    border-radius: 2px;
    overflow: hidden;
    cursor: grab;
    /* a soft pool of light behind the model, like the grey viewport in Blender: dark characters would vanish on a black page */
    background: radial-gradient(ellipse at 50% 42%, rgba(255, 255, 255, .20), rgba(255, 255, 255, .06) 55%, rgba(255, 255, 255, 0) 80%);
}
.p-model.dragging { cursor: grabbing; }
.p-model-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.p-model-canvas:focus-visible { outline: 1px dashed var(--p-accent, #fff); outline-offset: -4px; }
.p-model-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .85rem; letter-spacing: .12em; color: var(--p-muted, #8a8a8a); text-align: center; padding: 16px; }
.p-model-fig figcaption { text-align: center; text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; }
.p-model-clips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 520px; margin: 12px auto 0; }
.p-model-btn.active { background: var(--p-accent, #fff); color: var(--p-bg, #000); }


/* 3D MODELS page (phones) */
.models-page { max-width: 560px; margin: 0 auto; padding-bottom: 40px; }
.models-lead { text-align: center; color: #9a9a9a; font-size: .9rem; line-height: 1.6; margin: 0 0 24px; }
.models-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.model-card { display: flex; align-items: center; gap: 18px; width: 100%; padding: 12px 16px; background: #141414; color: #f0f0f0; border: 1px solid #333; cursor: pointer; text-align: left; font: inherit; }
.model-card:hover { border-color: #888; }
.model-card.no-model { opacity: .55; }
.model-thumb { --h: 88px; flex: none; display: block; height: var(--h); width: calc(var(--h) * var(--ratio, .727)); overflow: hidden; transform: rotate(180deg); }   /* ONE frame of the sheet: the width is worked out from the height, so big, small and phone sizes all cut it the same way */
.model-thumb img { display: block; height: 100%; width: auto; max-width: none; min-width: 0; flex: none; }
.model-text { display: flex; flex-direction: column; gap: 4px; }
.model-text strong { letter-spacing: .2em; text-transform: uppercase; font-size: 1rem; }
.model-text em { font-style: normal; font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: #9a9a9a; }

/* bullet lists inside page text ("- item" lines) */
.p-text ul, .about ul { margin: 0 0 1em; padding-left: 1.3em; line-height: 1.7; }
.p-text li { margin-bottom: .35em; }


/* Artwork with several frames: a count badge on the thumbnail, a row of frames in the lightbox */
.artwork-item { position: relative; }
.frames-badge {
    position: absolute; right: 8px; top: 8px;
    padding: 2px 8px; font-size: 0.7rem; letter-spacing: 0.1em;
    background: rgba(0, 0, 0, 0.7); color: #fff; border: 1px solid rgba(255, 255, 255, 0.6);
    pointer-events: none;
}
.lightbox-frames {
    display: flex; gap: 8px; max-width: 80vw; overflow-x: auto; padding: 4px;
    z-index: 3;
}
.lightbox-frames[hidden] { display: none; }
.lightbox-frame {
    flex: none; width: 56px; height: 56px; padding: 0; background: #000;
    border: 1px solid rgba(255, 255, 255, 0.35); opacity: 0.6; cursor: pointer;
}
.lightbox-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox-frame:hover { opacity: 1; }
.lightbox-frame.on { opacity: 1; border-color: #fff; }


/* card size, section switcher, tools, project ↔ character, behind the scenes */

/* Return + card size, side by side */
.head-left { display: flex; align-items: flex-start; gap: 12px; justify-self: start; min-width: 0; }
.size-toggle { display: inline-flex; margin-top: -10px; border: 1px solid #ffffff; }
.size-toggle button {
    display: flex; align-items: center; justify-content: center;
    width: 40px; padding: 0; background: none; color: #ffffff; border: 0; cursor: pointer; opacity: .55;
    transition: background .2s, color .2s, opacity .2s;
}
.size-toggle button + button { border-left: 1px solid #ffffff; }
.size-toggle svg { fill: currentColor; display: block; }
.size-toggle button:hover { opacity: 1; }
.size-toggle button[aria-pressed="true"] { background: #ffffff; color: #0d0d0d; opacity: 1; }
.size-toggle button:focus-visible { outline: 1px dashed #fff; outline-offset: 2px; }
/* only pages made of cards have a size to choose */
.content-view[data-type="about"] .size-toggle,
.content-view[data-type="diagram"] .size-toggle { display: none; }

/* small cards */
body[data-size="small"] .gallery-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
body[data-size="small"] .project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
body[data-size="small"] .project-card-info { padding: 34px 10px 8px; }
body[data-size="small"] .project-card-title { font-size: .72rem; letter-spacing: .08em; }
body[data-size="small"] .project-card-tagline { display: none; }
body[data-size="small"] .models-page { max-width: 760px; }
body[data-size="small"] .models-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body[data-size="small"] .model-card, body[data-size="small"] .cast-card { padding: 8px 10px; gap: 10px; }
body[data-size="small"] .model-thumb { --h: 56px; }
body[data-size="small"] .model-text strong { font-size: .72rem; letter-spacing: .1em; }
body[data-size="small"] .model-text em { display: none; }
body[data-size="small"] .p-gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
body[data-size="small"] .p-gallery .cap-text { display: none; }
@media (max-width: 1024px) {
    body[data-size="small"] .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* The other sections: small half-transparent cubes with names (wide windows) */
.section-cycle { justify-self: end; display: flex; gap: 14px; align-items: flex-start; margin-top: -6px; }
.cyc {
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    background: none; border: 0; padding: 4px 6px; color: #fff; cursor: pointer;
    opacity: .5; transition: opacity .25s; font: inherit;
}
.cyc:hover, .cyc:focus-visible { opacity: 1; }
.cyc.is-current { opacity: .95; cursor: default; }
.cyc-cube { position: relative; display: block; width: 22px; height: 22px; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(38deg); transition: transform .6s ease; }
.cyc:hover .cyc-cube { transform: rotateX(-24deg) rotateY(218deg); }
.cyc-cube i { position: absolute; inset: 0; border: 1px solid #fff; background: rgba(255, 255, 255, .08); }
.cyc.is-current .cyc-cube i { background: rgba(255, 255, 255, .35); }
.cyc-cube .f1 { transform: translateZ(11px); }
.cyc-cube .f2 { transform: rotateY(180deg) translateZ(11px); }
.cyc-cube .f3 { transform: rotateY(90deg) translateZ(11px); }
.cyc-cube .f4 { transform: rotateY(-90deg) translateZ(11px); }
.cyc-cube .f5 { transform: rotateX(90deg) translateZ(11px); }
.cyc-cube .f6 { transform: rotateX(-90deg) translateZ(11px); }
.cyc-name { font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; white-space: nowrap; }
.cyc-name.vivi, .bar-item.vivi { font-family: 'VIVI_LANG', monospace; text-transform: none; letter-spacing: .1em; }
.cyc.is-current .cyc-name { border-bottom: 1px solid #fff; }

/* Phones: the same sections as a bar along the bottom */
.section-bar { display: none; }
@media (max-width: 768px) {
    .section-cycle { display: none; }
    .section-head { grid-template-columns: auto 1fr; }
    .section-head .section-title { text-align: right; }
    .section-bar {
        display: flex; flex: none; justify-content: space-around; gap: 4px;
        margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .35);
    }
    .bar-item {
        flex: 1 1 0; min-width: 0; padding: 12px 2px; background: none; border: 0; color: #fff; opacity: .55;
        font: inherit; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; text-align: center;
        border-bottom: 2px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .bar-item.is-current { opacity: 1; border-bottom-color: #fff; }
    .bar-item.vivi { font-size: .8rem; }
    body[data-size="small"] .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    body[data-size="small"] .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    body[data-size="small"] .models-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Tools: little icons on the bottom right of a card */
.card-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; z-index: 2; pointer-events: none; }
.card-tools .tool-mark.is-link { pointer-events: auto; cursor: pointer; transition: transform .15s, border-color .15s; }
.card-tools .tool-mark.is-link:hover, .card-tools .tool-mark.is-link:focus-visible { transform: translateY(-2px) scale(1.12); border-color: rgba(255, 255, 255, .8); outline: none; }
.p-tools .tool-mark.is-link { cursor: pointer; transition: transform .15s; }
.p-tools .tool-mark.is-link:hover, .p-tools .tool-mark.is-link:focus-visible { transform: translateY(-2px); outline: 1px dashed currentColor; outline-offset: 3px; }
.project-card-info { padding-right: 150px; }
.card-tools .tool-mark {
    display: flex; align-items: center; justify-content: center; height: 24px; min-width: 24px;
    background: rgba(0, 0, 0, .72); border: 1px solid rgba(255, 255, 255, .25); border-radius: 4px; padding: 3px;
}
.card-tools .tool-mark img { height: 100%; width: auto; max-width: 22px; object-fit: contain; display: block; }
.card-tools .tool-mark.no-icon { padding: 0 6px; }
.card-tools .tool-name { font-size: .55rem; letter-spacing: .06em; text-transform: uppercase; color: #fff; }
.model-card, .cast-card { position: relative; }
body[data-size="small"] .card-tools .tool-mark { height: 18px; min-width: 18px; padding: 2px; }
body[data-size="small"] .card-tools { right: 5px; bottom: 5px; gap: 3px; }
body[data-size="small"] .project-card-info { padding-right: 90px; }
@media (max-width: 768px) { .project-card-info { padding-right: 18px; padding-bottom: 38px; } }

/* "Tools used" on a page */
.p-tools { margin: 40px 0 10px; }
.p-tools-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.p-tools .tool-mark {
    display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px;
    border: 1px solid color-mix(in srgb, var(--p-muted, #8a8a8a) 55%, transparent);
    background: color-mix(in srgb, var(--p-text, #fff) 6%, transparent);
}
.p-tools .tool-mark img { height: 26px; width: auto; max-width: 40px; object-fit: contain; display: block; }
.p-tools .tool-name { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.p-tools-note { font-size: .85rem; color: var(--p-muted, #8a8a8a); max-width: 60ch; }

/* A character says which project it is from */
.p-from {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 22px 0 0; padding: 12px 16px;
    border: 1px dashed color-mix(in srgb, var(--p-accent, #fff) 70%, transparent);
    background: color-mix(in srgb, var(--p-accent, #fff) 8%, transparent);
}
.p-from p { margin: 0; flex: 1 1 220px; line-height: 1.5; font-size: .92rem; }

/* The characters of a project (and the 3D models inside them) */
.p-cast { margin: 36px 0; }
.p-cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cast-card {
    display: flex; align-items: center; gap: 14px; padding: 10px 14px; text-decoration: none; color: inherit;
    border: 1px solid color-mix(in srgb, var(--p-muted, #8a8a8a) 55%, transparent);
    background: color-mix(in srgb, var(--p-text, #fff) 5%, transparent);
    transition: border-color .2s, background .2s;
}
.cast-card:hover { border-color: var(--p-accent, #fff); background: color-mix(in srgb, var(--p-accent, #fff) 12%, transparent); }
.cast-card .model-thumb { --h: 72px; }
.cast-card .model-text strong { font-size: .9rem; }
.cast-card .model-text em { color: var(--p-muted, #8a8a8a); }

/* A project without a background picture: its cover, blurred up and down, under the page colour */
.project-view.auto-bg::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: color-mix(in srgb, var(--p-bg, #0d0d0d) 72%, transparent);
}

/* Captions under pictures */
.p-figure figcaption { display: flex; flex-direction: column; gap: 3px; line-height: 1.5; }
.p-figure .cap-title { font-weight: bold; color: var(--p-text, #f2f2f2); letter-spacing: .04em; }
.p-figure .cap-text { color: var(--p-muted, #8a8a8a); }
.p-pic { position: relative; }
.p-pic .frames-badge { pointer-events: auto; cursor: pointer; }

/* BEHIND THE SCENES: pages torn out of a sketchbook */
.p-bts-head { margin: 56px 0 18px; }
.p-bts-head .p-h2 { margin-bottom: 4px; }
.p-bts-sub { margin: 0; font-size: .85rem; color: var(--p-muted, #8a8a8a); font-style: italic; }
.p-gallery.bts-grid, .p-figure.bts { --paper: #f3eee1; --ink: #2b2620; }
.p-gallery.bts-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 30px 26px; padding: 8px 4px; }
.p-figure.bts {
    position: relative; margin: 26px 0; padding: 12px 12px 14px; background: var(--paper); color: var(--ink);
    transform: rotate(var(--tilt, 0deg)); box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    transition: transform .25s ease, box-shadow .25s ease;
}
.p-gallery.bts-grid .p-figure.bts { margin: 0; }
.p-figure.bts::before {                                  /* a strip of tape */
    content: ''; position: absolute; top: -11px; left: 50%; width: 84px; height: 22px; transform: translateX(-50%) rotate(-3deg);
    background: rgba(230, 218, 160, .72); box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.p-figure.bts:hover { transform: rotate(0deg) scale(1.025); box-shadow: 0 10px 26px rgba(0, 0, 0, .55); z-index: 2; }
.p-figure.bts img { filter: saturate(.92); }
.p-figure.bts figcaption { margin-top: 10px; color: var(--ink); font-family: 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive; }
.p-figure.bts .cap-title { color: var(--ink); font-size: .9rem; letter-spacing: 0; }
.p-figure.bts .cap-text { color: #5a5247; font-size: .82rem; }

@media (prefers-reduced-motion: reduce) {
    .p-figure.bts, .cyc-cube { transition: none; }
}

/* tools inside a character card sit at its end instead of over its text */
.model-card .card-tools, .cast-card .card-tools { position: static; margin-left: auto; align-self: flex-end; flex: none; }
.model-card .model-text, .cast-card .model-text { flex: 1 1 auto; min-width: 0; }

/* The viewer's title and description for a picture */
.lightbox-caption {
    width: min(680px, 86vw); display: flex; flex-direction: column; gap: 4px; text-align: center;
    padding: 10px 16px; background: rgba(0, 0, 0, .62); border: 1px solid rgba(255, 255, 255, .22);
    color: #e9e9e9; font-size: .9rem; line-height: 1.55; pointer-events: none;
}
.lightbox-caption[hidden] { display: none; }
.lightbox-caption strong { letter-spacing: .06em; color: #fff; }
.lightbox-caption span { color: #bdbdbd; font-size: .84rem; }
@media (max-width: 768px) {
    .lightbox-caption { bottom: 18px; }
        .lightbox-frames { bottom: 20px; }
}




/* Download button (wallpapers): the untouched file */
.dl-btn {
    display: inline-block; align-self: flex-start; margin-top: 8px; padding: 5px 12px;
    border: 1px solid currentColor; color: inherit; text-decoration: none; text-transform: uppercase; letter-spacing: .14em;
    font-size: .68rem; background: transparent; opacity: .85; transition: opacity .2s, background .2s, color .2s;
}
.dl-btn:hover, .dl-btn:focus-visible { opacity: 1; background: var(--p-accent, #fff); color: var(--p-bg, #000); outline: none; }
.dl-btn::before { content: '\2193  '; }
.p-figure.is-wallpaper { display: flex; flex-direction: column; }
.lightbox-dl { margin: 0; align-self: center; color: #fff; background: rgba(0,0,0,.55); }
.lightbox-dl:hover, .lightbox-dl:focus-visible { background: #fff; color: #000; }


/* Project and character pages: the Return bar is fixed at the top (like Artwork / Projects); only what is below it scrolls */
.project-view { --p-bar-h: calc(var(--frame-w) + 22px + 44px + 8px); }
.project-view[data-frame] { --p-bar-h: calc(var(--p-frame-w, 48px) * .7 + 14px + 44px + 8px); }
.p-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 8; height: var(--p-bar-h); max-width: none; margin: 0;
    padding: calc(var(--frame-w) + 22px) calc(var(--frame-w) + 24px) 0; box-sizing: border-box; pointer-events: none;
}
.project-view[data-frame] .p-bar { top: 0; padding: calc(var(--p-frame-w, 48px) * .7 + 14px) calc(var(--p-frame-w, 48px) * .7 + 20px) 0; }
.project-view.active .p-bar .p-btn { pointer-events: auto; background: none; }
.project-view:not(.active) .p-bar .p-btn { pointer-events: none; }
.p-scroll { top: var(--p-bar-h); padding-top: 18px !important; }
.project-view:not([data-frame]) .p-scroll {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--edge-fade), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--edge-fade), #000 calc(100% - var(--frame-w) - var(--edge-fade)), transparent calc(100% - var(--frame-w)), transparent 100%);
}
@media (max-width: 768px) {
    .project-view { --p-bar-h: calc(var(--frame-w) + 14px + 40px + 6px); }
    .p-bar { padding: calc(var(--frame-w) + 14px) calc(var(--frame-w) + 12px) 0; }
    .p-bar .p-btn { padding: 8px 12px; }
    #project-back-label { display: none; }
}

/* Phones: the ornament around a section title is as wide as the title, and sits on it */
@media (max-width: 768px) {
    .section-head .section-title { justify-self: end; width: fit-content; text-align: center; }
    .section-title::after { width: calc(100% + 30px); }
    .section-title::before { width: calc(100% + 6px); }
}

/* Artwork folders: the versions of one artwork (Landscape / Portrait / ...) as buttons at the top of the viewer */
.lightbox-versions {
    position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 4;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 70vw;
}
.lightbox-versions[hidden] { display: none; }
.lightbox-version {
    background: rgba(0, 0, 0, .6); color: #fff; border: 1px solid rgba(255, 255, 255, .45);
    padding: 6px 14px; font: inherit; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; opacity: .8;
}
.lightbox-version:hover { opacity: 1; border-color: #fff; }
.lightbox-version.on { background: #fff; color: #000; opacity: 1; }
.lightbox.with-versions .lightbox-wrapper { box-sizing: border-box; padding-top: 52px; }

/* Artwork on a character's page: the same cards as the Artwork section, in the page's own colours */
.p-artwork-grid { padding-bottom: 8px; }
.p-artwork-grid .artwork-item { background: rgba(255, 255, 255, .05); border-color: color-mix(in srgb, var(--p-text, #fff) 30%, transparent); }
.p-artwork { margin-top: 2.2em; }


/* 3D viewer: animations beside the picture on a wide screen, zoom buttons in its corner */
.p-model-fig figcaption { grid-column: 1 / -1; }
.p-model-zoom { position: absolute; right: 10px; bottom: 10px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.p-model-zoom button {
    width: 32px; height: 32px; padding: 0; font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer;
    color: var(--p-text, #fff); background: color-mix(in srgb, var(--p-bg, #000) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--p-text, #fff) 40%, transparent);
}
.p-model-zoom button:hover { background: var(--p-accent, #fff); color: var(--p-bg, #000); }
@media (min-width: 900px) {
    .p-model-fig { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 18px 24px; align-items: start; }
    .p-model-fig .p-model { max-width: none; margin: 0; }
    .p-model-fig .p-model-clips { flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: stretch; max-width: none; margin: 0; max-height: min(640px, calc(100vh - 280px)); overflow-y: auto; }
    .p-model-fig .p-model-btn { text-align: left; }
}


/* Decks: a set of pictures as one stacked card. Hover fans it out like a hand of cards; click opens the viewer */
.deck-row { padding: 14px 4px 8px; }      /* plain block, not a grid: the cards wrap around the floating rail and take the full width below it */
.deck { --paper: #f3eee1; --ink: #2b2620; position: relative; display: flex; flex-direction: column; gap: 14px; }
.deck-row > .deck { display: inline-flex; vertical-align: top; width: min(100%, var(--deck-w, 360px)); margin: 0 32px 44px 0; }   /* (the viewer also carries the class 'deck', so the size is only for cards in a row) */
.deck-cards { position: relative; aspect-ratio: 4 / 3; margin: 10px 12px 0; }
.deck-wall .deck-cards { aspect-ratio: 16 / 10; }
.deck-card {
    position: absolute; inset: 0; padding: 0; margin: 0; border: 0; cursor: pointer; overflow: hidden;
    transform-origin: 50% 130%;
    transform: rotate(calc(var(--d) * 3.2deg)) translateX(calc(var(--d) * 5px));
    transition: transform .35s cubic-bezier(.2, .8, .25, 1), box-shadow .25s ease, filter .25s ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .5);
}
.deck-card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.deck-paper .deck-card { background: var(--paper); padding: 10px; }
.deck-paper .deck-card img { filter: saturate(.92); }
.deck-paper .deck-cards::before {                       /* tape on the top card */
    content: ''; position: absolute; z-index: 9; top: -12px; left: 50%; width: 86px; height: 22px;
    transform: translateX(-50%) rotate(-3deg); background: rgba(230, 218, 160, .75); box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    pointer-events: none;
}
.deck-wall .deck-card { border: 1px solid rgba(255, 255, 255, .35); background: #000; box-shadow: 0 8px 22px rgba(0, 0, 0, .6), 0 0 0 1px rgba(0, 0, 0, .6); }
.deck-plain .deck-card { border: 1px solid color-mix(in srgb, var(--p-text, #fff) 35%, transparent); background: rgba(255, 255, 255, .06); padding: 6px; }
.deck-plain .deck-card img { object-fit: contain; }

.deck:hover .deck-card, .deck:focus-within .deck-card {
    transform: translateX(calc(var(--d) * 22%)) translateY(calc(var(--d) * var(--d) * 4px)) rotate(calc(var(--d) * 8deg));
}
.deck-cards .deck-card:hover, .deck-cards .deck-card:focus-visible {
    z-index: 20 !important; filter: brightness(1.06); outline: none;
    transform: translateX(calc(var(--d) * 22%)) translateY(calc(var(--d) * var(--d) * 4px - 16px)) rotate(calc(var(--d) * 8deg)) scale(1.04);
    box-shadow: 0 16px 34px rgba(0, 0, 0, .6);
}
.deck-label { display: flex; flex-direction: column; gap: 3px; }
.deck-title { font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; }
.deck-text { font-size: .85rem; color: var(--p-muted, #8a8a8a); font-style: italic; }
.deck-count { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--p-muted, #8a8a8a); }
.deck-peek { min-height: 1.2em; margin: 0; font-size: .8rem; color: var(--p-accent, currentColor); }
@media (hover: none) { .deck-card { transform: rotate(calc(var(--d) * 4.5deg)) translateX(calc(var(--d) * 8px)); } }

/* The viewer for a deck: a picker bar at the bottom, and a paper (or blurred wallpaper) backdrop */
.lightbox-picker { display: flex; gap: 10px; max-width: 94vw; overflow-x: auto; padding: 8px 6px; }
.lightbox-picker[hidden] { display: none; }
.lightbox-pick { flex: none; width: 76px; height: 58px; padding: 0; background: #000; border: 1px solid rgba(255, 255, 255, .35); opacity: .6; cursor: pointer; transition: opacity .2s, transform .2s; }
.lightbox-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox-pick:hover { opacity: 1; }
.lightbox-pick.on { opacity: 1; border-color: #fff; transform: translateY(-5px); }

.lightbox.skin-paper { background: #e9e2d0 var(--paper-bg, none) center / cover; color: #2b2620; }
.lightbox.skin-paper .lightbox-close, .lightbox.skin-paper .lightbox-arrow, .lightbox.skin-paper .lightbox-count, .lightbox.skin-paper .lightbox-hint { color: #2b2620; }
.lightbox.skin-paper .lightbox-caption { background: rgba(243, 238, 225, .9); border-color: rgba(43, 38, 32, .3); color: #2b2620; font-family: 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive; }
.lightbox.skin-paper .lightbox-caption strong { color: #2b2620; }
.lightbox.skin-paper .lightbox-caption span { color: #5a5247; }
.lightbox.skin-paper .lightbox-pick, .lightbox.skin-paper .lightbox-frame { background: #f3eee1; padding: 4px; border-color: rgba(43, 38, 32, .4); }
.lightbox.skin-paper .lightbox-pick.on, .lightbox.skin-paper .lightbox-frame.on { border-color: #2b2620; }
.lightbox.skin-paper .lightbox-play, .lightbox.skin-paper .lightbox-version { background: #f3eee1; color: #2b2620; border-color: #2b2620; }

.lightbox.skin-wall { background: #000; }
.lightbox.skin-wall::before {
    content: ''; position: absolute; inset: -40px; background: var(--shot) center / cover; filter: blur(46px) brightness(.45) saturate(1.2);
    transition: background-image .3s; z-index: 0; pointer-events: none;
}
.lightbox.skin-wall .lightbox-wrapper { z-index: 1; }

/* A wide screen: the page header stays on the left, the sections fill the right */
.p-section { margin-bottom: 8px; }
@media (min-width: 1100px) {
    #project-body { max-width: 1320px !important; display: grid; grid-template-columns: 330px minmax(0, 1fr); column-gap: 56px; align-items: start; }
    #project-body > .p-left { grid-column: 1; grid-row: 1 / span 40; }
    #project-body:not([data-shots]) > .p-left { position: sticky; top: 0; }
    .p-left .p-head { margin-bottom: 0; }
    #project-body > .p-main { grid-column: 2; min-width: 0; }
    #project-body .p-section > .p-text, #project-body .p-section > p { max-width: 70ch; }
}


/* the viewer: the picture fills the whole screen (so zooming does too); title, download, frames and picker sit in a bar over its bottom */
.lightbox-dock {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 16px 14px;
    pointer-events: none;
}
.lightbox-dock > * { pointer-events: auto; }
.lightbox-dock .lightbox-hint { position: static; transform: none; order: 9; pointer-events: none; }
.lightbox.skin-paper img.lightbox-content { padding: 0; background: none; border: 2px solid #2b2620; box-shadow: 0 10px 34px rgba(60, 45, 20, .45); }


/* scrollbars: thin, in the page's own accent colour */
* { scrollbar-width: thin; scrollbar-color: var(--p-accent, #8a8a8a) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--p-accent, #8a8a8a); border: 3px solid transparent; background-clip: padding-box; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--p-text, #fff); background-clip: padding-box; }
.lightbox * { scrollbar-color: #d8d2c0 transparent; }

.about-credits li { margin: 0 0 8px; list-style: none; }
.about-credits .credit-note { display: block; color: var(--muted, #8a8a8a); font-size: .85rem; }
.about-credits ul { padding: 0; margin: 0; }


/* Store icons (itch, Steam) for games: top left of the card, with one label per status */
.platforms { display: flex; flex-wrap: wrap; gap: 6px; }
.project-card .platforms { position: absolute; left: 8px; top: 8px; z-index: 2; pointer-events: none; }
.platform-group { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 3px; background: rgba(0, 0, 0, .68); border: 1px solid rgba(255, 255, 255, .35); }
.platform-group img { width: 22px; height: 22px; border-radius: 4px; display: block; }
.platform-label { margin-left: 4px; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: #fff; }
.platform-group:not(:has(.platform-label)) { padding-right: 3px; }
.p-head .platforms { margin: 0 0 14px; }


/* About on a wide screen: the story left, credits / contact / links right */
@media (min-width: 1000px) {
    .about { max-width: 1120px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: 80px; align-items: start; }
    .about-name, .about-sub, .about-notice, .about-credits, .about-copy { grid-column: 1 / -1; }
    .about-sub { margin-bottom: 40px; }
}

.about-facts dd, .about-contact dd { overflow-wrap: anywhere; }
.about-notice, .about-credits { margin-top: 24px; }
.about-copy {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #333333;
    color: #777777;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
}

/* Screenshots (itch.io style): one tall column of full-width pictures. Under the header, in the left column on a wide screen */
.p-trailer { margin: 28px 0 0; }
.p-trailer .p-embed { margin: 0; }
.p-shots { margin: 36px 0 0; }
.p-shots-title { font-size: .8rem; letter-spacing: .24em; text-transform: uppercase; color: var(--p-muted, #8a8a8a); margin: 0 0 12px; }
.p-shots-grid { display: flex; flex-direction: column; gap: 12px; }
.p-shot { padding: 0; border: 1px solid color-mix(in srgb, var(--p-text, #fff) 28%, transparent); background: #000; cursor: pointer; overflow: hidden; transition: transform .2s, border-color .2s; }
.p-shot img { width: 100%; height: auto; display: block; }
.p-shot:hover, .p-shot:focus-visible { transform: translateX(-3px); border-color: var(--p-accent, #fff); outline: none; }
@media (min-width: 1100px) {
    #project-body[data-shots] { grid-template-columns: 400px minmax(0, 1fr); }
}

.p-shots-deck { display: flex; max-width: 420px; margin: 0; }
@media (min-width: 1100px) { .p-shots-deck { display: none; } }
@media (max-width: 1099px) { .p-shots-grid { display: none; } }
.dl-btn[hidden] { display: none; }


/* Characters and tools: a column floating on the right of a wide screen; below it the sections use the full width */
.p-main { min-width: 0; }
@media (min-width: 1280px) {
    .p-main { display: flow-root; }
    .p-rail { float: right; width: 280px; margin: 0 0 24px 44px; }
    .p-rail > * { margin-top: 0; margin-bottom: 36px; }
}

.p-left > .p-tools { margin-top: 36px; }
@media (max-width: 760px) { .deck-row > .deck { margin-right: 0; } }

/* Group cards: paper in a colour of their own (only the cards, not the viewer); an animation is blue paper */
.deck-tint .deck-card { background: var(--paper); border: 0; padding: 10px; box-shadow: 0 6px 16px rgba(0, 0, 0, .5); }
.deck-tint .deck-card img { filter: saturate(.92); }
.deck-tint .deck-cards::before {                         /* tape, like the sketches, in a lighter shade of the paper */
    content: ''; position: absolute; z-index: 9; top: -12px; left: 50%; width: 86px; height: 22px;
    transform: translateX(-50%) rotate(-3deg); background: color-mix(in srgb, var(--paper) 55%, #fff); opacity: .85;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25); pointer-events: none;
}
.deck .deck-card.is-anim { background: #c6dbf1; }
