/* tiny-consoles · gallery page
 * One index page and one page per piece, laid side by side.
 * The pages sit in a ring: from the index, one way is the newest piece, the other way is 01.
 */

:root {
  --paper: #f3f2ef;
  --ink: #1b1a19;
  --muted: #7a766f;
  --line: rgba(27, 26, 25, 0.13);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --bar: 52px;
  --ease: cubic-bezier(.7, 0, .2, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
/* no underline or fade on hover: the cursor does the work */
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus:not(:focus-visible) { outline: none; }
@media (hover: none) { button:focus, a:focus { outline: none; } }  /* touch screens: no ring left behind after a tap */  /* no ring after a mouse click, keep it for the keyboard */
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 40px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 20px; }
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .grid { grid-template-columns: repeat(4, 1fr); column-gap: 12px; }
}

/* ---------- bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto; height: var(--bar); z-index: 10;
  background: var(--paper);
  font-size: 12px;
}
.bar .grid { height: 100%; display: flex; align-items: center; }
.bar .c1 { margin-right: auto; font-weight: 500; font-size: 16px; }   /* the name is the larger voice in the bar; the page controls stay small */
.bar .brand { display: inline-flex; align-items: center; gap: 10px; }
.bar .mark { width: 21px; height: 21px; flex: none; }
.bar .c3 { display: flex; align-items: center; gap: 18px; }   /* Prev, where you are, Next */
.bar #where { text-align: center; color: var(--muted); }
.bar { line-height: 1; }
.bar .c3 a, .bar .c3 button { display: flex; align-items: center; height: 28px; }
.bar .c3 button { padding: 0; color: var(--ink); }
.bar .c3 svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 720px) {
  .bar .c1 { grid-column: 1 / 3; } .bar .c3 { grid-column: 3 / 5; }
  /* on phones the bar sits next to 15px body text, so it grows to match */
  :root { --bar: 64px; }
  .bar { font-size: 18px; }
  .bar .mark { width: 23px; height: 23px; }
  .bar .brand { gap: 11px; }
  .bar .c1 { white-space: nowrap; font-size: 18px; }
  .bar .c3 { display: none; }   /* phones use the menu button instead */
  .bar .c3 svg { width: 7px; height: 12px; }
}

/* ---------- menu: phones only, a button in the bar and a full page list behind it ---------- */
.menu-btn, .menu { display: none; }
@media (max-width: 720px) {
  /* three equal lines on whole pixels, so none of them renders thicker than the others */
  .menu-btn { display: block; position: relative; width: 40px; height: 40px; margin: 0 -10px 0 auto; }
  .menu-btn i { position: absolute; left: 9px; width: 22px; height: 2px; border-radius: 1px; background: currentColor; transition: transform .35s var(--ease), opacity .2s ease; }
  .menu-btn i:nth-child(1) { top: 11px; } .menu-btn i:nth-child(2) { top: 18px; } .menu-btn i:nth-child(3) { top: 25px; }
  .menu-btn[aria-expanded="true"] i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .menu-btn[aria-expanded="true"] i:nth-child(2) { opacity: 0; }
  .menu-btn[aria-expanded="true"] i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .menu { position: fixed; inset: var(--bar) 0 0; z-index: 9; background: var(--paper); padding-top: 12px; overflow-y: auto;
    opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility 0s .3s; }
  .menu.open { opacity: 1; visibility: visible; transition: opacity .3s ease; }
  .menu { display: flex; flex-direction: column; }
  .menu .wrap { position: relative; z-index: 1; }
  .menu ol { list-style: none; padding-top: 22px; background: var(--trace); }   /* the same hand-drawn trace as the index and plates */
  .menu canvas { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46%; pointer-events: none; }
  .menu a { display: flex; align-items: baseline; gap: 12px; padding: 11px 0; font-size: 17px; letter-spacing: -0.01em; color: var(--muted); }
  .menu a span { flex: none; width: 22px; font-size: 12px; letter-spacing: 0; font-feature-settings: "tnum" 1; }
  .menu a[aria-current] { color: var(--ink); }
  /* the way home is a button, set apart from the numbered pieces below it */
  .menu li:first-child { margin-bottom: 10px; }
  .menu li:first-child a { display: inline-flex; padding: 7px 18px; border: 1px solid rgba(27, 26, 25, 0.22); border-radius: 999px; font-size: 15px; }
  .menu li:first-child a span { display: none; }
  .menu li:first-child a[aria-current] { border-color: var(--ink); }
  .menu li:first-child a[aria-current]::after { content: none; }
  .menu a[aria-current]::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-left: auto; align-self: center; }
  .menu.open a { animation: menu-in .5s var(--ease) both; }
  .menu.open li:nth-child(2) a { animation-delay: .03s; } .menu.open li:nth-child(3) a { animation-delay: .06s; }
  .menu.open li:nth-child(4) a { animation-delay: .09s; } .menu.open li:nth-child(5) a { animation-delay: .12s; } .menu.open li:nth-child(n+6) a { animation-delay: .15s; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .menu.open a { animation: none; } }

