:root {
  /* Six stops instead of four, so the falloff has room to breathe. */
  --bg-core:   #503d72;
  --bg-glow:   #3a2c56;
  --bg-mid:    #281e3d;
  --bg-soft:   #171126;
  --bg-deep:   #0b0814;
  --bg-edge:   #040309;
  --bg-size:   68vmax;
  --bg-x:      50%;
  --bg-y:      46%;

  /* A separate vignette pass darkens the corners past the colour ramp. */
  --vignette-size:     100vmax;
  --vignette-start:    38%;
  --vignette-strength: 0.72;

  --grain-opacity: 0.42;
  --grain-scale:   150px;

  --banner-width:   clamp(150px, 17vw, 270px);
  --edge-pad:       clamp(1.25rem, 3vw, 3rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-edge);
  font-family: 'Pixelify Sans', ui-monospace, monospace;
}

#bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse var(--vignette-size) var(--vignette-size)
      at var(--bg-x) var(--bg-y),
      rgba(2, 1, 6, 0) var(--vignette-start),
      rgba(2, 1, 6, calc(var(--vignette-strength) * 0.45)) 72%,
      rgba(2, 1, 6, var(--vignette-strength)) 100%),
    radial-gradient(circle var(--bg-size) at var(--bg-x) var(--bg-y),
      var(--bg-core) 0%,
      var(--bg-glow) 18%,
      var(--bg-mid)  36%,
      var(--bg-soft) 56%,
      var(--bg-deep) 76%,
      var(--bg-edge) 100%);
  z-index: 0;
}

#grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: var(--grain-opacity);
  z-index: 3;
  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'>\
<filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/>\
<feColorMatrix type='saturate' values='0'/>\
<feComponentTransfer><feFuncA type='linear' slope='2.6' intercept='-0.7'/></feComponentTransfer></filter>\
<rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: var(--grain-scale) var(--grain-scale);
  mix-blend-mode: soft-light;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  touch-action: none;
}

#titleblock {
  position: fixed;
  left: var(--edge-pad);
  bottom: var(--edge-pad);
  z-index: 4;
  pointer-events: none;
}

#titleblock img {
  display: block;
  width: var(--banner-width);
  height: auto;
  /* The artwork is black; turned cream to sit on the dark page. */
  filter: brightness(0) invert(0.93) sepia(0.18);
}

/* Bottom right: MAGI and RMIT, divided by a faint rule. */
#partners {
  position: fixed;
  right: var(--edge-pad);
  bottom: var(--edge-pad);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 1.6vw, 1.4rem);
  pointer-events: none;
}
#partners img { display: block; height: auto; }
.partner-magi { width: clamp(64px, 6.5vw, 104px); opacity: 0.92; }
.partner-rmit { width: clamp(70px, 7vw, 112px); filter: brightness(0) invert(0.93) sepia(0.18); opacity: 0.92; }
.partner-rule {
  width: 1px;
  height: clamp(18px, 2.2vw, 30px);
  background: rgba(244, 236, 216, 0.35);
}

/* Shared link between the cabinet and the students page, top right. */
.page-link {
  position: fixed;
  z-index: 6;
  top: clamp(1rem, 2.5vw, 1.75rem);
  right: clamp(1rem, 3vw, 2.5rem);
  padding: 0.35rem 0;
  border-bottom: 1px solid currentColor;
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.95rem;
  text-decoration: none;
}

.page-link:hover { border-bottom-width: 2px; }

.page-link:focus-visible {
  outline: 2px dashed #f4ecd8;
  outline-offset: 4px;
}

/* The TV's video, laid over the set's glass in 3D. */
.tv-layer {
  position: fixed !important;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
/* The playing video seen through old glass: scan lines, phosphor stripes,
   darkened corners and a faint flicker. The overlay lets clicks through. */
.tv-glass {
  position: relative;
  overflow: hidden;
  border-radius: 6% / 8%;
  background: #000;
  pointer-events: auto;
}
.tv-glass iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  filter: contrast(1.12) saturate(1.15) brightness(1.04);
}
.tv-glass::before,
.tv-glass::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tv-glass::before {
  /* Plain translucent lines rather than a blend mode, which doesn't survive the 3D transform. */
  z-index: 1;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.42) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(to right, rgba(255, 40, 40, 0.07) 0 2px, rgba(40, 255, 40, 0.06) 2px 4px, rgba(40, 40, 255, 0.07) 4px 6px);
  animation: tv-flicker 0.12s steps(2) infinite;
}
.tv-glass::after {
  z-index: 2;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255, 255, 255, 0.08), transparent 40%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.65) 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}
@keyframes tv-flicker {
  to { opacity: 0.88; }
}

