/* =========================================================
   DANSEPLUS.CA — CRT EDITION
   The cabinet is modelled on the orange TV from the
   Simpsons title cards: pink wall, hand-inked outline,
   bevelled grey bezel, bowed blue tube, green knobs.
   Only the glass behaves like a real CRT.
   ========================================================= */

@font-face {
  font-family:"Covered By Your Grace";
  src:url("../fonts/covered-by-your-grace.woff2") format("woff2");
  font-weight:400;
  font-style:normal;
  font-display:swap;
}

@font-face {
  font-family:"Patrick Hand SC";
  src:url("../fonts/patrick-hand-sc.woff2") format("woff2");
  font-weight:400;
  font-style:normal;
  font-display:swap;
}

:root {
  /* wall */
  --wall-1:#f8c6df;
  --wall-2:#ee9ccb;
  --wall-3:#d9669f;
  --wall-4:#a53370;

  /* cabinet inks */
  --ink:#6a2412;
  --knob:#46b695;
  --knob-dark:#1f6e57;
  --knob-line:#1d4a3a;

  /* glass */
  --glass-top:#2a52e6;
  --glass-bot:#4a73f1;
  --phosphor:#ffe96b;
  --cream:#fff6cf;
  --navy:#10206a;

  --display:"Covered By Your Grace","Segoe Print","Bradley Hand","Marker Felt",cursive;
  --hand:"Patrick Hand SC","Segoe Print","Bradley Hand","Marker Felt",cursive;
}

* {
  box-sizing:border-box;
}

html {
  min-height:100%;
  background:
    linear-gradient(
      172deg,
      var(--wall-1) 0%,
      var(--wall-2) 30%,
      var(--wall-3) 62%,
      var(--wall-4) 100%
    );
  background-attachment:fixed;
}

body {
  margin:0;
  min-height:100svh;
  overflow-x:hidden;
  background:transparent;
  color:#fff;
  font-family:var(--hand);
}

button {
  font:inherit;
}

.svg-defs {
  position:absolute;
  width:0;
  height:0;
  overflow:hidden;
}

.noscript {
  position:fixed;
  inset:auto 0 12px;
  margin:0;
  text-align:center;
  color:#fff;
  font:16px var(--hand);
}


/* =========================================================
   STAGE + TV FRAME
   --u is one viewBox unit (the cabinet art is 1290 wide),
   so every overlay is placed in the same coordinates the
   SVG is drawn in and the whole set scales as one object.
   ========================================================= */

.tv-stage {
  min-height:100svh;
  display:grid;
  place-content:center;
  justify-items:center;
  gap:clamp(6px,1.4vh,14px);

  padding:
    max(10px,env(safe-area-inset-top))
    2vw
    max(12px,env(safe-area-inset-bottom));
}

.tv {
  --tv-w:min(
    940px,
    96vw,
    calc((100svh - 70px) * 1290 / 1400)
  );
  --u:calc(100cqw / 1290);

  position:relative;

  width:max(300px,var(--tv-w));
  aspect-ratio:1290 / 1400;

  container-type:inline-size;
}

.tv-art {
  position:absolute;
  inset:0;

  width:100%;
  height:100%;

  overflow:visible;
  pointer-events:none;
}

.tv-art .brand {
  fill:var(--ink);
  font-family:var(--display);
  font-size:40px;
  letter-spacing:9px;
}

.outside-note {
  color:rgba(255,255,255,.9);
  text-shadow:0 1px 0 rgba(120,20,70,.45);

  font:clamp(12px,1.6vw,15px)/1 var(--hand);
  letter-spacing:.2em;
}


/* =========================================================
   THE TUBE
   ========================================================= */

