/* Maxtapes: the app's cassette-case spines, on the app's deck.
 *
 * A port of `Spine` (ios/Mixtape/Mixtape/Cassette/TapeRack.swift, body from l.328)
 * as it is drawn on the second welcome card, "WORKS LIKE A REAL TAPE": the edge
 * of a cassette case as it faces out of a rack, 109 x 17 mm, so 6.4 : 1. Smoked
 * plastic, the card folded into it with the day written on, a dark block at each
 * end, the clear lid over all of it, a hard rim.
 *
 * This is the one place on the site that is allowed gradients and soft light:
 * it is a picture of a real thing, not of the icon. Everything else stays hard.
 *
 * Every number is a fraction of the spine's HEIGHT, h, the way the Swift writes
 * them (`h * 0.30`), so a spine at 250 px wide and one at 500 px are the same
 * drawing. Where the app's own number is a percentage of the card it is kept as
 * one. The Swift line each number came from is in the comment beside it (l.NNN
 * is TapeRack.swift unless a file is named; as of mixtape/app a1a3dbf).
 *
 * Not ported: the shine that slides as the phone tilts (it is held still, at
 * the app's own resting place), the shrink-to-fit the app tries before it cuts
 * a long date off (`minimumScaleFactor`), the MAXING badge, the label-maker
 * strips (switched off in the app as well), and tapping a spine to open it.
 *
 *   <div class="rstack">                       the size container (see below)
 *     <ul class="rstack__panel" role="list" aria-label="...">
 *       <li class="rspine rhand-nothing" style="--card:#f29eb3;--pen:#4d1a73;...">
 *         <span class="rspine__row">
 *           <time class="rspine__date" datetime="1976-04-11">Apr 11, 1976</time>
 *           <span class="rspine__len">C-90</span>
 *         </span>
 *       </li>
 *       ...
 *
 * A spine wants `--h` (its height) from somewhere above it: `.rstack` sets it
 * from its own width. For a lone spine set `--h:48px` on any parent and give the
 * spine `width:calc(var(--h) * 6.4)`.
 *
 * A "hand" is the app's `Spine.Hand`: what THIS tape's spine is written with.
 *   --card    the card         Spine.Hand.cards[...]
 *   --pen     the pen          Spine.Hand.pens[...]
 *   --size    writing size, against h   (Hand.size, .45 to .50)
 *   --rot     degrees          (Hand.slant * 0.5, l.392)
 *   --nudge   up or down, against h     (Hand.nudge, l.393)
 *   --caps    uppercase | none (Hand.capitals)
 * and the face is a class, `.rhand-*`, which also carries that face's `scale`
 * (Hand.spineHands, DeckFace.swift l.347): handwriting faces run very different
 * sizes at one point size, so the app evens them out with a factor per face.
 */

/* Four of the app's twelve spine hands: the ones this page uses, subset to
   printable ASCII. All Google Fonts, SIL OFL 1.1, licence beside each file. */
@font-face{font-family:'Nothing You Could Do';font-weight:400;font-style:normal;font-display:block;src:url(../fonts/NothingYouCouldDo.woff2) format('woff2')}
@font-face{font-family:'Kalam';font-weight:700;font-style:normal;font-display:block;src:url(../fonts/KalamBold.woff2) format('woff2')}
@font-face{font-family:'Reenie Beanie';font-weight:400;font-style:normal;font-display:block;src:url(../fonts/ReenieBeanie.woff2) format('woff2')}
@font-face{font-family:'Covered By Your Grace';font-weight:400;font-style:normal;font-display:block;src:url(../fonts/CoveredByYourGrace.woff2) format('woff2')}

/* ------------------------------------------------------------ the faces */
/* `scale` from Mixtape_Hand.spineHands; the app sets a spine's writing at
   h * Hand.size * scale. The system cursives are for the moment before the file
   arrives (font-display:block holds the text back for that first moment) or if
   it never does. */
.rhand-nothing{--face:'Nothing You Could Do','Bradley Hand','Segoe Script',cursive;--scale:.86}
.rhand-kalam{--face:'Kalam','Bradley Hand','Segoe Script',cursive;--scale:.95;--fw:700}
.rhand-reenie{--face:'Reenie Beanie','Bradley Hand','Segoe Script',cursive;--scale:1.40}
.rhand-covered{--face:'Covered By Your Grace','Bradley Hand','Segoe Script',cursive;--scale:1.28}