.partner-link { pointer-events: auto; display: block; transition: opacity 0.2s ease; }
.partner-link:hover { opacity: 0.7; }
.partner-link:focus-visible { outline: 2px dashed #f4ecd8; outline-offset: 4px; }

/* Social links, small, top left. Add more <a> icons inside .socials as needed. */
.socials {
  position: fixed;
  z-index: 6;
  top: clamp(1rem, 2.5vw, 1.75rem);
  left: var(--edge-pad);
  display: flex;
  gap: 0.75rem;
}
.socials a {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
  color: #f4ecd8;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}
.socials a:hover { opacity: 1; }
.socials a:focus-visible { outline: 2px dashed #f4ecd8; outline-offset: 4px; }
.socials svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.socials svg .dot { fill: currentColor; stroke: none; }

/* Event details beside the Cabinet of Curiosities logo, bottom left. */
#titleblock {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 1.6vw, 1.4rem);
}
.event-rule {
  align-self: stretch;
  width: 1px;
  margin: 0.4rem 0;
  background: rgba(244, 236, 216, 0.35);
}
.event-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0;
  color: rgba(244, 236, 216, 0.75);
  font-family: 'Satoshi', system-ui, sans-serif;
  font-size: clamp(0.72rem, 0.9vw, 0.88rem);
  line-height: 1.35;
}
.event-info strong {
  color: #f4ecd8;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
@media (max-width: 640px) {
  .event-rule, .event-info { display: none; }
}
.event-info a {
  color: #f4ecd8;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  pointer-events: auto;
}
.event-info a:hover { text-decoration-thickness: 2px; }

/* A picked-up object's details, gathered round it: title above, the student
   and a link to their profile below. Positioned each frame from the object. */
.object-halo {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  color: #f4ecd8;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.object-halo.is-shown { opacity: 1; }
.object-halo-title {
  position: absolute;
  left: var(--cx);
  top: var(--top);
  width: max-content;
  max-width: min(80vw, 640px);
  margin: 0;
  font-family: 'Pixelify Sans', ui-monospace, monospace;
  font-size: clamp(1.4rem, 2.6vw, 2.2rem);
  line-height: 1.1;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  translate: -50% calc(-100% - 1rem);
}
.object-halo-below {
  position: absolute;
  left: var(--cx);
  top: var(--bottom);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  width: max-content;
  max-width: min(80vw, 560px);
  translate: -50% 1rem;
}
.object-halo-faces {
  position: absolute;
  right: calc(100vw - var(--left) + 2rem);
  top: var(--cy);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  width: min(30vw, 300px);
  translate: 0 -50%;
}
.object-halo-faces img {
  width: clamp(90px, 11vw, 150px);
  aspect-ratio: 1;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.object-halo-faces:has(img:nth-child(3)) img { width: clamp(70px, 7vw, 100px); }
.object-halo-bios {
  position: absolute;
  left: calc(var(--right) + 2rem);
  top: var(--cy);
  display: grid;
  gap: 1.1rem;
  width: min(30vw, 380px);
  max-height: 80vh;
  overflow: hidden;
  translate: 0 -50%;
  font-family: 'DM Mono', ui-monospace, monospace;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.object-halo-bio h3 { margin: 0; font-size: 0.95rem; font-weight: 500; }
.object-halo-bio p {
  display: -webkit-box;
  margin: 0.35rem 0 0;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 9;
}
.object-halo-bios.is-many .object-halo-bio p { -webkit-line-clamp: 3; }
.object-halo-link {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: #f4ecd8;
  color: #140f1f;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.82rem;
  text-decoration: none;
  pointer-events: auto;
  transition: background 0.2s ease;
}
.object-halo-link:hover { background: #fff; }
.object-halo-below:has(.object-halo-collect) { flex-direction: row; }
.object-halo-collect {
  border: 1px solid #f4ecd8;
  background: transparent;
  color: #f4ecd8;
  cursor: pointer;
}
.object-halo-collect:hover { background: rgba(244, 236, 216, 0.15); }
.object-halo-collect.is-collected { background: rgba(244, 236, 216, 0.15); }

/* The cover while the cabinet loads: the Cabinet of Curiosities logo, with a
   spinning ring circling the "o" of "of". */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(circle 70vmax at 50% 46%, #3a2c56, #0b0814 70%);
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader { grid-auto-flow: row; align-content: center; gap: clamp(1.6rem, 4vh, 2.6rem); }
/* MAGI and RMIT beneath the logo, fading up once the loading fill starts. */
.loader-partners {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.9rem, 1.6vw, 1.4rem);
  opacity: 0;
  translate: 0 6px;
  transition: opacity 0.9s ease, translate 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.loader-partners img { display: block; height: auto; }
.loader.is-started .loader-partners { opacity: 1; translate: 0 0; }
.loader-logo { position: relative; width: clamp(220px, 30vw, 420px); }
.loader-logo img {
  display: block;
  width: 100%;
  height: auto;
  filter: brightness(0) invert(0.93) sepia(0.18);
}
/* The logo's own "o" (with its dot) sits faint in its place and fills in a
   clockwise sweep with real loading progress (--p, 0 to 1). */
.loader-logo { --p: 0; }
.loader-logo .loader-o-dim,
.loader-logo .loader-o { position: absolute; inset: 0; }
.loader-logo .loader-o-dim { opacity: 0.22; }
/* Filled like a clock hand sweeping round from twelve, centred on the o. */
@property --p {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}
.loader-logo { transition: --p 0.4s ease-out; }
.loader-logo .loader-o {
  -webkit-mask-image: conic-gradient(from 0deg at 69.49% 40.58%, #000 calc(var(--p) * 360deg), transparent 0);
  mask-image: conic-gradient(from 0deg at 69.49% 40.58%, #000 calc(var(--p) * 360deg), transparent 0);
}

/* Phones: the held object rises to the top and its details stack beneath it. */
@media (max-width: 760px) and (orientation: portrait) {
  .object-halo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: calc(var(--bottom) + 1rem) 1.25rem 1.5rem;
  }
  .object-halo > * {
    position: static;
    translate: none;
    width: 100%;
    max-width: 30rem;
  }
  .object-halo-title { text-align: center; font-size: 1.5rem; }
  .object-halo-faces { justify-content: center; gap: 0.5rem; }
  .object-halo-faces img,
  .object-halo-faces:has(img:nth-child(3)) img { width: 64px; border-radius: 10px; }
  .object-halo-bios { max-height: none; gap: 0.8rem; text-align: center; }
  .object-halo-bio p { -webkit-line-clamp: 4; }
  .object-halo-bios.is-many .object-halo-bio p { -webkit-line-clamp: 2; }
  .object-halo-below { justify-content: center; align-items: center; }
}

/* Phones: the details under a held object shrink to fit above the logos (set
   from script as --fit), and if they still can't fit the logos fade away. */
@media (max-width: 760px) and (orientation: portrait) {
  .object-halo > * { zoom: var(--fit, 1); }
  #titleblock, #partners { transition: opacity 0.3s ease; }
  body.halo-over-logos #titleblock,
  body.halo-over-logos #partners { opacity: 0; pointer-events: none; }
}

/* Hovering the ringed planet names last year's expo in a small label beside it. */
.socials a.socials-orbit { position: relative; }
.socials-orbit::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 0.6rem);
  top: 50%;
  padding: 0.12em 0.45em;
  background: #000;
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  translate: -4px -50%;
  pointer-events: none;
  transition: opacity 0.2s ease, translate 0.2s ease;
}
.socials-orbit:hover::after,
.socials-orbit:focus-visible::after { opacity: 1; translate: 0 -50%; }

/* Phones: the gesture hint, in the middle of the screen over the cabinet. */
.touch-hint {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 50%;
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  background: rgba(10, 7, 18, 0.78);
  backdrop-filter: blur(6px);
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  translate: -50% calc(-50% + 8px);
  transition: opacity 0.4s ease, translate 0.4s ease;
}
.touch-hint p { margin: 0; }
.touch-hint.is-shown { opacity: 1; translate: -50% -50%; }

/* Phones: asking before leaving for last year's expo site. */
.leave-dialog {
  max-width: min(320px, calc(100vw - 2rem));
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(244, 236, 216, 0.3);
  border-radius: 14px;
  background: #140f1f;
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}
.leave-dialog::backdrop { background: rgba(5, 3, 10, 0.6); }
.leave-dialog p { margin: 0 0 1rem; }
.leave-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.leave-actions button {
  padding: 0.45rem 1rem;
  border: 1px solid #f4ecd8;
  border-radius: 999px;
  background: transparent;
  color: #f4ecd8;
  font: inherit;
  cursor: pointer;
}
.leave-actions .is-go { background: #f4ecd8; color: #140f1f; }

/* Touch screens: the cabinet page never scrolls or pulls to refresh (Android
   Chrome would otherwise take a downward drag for itself), so every drag goes
   to turning the cabinet. */
/* Cabinet page only (it's the page with the 3D scene). styles.css is shared
   with the student page, which must keep scrolling normally. */
html:has(#scene), html:has(#scene) body { overscroll-behavior: none; }
body:has(#scene) { touch-action: none; }

/* Phones: the TV's flat video player, laid over the screen from script. It sits
   under the dimmer and details layers, like the 3D one did. */
.tv-glass.tv-flat {
  position: fixed;
  z-index: 2;
  pointer-events: none;
  transform-origin: 0 0;
}
.tv-glass.tv-flat iframe { pointer-events: none; }

/* The site credit on the logo: a small label above it on hover, focus, or a tap. */
.site-credit {
  position: relative;
  display: block;
  pointer-events: auto;
  cursor: default;
  outline: none;
}
.site-credit::after {
  content: attr(data-label);
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.6rem);
  width: max-content;
  max-width: min(78vw, 360px);
  padding: 0.3em 0.55em;
  background: #000;
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0;
  translate: 0 4px;
  pointer-events: none;
  transition: opacity 0.2s ease, translate 0.2s ease;
}
/* With a mouse the credit follows the cursor instead (.credit-tag, below);
   the label above the logo is for a tap on touch screens and keyboard focus. */
.credit-tag {
  position: fixed;
  z-index: 30;
  left: 0;
  top: 0;
  max-width: min(78vw, 340px);
  padding: 0.3em 0.55em;
  background: #000;
  color: #f4ecd8;
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.credit-tag.is-shown { opacity: 1; }
.site-credit:focus-visible::after,
.site-credit.is-shown::after { opacity: 1; translate: 0 0; }
