/* Neon: near-black, with neon cyan - the mark's own colour - and neon purple, each
   carrying a soft glow. Glows are for the name, edges and buttons; text that has to be
   read stays plain, because glowing small type blurs. */
:root {
  --bg:          #07060d;
  --cyan:        #2ef6ff;
  --purple:      #bc13fe;  /* the 'psy' in the name, so the button is the same purple */
  --purple-deep: #8a0cc4;
  --muted:       #8f8aa8;
  --glow-cyan:   rgba(46, 246, 255, .55);
  --glow-purple: rgba(188, 19, 254, .55);
}

* { box-sizing: border-box; }

/* The page never moves. A finger dragged anywhere - across the buttons too - is the
   grid's to play with, so the browser is told not to scroll, pan or bounce on it; a
   pinch still zooms. Nothing here is taller than the window, so nothing is lost by it. */
html, body {
  height: 100%; overflow: hidden; overscroll-behavior: none;
  touch-action: pinch-zoom;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
html { background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(138, 12, 196, .27), transparent 60%),
    radial-gradient(900px 520px at 100% 30%, rgba(46, 246, 255, .11), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(188, 19, 254, .14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: #d6d3ea;
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

/* The grid (grid.js) between the background and the page. It takes no pointer events:
   grid.js listens on the window, so the page keeps every click. */
.grid { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }

/* The whole page, for now: the mark, the name, the buttons and the version, lit like a
   sign and centred in the window. */
.hero {
  position: relative; z-index: 2;
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 16px; text-align: center;
}
.mark {
  display: block; width: 128px; height: 128px; margin-bottom: 22px;
  filter: drop-shadow(0 0 10px var(--glow-cyan)) drop-shadow(0 0 28px rgba(188, 19, 254, .35));
  animation: breathe 6s ease-in-out infinite;
}
/* Lettered like the mark: a neon colour with a heavy black outline round it, and no
   glow. The stroke is painted under the fill, so it thickens outward and never eats
   into the letters. Cyan is the mark's own #00ffff. */
h1 {
  margin: 0 0 36px; padding: 4px 24px 8px;
  font-size: 52px; font-weight: 700; letter-spacing: .04em; line-height: 1.1;
  -webkit-text-stroke: .14em #000;
  paint-order: stroke fill;
}
h1 .psy { color: var(--purple); }
h1 .browser { color: #00ffff; }

/* [ platform v ] [ Download ]: the box, and the button that fetches what the box says.
   One height for both so they read as one control. */
.download {
  display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap;
  --h: 44px;
}
.select { position: relative; display: inline-block; }
.select::after {
  /* The box's own arrow, drawn here because appearance: none takes the platform's away. */
  content: ""; position: absolute; right: 14px; top: 50%; margin-top: -3px;
  border: 6px solid transparent; border-top-color: var(--cyan); border-bottom: 0;
  filter: drop-shadow(0 0 4px var(--glow-cyan)); pointer-events: none;
}
.select select {
  appearance: none; -webkit-appearance: none;
  height: var(--h); min-width: 170px; padding: 0 42px 0 16px; border-radius: 6px;
  background: rgba(17, 12, 30, .8); color: var(--cyan);
  border: 1px solid rgba(46, 246, 255, .45);
  box-shadow: 0 0 10px rgba(46, 246, 255, .12);
  font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: box-shadow .2s;
}
.select select:hover { box-shadow: 0 0 16px rgba(46, 246, 255, .35), 0 0 40px rgba(46, 246, 255, .12); }
.select select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
/* The open list is drawn by the platform; this is as much of it as can be coloured. */
.select option { background: #110c1e; color: var(--cyan); }

.button {
  display: inline-block; height: var(--h); padding: 0 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple));
  color: #fff; font-family: inherit; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid rgba(228, 150, 255, .55);
  box-shadow: 0 0 14px rgba(188, 19, 254, .5), 0 0 36px rgba(138, 12, 196, .25), inset 0 0 10px rgba(255, 255, 255, .08);
  transition: box-shadow .2s, transform .2s;
}
.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(188, 19, 254, .75), 0 0 52px rgba(138, 12, 196, .4), inset 0 0 12px rgba(255, 255, 255, .12);
}
.button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* In place of the download control on a phone or tablet: the same height and edge as the
   box, lit the same cyan, so the row is a sign rather than a hole. */
.soon {
  margin: 0; height: 44px; padding: 0 22px; border-radius: 6px;
  display: inline-flex; align-items: center;
  font-size: 16px; font-weight: 600; letter-spacing: .3px; color: var(--cyan);
  text-shadow: 0 0 10px rgba(46, 246, 255, .45);
  background: rgba(17, 12, 30, .8);
  border: 1px solid rgba(46, 246, 255, .45);
  box-shadow: 0 0 12px rgba(46, 246, 255, .18), 0 0 36px rgba(188, 19, 254, .12);
}
/* Sent to every Mac in case it is an iPad, and shown only if it is one. */
.only-touch { display: none; }

/* The page starts as the background and one round button in the corner, on every
   device; the button brings the page up and takes it away again. Only with scripts
   running - ui.js marks the document - so that without them the page is simply shown. */
.opener { display: none; }
.js .opener {
  display: grid; place-items: center;
  position: fixed; right: 24px; bottom: 24px; z-index: 3;
  width: 56px; height: 56px; padding: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple));
  color: #fff; cursor: pointer;
  border: 1px solid rgba(228, 150, 255, .55);
  box-shadow: 0 0 14px rgba(188, 19, 254, .5), 0 0 36px rgba(138, 12, 196, .25), inset 0 0 10px rgba(255, 255, 255, .08);
  transition: box-shadow .2s, transform .2s;
}
.js .opener:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(188, 19, 254, .75), 0 0 52px rgba(138, 12, 196, .4), inset 0 0 12px rgba(255, 255, 255, .12);
}
.opener:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.opener svg {
  width: 26px; height: 26px;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.opener .close, .opener[aria-expanded="true"] .get { display: none; }
.opener[aria-expanded="true"] .close { display: block; }

.js .hero.closable { transition: opacity .25s ease, visibility .25s; }
.js .hero.closable:not(.open) { opacity: 0; visibility: hidden; }

/* An iPad that says it is a Mac: the message in the download's place, as on any other
   tablet. */
@media (hover: none) and (pointer: coarse) {
  .mac .only-touch { display: inline-flex; }
  .mac .download { display: none; }
}

.version {
  margin: 22px 0 0; padding: 2px 12px; border-radius: 999px;
  font-size: 14px; color: #fff;
  /* A backing of its own, because the grid lights up behind it and small grey type
     has nothing to spare against a lit cell. */
  background: rgba(7, 6, 13, .85);
}

/* The copyright, on every view, open or shut: a pill like the version's in light grey,
   centred on the bottom of the window and lifted off it by half its own height. */
.footer {
  position: fixed; left: 50%; bottom: 0; z-index: 2;
  transform: translate(-50%, -50%);
  padding: 2px 12px; border-radius: 999px; white-space: nowrap;
  font-size: 14px; color: #c8c8c8;
  background: rgba(7, 6, 13, .85);
}

/* Across the top of the window, on every view, open or shut: a square for each of the
   grid's modes, in the order a right click goes round them, the one it is in filled and
   any other a click away - lowered off the top by half its own height, as the copyright
   is lifted off the bottom. Glass: the box's own dark tint, thinner, over the grid
   blurred, so the neon behind still shows through, and the filled one the box's cyan the
   same way. Which is filled is aria-pressed, which grid.js moves with the mode and
   index.php sets first. Only with scripts running, because without them there is no grid
   to switch.
   Everything that dresses a square is on the square itself, never on the row: a filter
   or an opacity on the row would cut each square's glass off from the grid behind it. */
.modes { display: none; }
.js .modes {
  display: flex; gap: 10px;
  position: fixed; left: 50%; top: 0; z-index: 3;
  transform: translate(-50%, 50%);
}
.mode {
  appearance: none; -webkit-appearance: none;
  display: block; width: 22px; height: 22px; padding: 0; border-radius: 5px; cursor: pointer;
  background-color: rgba(17, 12, 30, .45);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0) 55%);
  -webkit-backdrop-filter: blur(6px) saturate(1.5); backdrop-filter: blur(6px) saturate(1.5);
  border: 1px solid rgba(46, 246, 255, .45);
  box-shadow: 0 0 10px rgba(46, 246, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: background-color .25s, border-color .25s, box-shadow .25s;
}
.mode:hover { box-shadow: 0 0 16px rgba(46, 246, 255, .35), 0 0 40px rgba(46, 246, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .14); }
.mode:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.mode[aria-pressed="true"] {
  cursor: default;
  background-color: rgba(46, 246, 255, .6);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(46, 246, 255, .55), 0 0 32px rgba(46, 246, 255, .2), inset 0 1px 0 rgba(255, 255, 255, .3);
}