/* ------------------------------------------------------- the size of it all */
/* The panel is 12 pt of padding, 7 pt between spines and a 6 pt corner round
   spines that are 302 pt wide on a 390 pt phone (WelcomeFace.swift l.100-104,
   with the whole picture capped at width - 64 = 326, l.63; measured off a render
   of the app's own card: tray 327 pt, spine 302.6), so h = 47.2 pt, and those
   three are .254 h, .148 h and .127 h. A phone's spine is the reference; the
   panel keeps those proportions at any width.

   Width is 6.4 h + 2 pads, so h = the stack's width / (6.4 + 2 pad). A container
   query unit reads the stack's width for everything inside it, which lets the
   whole thing scale with no script. Without them (a browser from before 2022)
   the spine is sized from the viewport instead: 7.6vw, held between 22 and 56
   px. That is about what the card's window leaves (24.8 px at 320 wide, 31.3 at
   390, 56.7 on the widest card), a little under on a phone, which only leaves
   the tray a little narrower than its window. */
.rstack{--pad:.254;--gap:.148;--h:clamp(22px,7.6vw,56px);
  width:calc(var(--h) * (6.4 + 2 * var(--pad)));max-width:100%;margin-inline:auto}
@supports (width:1cqw){
  .rstack{container-type:inline-size;width:100%;max-width:34rem;
    --h:calc(100cqw / (6.4 + 2 * var(--pad)))}
}

/* The dark tray behind the spines: black at .55 over whatever is under it
   (WelcomeFace.swift l.104), here the deck. */
.rstack__panel{list-style:none;margin:0;padding:calc(var(--h) * var(--pad));
  display:grid;gap:calc(var(--h) * var(--gap));
  border-radius:calc(var(--h) * .127);background:rgba(0,0,0,.55)}

/* ------------------------------------------------------------------ a spine */
/* Layers, bottom to top, as the ZStack in `Spine.body` has them:
     the case (this element)  ->  the card + its grain (::before)
     ->  the writing (.rspine__row)
     ->  the two end blocks, the lid, the glint (::after's backgrounds)
     ->  the hard rim (::after's inset shadow).
   The writing sits UNDER the lid and the glint, as it does in the app: the
   shine washes over the ink, which is most of why it reads as plastic. */
.rspine{position:relative;isolation:isolate;overflow:hidden;list-style:none;
  aspect-ratio:6.4;                              /* 109 x 17 mm, TapeRack.swift l.236 */
  border-radius:calc(var(--h) * .035);           /* l.333: hard, moulded, not a pill */
  background:#212125;                            /* l.336: smoked plastic, (.13, .13, .145) */
  color:var(--pen)}

/* The card, folded into the case: inset h * .30 at each end (`end`, l.332) and
   h * .07 top and bottom (l.397). Insets are percentages of the spine's own
   box, so they are 4.6875% (.30 / 6.4) and 7%. A plain rectangle, no corners.

   The grain is `Realism.Grain(opacity: .04, cells: 70)` (l.396): 70 cells across
   the card, each white or black at a random alpha of at most .02, laid on with
   the overlay blend, which is why it barely shows on a pale card. The picture is
   those cells themselves: the app's own generator (Realism.swift l.156, seeded
   with "mixt") run through the app's own loop for a card this shape, 70 x 11,
   672 bytes. Its 11th row is cut off in the app (the card is 10.4 cells tall),
   so it is drawn 105.98% of the card's height and cut off here too. Held against
   the app's own drawing of a spine it comes out closer than no grain at all,
   which a different set of random cells would not. */
.rspine::before{content:"";position:absolute;inset:7% 4.6875%;
  background:
    url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAAALCAYAAADC6Ps2AAACZ0lEQVR42m2WWY7DMAxDtd7/yK2DEd0XYT6MNokXiqIom5nVjDjDn9/P51NnPL8xz3rnz5i5Nd/sjD4jOf/Za9b0/Ded9byfeT17J7619p9vLlxYQ7wXE3AI051zRiOGmHNa64jrjDQBBtjQYoATGM0TEAWbDBaARXqDJJv9BV4BcF5cgD9SbZEjEhS4raQESNe8nGdXkoFbcf2dr8XMhLI2h4g4gnAoQusLmfAJqoYAAbc5IxGIsulQXDG7k1kR43NeIjglxrGGc4SlcYZIMGDpq0SxBnISZeJ4F2A7UToJ1Tnkb/MtmCmpAkASmTWoLKleKMFnnshgSSSSpLkiLIGjkECWkLA2wRckp80C7wxeQ9+gCgJy17MkrzrOCcQVEFSSCDgW+MT5Kif6hwNTgAwDoQ57eJWXYiX5AeAOMy4EdQODmrh5w5Rf3oQscTRGgSSa5iVi+QwNV6Wag6FnnvbTeQ7PoiJZjrdyZq7RgOTojgzoUMNCgwIoWWXbZK4igr4BDwp0DpWYsqfzDN9qnckyp/81vhlw5X9qgdp/yYMzMyOFFpiow4LZqWZ3Z2EnaWSMpcSuJR8zGjxM01EOscyW2C5ZVCXeObDJiBvvElViBj8xBKMJza60OgY7y5XfIi54P8IQ6G3ovC7UUpDDiGvhUkkV2zZ8iy05V8eLtYerXbO2cxlQQzmGDCZMTkYs9g2AeKfYneBmSFlmp1kSN5SXI3kFYmt3Pyg315WDdxbHvemqxSDD10VNLRElwNZJk3KWklr8Nrd173kpj2UKWccq6V4qiHWps1VGBnU0EsZ7TYD8gorrCye8lXVahegCAAAAAElFTkSuQmCC") 0 0/100% 105.98% no-repeat,
    var(--card);
  background-blend-mode:overlay,normal;image-rendering:pixelated}

