@property --accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #efede7;
}

:root {
  --bg: #fbfaf7;
  --ink: #131312;
  --muted: #5f5d58;
  --faint: #8a8882;
  --rule: #e1ded6;
  --accent: #131312;
  --hot: color-mix(in srgb, var(--accent) 62%, #000);
  --blend: source-over;

  --term-bg: #0f0f0e;
  --term-fg: #e9e7e1;
  --term-dim: #85837d;
  --term-rule: #292826;

  --gutter: clamp(1.25rem, 4.5vw, 6rem);
  --measure: clamp(36rem, 34vw, 50rem);

  --sans: Archivo, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;

  transition: --accent .4s ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a09;
    --ink: #efede7;
    --muted: #a3a19a;
    --faint: #6e6c66;
    --rule: #242321;
    --accent: #efede7;
    --hot: var(--accent);
    --blend: lighter;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a09;
  --ink: #efede7;
  --muted: #a3a19a;
  --faint: #6e6c66;
  --rule: #242321;
  --accent: #efede7;
  --hot: var(--accent);
  --blend: lighter;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}

::selection {
  background: var(--hot);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 3px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* full width on big screens, with a gutter that grows with the window */
.wrap {
  position: relative;
  max-width: 150rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* top bar */

.bar {
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.5rem 0;
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--muted);
}

.portrait {
  display: block;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  transition: transform .2s ease;
}

.portrait:hover { transform: rotate(-6deg) scale(1.06); }

.bar nav {
  margin-left: auto;
  display: flex;
  gap: 1.5rem;
}

.bar button:hover { color: var(--ink); }

kbd {
  font: inherit;
  font-size: .75rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 .3rem;
  margin-right: .4rem;
}

/* two columns: the page on the left, the stage on the right */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 11fr) minmax(0, 10fr);
  gap: 0 4rem;
}

.page {
  grid-column: 1;
  grid-row: 1;
  padding-top: 8.5rem;
}

.stage {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  padding: 5rem 0 2rem;
  color: var(--hot);
}

.viewport {
  position: relative;
  height: 100%;
  --c: var(--faint);
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / 14px 1px,
    linear-gradient(var(--c), var(--c)) 0 0 / 1px 14px,
    linear-gradient(var(--c), var(--c)) 100% 0 / 14px 1px,
    linear-gradient(var(--c), var(--c)) 100% 0 / 1px 14px,
    linear-gradient(var(--c), var(--c)) 0 100% / 14px 1px,
    linear-gradient(var(--c), var(--c)) 0 100% / 1px 14px,
    linear-gradient(var(--c), var(--c)) 100% 100% / 14px 1px,
    linear-gradient(var(--c), var(--c)) 100% 100% / 1px 14px;
  background-repeat: no-repeat;
}

.viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
}

.viewport canvas:active { cursor: grabbing; }

.count,
.caption {
  position: absolute;
  left: 1.1rem;
  margin: 0;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
  pointer-events: none;
}

.count { top: .9rem; }

.caption {
  right: 1.1rem;
  bottom: .9rem;
  line-height: 1.5;
}

.caption b {
  font-weight: 400;
  color: var(--hot);
  margin-right: .9rem;
}

/* hero */

.hero { padding: 0 0 3.5rem; }

h1 {
  margin: 0 0 2rem;
  font-size: clamp(2.4rem, 5.4vw, 8rem);
  font-weight: 650;
  font-stretch: 125%;
  line-height: .92;
  letter-spacing: -.04em;
}

h1 span {
  display: block;
  animation: rise .7s cubic-bezier(.2, .7, .2, 1) both;
}

h1 span + span { animation-delay: .08s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(.18em); }
}

.facts {
  list-style: none;
  margin: 0 0 2.25rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem 1.5rem;
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--muted);
}

.age {
  color: var(--ink);
  cursor: help;
  border-bottom: 1px dotted var(--faint);
}

.prose p {
  margin: 0 0 1.1rem;
  max-width: var(--measure);
  color: var(--muted);
}

.prose p:last-child { margin-bottom: 0; }

.prose .lede {
  font-size: clamp(1.2rem, 1.45vw, 1.9rem);
  line-height: 1.42;
  letter-spacing: -.01em;
  color: var(--ink);
}