.screen {
  position:absolute;

  left:calc(var(--u) * 165);
  top:calc(var(--u) * 295);
  width:calc(var(--u) * 955);
  height:calc(var(--u) * 770);

  /* bowed glass, same curve as the drawn outline */
  clip-path:url(#tube);

  display:flex;
  flex-direction:column;

  padding:6.2cqw 6.6cqw 6.6cqw;

  overflow:hidden;
  container-type:inline-size;

  background:
    linear-gradient(
      to bottom,
      var(--glass-top) 0%,
      #3560ee 50%,
      var(--glass-bot) 100%
    );

  color:var(--phosphor);

  /* phosphor bloom + the faintest red/cyan misconvergence */
  text-shadow:
    .025em 0 rgba(255,70,110,.32),
    -.025em 0 rgba(70,220,255,.32),
    0 0 .5em rgba(255,233,107,.38);

  animation:crt-on .85s .12s cubic-bezier(.2,.85,.3,1) backwards;
}

/* scanlines, vignette and glass glare */
.screen::after {
  content:"";
  position:absolute;
  inset:0;
  z-index:30;
  pointer-events:none;

  background:
    radial-gradient(
      120% 80% at 20% 6%,
      rgba(255,255,255,.15) 0%,
      transparent 40%
    ),
    radial-gradient(
      ellipse at 50% 50%,
      transparent 55%,
      rgba(4,10,70,.55) 100%
    ),
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,40,.18) 0,
      rgba(0,0,40,.18) 1px,
      transparent 1px,
      transparent 3px
    );
}

/* slow refresh band rolling down the glass */
.screen::before {
  content:"";
  position:absolute;
  left:0;
  right:0;
  top:-30%;
  height:30%;
  z-index:29;
  pointer-events:none;

  background:
    linear-gradient(
      to bottom,
      transparent 0%,
      rgba(255,255,255,.07) 50%,
      transparent 100%
    );

  animation:roll 9s linear infinite;
}

@keyframes roll {
  from { transform:translateY(0); }
  to   { transform:translateY(480%); }
}

/* the one orchestrated moment: switching on */
@keyframes crt-on {
  0% {
    transform:scale(0,.006);
    filter:brightness(9);
  }

  38% {
    transform:scale(1,.006);
    filter:brightness(9);
  }

  100% {
    transform:scale(1,1);
    filter:brightness(1);
  }
}

.screen-background-video {
  position:absolute;
  inset:0;
  z-index:0;

  width:100%;
  height:100%;

  object-fit:cover;
  pointer-events:none;

  opacity:.26;
  mix-blend-mode:screen;
  filter:grayscale(1) contrast(1.1);
}

.screen-noise {
  position:absolute;
  inset:0;
  z-index:25;

  width:100%;
  height:100%;

  opacity:0;
  pointer-events:none;
  image-rendering:pixelated;
}


/* =========================================================
   ON-SCREEN DISPLAY BAR
   ========================================================= */

.statusbar {
  flex:0 0 auto;

  position:relative;
  z-index:2;

  display:grid;
  grid-template-columns:max(9cqw,30px) 1fr max(9cqw,30px);
  align-items:center;
  gap:1cqw;

  height:9cqw;
  margin-bottom:1.6cqw;
  padding-bottom:1.2cqw;

  border-bottom:.7cqw solid var(--phosphor);
  border-radius:0 0 1cqw 1cqw / 0 0 .6cqw .6cqw;
}

.status-title {
  overflow:hidden;

  text-align:center;
  text-overflow:ellipsis;
  white-space:nowrap;

  font:5.4cqw/1.1 var(--display);
  letter-spacing:.12em;
  text-transform:uppercase;
}

.status-icon {
  position:relative;

  display:grid;
  place-items:center;

  height:100%;
  padding:0;

  border:0;
  background:transparent;
  color:inherit;
  cursor:pointer;

  -webkit-tap-highlight-color:transparent;
}

/* generous hit area without growing the glyph */
.status-icon::after {
  content:"";
  position:absolute;
  inset:-2cqw;
}

.status-back {
  opacity:.35;
}

.status-back.active {
  opacity:1;
}

.tri {
  display:block;
  width:0;
  height:0;
  border-style:solid;
  border-color:transparent;
}

.tri-left {
  border-width:2.4cqw 3.4cqw 2.4cqw 0;
  border-right-color:var(--phosphor);
}

.tri-play {
  border-width:2.4cqw 0 2.4cqw 3.6cqw;
  border-left-color:var(--phosphor);
}

.bars {
  display:none;
  width:3.8cqw;
  height:4.8cqw;

  background:
    linear-gradient(
      90deg,
      var(--phosphor) 0 34%,
      transparent 34% 66%,
      var(--phosphor) 66% 100%
    );
}