/* In the light, every piece of the page wears a black glow that breathes, about half as
   deep as the stained band grid.js holds along its edges. A filter's shadow follows what
   is drawn, so the icon glows round its outline and the name round its letters rather
   than round their boxes. */
[data-grid="light"] :is(.opener, .mode, .mark, h1, .select, .button, .soon, .version, .footer) {
  animation: shade 6s ease-in-out infinite;
}

@keyframes shade {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(0, 0, 0, .7)) drop-shadow(0 0 9px rgba(0, 0, 0, .45)); }
  50%      { filter: drop-shadow(0 0 4px rgba(0, 0, 0, .9)) drop-shadow(0 0 15px rgba(0, 0, 0, .75)); }
}

/* In the deep, the name, the version and the footer each sit in a little still night of
   their own - a softer edge on the clear band grid.js keeps round them - so the stars
   crowding round the page never quite reach them. Still, because the sky moves and the page
   does not. Not the icon, which keeps its own breathing glow, nor the buttons and the box:
   a filter's shadow follows their neon glow out as far as it reaches, and would have laid a
   dark ring that wide round each, under the glow itself. */
[data-grid="deep"] :is(h1, .version, .footer) {
  filter: drop-shadow(0 0 4px rgba(3, 3, 10, .9)) drop-shadow(0 0 10px rgba(3, 3, 10, .55));
}

