/* things-gravity.css: WS4 Things and gravity (III contest, rows 05/08/09, IV read-down). Scoped to .things / .gravity. */

/* ================================================================ III: header */

/* rotated and falling glyphs never widen the page */
.things { overflow-x: clip; }

.things .things-head { flex-wrap: wrap; gap: 6px 18px; }
.things .things-head .tg-score { font-weight: inherit; white-space: nowrap; }
/* v1 gives the right span a blinking dot; keep it off the nested hint span */
.things .things-head > span:last-child span::before { content: none; display: none; }
.things .things-head .hint { margin-left: 1.2em; }

/* ================================================================ III: rows (block layout, labels on top) */

.things .thing {
  display: block;
  position: relative;
  isolation: isolate;
  padding: 2.8vw 0 .6vw;
  touch-action: manipulation;
}
.things .thing .n { position: absolute; left: 0; top: .9vw; }
.things .thing .aside {
  position: absolute; right: 0; top: .9vw;
  max-width: calc(100% - 5ch);
  text-align: right;
}
.things .thing .w { position: relative; }

/* the red down-arrow cursor on everything that can still be pushed */
.things .thing[data-state="up"][data-verb],
.things .thing[data-state="up"] .toy {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12 3v15M5.5 12l6.5 7 6.5-7' stroke='%23ECE8DF' stroke-width='5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12 3v15M5.5 12l6.5 7 6.5-7' stroke='%23FF3B1F' stroke-width='2.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 12 20, s-resize;
}
.things .thing[data-state="down"]:not(.t-bass) .toy,
.things .thing[data-state="down"]:not(.t-bass) { cursor: default; }

/* fuse: '↓' with a 1 px line burning toward it */
.things .tg-fz { white-space: nowrap; color: var(--signal); }
.things .tg-fz[hidden] { display: none; }
.things .tg-fz-line {
  display: inline-block;
  width: 2.6em; height: 1px;
  margin-right: .45em;
  vertical-align: .32em;
  background: currentColor;
  transform-origin: right center;
  animation: tg-burn var(--fuse, 2600ms) linear forwards;
  animation-play-state: paused;
}
.things .tg-burning .tg-fz-line { animation-play-state: running; }
@keyframes tg-burn { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.things .tg-wo[hidden] { display: none; }
.things .tg-count { color: var(--signal); }

/* 01 markets: the rule sits after the ticker; chars step down like a chart */
.things .t-markets .tg-tk { white-space: nowrap; }
.things .t-markets .ch { will-change: auto; }

/* 03 sun: a signal horizon behind the tiles while it sets */
.things .t-sun::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 46% 78% at 26% 100%, var(--signal) 0%, color-mix(in srgb, var(--signal) 40%, transparent) 38%, transparent 72%);
  opacity: 0;
}
.things .t-sun.tg-horizon::before { animation: tg-horizon 1.8s ease-in-out both; }
@keyframes tg-horizon { 0% { opacity: 0; } 45% { opacity: 1; } 100% { opacity: 0; } }

/* 04 curtain: scaleY driven by --drop (tap, or drag on fine pointers) */
/* v1's inset (-.15em up, -.25em left) reached into the label strip (04 + its aside) and past the gutter in the
   block layout: the curtain hangs from just above the caps, inside the list, and ends after the N rather than
   after its trailing .3em tracking */
.things .t-curtain .w::after { inset: -.02em .2em -.08em 0; transform: scaleY(var(--drop, 0)); transition: none; }
.things .t-curtain.tg-drop .w::after { transition: transform .26s cubic-bezier(.3, 1.3, .5, 1); }

/* 05 bass */
.things .t-bass .bw { display: inline-block; transform-origin: 0 100%; white-space: nowrap; }
.things .t-bass.charging .w,
.things .t-bass.synced .w { animation: none; }
.things .t-bass.tg-slump .w { opacity: .5; transition: opacity .9s; }

/* 06 house: no v1 auto-collapse; dominoes only when it is brought down */
.things .t-house .ch { transition: none; transform: none; }
.things .t-house.in .ch { transform: none; }
/* the rubble (--y up to .4em of a fitted, very large word, plus the topple) used to land on row 07 and cover its
   label, aside and word: the house falls onto its own floor, and whatever sinks past the row's bottom rule is cut
   off there (clipped at the bottom edge only, so the topple can still swing out sideways and up) */