.prose a {
  color: inherit;
  text-decoration: none;
  padding: 0 .1em;
  margin: 0 -.1em;
  background: linear-gradient(var(--hot), var(--hot)) no-repeat 0 100% / 100% 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size .18s ease, color .18s ease;
}

.prose a:hover {
  background-size: 100% 100%;
  color: var(--bg);
}

/* sections */

section { padding: 3rem 0; }

h2 {
  margin: 0 0 1.5rem;
  font-family: var(--mono);
  font-size: .8125rem;
  font-weight: 400;
  color: var(--muted);
}

/* projects */

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--rule);
}

.projects li { position: relative; }

.projects .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem 1rem;
  align-items: baseline;
  padding: 1.5rem 0 1.6rem;
  border-top: 1px solid var(--rule);
  color: inherit;
  text-decoration: none;
  transition: opacity .2s ease;
}

.projects .body {
  grid-row: 2;
  grid-column: 1 / 3;
}

.projects h3,
.out a {
  margin: 0;
  font-size: clamp(1.4rem, 2.1vw, 2.75rem);
  font-weight: 620;
  font-stretch: 112%;
  line-height: 1.15;
  letter-spacing: -.025em;
}

.projects h3 { transition: color .25s ease; }

.projects h3::before {
  content: "";
  display: inline-block;
  width: 0;
  height: .5em;
  margin-right: 0;
  vertical-align: .06em;
  background: var(--hot);
  transition: width .25s cubic-bezier(.2, .7, .2, 1), margin .25s cubic-bezier(.2, .7, .2, 1);
}

.projects .row.on h3 { color: var(--hot); }

.projects .row.on h3::before {
  width: .5em;
  margin-right: .4em;
}

@media (hover: hover) {
  .projects li { transition: opacity .2s ease; }
  .projects:hover li:not(:hover) { opacity: .42; }
}

.badge {
  display: inline-block;
  margin-left: .35rem;
  padding: .1rem .4rem;
  vertical-align: .35em;
  font-family: var(--mono);
  font-size: .7rem;
  font-style: normal;
  font-weight: 400;
  font-stretch: 100%;
  letter-spacing: 0;
  color: var(--hot);
  border: 1px solid currentColor;
  border-radius: 3px;
}

.also {
  position: absolute;
  right: 0;
  bottom: 1.6rem;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  text-decoration: none;
}

.also:hover { color: var(--hot); }

/* the same links as the footer, small, under the intro */
.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.5rem;
  margin-top: 1.75rem;
  font-family: var(--mono);
  font-size: .8125rem;
}

.elsewhere a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color .15s ease, border-color .15s ease;
}

.elsewhere a:hover {
  color: var(--ink);
  border-color: var(--hot);
}

.projects p {
  margin: 0 0 .5rem;
  max-width: var(--measure);
  color: var(--muted);
}

.stack,
.when {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--faint);
}

.when {
  white-space: nowrap;
  color: var(--muted);
}

/* footer */

footer { padding: 3rem 0 2.5rem; }

.out {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 2.25rem;
}

.out a {
  color: inherit;
  text-decoration: none;
}

.out a span {
  padding: 0 .14em;
  margin: 0 -.14em;
  background: linear-gradient(var(--hot), var(--hot)) no-repeat 0 0 / 0 100%;
  transition: background-size .28s cubic-bezier(.2, .7, .2, 1), color .15s ease;
}

.out a:hover span {
  background-size: 100% 100%;
  color: var(--bg);
}

.fine {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 1.5rem;
  margin-top: 3.5rem;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--faint);
}

.fine button:hover { color: var(--ink); }

/* shell */

