/* Direction 1 "Plank". Component rules for the home shelf.
   Tokens live in tokens-shelf.css, loaded after tokens.css.
   Animate only transform and opacity. will-change is limited to press and open. */

.tf-shelf a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.tf-shelf h2, .tf-shelf p, .tf-shelf ul { margin: 0; }
.tf-shelf { --tf-text-scale: 1; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tf-shelf .shelf-row { --headroom: var(--tf-shelf-headroom); margin-top: 18px; }
.tf-shelf .sec-h { display: flex; align-items: center; min-height: 20px; margin-bottom: 4px; }
.tf-shelf .mood-row .sec-h,
.tf-shelf .mood-row .mood-line,
.tf-shelf .feat-row { padding-left: var(--tf-screen-pad, 20px); padding-right: var(--tf-screen-pad, 20px); }
.tf-shelf .feat-row { padding-bottom: 8px; }
.tf-shelf .kicker {
  font: var(--tf-kicker, 700 11px/16px "Source Sans 3", system-ui, sans-serif);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tf-ink-2, #5E564C);
}
.tf-shelf .see {
  margin-left: auto;
  font-family: var(--tf-font-ui, "Source Sans 3", system-ui, sans-serif);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  position: relative;
  padding: 0 2px;
  color: var(--tf-ink, #2C2620);
}
.tf-shelf .see::after { content: ""; position: absolute; inset: -12px -8px; }
.tf-shelf .see:focus-visible { outline: 2px solid var(--tf-focus, #2C2620); outline-offset: 3px; }
.tf-shelf .mood-line {
  font: var(--tf-meta, 400 13px/18px "Source Sans 3", system-ui, sans-serif);
  color: var(--tf-ink-2, #5E564C);
  margin-bottom: -6px;
}

/* book */
.tf-shelf .book { display: block; position: relative; outline: none; color: var(--tf-ink, #2C2620); user-select: none; }
.tf-shelf .book-stage { position: relative; display: block; width: var(--tf-book-w); height: var(--tf-book-h); perspective: 700px; isolation: isolate; }
.tf-shelf .book-lean {
  position: absolute; left: 0; bottom: 0; width: var(--tf-book-w); height: var(--h, var(--tf-book-h));
  transform: rotate(var(--lean, 0deg)); transform-origin: 0 100%;
}
.tf-shelf .book-body {
  position: absolute; inset: 0; display: block; transform-origin: 50% 100%;
  transition: transform var(--tf-dur-release) var(--tf-ease-lift), opacity 120ms linear;
}
.tf-shelf .book-lift {
  position: absolute; inset: 0; border-radius: var(--tf-book-radius); box-shadow: var(--tf-book-lift);
  opacity: 0; pointer-events: none; transition: opacity var(--tf-dur-release) linear;
}
.tf-shelf .book-leaf {
  position: absolute; inset: 1px 0 1px 2px; border-radius: var(--tf-book-radius);
  background: linear-gradient(90deg, rgba(0,0,0,.18), rgba(0,0,0,0) 14px), var(--tf-book-pages);
}
.tf-shelf .book-pages {
  position: absolute; top: 3px; bottom: 2px; right: -3px; width: 4px; border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--tf-book-pages-line) 0 1px, var(--tf-book-pages) 1px 2px, var(--tf-book-pages-line) 2px 2.5px, var(--tf-book-pages) 2.5px 3.5px, rgba(0,0,0,.25) 3.5px);
}
.tf-shelf .book-board {
  position: absolute; inset: 0; overflow: hidden; border-radius: var(--tf-book-radius); background: #2A241C;
  box-shadow: var(--tf-book-cast), inset 0 0 0 .5px rgba(0,0,0,.35);
  transform-origin: 0 50%; backface-visibility: hidden;
}
.tf-shelf .book-board img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; display: block; }
.tf-shelf .book-board::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 10px; background: var(--tf-book-spine); pointer-events: none; }
.tf-shelf .book-board::after { content: ""; position: absolute; inset: 0; background: var(--tf-book-gloss); pointer-events: none; }
.tf-shelf .book-contact {
  position: absolute; left: -7px; right: -9px; bottom: -8px; height: 13px; pointer-events: none;
  background:
    radial-gradient(ellipse 48% 24% at 50% 42%, var(--tf-book-contact-core) 0, var(--tf-book-contact-core) 55%, transparent 100%),
    radial-gradient(ellipse 50% 50% at 50% 45%, var(--tf-book-contact) 0, var(--tf-book-contact) 40%, transparent 100%);
  transform-origin: 50% 50%;
  transition: opacity var(--tf-dur-release) linear, transform var(--tf-dur-release) var(--tf-ease-lift);
}
.tf-shelf .new {
  position: absolute; top: 6px; left: 12px; z-index: 2; background: var(--tf-gold, #FFCF5C); color: var(--tf-gold-ink, #2C2620);
  font-family: var(--tf-font-ui, "Source Sans 3", system-ui, sans-serif);
  font-size: 9px; line-height: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 3px 5px; border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.tf-shelf .cap { display: block; width: calc(var(--tf-book-w) + var(--tf-book-gap) - 6px); margin-top: 12px; }
.tf-shelf .cap-t {
  font-family: var(--tf-font-ui, "Source Sans 3", "Source Sans Pro", system-ui, sans-serif);
  font-size: calc(13px * var(--tf-text-scale, 1));
  line-height: calc(16px * var(--tf-text-scale, 1));
  font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tf-shelf.tf-titles-3 .cap-t {
  -webkit-line-clamp: 3;
  /* 16px * scale * 3 rounds down and clips the third line by about 2px. */
  max-height: calc(16px * var(--tf-text-scale, 1) * 3 + 2px);
  padding-bottom: 2px;
}
.tf-shelf .book:focus-visible { outline: none; }
.tf-shelf .book:focus-visible .book-board { outline: 2px solid var(--tf-focus, #2C2620); outline-offset: 3px; }
.tf-shelf .book:focus-visible .cap-t,
.tf-shelf .book:focus-visible .feat-t { text-decoration: underline; text-underline-offset: 2px; }

/* motion: transform and opacity only. will-change only while pressed or opening. */
@media (hover: hover) {
  .tf-shelf .book:hover .book-body { transform: translateY(-4px) rotateX(2deg) rotateZ(-1deg); transition-duration: var(--tf-dur-lift); }
  .tf-shelf .book:hover .book-lift { opacity: 1; transition-duration: var(--tf-dur-lift); }
  .tf-shelf .book:hover .book-contact { opacity: .5; transform: scaleX(.88); transition-duration: var(--tf-dur-lift); }
}
.tf-shelf .book.is-pressed .book-body,
.tf-shelf .book.is-opening .book-body { will-change: transform; }
.tf-shelf .book.is-pressed .book-body { transform: translateY(-4px) rotateX(2deg) rotateZ(-1deg); transition-duration: var(--tf-dur-lift); }
.tf-shelf .book.is-pressed .book-lift { opacity: 1; transition-duration: var(--tf-dur-lift); }
.tf-shelf .book.is-pressed .book-contact { opacity: .5; transform: scaleX(.88); transition-duration: var(--tf-dur-lift); }

.tf-shelf .slot.is-opening, .tf-shelf .feat.is-opening { z-index: 5; }
.tf-shelf .book.is-opening .book-body { animation: tf-pull var(--tf-dur-pull) var(--tf-ease-pull) forwards; }
.tf-shelf .book.is-opening .book-board { animation: tf-open var(--tf-dur-pull) var(--tf-ease-pull) forwards; }
.tf-shelf .book.is-opening .book-lift { opacity: 1; transition-duration: 80ms; }
.tf-shelf .book.is-opening .book-contact { opacity: 0; transform: scaleX(.7); transition-duration: 160ms; }
@keyframes tf-pull {
  from { transform: translateY(-4px) rotateX(2deg) rotateZ(-1deg); }
  to   { transform: translateY(-14px) scale(1.06); }
}
@keyframes tf-open {
  0%, 30% { transform: perspective(500px) rotateY(0); }
  100%    { transform: perspective(500px) rotateY(-38deg); }
}

.tf-shelf.settle-ready .shelf-row:not(.settle) .book-body,
.tf-shelf.settle-ready .shelf-row:not(.settle) .book-contact { opacity: 0; }
.tf-shelf .shelf-row.settle .book-body { animation: tf-settle var(--tf-dur-settle) var(--tf-ease-settle) backwards; animation-delay: calc(var(--i) * var(--tf-stagger)); }
.tf-shelf .shelf-row.settle .book-contact { animation: tf-contact var(--tf-dur-settle) var(--tf-ease-settle) backwards; animation-delay: calc(var(--i) * var(--tf-stagger)); }
@keyframes tf-settle {
  0%   { opacity: 0; transform: translateY(-12px); }
  55%  { opacity: 1; transform: translateY(0) scale(1.02, .965); }
  78%  { transform: translateY(-1px) scale(.995, 1.006); }
  100% { opacity: 1; transform: none; }
}
@keyframes tf-contact {
  0%   { opacity: 0; transform: scaleX(.6); }
  55%  { opacity: 1; transform: scaleX(1.06); }
  100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-shelf .book .book-body,
  .tf-shelf .book:hover .book-body,
  .tf-shelf .book.is-pressed .book-body,
  .tf-shelf .book.is-opening .book-body { transform: none !important; animation: none !important; transition: opacity 0s !important; will-change: auto !important; }
  .tf-shelf .book.is-pressed .book-body { opacity: .82; }
  .tf-shelf .book .book-board,
  .tf-shelf .book.is-opening .book-board,
  .tf-shelf .shelf-row.settle .book-body,
  .tf-shelf .shelf-row.settle .book-contact { animation: none !important; }
  .tf-shelf .book:hover .book-lift,
  .tf-shelf .book.is-pressed .book-lift,
  .tf-shelf .book.is-opening .book-lift { opacity: 0 !important; }
  .tf-shelf .book:hover .book-contact,
  .tf-shelf .book.is-pressed .book-contact,
  .tf-shelf .book.is-opening .book-contact { opacity: 1 !important; transform: none !important; }
  .tf-shelf.settle-ready .shelf-row:not(.settle) .book-body,
  .tf-shelf.settle-ready .shelf-row:not(.settle) .book-contact { opacity: 1 !important; }
  .tf-shelf .book-lean { transform: none !important; }
}

/* row scroller: the plank lives in the track, so it scrolls and snaps with the books */
.tf-shelf .row-scroll {
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding-inline: var(--tf-screen-pad, 20px);
}
.tf-shelf .row-scroll::-webkit-scrollbar { display: none; }
.tf-shelf .track {
  position: relative; z-index: 0; display: flex; gap: var(--tf-book-gap); width: max-content; min-width: 100%;
  list-style: none; padding-top: var(--headroom); padding-bottom: 4px;
  padding-left: var(--tf-screen-pad, 20px); padding-right: var(--tf-screen-pad, 20px);
}
.tf-shelf .slot { flex: 0 0 auto; width: var(--tf-book-w); position: relative; scroll-snap-align: start; }
.tf-shelf .plank-space { display: block; height: calc(var(--tf-plank-top) - var(--tf-plank-sink) + var(--tf-plank-lip)); }

.tf-shelf .plank {
  position: absolute; left: 2px; right: 2px; z-index: -1; pointer-events: none;
  top: calc(var(--headroom) + var(--tf-book-h) - var(--tf-plank-sink));
  height: calc(var(--tf-plank-top) + var(--tf-plank-lip));
}
.tf-shelf .plank .wood-top {
  position: absolute; left: 0; right: 0; top: 0; height: var(--tf-plank-top);
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 100%, 0 100%);
  background:
    linear-gradient(180deg, rgba(0,0,0,.45) 0 1px, transparent 1px),
    linear-gradient(180deg, transparent 35%, var(--tf-shelf-top-sheen) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 37px, rgba(0,0,0,.05) 37px 89px, transparent 89px 151px),
    repeating-linear-gradient(180deg, transparent 0 3px, var(--tf-shelf-grain) 3px 4px, transparent 4px 6px, var(--tf-shelf-grain-strong) 6px 7px, transparent 7px 9px),
    linear-gradient(180deg, var(--tf-shelf-wood-top-back) 0, var(--tf-shelf-wood-top) 85%);
}
.tf-shelf .plank .wood-lip {
  position: absolute; left: 0; right: 0; top: var(--tf-plank-top); height: var(--tf-plank-lip); border-radius: 0 0 2px 2px;
  background:
    linear-gradient(180deg, var(--tf-shelf-lip-highlight) 0 1px, var(--tf-shelf-lip-sheen) 1px, transparent 55%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 53px, rgba(0,0,0,.06) 53px 131px, transparent 131px 197px),
    repeating-linear-gradient(178deg, transparent 0 2px, var(--tf-shelf-grain) 2px 3px, transparent 3px 6px, var(--tf-shelf-grain-strong) 6px 7px, transparent 7px 10px),
    linear-gradient(180deg, var(--tf-shelf-lip), var(--tf-shelf-lip-deep));
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.35);
}
.tf-shelf .plank .wood-lip::before {
  content: ""; position: absolute; inset: 0; border-radius: 0 0 2px 2px;
  background: linear-gradient(90deg, var(--tf-shelf-end) 0 4px, transparent 4px calc(100% - 4px), var(--tf-shelf-end) calc(100% - 4px));
}
.tf-shelf .plank::after {
  content: ""; position: absolute; left: 1px; right: 1px; top: 100%; height: var(--tf-plank-cast);
  background: linear-gradient(180deg, var(--tf-shelf-shadow) 0, var(--tf-shelf-shadow-mid) 35%, transparent 100%);
}
.tf-shelf .bracket {
  position: absolute; top: calc(100% - 2px); width: 10px; height: 22px; z-index: 1; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--tf-shelf-bracket) 0, var(--tf-shelf-bracket-hi) 35%, var(--tf-shelf-bracket) 100%);
  box-shadow: 1px 3px 4px rgba(0,0,0,.35), inset 0 -1px 0 rgba(0,0,0,.3);
}
.tf-shelf .bracket::before, .tf-shelf .bracket::after {
  content: ""; position: absolute; left: 3.5px; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(0,0,0,.45); box-shadow: 0 .5px 0 rgba(255,255,255,.35);
}
.tf-shelf .bracket::before { top: 5px; }
.tf-shelf .bracket::after { top: 14px; }
.tf-shelf .bracket.l { left: 3px; }
.tf-shelf .bracket.r { right: 3px; }

/* continue reading: the same book, smaller, with a ribbon and no plank */
.tf-shelf .feat { display: flex; gap: 16px; align-items: center; position: relative; margin-top: 8px; }
.tf-shelf .feat .book-stage { --tf-book-w: 78px; --tf-book-h: 104px; }
.tf-shelf .feat .book-lean { width: 78px; height: 104px; }
.tf-shelf .ribbon {
  position: absolute; left: 58px; bottom: -11px; width: 8px; height: 16px; z-index: -1;
  background: var(--tf-book-ribbon); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
}
.tf-shelf .feat-meta { flex: 1; min-width: 0; }
.tf-shelf .feat-t {
  display: block;
  font-family: var(--tf-font-display, Fraunces, Georgia, serif);
  font-size: 19px; line-height: 24px; font-weight: 600; letter-spacing: -0.02em;
}
[data-theme="dark"] .tf-shelf .feat-t { font-weight: 700; }
.tf-shelf .feat-d {
  display: block;
  font: var(--tf-meta, 400 13px/18px "Source Sans 3", system-ui, sans-serif);
  color: var(--tf-ink-2, #5E564C);
  margin-top: 4px;
}
.tf-shelf .bar { display: block; height: 4px; border-radius: 2px; background: var(--tf-line, #D6CDBE); margin-top: 12px; overflow: hidden; }
.tf-shelf .bar i { display: block; height: 100%; background: var(--tf-book-ribbon); border-radius: 2px; }