/* ---------- pager: every page fills the view and slides sideways ---------- */
.pager { position: fixed; inset: var(--bar) 0 0; overflow: hidden; touch-action: pan-y; }
.page {
  position: absolute; inset: 0;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper);
  transform: translateX(calc(var(--at, 0) * 100% + var(--drag, 0px)));
  transition: transform .8s var(--ease);
  will-change: transform;
}
.page.still { transition: none; }
/* while a finger drags the pages sideways, they cannot scroll up or down */
.pager.sliding .page { overflow-y: hidden; }
.page.away { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .page { transition: none; } }

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; }
.guides {
  position: absolute; inset: 0; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 20px;
  pointer-events: none;
}
.guides i { border-left: 1px solid var(--line); border-right: 1px solid var(--line); opacity: 0.45; }
@media (max-width: 720px) {
  .guides { grid-template-columns: repeat(4, 1fr); column-gap: 12px; }
  .guides i:nth-child(n+5) { display: none; }
  .guides { display: none; }
}
#field { position: absolute; left: 0; top: 0; width: 100%; height: 60%; display: block; pointer-events: none; }
.home-in { position: relative; flex: 1 0 auto; display: flex; flex-direction: column; min-height: 100%; padding-top: 56px; padding-bottom: clamp(32px, 6vh, 56px); }
/* on phones the title sits lower so the contour field has its own space above it */
@media (max-width: 720px) { .home-in { padding-top: 30vh; padding-bottom: calc(36px + env(safe-area-inset-bottom)); } }
/* phones: the piece pages also get room below their last line */
@media (max-width: 720px) { .piece .wrap { padding-bottom: calc(64px + env(safe-area-inset-bottom)); } }
.hero { align-items: end; margin-top: auto; }  /* pushes the title down when there is room, scrolls instead of clipping when there is not */
h1 {
  grid-column: 1 / 9;
  font-size: clamp(64px, 11vw, 168px);
  font-weight: 500; letter-spacing: -0.055em; line-height: 0.86;
}
.lede { grid-column: 10 / 13; font-size: 13px; line-height: 1.6; color: var(--muted); padding-bottom: 8px; }
@media (max-width: 720px) {
  h1 { grid-column: 1 / 5; }
  .lede { grid-column: 1 / 5; margin-top: 16px; padding: 0; }
}