/* What is written: the date, then C-90 at the far end. l.343-394.
   The row is the HStack: its box is the card less the padding the app gives it
   (leading h * .40, trailing h * .25, l.394), so it starts .30 + .40 = .70 h in
   and stops .30 + .25 = .55 h from the far end (10.9375% and 8.59375%), and its
   items are centred on the card's middle. Turned about its own middle by
   `slant * .5` degrees (l.392, so a tape's writing leans at most 1.1 degrees, not
   the 2.2 that `slant` is drawn from) and then moved by h * nudge (l.393). The
   gap is h * .2 either side of the Spacer, so .4 h between the two. */
.rspine__row{position:absolute;inset:7% 8.59375% 7% 10.9375%;
  display:flex;align-items:center;gap:calc(var(--h) * .4);
  transform:translateY(calc(var(--h) * var(--nudge,0))) rotate(var(--rot,0deg))}

/* The date, in this tape's hand. Never wraps; too long, it is cut off with an
   ellipsis (l.360; the app first shrinks it to .75, which no date here needs).
   An ellipsis needs overflow:hidden, and a handwriting face swashes well outside
   its own box (the A of "APR", the tail of a 9), so the box is grown by its
   padding and given the same back as a negative margin: it clips further out,
   and lays out where it always did. */
.rspine__date{display:block;flex:0 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  padding:.45em .35em;margin:-.45em -.35em;
  font:var(--fw,400) calc(var(--h) * var(--size,.47) * var(--scale,1))/normal var(--face);
  font-synthesis:none;text-transform:var(--caps,none);color:var(--pen)}

/* C-90: SF Mono semibold at h * .22, the app's ink (#1F1B14) at .45 (l.387-388).
   The system monospace is SF Mono on an Apple device, which is what the app uses. */
.rspine__len{flex:none;margin-left:auto;white-space:nowrap;
  font:600 calc(var(--h) * .22)/normal ui-monospace,'SF Mono',SFMono-Regular,Menlo,Consolas,'Liberation Mono',monospace;
  color:rgba(31,27,20,.45)}

/* Over the top of all of it, in the app's order (l.402-420). background layers
   run top first, so this list is upside down from the Swift's.
   - the shine (`Glint(width: .28, slope: .35, strength: .26)`, TiltLight.swift
     l.97-127), on the CARD only: the same white that barely shows on a pale card
     is glaring on near-black plastic (the comment at l.411). In the app it slides
     as the phone tilts; at rest (no tilt) it is centred, from
     (.2725, 0) to (.7275, 1) of the card in unit coordinates. In this card's
     5.8 h x .86 h that is a gradient line 108.05 degrees round, 2.776 h long,
     which is 48% of the length CSS would use, so the band runs from 26% to 74%
     and peaks at .26 in the middle. Held still here.
   - the lid: white .40 at the top edge, .06 at 22%, clear at 60%, black .16 at
     the bottom (l.408-410), over the whole case.
   - the dark end blocks, h * .30 wide, plain greys .20 to .07 (l.402-405): these
     are opaque greys, not white at low alpha, so the lid lies on top of them. */
