/* The explore page. Visitors arrive from a fully white screen, so this page is
   always white, whatever their color scheme. Separate from style.css on
   purpose: this room looks nothing like the writing site. */

:root {
  color-scheme: only light;

  --ink: #141414;
  --muted: #6e6e6e;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #fff;
  font-family: var(--font);
  font-size: 100%;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
}

/* With the script running the page is one fixed room: nothing scrolls. */
.js,
.js body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* What each category looks like from the outside. Used by the squares, the
   small swatch on an opened cube and the cube's outer faces. To add a
   category, add one rule here and a <section data-kind="..."> in index.html.
   A category without a rule falls back to plain ink. */
.sq,
.swatch,
.out {
  background: var(--ink);
}

/* Technical writing: graph paper */
.k-technical {
  background: #2443d6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M16 0v64M32 0v64M48 0v64M0 16h64M0 32h64M0 48h64' fill='none' stroke='%23fff' stroke-opacity='.55'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Literary writing: lines on a page */
.k-literary {
  background: #e2442b url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M13 20h38M13 28h30M13 36h38M13 44h18' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Research: data points */
.k-research {
  background: #141414 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M14 14h.01M26 14h.01M38 14h.01M50 14h.01M14 26h.01M26 26h.01M38 26h.01M50 26h.01M14 38h.01M26 38h.01M38 38h.01M50 38h.01M14 50h.01M26 50h.01M38 50h.01M50 50h.01' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Projects: a plain weave, each line broken where it passes under another */
.k-project {
  background: #f4b41a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M16 0V12M16 20V44M16 52V64M32 0V28M32 36V64M48 0V12M48 20V44M48 52V64M0 16H28M36 16H64M0 32H12M20 32H44M52 32H64M0 48H28M36 48H64' fill='none' stroke='%23141414' stroke-width='2.5'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Experience: straight rays spreading from one corner */
.k-experience {
  background: #1e9a5a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M0 64L64 50M0 64L64 28M0 64L64 0M0 64L36 0M0 64L14 0' fill='none' stroke='%23fff' stroke-width='2.5'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* About: hollow, with one point inside */
.k-about {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect x='1' y='1' width='62' height='62' fill='%23fff' stroke='%23141414' stroke-width='2'/%3E%3Ccircle cx='32' cy='32' r='4' fill='%23141414'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Competitions: arcs from the middle of one side, like rows of seats round a
   floor */
.k-competitions {
  background: #6b3fd4 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M22 64A10 10 0 0 1 42 64M12 64A20 20 0 0 1 52 64M2 64A30 30 0 0 1 62 64M-8 64A40 40 0 0 1 72 64M-18 64A50 50 0 0 1 82 64' fill='none' stroke='%23fff' stroke-width='1.5'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* The color each category lends to its opened cube */
.is-technical { --kc: #2443d6; }
.is-literary { --kc: #e2442b; }
.is-research { --kc: #141414; }
.is-project { --kc: #8f6400; }
.is-experience { --kc: #157a46; }
.is-about { --kc: #141414; }
.is-competitions { --kc: #6b3fd4; }

/* Interests, top left. Hidden until squares.js adds .on, when the last square
   has landed; then it fades in. Squares pass in front of it. */
.interests {
  margin: 0;
  padding: 1.25rem 1.5rem;
  list-style: none;
}

/* Every line ends with " &", and the last with a full stop. On a screen too
   short for the whole list, squares.js marks the last line shown as .end. */
.interests li::after {
  content: " &";
}

.interests li:last-child::after,
.interests li.end::after {
  content: ".";
}

.js .interests {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 1.6s ease;
}

.js .interests.on {
  opacity: 1;
}

.swatch {
  flex: none;
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* The room. Only the squares themselves take the pointer. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.sq {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--s);
  height: var(--s);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  transform: translate3d(-200vw, 0, 0);
  will-change: transform;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.sq.held {
  z-index: 1;
  cursor: grabbing;
}

.sq.away {
  visibility: hidden;
}

/* The title that floats beside a square under the mouse */
.tag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 3;
  padding: 0.15rem 0.4rem;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.tag.on {
  opacity: 1;
}

/* An opened square. The room whitens behind it. */
.veil {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #fff;
  opacity: 0;
}

/* The cube is a point at its own center; squares.js moves, turns and scales
   it. Six faces hang off it: the base, four sides hinged to the base, and a
   lid hinged to the far edge of one side. Each face has an inside (.in, what
   the unfolded cube shows) and an outside (.out, the category's look). */
.cube {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  width: 0;
  height: 0;
  font-size: clamp(10.5px, calc(var(--f) * 0.066), 15px);
  line-height: 1.3;
  transform-style: preserve-3d;
}

.face {
  position: absolute;
  width: var(--f);
  height: var(--f);
  transform-style: preserve-3d;
}

.base {
  left: calc(var(--f) / -2);
  top: calc(var(--f) / -2);
}

.f-top {
  left: 0;
  top: calc(var(--f) * -1);
  transform-origin: 50% 100%;
}

.f-bottom {
  left: 0;
  top: var(--f);
  transform-origin: 50% 0;
}

.f-left {
  left: calc(var(--f) * -1);
  top: 0;
  transform-origin: 100% 50%;
}

.f-right,
.lid.on-right {
  left: var(--f);
  top: 0;
  transform-origin: 0 50%;
}

.lid.on-bottom {
  left: 0;
  top: var(--f);
  transform-origin: 50% 0;
}

.face > .in,
.face > .out {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Insides overlap their neighbor by a pixel so shared edges are one line */
.face > .in {
  right: -1px;
  bottom: -1px;
  display: flex;
  flex-direction: column;
  padding: calc(var(--f) * 0.08);
  overflow: hidden;
  border: 1px solid var(--ink);
  background: #fff;
}

.face > .out {
  transform: rotateY(180deg);
}

/* The lid is the face seen while the cube is shut; keep its look upright */
.lid.on-bottom > .out {
  transform: rotateX(180deg);
}

/* Flat shading, so the shut cube reads as a solid while it turns */
.face > .out::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0.2;
}

.lid > .out::after { opacity: 0; }
.f-top > .out::after { opacity: 0.08; }
.f-right > .out::after { opacity: 0.16; }
.f-left > .out::after { opacity: 0.26; }
.f-bottom > .out::after { opacity: 0.34; }

.cube h2,
.cube p {
  margin: 0;
  font-size: 1em;
  font-weight: 400;
}

.cube .c-title {
  font-size: 1.22em;
  line-height: 1.2;
}

.f-top > .in {
  justify-content: flex-end;
}

.c-kind {
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: var(--kc);
  text-transform: lowercase;
}

.c-kind .swatch {
  width: 0.8em;
  height: 0.8em;
}

.c-date,
.c-note {
  color: var(--muted);
}

/* The links and the close button each fill a whole face */
.c-act,
.c-close {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 0;
  padding: calc(var(--f) * 0.08);
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.c-act span,
.c-close span {
  align-self: flex-end;
  font-size: 1.9em;
  line-height: 1;
}

/* A link on the left face points back the way: its arrow sits on the left */
.c-side span {
  align-self: flex-start;
}

.c-act {
  color: var(--kc);
}

/* Filled only while the pointer is on the face. Keyboard focus is shown
   differently, by a ring just inside the face's edge, so that a face holding
   focus never looks as if the pointer were still on it. */
.c-act:hover {
  background: var(--kc);
  color: #fff;
}

.c-close:hover {
  background: var(--ink);
  color: #fff;
}

.c-act:focus-visible,
.c-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -7px;
}

.cube:focus {
  outline: none;
}

/* Without JavaScript: the same entries as a plain list */
.items {
  max-width: 65ch;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.js .items {
  display: none;
}

.items h2 {
  margin: 2rem 0 0.5rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
}

.items ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.items li {
  padding: 0.5rem 0;
}

.items .title,
.items time,
.items .desc {
  display: block;
}

.items time,
.items .desc,
.items .note {
  color: var(--muted);
  font-size: 0.9rem;
}

.items a {
  color: var(--ink);
  font-size: 0.9rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 40em) {
  .interests {
    padding: 1rem 1.25rem;
  }

  .items {
    padding-inline: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .interests {
    transition: none;
  }
}