body.is-playing .tri-play {
  display:none;
}

body.is-playing .bars {
  display:block;
}


/* =========================================================
   SCREEN CONTENT
   ========================================================= */

.screen-main {
  flex:1;

  min-width:0;
  min-height:0;

  position:relative;
  z-index:1;

  overflow:hidden;
}

.screen-main.screen-change {
  animation:tune .28s steps(7,end);
}

@keyframes tune {
  0% {
    transform:translateX(-2.4%) scaleY(1.05);
    filter:brightness(2.1) saturate(0);
  }

  35% {
    transform:translateX(1.4%);
    filter:brightness(1.4) saturate(.4);
  }

  70% {
    transform:translateX(-.4%);
    filter:brightness(1.1);
  }

  100% {
    transform:none;
    filter:none;
  }
}


/* =========================================================
   MENUS
   ========================================================= */

.menu {
  width:100%;
  height:100%;

  margin:0;
  padding:0;

  list-style:none;
  overflow:auto;

  scrollbar-width:thin;
  scrollbar-color:var(--phosphor) transparent;
}

.menu-item {
  min-height:11.6cqw;

  display:grid;
  grid-template-columns:1fr auto;
  align-items:center;
  gap:3cqw;

  padding:0 3.4cqw;

  border-bottom:.45cqw dashed rgba(255,233,107,.3);
  border-radius:1.6cqw;

  font:6.9cqw/1.1 var(--display);
  letter-spacing:.08em;
  text-transform:uppercase;

  cursor:default;
  outline:none;
}

.menu-item.active {
  background:var(--phosphor);
  color:#1534c4;
  border-bottom-color:transparent;
  text-shadow:none;
}

.menu-arrow {
  font:7cqw/1 var(--hand);
}


/* =========================================================
   PAGES
   ========================================================= */

.page {
  width:100%;
  height:100%;

  min-width:0;
  min-height:0;

  overflow:hidden;
}

.page-scroll {
  width:100%;
  height:100%;

  min-width:0;
  min-height:0;

  padding:.4cqw 1.2cqw 2cqw .4cqw;

  overflow:auto;
  scrollbar-width:thin;
  scrollbar-color:var(--phosphor) transparent;
}

.page-heading {
  margin-bottom:1.6cqw;

  font:6cqw/1.05 var(--display);
  letter-spacing:.1em;
  text-transform:uppercase;
}

/* the OSD bar already names the page, so the photo grid skips its own title */
.page-scroll:has(.photo-grid) .page-heading {
  display:none;
}

.page-meta {
  margin-bottom:2.4cqw;

  color:var(--cream);
  text-shadow:none;

  font:3.8cqw/1.35 var(--hand);
  letter-spacing:.05em;
}

.page-meta strong,
.page-meta b {
  color:inherit;
  font:inherit;
}

.page-copy {
  color:var(--cream);
  text-shadow:none;

  font:4.2cqw/1.4 var(--hand);
  letter-spacing:.03em;
}

.small-rule {
  height:0;
  margin:2.4cqw 0;
  border-top:.45cqw dashed rgba(255,233,107,.4);
}

.row {
  min-height:9cqw;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:2cqw;

  padding:1.6cqw .8cqw;

  border-top:.45cqw dashed rgba(255,233,107,.3);

  font:4.4cqw/1.2 var(--hand);
  letter-spacing:.05em;
}

.row:first-of-type {
  border-top:0;
}

.row strong {
  font-weight:400;
}

.row-arrow {
  font-size:6cqw;
}


/* =========================================================
   RELEASE / RECORD PAGES
   ========================================================= */

.release {
  min-height:100%;

  display:grid;
  grid-template-columns:34cqw 1fr;
  grid-template-areas:
    "cover track"
    "cover credits";
  grid-template-rows:auto 1fr;
  gap:2cqw 3.4cqw;
  align-content:start;
}

.release > div:first-child {
  grid-area:cover;
}

.release > .tracklist {
  grid-area:track;
}

.release > div:last-child {
  grid-area:credits;
}

.art {
  width:34cqw;
  height:34cqw;

  margin:0 0 1.8cqw;

  overflow:hidden;
  background:var(--navy);

  border:.8cqw solid var(--phosphor);
  border-radius:.8cqw;

  transform:rotate(-1.6deg);
}

