/* templates.css - the Templates grid (view-templates.js), the fullscreen view a tile opens into (template-lightbox.js) and the
   person's own videos on it (own-videos.js). Split from style.css on 2026-10-04, when that file passed the repo's 500 lines; index.html
   loads it AFTER style.css, so its rules follow and use its variables, .fmt, .poster and button looks. Since 10-05 the home is the
   reels feed (.rfeed, .rslide, below) and the grid waits behind HOME_GRID=1. Only transform and opacity animate (Grady, 10-04: "Animate only
   opacity and transform"); a tile is a fixed 9:16 box whatever loads into it, so nothing moves while the page scrolls. No inline style anywhere: the CSP forbids it, so every look is a class. */
/* Templates, as a grid (view-templates.js; William, 2026-10-03: "a responsive grid of templates (e.g., 2 to 3 columns on mobile,
   expanding gracefully on desktop)", and after seeing it: "I want the grid to be three across, though, not just two"; 2026-10-04, a
   written spec: "renders strictly as a 3-wide column grid"): 9:16 tiles, THREE ACROSS ON EVERY SCREEN. No rule below may change the
   column count; only the gaps and the corners grow with the screen. On a desktop the grid is wider than the page's 560 px column and
   stops at 720 px, so a tile is 229 px wide and two rows fit a laptop's screen (at four and five across, until 10-04, it ran to 1040).
   A tile is the drawn poster with the name on it, under the video's own cover once that has loaded (.tile-cover, below); the two
   glows take turns so no row or column is one colour. A phone's tile is about
   109 px wide (91 on the narrowest phone), so the words and the play mark are sized from the tile's own width (cqw),
   not the screen's, each with a floor for the phone and a ceiling for the desktop: the name keeps to three lines and breaks at a
   hyphen, the creator and the clip count keep to one line each. */
.tpage { --w: min(720px, calc(100vw - 32px)); width: var(--w); margin-left: calc((100% - var(--w)) / 2); }   /* centred on the page's column, wider than it */
/* two across (Grady, 2026-10-08: "there should be 4, in a 2x2 grid") */
.tgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
@media (min-width: 520px) { .tgrid { gap: 12px; } }
@media (min-width: 800px) { .tgrid { gap: 16px; } }
.tile { position: relative; container-type: inline-size; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--poster-base); box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.2, .7, .3, 1); }
@media (min-width: 520px) { .tile { border-radius: 18px; } }
@media (min-width: 800px) { .tile { border-radius: 22px; } }
button.tile-open { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: inherit;
  background: transparent; color: var(--ink); box-shadow: none; text-align: left; font-weight: 500; letter-spacing: 0; }
button.tile-open:active { transform: none; }   /* the tile itself presses in, below */
button.tile-open:focus-visible { outline-offset: -5px; }
.tile .poster { position: absolute; inset: 0; display: block; width: auto; max-height: none; aspect-ratio: auto; margin: 0; padding: 0; border: 0; border-radius: 0;
  transition: transform .35s cubic-bezier(.2, .7, .3, 1); }
.tile:nth-child(4n+2) .poster, .tile:nth-child(4n+3) .poster { background: url(noise.svg) 0 0 / 256px 256px, var(--poster-b); background-color: var(--poster-base);
  background-blend-mode: soft-light, normal, normal; }
.tile-words { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 3px; padding: clamp(8px, 7cqw, 16px); }
.tile-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; padding-bottom: .08em;
  font-size: clamp(.78rem, 10.5cqw, 1.34rem); font-weight: 700; line-height: 1.04; letter-spacing: -.035em; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }
