@font-face { font-family: 'ET Book'; src: url(render/fonts/text/et-book-roman-old-style-figures.ttf); }
@font-face { font-family: 'ET Book'; font-style: italic; src: url(render/fonts/text/et-book-display-italic-old-style-figures.ttf); }

:root {
	--paper: #f3efe6;
	--sheet: #fbf8f1;
	--ink: #2b2824;
	--quiet: #857d70;
	--tile: 512px;
}
/* touch-action: a double tap is the page's own (more like this), never the browser's zoom */
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); touch-action: manipulation; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body { font: 15px/1.25 'ET Book', Georgia, serif; color: var(--ink); overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button, a { font: inherit; }

#field { position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none; background: var(--paper); }
#field.dragging { cursor: grabbing; }
#paper { position: absolute; left: calc(-1 * var(--tile)); top: calc(-1 * var(--tile)); width: calc(100% + 2 * var(--tile)); height: calc(100% + 2 * var(--tile)); background-size: var(--tile) var(--tile); will-change: transform; }
.flat #paper { background-image: none !important; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }

/* --lean: neighbours leaning out of the picked initial's way, and back */
:root { --lean: transform .45s cubic-bezier(.25, .8, .3, 1); }
.cap { position: absolute; opacity: 0; transition: opacity .35s ease, var(--lean); }
.cap.shown { opacity: 1; cursor: pointer; }
/* inked in (inking.js) rather than faded */
.cap.inked { transition: var(--lean); }
.cap.gone { opacity: 0; transition: opacity .3s ease, var(--lean); pointer-events: none; }
/* the copy that replays the growth over a cell */
.cap.grow { transition: var(--lean); pointer-events: none; }
.cap.grow.fading { opacity: 0; transition: opacity .25s ease, var(--lean); }
/* the still under it, out of sight but still clickable */
.cap.under { opacity: 0 !important; transition: var(--lean) !important; }

/* paper pieces: the torn sheet is a canvas behind each (torn.js) */

/* the lesson (lesson.js): a scrap with a printer's hand pointing where the thing happens. It never
   takes a click: the field under it stays live */
/* the hand sits on the side of what it points at: right of the words, unless .left or .up */
.lesson { position: absolute; z-index: 4; display: flex; flex-direction: row-reverse; align-items: center; gap: 9px; padding: 7px 10px 8px 14px; pointer-events: none; isolation: isolate; transform: rotate(var(--tilt, 0deg)); --from: 6px; animation: arrive .35s cubic-bezier(.25, .8, .3, 1) both; transition: opacity .25s ease; }
.lesson.fixed { position: fixed; z-index: 9; }
.lesson.going { opacity: 0; }
.lesson .hand { flex: none; animation: nudge .7s ease-in-out infinite alternate; }
.lesson.left { flex-direction: row; padding: 7px 14px 8px 10px; }
.lesson.left .hand { scale: -1 1; animation-name: nudge-left; }
.lesson.up { flex-direction: column; align-items: flex-start; gap: 3px; padding: 6px 14px 8px 12px; }
.lesson.up .hand { rotate: -90deg; margin: 2px 0 -2px 6px; animation-name: nudge-up; }
.lesson.down { flex-direction: column-reverse; align-items: flex-start; gap: 3px; padding: 8px 14px 6px 12px; }
.lesson.down .hand { rotate: 90deg; margin: -2px 0 2px 6px; animation-name: nudge-down; }
.lesson.sway .hand { animation: sway 1.4s ease-in-out infinite alternate; }
@keyframes nudge { to { translate: 4px 0; } }
@keyframes sway { from { translate: -7px 0; } to { translate: 7px 0; } }
@keyframes nudge-left { to { translate: -4px 0; } }
@keyframes nudge-up { to { translate: 0 -4px; } }
@keyframes nudge-down { to { translate: 0 4px; } }
.lesson .say { display: flex; flex-direction: column; gap: 1px; }
.lesson b { font-weight: normal; font-style: italic; font-size: 18px; line-height: 1.1; white-space: nowrap; }
.lesson small { font-size: 12.5px; font-style: italic; color: var(--quiet); white-space: nowrap; }
.lesson small.fine { font-size: 11px; }
.sheet-bg { z-index: -1; }
#bar, .tag, #collection, .tab, .sheet { isolation: isolate; }

button.plain, #bar button, .tag button, .tag a { all: unset; cursor: pointer; color: var(--quiet); }
#bar button:hover, .tag button:hover, .tag a:hover { color: var(--ink); }
[hidden] { display: none !important; }
/* on GitHub: the top right corner, a piece of black paper torn along the diagonal. The sheet is a rectangle
   turned on its corner, so only its torn edge shows */
#corner { position: fixed; top: 0; right: 0; z-index: 12; width: 112px; height: 112px; overflow: hidden; pointer-events: none; }
#corner a { position: absolute; left: 50%; top: 50%; width: 210px; height: 112px; margin: -112px 0 0 -105px; isolation: isolate; transform-origin: 50% 100%; transform: rotate(45deg); pointer-events: auto; }
#corner a canvas:not(.sheet-bg) { position: absolute; left: 50%; bottom: 33px; transform: translate(-50%, 50%) rotate(-45deg); transition: transform .15s ease; }
#corner a:hover canvas:not(.sheet-bg) { transform: translate(-50%, 50%) rotate(-45deg) scale(1.1); }
@media (max-width: 560px) { #corner { transform: scale(.82); transform-origin: top right; } }
/* the popover that stands in for title tooltips (tips.js): a scrap of paper, a few words */
#tip { position: fixed; left: 0; top: 0; z-index: 60; max-width: min(280px, calc(100vw - 24px)); padding: 5px 11px 6px; isolation: isolate; pointer-events: none; font-size: 14px; font-style: italic; line-height: 1.25; color: var(--ink); opacity: 0; transition: opacity .1s ease; }
#tip.on { opacity: 1; }
/* text for screen readers and agents, off the page */
.for-agents { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the bar: a torn strip at the top */
#bar { position: fixed; left: 14px; top: calc(14px + env(safe-area-inset-top)); display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; max-width: calc(100vw - 130px); box-sizing: border-box; padding: 8px 16px 9px; }
/* the name: Cinzel's Roman capitals (ET Book has no Ā), drawn as an outline in index.html */
#name { color: var(--ink); line-height: 1; text-decoration: none; cursor: pointer; }
#name svg { display: inline-block; vertical-align: -1px; }
#hint { color: var(--quiet); font-style: italic; }
#hint:empty { display: none; }
#catalogue { position: fixed; left: 150px; top: calc(14px + env(safe-area-inset-top)); z-index: 12; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; max-width: calc(100vw - 260px); font: 12px/1.5 Georgia, serif; }
.control-island { position: relative; isolation: isolate; display: flex; align-items: center; flex-wrap: wrap; gap: 7px 14px; padding: 8px 12px 9px; }
#catalogue label { display: flex; align-items: center; gap: 6px; color: var(--quiet); }
#catalogue select { max-width: min(230px, 46vw); border: 1px solid #d9d0be; border-radius: 3px; padding: 4px 6px; background: #fbf8f1; color: var(--ink); font: inherit; cursor: pointer; }
#catalogue select:focus-visible { outline: 2px solid #856a47; outline-offset: 2px; }
#font-count { color: var(--quiet); }
#letter-choice { width: 26px; border: 1px solid #d9d0be; border-radius: 3px; padding: 4px; background: #fbf8f1; color: var(--ink); font: inherit; text-align: center; user-select: text; -webkit-user-select: text; }
body:has(#sheet.shown) #catalogue, body:has(#context:not([hidden])) #catalogue { display: none; }

/* back and forward: two arrows on scraps of their own, under the name; faint when there's nowhere to go */
#nav { position: fixed; left: 16px; top: calc(56px + env(safe-area-inset-top)); z-index: 12; display: flex; gap: 6px; }
#nav .scrap { all: unset; position: relative; isolation: isolate; display: inline-flex; padding: 7px 9px; cursor: pointer; transform: rotate(var(--tilt, 0deg)); transition: transform .15s ease; }
#nav .scrap canvas:not(.sheet-bg) { display: block; }
#nav .scrap:hover { transform: rotate(0deg) translateY(-1px) scale(1.07); }
/* nowhere to go: the whole scrap ghosted, paper and all, and it takes no clicks */
#nav .scrap.off { opacity: .28; pointer-events: none; transform: rotate(var(--tilt, 0deg)); }

/* the tag under the chosen initial: each thing it does on its own scrap of paper, a little askew.
   Picked, its scraps come out from under it once its neighbours have leant away */
.tag { position: absolute; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 3px; --from: -9px; }
.tag.above { --from: 9px; }
.tag.arrive { animation: arrive .32s cubic-bezier(.25, .8, .3, 1) .12s both; }
@keyframes arrive { from { opacity: 0; transform: translateY(var(--from)); } }
.tag .row { display: flex; align-items: center; gap: 5px; }
.tag .space { width: 7px; }
.tag .scrap { all: unset; position: relative; isolation: isolate; display: inline-flex; padding: 7px; cursor: pointer; transform: rotate(var(--tilt, 0deg)); transition: transform .15s ease; }
.tag .scrap.small { padding: 6px; }
.tag .scrap:hover { transform: rotate(0deg) translateY(-1px) scale(1.07); }
.tag .scrap canvas:not(.sheet-bg) { display: block; }
.tag .scrap.busy canvas:not(.sheet-bg) { opacity: .45; }
.tag .scrap.busy { cursor: progress; }
/* what a scrap has to say (link copied, how a download is going): a slip of paper under it */
.tag .note { position: absolute; top: 100%; left: 50%; z-index: 2; translate: -50% 0; rotate: -1.2deg; margin-top: 7px; padding: 4px 11px 5px; isolation: isolate; font-size: 13.5px; font-style: italic; line-height: 1.2; color: var(--ink); white-space: nowrap; pointer-events: none; --from: -4px; animation: arrive .25s cubic-bezier(.25, .8, .3, 1) both; }
/* the row above the initial: its notes go above it, clear of the initial */
.tag.above .note { top: auto; bottom: 100%; margin: 0 0 7px; --from: 4px; }
/* more like this says what it does, in words, unlike the icons */
.tag .scrap.word { padding: 6px 13px 8px; font-style: italic; font-size: 19px; line-height: 1; color: var(--ink); white-space: nowrap; }
/* a word scrap with an icon before it (share) */
.tag .scrap.word canvas:not(.sheet-bg) { margin: -2px 6px -2px -3px; }
.tag .scrap.word[data-icon] { align-items: center; padding: 6px 12px 7px 11px; }
/* who a share is for comes out from behind its icon (icons.js) */
.tag .scrap.word canvas.sharemark { margin: -4px 4px -4px -5px; }
#pins { font-size: 12px; font-style: italic; color: var(--quiet); }
#pins:empty { display: none; }

/* the collection: a row along the foot, in the middle, newest first, after a bookmark */
#collection { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 28px); box-sizing: border-box; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 12px; transition: opacity .3s ease; }
/* the bookmark: opens the collection's own page */
#collection .mark { all: unset; flex: none; display: flex; padding: 4px 3px; cursor: pointer; transition: transform .15s ease; }
#collection .mark:hover { transform: translateY(-1px) scale(1.1); }
.album #collection { opacity: 0; pointer-events: none; }
#collection .item.away { visibility: hidden; }

/* the collection all at once: a page over the field, the initials on it as they are in the field,
   flush left under the bar; the paper round them puts it away */
#album { position: fixed; inset: 0; z-index: 11; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; box-sizing: border-box; padding: calc(106px + env(safe-area-inset-top)) 18px calc(40px + env(safe-area-inset-bottom)); cursor: zoom-out; }
/* its paper and its words fade in by themselves, while the initials fly to their places (app.js) */
#album-paper { position: fixed; inset: 0; z-index: 11; pointer-events: none; background-color: var(--paper); background-size: var(--tile) var(--tile); opacity: 0; transition: opacity .3s ease .05s; }
#album header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin: 0 0 14px 6px; cursor: auto; opacity: 0; transition: opacity .3s ease; }
.album #album-paper, .album #album header { opacity: 1; }
.album #album-paper { transition-delay: 0s; }
/* in the air they pass in front of the row's paper and the toolbar */
#album.flying { overflow: hidden; z-index: 13; }
#album.flying .one canvas { transition: none; will-change: transform; }
#album.flying .one button { opacity: 0; transition: none; }
#album.gathering .one { pointer-events: none; }
#album h2 { margin: 0; font-weight: normal; font-style: italic; font-size: 22px; line-height: 1.2; color: var(--ink); }
#album h2 .n { font-size: 15px; color: var(--quiet); }
#album .tag { position: static; flex-direction: row; gap: 6px; animation: none; }
#album .tag .scrap[disabled] { cursor: default; opacity: .6; }
#album .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(168px, 28vw), 1fr)); gap: 12px; }
#album .one { position: relative; aspect-ratio: 1; cursor: pointer; }
#album .one canvas { display: block; width: 100%; height: 100%; transition: transform .15s ease; }
#album .one:hover canvas { transform: translateY(-2px) scale(1.03); }
#album .one button { all: unset; position: absolute; top: -10px; right: -8px; isolation: isolate; padding: 0 6px 2px; font-size: 18px; line-height: 1.1; color: var(--ink); opacity: 0; cursor: pointer; rotate: 5deg; transition: opacity .15s ease, scale .15s ease; }
#album .one:hover button { opacity: 1; }
#album .one button:hover { scale: 1.12; }
@media (hover: none) { #album .one button { opacity: 1; } }
#collection .items { min-width: 0; overflow-x: auto; display: flex; align-items: center; gap: 4px; padding: 7px 7px 4px 2px; scrollbar-width: none; }
#collection .item { position: relative; width: 56px; height: 56px; flex: none; cursor: pointer; }
#collection canvas { width: 56px; height: 56px; display: block; transition: opacity .2s; }
#collection .item.arriving canvas { opacity: 0; }
/* resting on one: download and share above it, and a scrap at its corner to let it go (app.js) */
.tag.itemtag { position: fixed; z-index: 13; --from: 6px; }
.tag.itemtag .scrap.small { padding: 5px; }
.letgo { all: unset; position: fixed; z-index: 14; isolation: isolate; padding: 0 6px 2px; font-size: 17px; line-height: 1.1; color: var(--ink); cursor: pointer; rotate: 5deg; transition: scale .15s ease; }
.letgo:hover { scale: 1.12; }
.flying { position: fixed; z-index: 50; pointer-events: none; transform-origin: 0 0; transition: transform .75s cubic-bezier(.3, .6, .2, 1); }

/* in context: an aged sheet over the whole screen, the initial laid on it */
#sheet { position: fixed; inset: 0; z-index: 10; opacity: 0; transition: opacity .5s ease; cursor: zoom-out; }
#sheet.shown { opacity: 1; }
#sheet .aged { position: absolute; inset: 0; width: 100%; height: 100%; }
#sheet .initial { position: absolute; mix-blend-mode: multiply; }
#bar, #collection { z-index: 12; }

/* the flat page, for browsers without WebGPU */
#context { position: fixed; inset: 0; padding: 16px; background: color-mix(in srgb, var(--paper) 88%, transparent); cursor: zoom-out; z-index: 20; }
#context canvas { display: block; box-shadow: 0 1px 10px rgba(40, 30, 20, .18); }
#context p { margin: 0; color: var(--quiet); }


#incontext:disabled { opacity: .28; cursor: default; pointer-events: none; }

@media (max-width: 700px) { #catalogue { left: 14px; top: calc(100px + env(safe-area-inset-top)); max-width: calc(100vw - 28px); } }