/* the index itself: a row of entries, read left to right */
.index { margin-top: 56px; row-gap: 28px; }
.entry { grid-column: span 3; display: grid; grid-template-columns: 64px 1fr; column-gap: 14px; row-gap: 2px; align-content: start; font-size: 12px; line-height: 1.5; }
.entry:hover { text-decoration: none; }
.entry .thumb { grid-row: 1 / 5; width: 64px; height: 64px; overflow: hidden; border-radius: 6px; background: var(--line); }
.entry img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.85); transition: transform .9s var(--ease), filter .6s ease; }
.entry:hover img { transform: scale(1.08); filter: none; }
.entry .n { color: var(--muted); font-feature-settings: "tnum" 1; }
.entry b { font-size: 16px; font-weight: 500; letter-spacing: -0.015em; }
.entry .about, .entry .made { color: var(--muted); }
@media (max-width: 960px) { .entry { grid-column: span 6; } }
@media (max-width: 720px) { .entry { grid-column: span 4; } }

.colophon { margin-top: clamp(64px, 13vh, 130px); padding: 0; font-size: 11px; color: var(--muted); row-gap: 6px; }
.colophon > div:nth-child(1) { grid-column: 1 / 5; }
.colophon > div:nth-child(2) { grid-column: 5 / 9; }
.colophon > div:nth-child(3) { grid-column: 9 / 13; text-align: right; }
.colophon a { color: var(--ink); }
@media (max-width: 720px) {
  /* phones: licence across the top, then credit on the left and source on the right, like the desktop row folded once */
  .colophon { margin-top: 48px; row-gap: 8px; grid-template-columns: auto auto; justify-content: space-between; column-gap: 16px; }
  .colophon > div:nth-child(1) { grid-column: 1 / 3; }
  .colophon > div:nth-child(2) { grid-column: 1; white-space: nowrap; }
  .colophon > div:nth-child(3) { grid-column: 2; text-align: right; white-space: nowrap; }
}

/* ---------- a piece page: set like a plate in a catalogue ---------- */
/* the caption and code sit at the bottom of the page, however tall the piece is */
.piece .wrap { display: flex; flex-direction: column; min-height: 100%; padding-top: 24px; padding-bottom: 24px; }
.piece .stage { width: 100%; }
.piece .foot { margin-top: auto; padding-top: 24px; }
/* on wide screens each piece sits in the middle of the space between its plate and its caption */
@media (min-width: 721px) { .piece .stage { margin-top: auto; } }
.plate { padding-top: 28px; margin-bottom: 32px; align-items: start; }
/* every column starts on the same line: the top of the capitals */
.plate > * { text-box: trim-start cap alphabetic; }
h2 { grid-column: 1 / 7; font-weight: 400; line-height: 1.3; letter-spacing: -0.01em; }
h2 .lead { font-size: 24px; font-weight: 500; font-feature-settings: "tnum" 1; }
h2 .name { font-size: 20px; color: var(--muted); }
.plate p { grid-column: 7 / 11; font-size: 14px; line-height: 1.6; color: var(--muted); }
.chips { grid-column: 11 / 13; list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; gap: 6px; font-size: 11.5px; color: var(--muted); }
/* tags read as tags: a hairline pill around each one */
.chips li { border: 1px solid rgba(27, 26, 25, 0.22); border-radius: 999px; padding: 3px 10px; line-height: 1.4; white-space: nowrap; }
@media (max-width: 720px) {
  h2 { grid-column: 1 / 5; }
  h2 .lead { font-size: 18px; } h2 .name { font-size: 15px; }   /* phones: the title stays above the text without shouting over it */
  .plate p { grid-column: 1 / 5; margin-top: 14px; }
  .chips { grid-column: 1 / 5; margin-top: 14px; justify-content: flex-start; }
}
.stage { margin: 0 auto; max-width: var(--max, 704px); }
/* on wide screens the pieces shrink with the window height, so a piece page never needs scrolling */
@media (min-width: 721px) { .stage { max-width: clamp(var(--min, 400px), calc((100dvh - var(--bar) - 320px) / var(--ratio, 0.66)), var(--max, 704px)); } }
.foot { margin-top: 40px; align-items: start; }
.fig { grid-column: 1 / 5; font-size: 12px; line-height: 1.6; color: var(--muted); }
.fig b { font-weight: 500; color: var(--ink); }
.use { grid-column: 6 / 13; display: flex; align-items: flex-start; gap: 20px; }
.use pre { flex: 1; min-width: 0; overflow-x: auto; font-family: var(--mono); font-size: 11.5px; line-height: 1.8; color: var(--muted); }
.use button {
  flex: none; font-size: 11.5px; line-height: 1.4; color: var(--muted);
  border: 1px solid rgba(27, 26, 25, 0.22); border-radius: 999px; padding: 3px 12px;
  margin-top: -1px; min-width: 64px; text-align: center;   /* sits on the first line of code, keeps its width when it says Copied */
  transition: color .25s ease, background-color .25s ease, border-color .25s ease;
}
.use button:hover { color: var(--ink); border-color: var(--ink); }
@media (max-width: 720px) {
  .fig, .use { grid-column: 1 / 5; }
  /* phones: a small header row, "Embed" on the left and Copy on the right, then the code wrapped in full */
  .use { margin-top: 18px; display: grid; grid-template-columns: 1fr auto; row-gap: 8px; }
  .use::before { content: "Embed"; font-size: 12px; color: var(--muted); }
  .use button { grid-column: 2; grid-row: 1; }
  .use pre { grid-column: 1 / 3; white-space: pre-wrap; overflow-wrap: anywhere; overflow: visible; }
}