.art img {
  display:block;

  width:100%;
  height:100%;

  object-fit:cover;
}

.release-title {
  font:5cqw/1.1 var(--display);
  letter-spacing:.06em;
  text-transform:uppercase;
}

.release-sub {
  margin-top:.8cqw;

  color:var(--cream);
  text-shadow:none;

  font:3.4cqw var(--hand);
  letter-spacing:.2em;
}

.tracklist {
  margin:0;
}

.track {
  width:100%;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:2cqw;

  padding:2.4cqw 3cqw;

  border:.6cqw solid var(--phosphor);
  border-radius:1.8cqw;

  background:transparent;
  color:var(--phosphor);
  text-shadow:inherit;
  text-align:left;

  cursor:pointer;

  font:4.2cqw/1.15 var(--hand);
  letter-spacing:.06em;
  text-transform:uppercase;
}

.track.active {
  background:var(--phosphor);
  color:#1534c4;
  text-shadow:none;
}

.release .page-meta {
  margin:0;
  font-size:3.3cqw;
}


/* =========================================================
   MEDIA / VIDEO / PHOTO VIEWER
   ========================================================= */

.media {
  width:100%;
  height:100%;

  min-width:0;
  min-height:0;

  display:grid;
  grid-template-rows:minmax(0,1fr) auto;

  overflow:hidden;

  background:#071046;
  color:var(--cream);
  text-shadow:none;

  border:.6cqw solid var(--phosphor);
  border-radius:1.4cqw;
}

.media-stage {
  width:100%;
  height:100%;

  min-width:0;
  min-height:0;

  position:relative;
  overflow:hidden;

  display:grid;
  place-items:center;

  background:#071046;
}

.media-stage>img,
.media-stage>video,
.media-stage>iframe {
  position:absolute;
  inset:0;

  display:block;

  width:100%;
  height:100%;

  max-width:none;
  max-height:none;

  margin:0;
  padding:0;

  border:0;
  background:#071046;

  object-fit:contain;
}

.media-toolbar {
  position:absolute;

  left:1.6cqw;
  right:1.6cqw;
  bottom:1.6cqw;

  z-index:5;

  display:flex;
  justify-content:space-between;
  gap:1.6cqw;

  pointer-events:none;
}

.media-toolbar button {
  padding:1.2cqw 2.6cqw;

  border:.5cqw solid var(--phosphor);
  border-radius:1.4cqw;

  background:rgba(7,16,70,.8);
  color:var(--phosphor);

  pointer-events:auto;
  cursor:pointer;

  font:3.6cqw/1 var(--hand);
  letter-spacing:.08em;
}

.media-caption {
  width:100%;
  min-width:0;

  padding:1.8cqw 2.6cqw;

  border-top:.5cqw dashed rgba(255,233,107,.5);

  background:rgba(7,16,70,.92);

  font:3.2cqw/1.3 var(--hand);
  letter-spacing:.05em;

  overflow:hidden;
}

.media-caption strong {
  display:block;
  margin-bottom:.4cqw;

  color:var(--phosphor);
  font:inherit;
  font-size:3.6cqw;
  font-weight:400;
}


/* =========================================================
   PHOTO GRID
   ========================================================= */

.photo-grid {
  width:100%;

  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));

  gap:2.4cqw;
  padding:.8cqw .8cqw 2cqw;
}

.thumb {
  width:100%;
  aspect-ratio:1 / 1;

  min-width:0;
  padding:0;

  position:relative;

  border:.5cqw solid rgba(255,233,107,.55);
  border-radius:.8cqw;

  overflow:hidden;
  background:var(--navy);

  cursor:pointer;
}

.thumb img {
  display:block;

  width:100%;
  height:100%;

  object-fit:cover;
  object-position:center;
}

.thumb::after {
  content:attr(data-label);

  position:absolute;
  left:.8cqw;
  bottom:.8cqw;

  padding:.3cqw 1cqw;

  border-radius:.8cqw;
  background:rgba(7,16,70,.8);
  color:var(--phosphor);
  text-shadow:none;

  font:2.8cqw/1.2 var(--hand);
  letter-spacing:.06em;
}

