/* Keep the hero centred in the viewport below the navigation. */
.landing-mode main{margin-top:0}
.landing-mode .hero{min-height:calc(100dvh - 82px);padding:64px 0;box-sizing:border-box;justify-content:center}
.landing-intro h1,.landing-intro h1 *{cursor:default}
@media(min-width:1280px){
 .landing-mode .hero{width:min(1600px,calc(100vw - 64px));left:50%;translate:-50% 0}
 .landing-mode .landing-intro{max-width:calc(100% - 280px)}
 .landing-intro h1{font-size:clamp(80px,6.25vw,120px)}
 .landing-intro p{font-size:clamp(14px,1vw,18px)}
}

/* Hero tiles: eight little square photos scattered around the headline,
   drawn at random from the example fonts and the owner's finds on every
   visit (hero-motion.js). On screens over 900px the script places each tile
   in the free space around the text and sets its top-left corner and size
   (--hx, --hy, --ts, in px from the hero's corner); its lean is --a degrees.
   Until it has, the tiles stay hidden, so the markup's order never flashes.
   Tiles with a font open their example; the finds show their photo larger
   with where they were found (hero-examples.js). */
.hero .hero-examples .hero-tile{
 --t:max(64px,min(clamp(84px,8.2vw,128px),calc(50vh - 241px)));--card-angle:calc(var(--a,0)*1deg);
 position:absolute;inset:auto;margin:0;padding:0;
 left:var(--hx,calc(50% - var(--t)/2));top:var(--hy,calc(50% - var(--t)/2));
 width:var(--ts,var(--t));height:var(--ts,var(--t));flex:none;aspect-ratio:1;border-radius:calc(var(--ts,var(--t))*.14);
 border:0;background:#f2f2f2;overflow:hidden;
 box-shadow:0 1px 2px rgb(0 0 0 / .06),0 10px 22px -12px rgb(0 0 0 / .32);
 transform:rotate(var(--card-angle));
 transition:scale .32s cubic-bezier(.3,1.5,.5,1),box-shadow .2s ease-out;
}
@media(min-width:901px){
 .hero:not(.tiles-scattered) .hero-examples .hero-tile{visibility:hidden}
 .hero .hero-examples .hero-tile.is-unplaced{display:none}
}
.hero .hero-examples .hero-tile img{display:block;width:100%;height:100%;object-fit:cover;border-radius:inherit;pointer-events:none}
.hero .hero-examples .hero-tile:hover,.hero .hero-examples .hero-tile[aria-expanded=true]{scale:1.06;box-shadow:0 2px 4px rgb(0 0 0 / .06),0 16px 30px -14px rgb(0 0 0 / .38)}
.hero .hero-examples .hero-tile:active{scale:.97}
.hero .hero-examples .hero-tile:focus-visible{outline:2px solid #191919;outline-offset:4px;z-index:3}
.hero .hero-examples .hero-tile[data-find]{cursor:zoom-in}
/* The entrance is played by hero-motion.js (Web Animations, literal transform
   and opacity values only) once the photos are decoded. Until then the tiles
   wait unseen; the older CSS card entrance is switched off for them. No idle
   motion afterwards, so a settled hero costs nothing per frame. */
.hero .hero-examples .hero-tile:not(.entrance-complete){animation:none}
.hero .hero-examples.tiles-waiting .hero-tile:not(.entrance-complete){opacity:0}
.hero .hero-examples .hero-tile .tile-layer{position:absolute;inset:0;z-index:1;display:block;width:100%;height:100%;border-radius:inherit;pointer-events:none}
.hero .hero-examples .hero-tile .tile-flash{background:#fff}
.hero .hero-examples .hero-tile .tile-develop{background:#efe8dc}

/* The headline's words, the line under it and the button arrive on a spring
   too, like the tiles: up past their place (about a sixth of the rise), a
   touch back under, then still. Each curve is a damped spring sampled into
   linear(); a browser without linear() drops these lines and keeps the calmer
   entrance in interaction-polish.css. The fade rides the same curve, so it is
   done within the first quarter. Phones get the same. */
.hero-entering .hero-word{animation:hero-word-spring 700ms linear(0,0.039,0.141,0.281,0.439,0.599,0.748,0.878,0.983,1.063,1.118,1.15,1.162,1.16,1.145,1.124,1.099,1.072,1.048,1.025,1.007,0.993,0.983,0.977,0.974,0.974,0.976,0.979,0.983,0.987,0.991,0.995,0.998,1.001,1.002,1.004,1) both;animation-delay:calc(var(--word-index,0)*40ms)}
.hero-sequence .hero-copy-word{animation:hero-copy-spring 520ms linear(0,0.052,0.179,0.347,0.525,0.694,0.839,0.954,1.037,1.091,1.119,1.126,1.119,1.103,1.081,1.059,1.038,1.02,1.005,0.995,0.988,0.985,0.984,0.985,0.987,0.99,0.993,0.995,1) both;animation-delay:var(--entrance-delay,0ms)}
.hero-sequence .hero-action-entry{animation:hero-action-spring 640ms linear(0,0.048,0.171,0.335,0.514,0.688,0.841,0.966,1.059,1.12,1.153,1.163,1.155,1.135,1.108,1.079,1.051,1.026,1.005,0.99,0.98,0.975,0.973,0.975,0.978,0.982,0.987,0.992,0.996,0.999,1.002,1.003,1) 400ms both}
@keyframes hero-word-spring{from{opacity:0;transform:translateY(28px)}to{opacity:1;transform:translateY(0)}}
@keyframes hero-copy-spring{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:translateY(0)}}
@keyframes hero-action-spring{from{opacity:0;transform:translateY(16px) scale(.94)}to{opacity:1;transform:translateY(0) scale(1)}}

/* Phones and narrow tablets: a row above the headline and a row below the
   button, in the page flow so they never cover the text. hero-motion.js picks
   four and four, three and four or four and three (the spare tile is hidden),
   sets each tile a little high or low (--my) and to one side (--mx),
   alternating so the rows stay tidy; every tile is the same size. */
@media(max-width:900px){
 .landing-mode .hero .hero-examples{position:relative;inset:auto;display:flex;justify-content:center;align-items:center;gap:clamp(12px,4.6vw,24px);width:100%;margin:0;pointer-events:auto}
 .landing-mode .hero .hero-examples[data-count="3"]{gap:clamp(18px,7vw,40px)}
 .landing-mode .hero .hero-tiles-a{order:-1;margin-bottom:34px}
 .landing-mode .hero .hero-tiles-b{order:3;margin-top:40px}
 .hero .hero-examples .hero-tile{--t:76px;--ts:calc(var(--t)*var(--mk,1));position:relative;left:var(--mx,0px);top:calc(var(--my,0px)*1.4);border-radius:14px}
 .hero .hero-examples .hero-tile.hero-tile-spare{display:none}
}
@media(max-width:700px){
 .landing-mode main{margin-top:0}
 .landing-mode .generation-motion-toggle{position:absolute;top:88px;right:50%;translate:50% 0;font-size:10px;padding:8px 10px}
 /* The small viewport (svh), not the dynamic one: in iOS Safari dvh grows as the
    toolbars hide on the first scroll, which made the hero taller mid-scroll and
    pushed everything under it down. svh is the same height at load. */
 .landing-mode .hero[data-mobile-layout]{min-height:calc(100svh - 76px);padding:40px 0;justify-content:center;box-sizing:border-box}
 .landing-mode .hero[data-mobile-layout] .landing-intro{order:0;width:100%;margin:0 auto 28px}
 .landing-mode .hero[data-mobile-layout]>.note{order:2}
 .hero .hero-examples .hero-tile{--t:clamp(56px,15.6vw,68px);border-radius:12px}
}

/* Compact mobile navigation with matching primary and secondary controls. */
header #newButton .new-font-label{margin:0}
header #newButton .new-font-icon{display:none}
@media(max-width:700px){
 body>header,.landing-mode>header,.result-mode>header{padding-inline:16px;gap:12px}
 header .wordmark{font-size:16px;gap:8px;white-space:nowrap}
 header nav{gap:8px;flex-shrink:0}
 header #libraryButton{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:0 16px;border-radius:100px;background:#f2f2f2;color:#171717;font-size:12px;white-space:nowrap;transition:background .2s}
 header #libraryButton:hover{background:#e8e8e8}
 header #libraryCount:empty{display:none}
 header #newButton{width:44px;height:44px;min-height:44px;padding:0;flex-shrink:0}
 header #newButton .new-font-label{display:none}
 header #newButton .new-font-icon{display:block}
}
@media(max-width:360px){
 header .wordmark{font-size:14px;gap:6px}
 header #libraryButton{padding-inline:12px}
 body>header,.landing-mode>header,.result-mode>header{padding-inline:12px;gap:8px}
}

.library-item{gap:16px;text-align:left}
.library-item>span:not(.library-font-preview){flex:1;min-width:0;overflow-wrap:anywhere}
.library-font-preview{display:flex;align-items:center;justify-content:center;flex:0 0 64px;width:64px;height:64px;border-radius:14px;background:#f2f2f2;font-size:30px;line-height:1;font-weight:400;font-synthesis:none;overflow:hidden}
@media(max-width:700px){
 #libraryDialog,.font-refine-panel{position:fixed;inset:auto 0 0;width:100%;max-width:100%;max-height:85dvh;margin:0;padding:28px 20px calc(24px + env(safe-area-inset-bottom));border:0;border-radius:26px 26px 0 0;background:#fafafa;box-shadow:0 -8px 40px #00000012;overflow-y:auto;overscroll-behavior:contain}
 #libraryDialog::before,.font-refine-panel::before{content:'';position:absolute;top:10px;left:calc(50% - 18px);width:36px;height:4px;border-radius:4px;background:#ccc}
 #libraryDialog::backdrop,.font-refine-panel::backdrop{background:rgb(0 0 0 / .25)}
 #libraryDialog[open]{animation:none;will-change:transform}
 #libraryDialog .dialog-top{position:sticky;top:-28px;background:#fafafa;z-index:1;padding-block:8px}
 #closeLibrary,.font-refine-heading button{min-width:44px;min-height:44px}
 .reading-controls label,.display-toolbar label{display:none!important}
 .download-dock.refine-expanded #dockDownload{translate:0 0}
}
@keyframes mobile-sheet-enter{from{transform:translateY(100%)}to{transform:translateY(0)}}
@media(prefers-reduced-motion:reduce){#libraryDialog[open]{animation:none}}

/* Let specimen grid children shrink to the available phone width. */
.extended-specimens{grid-template-columns:minmax(0,1fr)}
.extended-specimens>*{min-width:0}
.library-item{align-items:center}
@media(max-width:700px){
 body:has(#libraryDialog[open]),body:has(.font-refine-panel:modal){overflow:hidden}
}

/* The card a photo-only hero tile opens (hero-examples.js): the photo larger,
   where it was found, and that its font is still to come. */
.hero-find-card{position:fixed;inset:auto;left:0;top:0;z-index:70;margin:0;padding:10px;border:0;width:min(244px,calc(100vw - 24px));box-sizing:border-box;overflow:visible;
 background:#fff;color:#191919;border-radius:20px;box-shadow:0 1px 2px rgb(0 0 0 / .06),0 18px 44px -12px rgb(0 0 0 / .28),0 0 0 1px rgb(0 0 0 / .04);font:400 13px/1.35 Inter,sans-serif}
.hero-find-card[hidden]{display:none}
.hero-find-card.is-open{animation:hero-find-card-in .26s cubic-bezier(.2,.9,.3,1.15) both}
@keyframes hero-find-card-in{from{opacity:0;transform:scale(.92)}to{opacity:1;transform:scale(1)}}
.hfc-photo{aspect-ratio:1;border-radius:12px;overflow:hidden;background:#f2f2f2}
.hfc-photo img{display:block;width:100%;height:100%;object-fit:cover}
.hfc-text{padding:12px 6px 4px}
.hfc-text p{margin:0}
.hfc-name{font-size:15px;font-weight:600;letter-spacing:-.01em;padding-right:4px}
.hfc-place{margin-top:2px!important;color:#6b6b6b}
.hfc-note{display:inline-flex;align-items:center;gap:7px;margin-top:10px!important;padding:5px 10px 5px 6px;border-radius:999px;background:#f2f2f2;color:#444;font-size:12px;font-weight:500}
.hfc-note span{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#fff;font-size:9px;font-weight:700;letter-spacing:-.02em;color:#191919}
.hfc-close{position:absolute;top:16px;right:16px;display:grid;place-items:center;width:30px;height:30px;padding:0;border:0;border-radius:50%;background:rgb(255 255 255 / .92);color:#191919;cursor:pointer;box-shadow:0 1px 4px rgb(0 0 0 / .14)}
.hfc-close:hover{background:#fff}
.hfc-close:focus-visible{outline:2px solid #191919;outline-offset:2px}
body:not(.landing-mode) .hero-find-card{display:none}
@media(prefers-reduced-motion:reduce){.hero-find-card.is-open{animation:none}}
