/* A small station ident, hidden behind the TV's TM key. */
.tape-player__tv { position: relative; }
.tape-player__secret {
  flex: 0 0 auto; cursor: pointer; padding: .28rem .38rem;
  border: 1px solid #b8aa9d75; border-radius: 3px; background: #29252a; color: #f6eadd;
  font: 800 .7rem/1 Arial, sans-serif; letter-spacing: -.06em;
  transition: border-color .18s, box-shadow .18s, color .18s, transform .12s;
}
.tape-player__secret span { color: #f4bd70; font-size: .55rem; }
@media (hover: hover) and (pointer: fine) {
  .tape-player__secret:hover { color: #fff5dc; border-color: #e4c58c; box-shadow: inset 0 0 8px #e8b76933, 0 0 9px -4px #e8b76988; }
}
.tape-player__secret:active { transform: translateY(1px); }
.tape-player__secret:focus-visible { outline: 2px solid #ffe391; outline-offset: 3px; }
.tape-ident[hidden] { display: none; }
.tape-ident {
  --ident-paper: #1a1726;
  --ident-border-bg: #15131d;
  --ident-ink: #fff1ce;
  --ident-muted: #d1c5bb;
  --ident-accent: #f9e7c0;
  --ident-scan: #07050b;
  --ident-line: #d4c5b7;
  --ident-sun: #f4d477;
  --ident-shadow: #1a1726;
  --ident-title-yellow: #ffe49a;
  --ident-title-orange: #ffac72;
  --ident-title-red: #ff8290;
  --ident-title-purple: #d7a2f3;
  --ident-title-pink: #ffa8d3;
  --ident-title-depth: -1px 0 #78c7ef99, 2px 1px #ed659899, 0 0 8px #ffdd8888, 0 0 20px #ed784455;
  --ident-title-solid-depth: 0 0 6px #ffecb988, 0 0 18px #ee984c55;
  position: absolute; z-index: 6; overflow: hidden; box-sizing: border-box;
  border: 7px solid #161a20; border-radius: 28px / 22px; pointer-events: none; background: var(--ident-border-bg);
}
/* Let the last frames dissolve into the picture underneath, instead of
   exposing an opaque rectangle when the ident is removed. */
.tape-ident.is-running { background: transparent; }
.tape-ident__announce { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tape-ident__art { position: absolute; inset: 0; overflow: hidden; background: var(--ident-paper); color: var(--ident-ink); }
.tape-ident__art::before {
  content: ''; position: absolute; inset: 5%; z-index: 4; pointer-events: none;
  border: 1px solid var(--ident-line); opacity: .11;
}
.tape-ident__art::after {
  content: ''; position: absolute; z-index: 6; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, var(--ident-scan) 0 1px, transparent 1px 4px); opacity: .06;
}
.tape-ident__masthead { position: absolute; z-index: 5; top: 8%; left: 8%; display: flex; align-items: baseline; gap: .7rem; }
.tape-ident__masthead b { font: 900 clamp(1rem, 2.2vw, 1.55rem)/1 Arial, sans-serif; letter-spacing: -.08em; }
.tape-ident__masthead b span { color: #d94f60; }
.tape-ident__masthead small { font: 700 clamp(.46rem, .75vw, .6rem)/1 var(--font-mono); letter-spacing: .1em; }
.tape-ident__composition { position: absolute; inset: 13% 0 14%; overflow: hidden; }
/* A narrow light streak gathers the colours into a final broadcast glint. */
.tape-ident__composition::after {
  content: ''; position: absolute; z-index: 1; left: 50%; top: 47%; width: 85%; height: 2px;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, #ee7848, #fff0c8 50%, #ab63bb, transparent);
  box-shadow: 0 0 10px 2px #f5b98b88;
  transform: translate(-50%, -50%) scaleX(0);
}
/* A quiet luminous ring, like the aperture of a vintage station ident. */
.tape-ident__sun {
  position: absolute; left: 50%; top: 47%; width: min(40%, 15rem); aspect-ratio: 1;
  transform: translate(-50%, -50%); border: 2px solid var(--ident-sun); border-radius: 50%;
  box-shadow: 0 0 9px #f4b85d66, inset 0 0 9px #f4b85d44;
  opacity: .45;
}
.tape-ident__sun::before, .tape-ident__sun::after {
  content: ''; position: absolute; border: 1px solid var(--ident-line); border-radius: 50%; inset: -7%; opacity: .6;
}
.tape-ident__sun::after { inset: -14%; opacity: .35; }
.tape-ident__grid {
  position: absolute; inset: 45% 7% -60%; opacity: .12; transform-origin: 50% 0;
  background: repeating-linear-gradient(90deg, var(--ident-line) 0 1px, transparent 1px 9%),
    repeating-linear-gradient(0deg, var(--ident-line) 0 1px, transparent 1px 13%);
  transform: perspective(220px) rotateX(58deg);
  mask-image: linear-gradient(transparent, #000 25%, transparent 78%);
  -webkit-mask-image: linear-gradient(transparent, #000 25%, transparent 78%);
}
.tape-ident__bars { position: absolute; inset: 55% 0 auto; display: flex; flex-direction: column; gap: clamp(2px, .34vw, 4px); transform: skewX(-18deg); }
.tape-ident__bars i { display: block; width: 114%; margin-left: -7%; height: clamp(4px, .8vw, 9px); border-radius: 999px; box-shadow: 0 0 8px currentColor; transform-origin: left center; }
.tape-ident__bars i:nth-child(1) { background: #f4b72e; color: #f4b72e88; --stripe-delay: 0s; }
.tape-ident__bars i:nth-child(2) { background: #ee7848; color: #ee784888; --stripe-delay: .08s; }
.tape-ident__bars i:nth-child(3) { background: #df5172; color: #df517288; --stripe-delay: .16s; }
.tape-ident__bars i:nth-child(4) { background: #ab63bb; color: #ab63bb88; --stripe-delay: .24s; }
.tape-ident__bars i:nth-child(5) { background: #7770c8; color: #7770c888; --stripe-delay: .32s; }
.tape-ident__title {
  position: absolute; z-index: 2; left: 50%; top: 47%; transform: translate(-50%, -50%);
  display: flex; align-items: baseline; padding: .12em .16em .2em .06em;
  color: var(--ident-ink); font: italic 900 clamp(3.5rem, 11vw, 7.2rem)/.9 Arial, sans-serif;
  letter-spacing: -.095em; white-space: nowrap;
  /* A soft phosphor bloom and slight colour separation at the edge of the type. */
  text-shadow: var(--ident-title-depth);
}
.tape-ident__dash { padding: 0 .04em; font-weight: 400; }
.tape-ident__subtitle {
  position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%);
  padding: .36em .65em; background: var(--ident-paper); color: var(--ident-ink);
  border: 1px solid var(--ident-line); white-space: nowrap;
  font: 700 clamp(.45rem, .8vw, .65rem)/1 var(--font-mono); letter-spacing: .15em;
}
.tape-ident__details { position: absolute; z-index: 5; left: 8%; right: 8%; bottom: 8%; display: flex; justify-content: space-between; gap: 1rem; color: var(--ident-muted); font: 700 clamp(.42rem, .8vw, .62rem)/1.2 var(--font-mono); letter-spacing: .07em; }
.tape-ident.is-running .tape-ident__art { animation: ident-stage 7.6s ease both; }
.tape-ident.is-running .tape-ident__sun { animation: ident-sun 7.6s cubic-bezier(.22,.8,.25,1) both; }
.tape-ident.is-running .tape-ident__grid { animation: ident-grid 7.6s ease both; }
.tape-ident.is-running .tape-ident__bars i { animation: ident-stripe 7.6s cubic-bezier(.65,0,.25,1) var(--stripe-delay) both; }
.tape-ident.is-running .tape-ident__title {
  animation: ident-title 7.6s cubic-bezier(.65,0,.25,1) both,
    ident-title-colours 555.56ms linear 2.85s 3 both,
    ident-title-resolve 350ms ease-out 4.517s forwards,
    ident-title-depth 7.6s ease both;
}
.tape-ident.is-running .tape-ident__composition::after { animation: ident-glint 7.6s ease-out both; }
.tape-ident.is-running .tape-ident__subtitle { animation: ident-caption 7.6s ease both; }
@keyframes ident-stage { 0% { opacity: 0; } 6%, 91% { opacity: 1; } 100% { opacity: 0; } }
@keyframes ident-sun {
  0%, 7% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-20deg); }
  28%, 68% { opacity: .6; transform: translate(-50%, -50%) scale(1) rotate(0); }
  90%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15) rotate(12deg); }
}
@keyframes ident-grid { 0%, 10% { opacity: 0; } 30%, 72% { opacity: .12; } 90%, 100% { opacity: 0; } }
@keyframes ident-stripe {
  0%, 5% { transform: translateX(110%); }
  24%, 66% { transform: translateX(0); }
  86%, 100% { transform: translateX(110%); }
}
@keyframes ident-title {
  /* Position the right edge beyond the left of the composition at both ends;
     unlike a percentage translation alone, this works at every screen width. */
  0%, 8% { left: -10%; transform: translate(-100%, -50%) skewX(-8deg); }
  30%, 46% { left: 50%; transform: translate(-50%, -50%) skewX(0); }
  58%, 68% { left: 50%; transform: translate(-50%, -50%) skewX(0); }
  88%, 100% { left: -10%; transform: translate(-100%, -50%) skewX(-8deg); }
}
/* The title arrives in one ink, holds, then changes ink nine times a second
   before resolving to the theme's neutral ink for its exit. */
@keyframes ident-title-colours {
  0%, 15% { color: var(--ident-title-yellow); }
  20%, 35% { color: var(--ident-title-orange); }
  40%, 55% { color: var(--ident-title-red); }
  60%, 75% { color: var(--ident-title-purple); }
  80%, 95% { color: var(--ident-title-pink); }
  100% { color: var(--ident-title-yellow); }
}
@keyframes ident-title-resolve { from { color: var(--ident-title-yellow); } to { color: var(--ident-ink); } }
@keyframes ident-title-depth {
  0%, 37.5% { text-shadow: var(--ident-title-solid-depth); }
  42%, 59% { text-shadow: var(--ident-title-depth); }
  64%, 100% { text-shadow: var(--ident-title-solid-depth); }
}
@keyframes ident-glint {
  0%, 58% { opacity: 0; transform: translate(-50%, -50%) scaleX(0); }
  62% { opacity: .65; transform: translate(-50%, -50%) scaleX(.18); }
  68% { opacity: .45; transform: translate(-50%, -50%) scaleX(1); }
  73%, 100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.08); }
}
@keyframes ident-caption { 0%, 19% { opacity: 0; transform: translate(-50%, 7px); } 32%, 66% { opacity: 1; transform: translate(-50%, 0); } 80%, 100% { opacity: 0; transform: translate(-50%, -5px); } }
@media (max-width: 480px) {
  .tape-ident__sun { width: 52%; }
  .tape-ident__title { font-size: clamp(3rem, 18vw, 4.5rem); }
  .tape-ident__subtitle { top: 70%; bottom: auto; }
  .tape-ident__masthead { gap: .45rem; }
}
@media (prefers-reduced-motion: reduce) {
  .tape-player__secret { transition: none; }
  .tape-player__secret:active { transform: none; }
  .tape-ident.is-running .tape-ident__art, .tape-ident.is-running .tape-ident__sun,
  .tape-ident.is-running .tape-ident__grid, .tape-ident.is-running .tape-ident__bars i,
  .tape-ident.is-running .tape-ident__title, .tape-ident.is-running .tape-ident__subtitle,
  .tape-ident.is-running .tape-ident__composition::after { animation: none; }
}

/* The ident follows the page theme, including the system preference. */
:root[data-theme="dark"] .tape-ident {
  --ident-paper: #080b13; --ident-border-bg: #080910; --ident-ink: #fff3d6;
  --ident-muted: #c2bdca; --ident-accent: #dfceff; --ident-scan: #03040a;
  --ident-line: #aaa2b4; --ident-sun: #f5d877; --ident-shadow: #080b13;
  --ident-title-yellow: #ffcf54; --ident-title-orange: #ff925f; --ident-title-red: #ff667c;
  --ident-title-purple: #c78be4; --ident-title-pink: #ff8fc4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tape-ident {
    --ident-paper: #080b13; --ident-border-bg: #080910; --ident-ink: #fff3d6;
    --ident-muted: #c2bdca; --ident-accent: #dfceff; --ident-scan: #03040a;
    --ident-line: #aaa2b4; --ident-sun: #f5d877; --ident-shadow: #080b13;
    --ident-title-yellow: #ffcf54; --ident-title-orange: #ff925f; --ident-title-red: #ff667c;
    --ident-title-purple: #c78be4; --ident-title-pink: #ff8fc4;
  }
}