.shell-bg {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1.25rem;
  background: rgba(0, 0, 0, .5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.shell-bg[open] { display: flex; }

.shell {
  width: 100%;
  max-width: 44rem;
  height: min(27rem, 72vh);
  display: flex;
  flex-direction: column;
  background: var(--term-bg);
  color: var(--term-fg);
  border: 1px solid var(--term-rule);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: .8125rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}

.shell-bar {
  display: flex;
  justify-content: space-between;
  padding: .55rem .875rem;
  border-bottom: 1px solid var(--term-rule);
  color: var(--term-dim);
  font-size: .75rem;
}

.shell-bar button:hover { color: var(--term-fg); }

.shell-scroll {
  flex: 1;
  overflow-y: auto;
  padding: .875rem;
  line-height: 1.55;
}

.shell-out { white-space: pre-wrap; }

.shell-out div { color: var(--term-dim); }
.shell-out .echo { color: var(--term-fg); }
.shell-out .plain { color: var(--term-fg); }
.shell-out .hl { color: var(--accent); }
.shell-out .err { color: #ee8a84; }

.shell-prompt {
  display: flex;
  gap: .5rem;
  align-items: baseline;
  padding: .55rem .875rem .8rem;
  border-top: 1px solid var(--term-rule);
}

.shell-prompt span { color: var(--accent); }

.shell-prompt input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  outline: none;
  padding: 0;
  caret-color: var(--accent);
}

/* the shell is always dark, so it wants the light version of the accent */
:root[data-theme="light"] .shell { --accent: #efede7; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-palette]) .shell { --accent: #efede7; }
}

/* status line */

.status {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 110;
  max-width: calc(100vw - 2.5rem);
  padding: .45rem .7rem;
  font-family: var(--mono);
  font-size: .75rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 4px;
  opacity: 0;
  transform: translateY(.4rem);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}

.status[data-on] {
  opacity: 1;
  transform: none;
}

/* return by death */

.veil {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: #000;
  opacity: 0;
  pointer-events: none;
  animation: veil .8s ease-out;
}

@keyframes veil {
  0%, 30% { opacity: 1; }
}

/* matsumoto */

.cube {
  position: fixed;
  left: 2rem;
  bottom: 4rem;
  z-index: 90;
  width: 24px;
  height: 24px;
  cursor: pointer;
  transform-style: preserve-3d;
  animation: spin 7s linear infinite;
}

.cube i {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1.5px solid var(--ink);
}

.cube i:nth-child(1) {
  transform: translateZ(12px);
  background: radial-gradient(circle, #4de1ff 0 3px, var(--ink) 3.5px 5px, var(--bg) 5.5px);
}
.cube i:nth-child(2) { transform: rotateY(180deg) translateZ(12px); }
.cube i:nth-child(3) { transform: rotateY(90deg) translateZ(12px); }
.cube i:nth-child(4) { transform: rotateY(-90deg) translateZ(12px); }
.cube i:nth-child(5) { transform: rotateX(90deg) translateZ(12px); }
.cube i:nth-child(6) { transform: rotateX(-90deg) translateZ(12px); }

.cube i.mark {
  background: var(--mark) center / 15px 21px no-repeat, var(--bg);
  image-rendering: pixelated;
}

@keyframes spin {
  from { transform: rotateX(-22deg) rotateY(0); }
  to { transform: rotateX(-22deg) rotateY(360deg); }
}

html.glitch .wrap {
  animation: glitch 1s steps(1) both;
}

@media (prefers-reduced-motion: reduce) {
  html.glitch .wrap { filter: invert(1) drop-shadow(4px 0 #ff2a5c) drop-shadow(-4px 0 #4de1ff); }
}

@keyframes glitch {
  0%   { transform: none; clip-path: none; filter: none; }
  8%   { transform: translate(-8px, 2px) skewX(10deg); clip-path: inset(12% 0 58% 0); filter: drop-shadow(4px 0 #ff2a5c) drop-shadow(-4px 0 #4de1ff); }
  16%  { transform: translate(10px, -3px); clip-path: inset(40% 0 22% 0); }
  26%  { transform: translate(-3px, 0) skewX(-14deg); clip-path: inset(0 0 74% 0); filter: invert(1) drop-shadow(-6px 0 #ff2a5c); }
  38%  { transform: translate(6px, 4px); clip-path: inset(66% 0 6% 0); filter: drop-shadow(6px 0 #4de1ff); }
  50%  { transform: translate(-12px, -2px) scaleY(1.04); clip-path: inset(28% 0 44% 0); filter: invert(1); }
  62%  { transform: translate(4px, 0); clip-path: inset(8% 0 8% 0); filter: drop-shadow(-3px 0 #ff2a5c) drop-shadow(3px 0 #4de1ff); }
  74%  { transform: translate(-6px, 3px) skewX(6deg); clip-path: inset(52% 0 30% 0); }
  86%  { transform: translate(2px, -1px); clip-path: inset(0); filter: drop-shadow(2px 0 #ff2a5c); }
  100% { transform: none; clip-path: none; filter: none; }
}

/* alternate palettes */

:root[data-palette="fontaine"] {
  --bg: #070d1a;
  --ink: #e8f0fb;
  --muted: #8b9bb4;
  --faint: #56688a;
  --rule: #1b2d49;
  --accent: #9fd0ff;
  --hot: var(--accent);
  --blend: lighter;
  --term-bg: #0a1426;
  --term-rule: #1b2d49;
}

/* furina's two scenes, only present while the fontaine theme is on */
.banner {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 11px;
  animation: surface .8s ease both;
}

.banner-header { margin: 0 0 2.5rem; }
.banner-footer { margin: 2.5rem 0 0; }

@keyframes surface {
  from { opacity: 0; transform: translateY(.6rem); }
}

/* bad apple behind everything. difference keeps the text readable on both
   the black and the white parts of the video */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  mix-blend-mode: difference;
  filter: blur(6px) contrast(24);
  opacity: 0;
  transition: opacity .5s ease;
}

.backdrop.on { opacity: 1; }

/* fushi */
html.held { overflow: hidden; }

.vessel {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
  color: var(--hot);
  opacity: 0;
  transition: opacity .4s ease;
}

.vessel.on { opacity: 1; }

.vessel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* the pieces fushi pulls in. the rules and link underlines fade instead of
   flying, since they aren't pieces of their own */
.bh { display: inline-block; }

.projects,
.projects .row,
.prose a { transition: border-color .6s ease, background-size .6s ease; }

html.emptied .projects,
html.emptied .projects .row { border-color: transparent; }

html.emptied .prose a { background-size: 0 0; }


:root[data-palette="onebit"] {
  --bg: #000;
  --ink: #fff;
  --muted: #fff;
  --faint: #fff;
  --rule: #fff;
  --accent: #fff;
  --hot: #fff;
  --blend: source-over;
  --term-bg: #000;
  --term-fg: #fff;
  --term-dim: #fff;
  --term-rule: #fff;
}

:root[data-palette="onebit"] .portrait { filter: grayscale(1) contrast(4); }

/* small screens: the stage becomes a band pinned to the top */

/* on very wide screens everything else grows a step too */
@media (min-width: 110rem) {
  body { font-size: 1.1875rem; }
  .bar, h2, .facts, .elsewhere, .stack, .when, .also, .fine { font-size: .875rem; }
  .count, .caption { font-size: .8125rem; }
}

@media (max-width: 60rem) {
  .wrap { padding: 0 1.25rem; }

  .bar {
    position: static;
    padding: 1.1rem 0;
  }

  .layout { display: block; }

  /* main.js moves the stage into the project list, so it only pins while
     you're scrolling through projects */
  .stage {
    top: 0;
    z-index: 5;
    height: 40vh;
    height: 40svh;
    min-height: 15rem;
    max-height: 26rem;
    margin: 0 -1.25rem;
    padding: .5rem 1.25rem .6rem;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
  }

  .count, .caption { font-size: .6875rem; }
  .count { top: .6rem; left: .75rem; }
  .caption { left: .75rem; right: .75rem; bottom: .6rem; }

  .page { padding-top: 1.5rem; }

  h1 { font-size: clamp(2.6rem, 13vw, 6rem); }
  .facts { margin-bottom: 1.75rem; }
  .prose .lede { font-size: 1.1875rem; }

  .hero { padding-bottom: 1.5rem; }
  section { padding: 2rem 0; }
  #projects h2 { margin-bottom: 1rem; }
  .projects .row { padding: 1.3rem 0 1.4rem; }
  .projects p { font-size: 1rem; }
  .also { position: static; display: block; margin: -.6rem 0 1.3rem; }
  .badge { vertical-align: .2em; }
  .out { gap: .5rem 1.5rem; }
  .banner-header { margin-bottom: 1.75rem; }
  .fine { margin-top: 2.75rem; }
  .cube { bottom: 1.25rem; left: auto; right: 1.25rem; }
  .backdrop { filter: blur(3px) contrast(24); }
}

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

@media print {
  .stage, .bar nav, .shell-bg, .status, .cube, .backdrop, .vessel { display: none; }
  .layout { display: block; }
  .fine::after { content: "printed from the internet. bold choice."; }
}