/* While the grid plays by itself (grid.js's show), the page steps aside: everything on it
   fades out, and takes no clicks, so the first touch that ends the show cannot press a
   button nobody can see. It fades back over the same 1.5s - SHOW_FADE in grid.js - under
   data-show="waking", and then the page's own transitions are its own again. */
html[data-show] :is(.opener, .mode, .hero.closable, .footer) { transition: opacity 1.5s ease, visibility 1.5s; }
html[data-show="on"] :is(.opener, .mode, .hero.closable, .footer) { opacity: 0; visibility: hidden; pointer-events: none; }

@keyframes breathe {
  0%, 100% { filter: drop-shadow(0 0 10px var(--glow-cyan)) drop-shadow(0 0 28px rgba(188, 19, 254, .35)); }
  50%      { filter: drop-shadow(0 0 16px rgba(46, 246, 255, .75)) drop-shadow(0 0 40px rgba(188, 19, 254, .5)); }
}

@media (prefers-reduced-motion: reduce) {
  .mark { animation: none; }
  [data-grid="light"] :is(.opener, .mode, .mark, h1, .select, .button, .soon, .version, .footer) {
    animation: none;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, .8)) drop-shadow(0 0 12px rgba(0, 0, 0, .6));
  }
  .button, .select select, .js .opener, .js .hero.closable, .mode { transition: none; }
  .button:hover, .js .opener:hover { transform: none; }
}

@media (max-width: 560px) {
  h1 { font-size: 40px; }
  .mark { width: 96px; height: 96px; }
}

/* A phone on its side: the page cannot scroll, so it has to fit. */
@media (max-height: 520px) {
  .hero { padding: 12px 16px; }
  .mark { width: 64px; height: 64px; margin-bottom: 10px; }
  h1 { font-size: 34px; margin-bottom: 18px; }
  .version { margin-top: 12px; }
}