.things .t-house[data-state="down"],
.things .t-markets[data-state="down"] { clip-path: inset(-100vh -100vw 0 -100vw); }
.things .t-house[data-state="down"] .ch {
  transform: translateY(var(--y)) rotate(var(--r));
  transition: transform .7s cubic-bezier(.6, 0, .25, 1.4);
  transition-delay: var(--dl, 0ms);
}

/* 07 battery */
.things .t-battery { padding-top: max(2.8vw, 30px); }
.things .t-battery .w { transition: opacity .6s; }
.things .t-battery .batt::before { width: calc(var(--lvl, 3) * .9%); }
.things .t-battery.tg-dead .w { opacity: .3; }
.things .t-battery.tg-dead .batt::before { animation: none; width: 0; }

/* ================================================================ III: row 08, yours */

.things .t-own { padding-bottom: 1.4vw; z-index: 3; max-width: 100%; min-width: 0; overflow-x: clip; overflow-clip-margin: var(--gutter, 16px); }
/* row 08 never grows past the list: the input scrolls inside itself instead of widening the page */
.things .t-own .own,
.things .t-own .own-w,
.things .t-own .own-in,
.things .t-own .own-past,
.things .t-own .own-line,
.things .t-own .own-actions { max-width: 100%; min-width: 0; box-sizing: border-box; }
.things .t-own .aside { max-width: calc(100% - 4ch); min-width: 0; }
.things .tg-vh {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.things .t-own .own { display: block; margin: 0; }
.things .t-own .own-w {
  display: block; position: relative;
  clip-path: none; transform: none;
  font-size: inherit;
}
.things .own-in {
  appearance: none; -webkit-appearance: none;
  display: block; width: 100%;
  height: var(--own-h, 200px);
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: none; color: inherit;
  font-family: var(--flex);
  font-variation-settings: "wdth" 151, "wght" 1000, "opsz" 144;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -.01em;
  text-transform: uppercase;
  caret-color: var(--signal);
}
.things .own-in:focus,
.things .own-in:focus-visible { outline: none; box-shadow: 0 2px 0 var(--signal); }
.things .own-in::placeholder {
  font-family: var(--serif);
  font-style: italic; font-weight: 300;
  font-variation-settings: "opsz" 144;
  font-size: var(--ph-fs, 44px);
  letter-spacing: -.02em;
  text-transform: none;
  color: color-mix(in srgb, currentColor 18%, transparent);
  opacity: 1;
}
.things .t-own.tg-ghosted .own-in::placeholder,
.things .t-own.tg-ph-gone .own-in:not(:focus)::placeholder { color: transparent; }
.things .t-own.tg-ph-gone .own-in::placeholder { transition: color .9s; }

/* outlines: what you sent down */
.things .own-ghost,
.things .own-txt {
  font-family: var(--flex);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: pre;
  -webkit-text-fill-color: transparent;
  -webkit-text-stroke: 1px currentColor;
  paint-order: stroke fill;
  opacity: .28;
}
.things .own-ghost {
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.things .own-ghost[hidden] { display: none; }
.things .own-past:empty { display: none; }
.things .own-line { display: block; margin: 0 0 1.2vw; }
.things .own-line .own-when { display: block; opacity: .55; margin-bottom: 4px; }
.things .own-line .own-txt { display: block; }

/* falling letters */
.things .own-fall {
  position: absolute; left: 0; top: 50%;
  translate: 0 -50%;
  z-index: 5;
  pointer-events: none;
  font-family: var(--flex);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -.01em;
  white-space: pre;
}
.things .own-fall .own-ch { display: inline-block; white-space: pre; }

.things .own-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 10px; }
.things .own-actions [hidden] { display: none; }
.things .own-drop,
.things .own-forget {
  appearance: none; -webkit-appearance: none;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid currentColor; border-radius: 99px;
  background: none; color: inherit;
  cursor: pointer;
}
.things .own-forget { border-color: transparent; opacity: .55; }
.things .own-drop:hover { background: var(--paper); color: var(--ink); }

/* probe for the live width fit (never visible). Its host is a zero-size clipped box, so the probe
   (100 px type, often far wider than the phone) never adds to the document's scroll width. */
.things .own-probe-host {
  position: absolute; left: 0; top: 0;
  width: 0; height: 0; overflow: hidden;
  visibility: hidden; pointer-events: none;
}
.things .own-probe {
  position: absolute; left: 0; top: 0;
  visibility: hidden; pointer-events: none;
  white-space: pre; font-size: 100px; line-height: 1;
}
.things .own-probe-flex { font-family: var(--flex); text-transform: uppercase; letter-spacing: -.01em; }
.things .own-probe-ph { font-family: var(--serif); font-style: italic; font-weight: 300; font-variation-settings: "opsz" 144; letter-spacing: -.02em; }

/* ================================================================ III: verdict + row 09 */

.things .tg-verdict-li { display: block; padding: 3.2vh 0 1.4vh; }
.things .things-verdict {
  max-width: 64ch;
  opacity: 0;
  transition: opacity .8s ease;
}
.things .things-verdict.on { opacity: .85; }

.things .t-lights { padding-top: max(2.8vw, 64px); }
.things .t-lights .aside { opacity: 1; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px 14px; top: max(.6vw, 6px); }
.things .t-lights .aside .tg-a { opacity: .55; }
.things .t-lights:not(.tg-off) .w { text-shadow: 0 0 .25em color-mix(in srgb, var(--paper) 35%, transparent); }
.things .switch {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 44px; min-width: 88px;
  padding: 0 14px 0 8px;
  border: 1px solid currentColor; border-radius: 99px;
  background: none; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer;
}
.things .switch .sw-track {
  position: relative; display: inline-block;
  width: 40px; height: 18px;
  border: 1px solid currentColor; border-radius: 99px;
}
.things .switch .sw-knob {
  position: absolute; left: 2px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: currentColor;
  transform: translateX(22px);
  transition: transform .14s cubic-bezier(.3, .7, .3, 1);
}
.things .switch[aria-pressed="false"] .sw-knob { transform: translateX(0); background: transparent; box-shadow: inset 0 0 0 1px currentColor; }

/* ================================================================ fit: measure at rest */

html[data-measure] .things .ch,
html[data-measure] .things .tile,
html[data-measure] .things .bw,
html[data-measure] .gravity .aao-ch {
  transform: none !important; translate: none !important; rotate: none !important; scale: none !important;
  animation: none !important;
}
html[data-measure] .things .t-bass .bw { font-variation-settings: "wdth" 151, "wght" 1000, "opsz" 144 !important; }

/* ================================================================ IV: gravity */

.gravity { height: 300vh; }
.gravity .prose { position: relative; z-index: 2; touch-action: pan-y; }
.gravity .prose .word {
  will-change: auto;
  paint-order: stroke fill;
  -webkit-text-stroke-color: currentColor;
}
.gravity .prose .word.tg-caret {
  text-decoration: underline;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: .14em;
}
.gravity .prose .word.tg-read { text-decoration: line-through; opacity: .25; transition: opacity .18s linear; }
.gravity .prose em { position: relative; z-index: 1; } /* the tail stays legible above the heap */
.gravity .prose em.tg-hide { visibility: hidden; }
.gravity .prose:focus-visible { outline-offset: 10px; }

.gravity .allatonce {
  position: absolute; left: 0; top: 0;
  margin: 0;
  z-index: 4;
  visibility: hidden;
  pointer-events: none;
  transform-origin: 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 900;
  font-variation-settings: "opsz" 144, "wght" 900, "SOFT" 100, "WONK" 1;
  line-height: .92;
}
.gravity .allatonce.on { visibility: visible; }
.gravity .allatonce .aao-line { display: block; width: max-content; white-space: nowrap; letter-spacing: -.02em; }
.gravity .allatonce .aao-ch { display: inline-block; transform-origin: 50% 80%; }

.gravity .brace {
  position: absolute; left: 0; top: 0;
  z-index: 3;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 720px) {
  .things .thing { padding: max(2.8vw, 34px) 0 2vw; }
  /* a resolved aside can wrap to two or three lines here ('back tomorrow. the only one that is. (without you)'):
     a tighter leading and a slightly higher strip keep it clear of the word below */
  .things .thing .n,
  .things .thing .aside { top: 6px; }
  .things .thing .aside { line-height: 1.15; }
  .things .thing .aside { max-width: calc(100% - 4ch); }
  .things .t-markets .tg-rule { display: block; }
  .things .t-markets { padding-top: 50px; }
  .things .t-lights { padding-top: 72px; }
  .things .t-lights .aside { top: 4px; }
  .things .t-battery { padding-top: 34px; }
  .things .own-drop, .things .own-forget { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .things .tg-fz-line { display: none; }
}