.tile-by { font-size: clamp(.66rem, 7.6cqw, .92rem); font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the name sits in a pill, in the snpz gradient (Grady, 2026-10-08: "make a pill shaped text box for the name of each video", "make it have the snpz gradient") */
.tile .tile-name { align-self: flex-start; max-width: 100%; padding: .2em .7em .26em; border-radius: 1.1em; background: #0a0a0a; color: #ffffff; text-shadow: none; }   /* near-black pill since 2026-11-07 (no gradient) */
/* a format's one line, under its pill: smaller, in the brand cyan (view-templates.js FORMATS) */
.tile-say { padding: 0 .2em; font-size: clamp(.66rem, 6.6cqw, .86rem); font-weight: 600; line-height: 1.2; color: #ffffffd9; }
.tile-meta { font-size: clamp(.66rem, 7.4cqw, .9rem); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-play, .tile-plus { --d: clamp(32px, 26cqw, 54px); position: absolute; top: 33%; left: 50%; display: flex; align-items: center; justify-content: center; width: var(--d); height: var(--d);
  margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); border-radius: 50%; background: rgba(17, 17, 17, .84); color: #fbf4ea;
  transition: transform .18s cubic-bezier(.2, .7, .3, 1); }
.tile-play svg { width: 44%; height: 44%; margin-left: 5%; fill: currentColor; }
@container (max-width: 99px) { .tile-play, .tile-plus { top: 27%; } }   /* a 320 px phone: a three-line name, the creator and the count reach higher up the tile */
@media (prefers-color-scheme: dark) { .tile-play { background: rgba(251, 244, 234, .18); } }   /* ink on a dark poster would vanish */
/* the flat tiles drawn before the list arrives (view-templates.js) */
.tile.skel { background: var(--line); box-shadow: none; }
/* a template's own cover (covers.js; William, 2026-10-05: "it's not showcasing the different templates ... it should still showcase
   what the template looks like"): TikTok's picture of the creator's video, loaded by the browser from TikTok, over the drawn poster.
   It fades in over the poster only once it has loaded (.has-cover), so a slow or missing one leaves the poster and never a blank
   tile, and the poster stays under it: no cut to black on the way (review, 10-05). Over a picture the words are white on a shade
   at the tile's foot, dark enough under a three-line name on a white wall, and the play mark is small in the top corner, off the
   haircut. On paper the picture is left out and the words are ink on the poster again (the print rule at the foot). */
.tile-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; pointer-events: none;
  transition: opacity .25s ease-out, transform .35s cubic-bezier(.2, .7, .3, 1); }
.tile.has-cover .tile-cover { opacity: 1; }
.tile.has-cover button.tile-open { color: #fff; }
.tile.has-cover button.tile-open:focus-visible { outline-color: var(--yellow); }   /* the ink ring would vanish on a dark picture */
.tile.has-cover .tile-words { background: rgba(0, 0, 0, .66);   /* a flat band, not a fade (no gradient) */
  text-shadow: 0 1px 3px rgba(0, 0, 0, .85); }
.tile.has-cover .tile-play { --d: clamp(20px, 17cqw, 34px); top: clamp(5px, 5cqw, 12px); right: clamp(5px, 5cqw, 12px); left: auto; margin: 0;
  background: rgba(17, 17, 17, .62); color: #fff; }
@media (hover: hover) {
  .tile:hover { transform: translateY(-4px); }
  .tile:hover .poster, .tile:hover .tile-cover { transform: scale(1.07); }
  .tile:hover .tile-play { transform: scale(1.14); background: #0a0a0a; color: #fff; }
  .tile:hover .tile-vid { transform: scale(1.07); }
  .tile:hover .tile-plus { transform: scale(1.14); }
}
.tile:active { transform: scale(.97); }

/* the person's own videos on the grid (own-videos.js; William, 2026-10-04, a written spec: "a prominent \"Upload Video\" UI section or drop
   zone ... append them into our active media grid alongside preset templates"). The way in is the grid's FIRST tile: a dashed tile with a
   yellow plus, as big as a template, so it costs a phone no row of its own. An own tile is the video's own first frame (a <video> that
   never plays: the CSP lets no blob: picture load) under a yellow "Yours" and its length in a dark chip (a chip, not a fade,
   like the feed's words). A file this browser cannot play keeps its tile on the drawn poster. While a file is dragged over the window
   (a desktop) the add tile turns yellow and says "Drop it here", and the grid gets a dashed ring. */
.tile-add { background: var(--surface); box-shadow: none; border: 2px dashed var(--line-strong); transition: transform .18s cubic-bezier(.2, .7, .3, 1); }
.tile-plus { background: var(--on-bg); color: var(--on-fg); }
.tile-plus svg { width: 50%; height: 50%; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.tile-hint { display: none; }   /* "or drop it here": only where there is a mouse to drag with */
@media (hover: hover) and (pointer: fine) { .tile-hint { display: block; } }
.tile-own { background: #000; }
.tile-own button.tile-open:focus-visible { outline-color: var(--yellow); }   /* the ink ring would vanish on a dark frame */
.tile-vid { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; transition: transform .35s cubic-bezier(.2, .7, .3, 1); }
.tile-own .poster, .tile-own.noplay .tile-vid { display: none; }
.tile-own.noplay .poster { display: block; }
.tile-own .tile-meta { align-self: flex-start; max-width: 100%; padding: .1em .6em; border-radius: 999px; background: rgba(17, 17, 17, .84); color: #fbf4ea; }
.tile-own .tile-meta:empty { display: none; }   /* until the phone has read how long the video is */
.tile-yours { position: absolute; top: clamp(5px, 4.5cqw, 10px); left: clamp(5px, 4.5cqw, 10px); padding: .12em .6em; border-radius: 999px; background: var(--yellow); color: var(--black);
  font-size: clamp(.62rem, 7.2cqw, .86rem); font-weight: 700; letter-spacing: -.01em; pointer-events: none; }
/* the person's own video, fullscreen (own-videos.js): a feed card whose stage is the file itself, shown whole (a sideways video is never
   cropped), its file name on one line, and under the facts what can be done with it (.own-acts): one sentence in a glass chip, the yellow
   "Make a reel from it" where a template has Recreate, then "Copy this one" and Remove side by side; or the question before a send,
   the bar during one, the sentence after a failed one. The view is always dark, so the quiet buttons are cream on glass. */
.fmt .stage .own-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.own .by { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.own-acts { display: flex; flex-direction: column; gap: 8px; }
.own-acts button { margin: 0; }
.own-acts .row { gap: 8px; }
.own-acts .row > button { padding-left: 10px; padding-right: 10px; }
.own-note { margin: 0; padding: 9px 13px; border-radius: 16px; background: rgba(17, 17, 17, .72); color: #fbf4ea; font-size: .9rem; font-weight: 600; line-height: 1.32; }
.own-note.bad { color: var(--yellow); font-weight: 700; }
.own-acts .bar { margin: 0; }
button.own-quiet { color: #fbf4ea; border-color: rgba(251, 244, 234, .55); background: rgba(17, 17, 17, .6); }
.own-acts button:focus-visible { outline-color: #fbf4ea; }

/* a template, fullscreen (template-lightbox.js): a native <dialog> the size of the screen. The column in it is the template's slide (.rslide)
   or an own video's card (.fmt) with the X above it, at the top left (Grady, 2026-10-05: "There can be an X button at the top left"): the
   whole screen on a phone, a phone-wide column in the middle of a desktop, where a click beside it closes. Always dark, like the film
   stage. While it is open the page behind does not scroll, and keeps the scrollbar's width as padding so it does not jump. */
html.tbox-open, html.tbox-open body { overflow: hidden; }
html.tbox-open body { padding-right: calc(var(--pad) + var(--sbw, 0px)); }
dialog.tbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent;
  color: var(--cream); overflow: hidden auto; overscroll-behavior: contain; }
dialog.tbox[open] { display: flex; justify-content: center; }
/* a view built ahead (template-lightbox.js, the home's tiles): drawn at full size, so TikTok's player in it loads and gets ready (at
   0 x 0 it never says ready, measured 10-12), but a screen's width off to the left, see-through and inert, until the tap shows it */
dialog.tbox.ahead:not([open]) { display: flex; justify-content: center; transform: translateX(-200vw); opacity: 0; pointer-events: none; z-index: -1; }
/* no blur behind it: on a phone the column covers the whole screen, so a blur there was a full-screen sheet redrawn under every frame
   of the video for nothing (feed-jank.md point 6, 2026-10-17); beside a desktop's column the .9 dark shows the same either way */
dialog.tbox::backdrop { background: rgba(13, 13, 15, .9); }
/* the column is as tall as the screen, up to 900 px, and never shorter than the feed's own card plus the X row: on a phone turned on its side
   the view scrolls down to Create instead of cutting it off. Centred by its margins, so a column taller than the screen starts at the top. */
.tbox-col { position: relative; flex: none; display: flex; flex-direction: column; width: 100%; max-width: 430px; height: 100%; min-height: 520px; max-height: 900px;
  margin: auto 0; padding-top: env(safe-area-inset-top); }
.tbox-top { display: flex; justify-content: flex-start; padding: 8px 10px; }
button.tbox-x { width: 44px; min-height: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(251, 244, 234, .16); color: #fbf4ea; box-shadow: none; }
button.tbox-x:focus-visible { outline-color: #fbf4ea; }
button.tbox-x svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.tbox-card { position: relative; flex: 1; min-height: 0; }
/* the grid's view is the reels feed (template-lightbox.js openReels): it fills the column, and the X floats at its top left */
.tbox-card .rfeed { position: absolute; inset: 0; }
.tbox-col:has(.rfeed) .tbox-top { position: absolute; top: env(safe-area-inset-top); left: 0; z-index: 5; }
.tbox .fmt { height: 100%; max-width: none; margin: 0; }
/* the home since 10-05: Instagram's Reels tab (home-reels.js; Grady, 2026-10-05: "just make it like literally like Instagram, the reels
   tab of Instagram ... it should be the entire screen, you just scroll just like Instagram"). The feed is the space between the two bars,
   fixed, and the browser scrolls it with its own snap, one slide a screen. Not scroll-snap-stop: always: with it, a second flick
   made while the first was still landing was swallowed (2 runs in 3, headless Edge, 10-05), the 10-04 "if you scroll too fast it
   doesn't scroll". Every slide is exactly the feed's size and holds nothing that can change it (contain: strict), so nothing is laid out
   again or re-snapped while it glides (feed-jank.md: Safari re-snaps when a size changes mid-glide). The page behind does not scroll,
   and the blobs, the grain and the glow are off under it (feed-jank.md point 6: fewer see-through sheets to redraw). Always dark. */
/* only a feed that is ON the page locks the scroll: the home's tiles each hold a feed built ahead in a closed dialog (template-lightbox.js
   `ahead`), and with the old `html:has(.rfeed)` those four hidden feeds held the home still (Aiden, 2026-10-16, Grady and William stuck in
   the shop: "they need to be able to scroll down and see all the formats") */
html:has(main > .rfeed), html:has(main > .rfeed) body, html:has(dialog.tbox[open] .rfeed), html:has(dialog.tbox[open] .rfeed) body { overflow: hidden; }
html:has(main > .rfeed)::before, html:has(main > .rfeed) body::before, html:has(main > .rfeed) body::after,
html:has(dialog.tbox[open] .rfeed)::before, html:has(dialog.tbox[open] .rfeed) body::before, html:has(dialog.tbox[open] .rfeed) body::after { display: none; }
.rfeed { position: fixed; left: 0; right: 0; top: calc(52px + env(safe-area-inset-top)); bottom: calc(var(--tabs, 0px) + env(safe-area-inset-bottom));
  overflow: hidden auto; overscroll-behavior: contain; scroll-snap-type: y mandatory; background: #000; scrollbar-width: none; }
.rfeed::-webkit-scrollbar { display: none; }
/* one template, full screen (reel-card.js reelSlide): the drawn poster, the creator's reel over it, the words and Create over its foot.
   Nothing of ours covers the rest of the video: a tap on it is TikTok's own (pause, and its bar with the speaker). The reel is shown
   whole, as wide as the slide or as tall as it, on the slide's floor. TikTok's own bar (progress, play, its speaker: 68 px at the
   player's foot, measured 10-05) and its likes column (the right 64 px) stay uncovered: the words end --tt-bar above the floor and
   --tt-side from the right. The poster is the dark one in either colour scheme: white words sit on it. */
.rslide { --tt-bar: 68px; --tt-side: 64px; --poster-base: #161618;
  position: relative; height: 100%; overflow: hidden; contain: strict; container-type: size; background: #000; color: #fff;
  scroll-snap-align: start; scroll-snap-stop: normal; }
.rslide > .poster { position: absolute; inset: 0; width: auto; max-height: none; aspect-ratio: auto; margin: 0; padding: 0; border: 0; border-radius: 0; }
.rslide:nth-child(even) > .poster { background: url(noise.svg) 0 0 / 256px 256px, var(--poster-b); background-color: var(--poster-base);
  background-blend-mode: soft-light, normal, normal; }
.rslide .stage { position: absolute; inset: 0; z-index: 1; }
.rslide .stage .player { position: absolute; left: 0; right: 0; top: 0; width: min(100cqw, 100cqh * 9 / 16); height: auto; aspect-ratio: 9 / 16;
  margin: 0 auto; border-radius: 0; }
/* "Tap for sound" (reel-card.js): see-through, over the video only while it plays muted after asking by itself did not hold; the words
   and Create (.rinfo, z-index 3) stay above it, and a swipe on it still scrolls the feed */
.rslide .stage .tap { position: absolute; inset: 0; z-index: 1; width: auto; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; cursor: pointer; }
/* A phone is taller than 9:16 (390 x 844), so the reel sits at the TOP and the black under it (--gap, 0 where the reel fills the slide)
   holds the words (Grady, 2026-10-09, on the gap over the video: "just slide the video up"). Where that black is shorter than the words
   (about 140 px, and 80 more for Create under them since 10-15) they go over the reel's foot, above TikTok's bar: clamp() picks 0
   when --gap reaches 220 px, else --over; at 0 the words leave Create its 84 px at the floor (the padding's own clamp).
   ponytail: 140 px is the words' height as drawn, not measured; a name that wraps spills ~20 px lower. */
.rinfo { --gap: max(0px, 100cqh - 100cqw * 16 / 9); --over: calc(var(--gap) + var(--tt-bar) + 8px);
  position: absolute; left: 0; right: 0; bottom: clamp(0px, (220px - var(--gap)) * 9999, var(--over)); z-index: 3;
  display: flex; flex-direction: column; gap: 2px; width: min(100cqw, 100cqh * 9 / 16); margin: 0 auto;
  padding: 0 var(--tt-side) max(8px, env(safe-area-inset-bottom)) 12px; padding-bottom: calc(clamp(8px, (var(--gap) - 219px) * 9999, 84px) + env(safe-area-inset-bottom));
  pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .85); }
.rinfo a, .rinfo button { pointer-events: auto; }   /* the rest lets a tap through to the video (TikTok's own pause) */
.rinfo h2 { margin: 0; color: #fff; font-size: 1.3rem; font-weight: 700; line-height: 1.05; letter-spacing: -.03em; }
.rby { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rinfo .by { display: flex; align-items: center; min-width: 0; min-height: 44px; margin: 0; color: #fff; font-weight: 700; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rinfo .views { flex: none; color: var(--yellow); font-weight: 700; }   /* in a different colour (Grady, 10-05) */
.rinfo .hint, .rinfo .cant { margin: 0 0 4px; color: var(--yellow); font-weight: 700; }
/* the sound line comes and goes as the player talks: it sits ABOVE the words, out of their box, so they never move (no layout shift) */
.rinfo .hint { position: absolute; bottom: 100%; left: 12px; right: var(--tt-side); color: #fff; font-size: .92rem; }   /* white: the yellow is the views' */
.rinfo .orig { display: inline-flex; align-items: center; align-self: flex-start; min-height: 44px; color: #fff; }
/* Create: full width, tall and yellow at the slide's floor, always in sight, with a soft glow that breathes so a barber knows to tap it
   (Grady, 2026-10-15: "the create button on the formats page needs to be bigger and it needs to have UI that makes it pop so barbers
   know to click it"; this replaces Aiden's small centred one of 10-12). On a phone whose black under the video is short it lies over
   the video's foot, TikTok's own bar included. Its bottom undoes the words' own offset (the same clamp as .rinfo), so it is measured
   from the slide's floor; never position: fixed (the slide scrolls). The glow is a ::before (motion.css owns ::after while it works),
   only opacity and transform move, and none under reduce motion. */
.rinfo button.create { position: absolute; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom) - clamp(0px, (220px - var(--gap)) * 9999, var(--over)));
  width: auto; min-height: 60px; margin: 0; padding: 10px 24px; font-size: 1.35rem; font-weight: 700;
  border: 0; text-shadow: none; color: #0a0a0a; background: var(--grad); box-shadow: none; }   /* the slide's ONE main button wears the sweep, never flat yellow (Grady, 2026-11-08 night: "the create button is just yellow ai slop"; the 11-07 law) */
.rinfo .notice { position: static; width: auto; margin: 0 0 6px; text-shadow: none; }
.rinfo .notice:not(.bad) { background: var(--cream); color: var(--black); }   /* on the dark slide an ink note would melt into the video */
.rinfo a:focus-visible, .rinfo button:focus-visible { outline-color: #fff; }
@media (prefers-reduced-motion: no-preference) {
  dialog.tbox[open] .tbox-col { animation: tbox-in .26s cubic-bezier(.2, .8, .25, 1); }
  dialog.tbox[open]::backdrop { animation: tbox-dim .2s ease-out; }
}
@keyframes tbox-in { from { opacity: 0; transform: translateY(18px) scale(.94); } }
@keyframes tbox-dim { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tile, .tile .poster, .tile-play, .tile-plus, .tile-vid, .tile-cover { transition: none; } }
/* on paper: the print rule above hides every button, and a tile's poster and words are inside one, so the tile's own is let through */
@media print { .tile { box-shadow: none; border: 1px solid #999; } button.tile-open { display: block !important; } .tile-play, .tile-add, .tile-cover { display: none; }
  .tile.has-cover button.tile-open { color: #000; } .tile.has-cover .tile-words { background: none; text-shadow: none; } }
/* a tile playing its template's own video needs no play mark over it (Grady, 2026-10-23) */
.tile.has-video .tile-play { display: none; }
.tile .tile-video { object-fit: cover; }
/* the template's original in TikTok's own player (tile-original.js, Grady 2026-10-28): no frame border; the tile's button takes the tap */
.tile iframe.tile-video { border: 0; }