/* the plate, the piece and its caption arrive one after another when the page comes in */
.piece .plate, .piece .stage, .piece .foot { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform 1.1s cubic-bezier(.2, .7, .2, 1); }
.piece.current .plate, .piece.current .stage, .piece.current .foot { opacity: 1; transform: none; }
.piece.current .plate { transition-delay: .35s; }
.piece.current .stage { transition-delay: .5s; }
.piece.current .foot  { transition-delay: .7s; }
@media (prefers-reduced-motion: reduce) {
  .piece .plate, .piece .stage, .piece .foot { opacity: 1; transform: none; transition: none; }
}

/* one divider per page: a broken trace, like the contours on the index */
:root { --trace: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='3'%3E%3Cpath d='M0.0 1.10h5.0M9.0 1.15h12.0M27.0 1.40h3.0M32.0 1.22h8.0M42.0 1.28h18.0M64.0 1.26h5.0M71.0 1.80h3.0M78.0 1.31h5.0M86.0 1.09h26.0M116.0 1.67h18.0M138.0 1.18h18.0M159.0 1.09h12.0M175.0 1.84h34.0M218.0 1.57h3.0M225.0 1.20h8.0M242.0 1.29h12.0M263.0 1.23h12.0M278.0 1.08h8.0M288.0 1.52h12.0' stroke='%231b1a19' stroke-opacity='.38' stroke-width='1' fill='none'/%3E%3C/svg%3E") left top / 300px 3px repeat-x; }
.index, .plate { background: var(--trace); }
.index { padding-top: 22px; }
.plate { padding-top: 22px; }

/* ---------- cursor: a small dot that swells into a lens over anything clickable ---------- */
.cursor { display: none; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  html.has-cursor, html.has-cursor * { cursor: none !important; }
  .cursor {
    display: block;
    position: fixed; left: 0; top: 0; z-index: 100;
    width: 34px; height: 34px; margin: -17px 0 0 -17px;
    border-radius: 50%;
    background: #fff;
    mix-blend-mode: difference;
    pointer-events: none;
    transform: translate3d(var(--x, -100px), var(--y, -100px), 0) scale(var(--s, 0.24));
    transition: opacity .3s ease;
    will-change: transform;
  }
  .cursor.hidden { opacity: 0; }
  /* over a picture: a magnifier, the picture under it shown larger (set by cursor.js) */
  .cursor.loupe {
    background-color: var(--line); background-repeat: no-repeat; mix-blend-mode: normal;
    box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 4px 14px rgba(0,0,0,.16);
  }
}