.photo-grid .thumb {
  transition:
    transform 120ms ease,
    box-shadow 120ms ease;
}

.photo-grid .thumb.active {
  z-index:2;
  transform:scale(1.06);
  border-color:var(--phosphor);

  box-shadow:
    0 0 0 .7cqw var(--phosphor),
    0 0 3.4cqw rgba(255,233,107,.8);
}

.live-list .live-item.active {
  background:var(--phosphor);
  color:#1534c4;
}


/* =========================================================
   EMPTY STATES
   ========================================================= */

.empty {
  width:100%;
  height:100%;

  display:grid;
  place-items:center;

  padding:3cqw;
  text-align:center;
}

.empty-inner {
  font:4.4cqw/1.4 var(--hand);
}

.empty-code {
  display:block;
  margin-top:1.4cqw;

  color:var(--cream);
  text-shadow:none;
  font-size:3.4cqw;
}


/* =========================================================
   KNOBS
   Same five jobs as the iPod click wheel.
   Sizes are in viewBox units but never fall under a
   comfortable touch target on small screens.
   ========================================================= */

.tv-controls {
  position:absolute;
  inset:0;
  pointer-events:none;
}

.knob {
  --d:max(calc(var(--u) * var(--d0)),var(--min,44px));
  --rot:0deg;

  position:absolute;
  left:calc(var(--u) * var(--x));
  top:calc(var(--u) * var(--y));

  width:var(--d);
  height:var(--d);

  margin:0;
  padding:0;

  transform:translate(-50%,-50%);

  border:0;
  border-radius:50%;
  background:none;

  cursor:pointer;
  pointer-events:auto;

  -webkit-tap-highlight-color:transparent;
}

.knob-dial {
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
  cursor:grab;
}

.knob-dial:active {
  cursor:grabbing;
}

.knob-face {
  position:absolute;
  inset:0;

  display:block;
  border-radius:50%;
  border:max(2.5px,calc(var(--u) * 5)) solid var(--knob-line);

  filter:url(#ink-sm);

  transform:rotate(var(--rot));
  transition:transform .18s cubic-bezier(.3,1.5,.5,1);
}

/* inner ring, as on the cartoon knobs */
.knob-face::after {
  content:"";
  position:absolute;
  inset:15%;

  border-radius:50%;
  border:max(1.5px,calc(var(--u) * 3)) solid var(--knob-line);
  opacity:.7;
}

.knob-dial .knob-face,
.knob-back .knob-face {
  background:
    radial-gradient(circle, var(--knob) 0 27%, transparent 28%),
    repeating-conic-gradient(
      from 8deg,
      var(--knob-dark) 0 6deg,
      var(--knob) 6deg 30deg
    );
}

.knob-ok .knob-face {
  background:
    radial-gradient(circle, #43b290 0 60%, #37a583 61% 100%);
}

.knob-dot .knob-face {
  background:#3fae8a;
}

.knob-dot .knob-face::after {
  display:none;
}

.knob.pressed .knob-face {
  transform:rotate(var(--rot)) scale(.92);
  transition-duration:.05s;
}

.knob:focus-visible {
  outline:none;
}

.knob:focus-visible .knob-face {
  outline:3px dashed #fff;
  outline-offset:4px;
}

.tag {
  position:absolute;
  left:calc(var(--u) * var(--x));
  top:calc(var(--u) * 1338);

  transform:translateX(-50%);

  color:var(--ink);
  pointer-events:none;

  font:max(9px,calc(var(--u) * 28))/1 var(--hand);
  letter-spacing:.14em;
  white-space:nowrap;
}


/* =========================================================
   FOCUS
   ========================================================= */

.screen :focus-visible {
  outline:.7cqw dashed #fff;
  outline-offset:.6cqw;
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion:reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior:auto!important;
    transition:none!important;
    animation:none!important;
  }

  .screen::before {
    display:none;
  }
}


/* =========================================================
   SMALL SCREENS
   ========================================================= */

@media (max-width:600px) {
  .tv-stage {
    padding-left:1.5vw;
    padding-right:1.5vw;
  }

  .tv {
    --tv-w:min(98vw,calc((100svh - 60px) * 1290 / 1400));
  }
}