.rspine::after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  background:
    linear-gradient(108.05deg,rgba(255,255,255,0) 26%,rgba(255,255,255,.26) 50%,rgba(255,255,255,0) 74%) 50% 50%/90.625% 86% no-repeat,
    linear-gradient(rgba(255,255,255,.40),rgba(255,255,255,.06) 22%,rgba(255,255,255,0) 60%,rgba(0,0,0,.16)),
    linear-gradient(#333,#121212) 0 0/4.6875% 100% no-repeat,
    linear-gradient(#333,#121212) 100% 0/4.6875% 100% no-repeat;
  /* the rim (l.420): white .32, h * .022 wide, never under half a pixel, drawn
     inside the edge */
  box-shadow:inset 0 0 0 max(.5px,calc(var(--h) * .022)) rgba(255,255,255,.32)}

/* ---------------------------------------------------- the four on the shelf */
/* WelcomeFace.swift `shelf` (l.127): four tapes with fixed ids
   (00000000-0000-0000-0000-0000000000A0 to ...A3), so the app draws them the same
   way on every device and every launch. Nothing here is remembered or judged by
   eye: the app's own drawing code was compiled and `Spine.Hand(for: id)` printed
   for each id. The markup in index.html carries these as custom properties.

     spine         card [Hand.cards]   pen [Hand.pens]     face (scale)                size   rot      nudge   caps
     Apr 11, 1976  #f29eb3 pink   [3]   #4d1a73 purple [4]  Nothing You Could Do (.86)  .4762  -.4933   .0166   yes
     Jan 9, 1984   #f0e8d6 cream  [0]   #0f5c38 green  [5]  Kalam Bold (.95)            .4534  -.9717   .0300   no
     Sep 24, 1991  #a8cce6 blue   [6]   #1a1714 black  [0]  Reenie Beanie (1.40)        .4676   .9691   .0030   yes
     May 30, 2016  #ed8f4d orange [5]   #0f5c38 green  [5]  Covered By Your Grace (1.28) .4925  -.4437  -.0236   yes

   A tape's card, pen and hand are drawn from its id (TapeRack.swift l.299-318),
   not chosen: these four ids do not draw a yellow card in red felt tip, or a
   pink one in blue biro; they draw the above. The dates are Paul's: 11 April
   1976, 9 January 1984, 24 September 1991, 30 May 2016 (WelcomeFace.swift
   l.121-127). The app writes each with `spineDate()` (MixtapeShelf.swift l.142:
   `.abbreviated`, upper-cased), then keeps the capitals or capitalises the
   words (TapeRack.swift l.350-351, `Hand.capitals`). Here the text is written
   as it reads and --caps does the capitals, so the source keeps its spelling. */

/* ---------------------------------------------------------------- the deck */
/* `Realism.Deck` (Realism.swift l.102-149): the gunmetal panel every screen of
   the app sits on. A radial gradient from (.40, .41, .43) at the middle to
   (.20, .205, .22), ending at .75 of the longer side, under a hex-packed mesh of
   holes and faint brushed streaks. For a window on this page: the same
   gradient, ending at 124% of the centre-to-corner distance (which is .75 of the
   long side for a window this shape).

   The holes: pitch .0130 of the screen's short side, never under 3 pt, radius
   .24 of the pitch, black at .62 under the mesh layer's .6 (so .37), with a white
   .12 (so .07) ring; rows .87 of a pitch apart, alternate rows half a pitch across
   (the tile is one pitch by 1.74 pitches, holding two holes). Here the pitch is
   this page's square, --sq (3 to 6 px, by the width of the page), which puts a
   tray 54 to 65 pitches across; the app's is 64 (327 pt / 5.07 pt on a phone). */
.window.deck{--pitch:var(--sq,4px);
  background:
    repeating-linear-gradient(0deg,rgba(255,255,255,.03) 0 1px,rgba(255,255,255,0) 1px 3px),
    radial-gradient(circle,rgba(0,0,0,.37) calc(var(--pitch) * .2),rgba(255,255,255,.07) calc(var(--pitch) * .28),rgba(255,255,255,0) calc(var(--pitch) * .38)) 0 0/var(--pitch) calc(var(--pitch) * 1.74),
    radial-gradient(circle,rgba(0,0,0,.37) calc(var(--pitch) * .2),rgba(255,255,255,.07) calc(var(--pitch) * .28),rgba(255,255,255,0) calc(var(--pitch) * .38)) calc(var(--pitch) * .5) calc(var(--pitch) * .87)/var(--pitch) calc(var(--pitch) * 1.74),
    radial-gradient(circle farthest-corner at 50% 50%,rgb(102,105,110) 3%,rgb(51,52,56) 124%)}
/* The deck shows round the tray, as it does behind the phone's picture. */
.window.deck .scene{padding:calc(var(--sq,4px) * 5) calc(var(--sq,4px) * 4)}
