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

:root {
  --gap: 12px;
  --ink: #1a1a1a;
  --bg: #fff;
  /* Secondary text: project titles, captions, coming-soon */
  --muted: #a3a3a3;
  /* 1px outlines and media placeholders */
  --line: #c4c4c4;
  /* The frame's rule lines and the spaces they enclose: one grey */
  --rule: #ececec;
  color-scheme: light;
}

/* What the spaces are filled with: the same grey as the lines. Set to
   var(--bg) to show only the lines. */
:root {
  --space: var(--bg);
}

/* Dark: follows the system until someone picks a theme with the nav's switch,
   which sets data-theme on <html> (see app.html and ProjectNav) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #c8c8c8;
    --bg: #111;
    --muted: #7a7a7a;
    --line: #3d3d3d;
    --rule: #1d1d1d;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --ink: #c8c8c8;
  --bg: #111;
  --muted: #7a7a7a;
  --line: #3d3d3d;
  --rule: #1d1d1d;
  color-scheme: dark;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
figure {
  margin: 0;
  font-size: inherit;
  font-weight: normal;
}

h1 {
  font-size: 13px;
}

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

a:hover {
  text-decoration: underline;
}

img,
video {
  max-width: 100%;
}

/* --- Frame ----------------------------------------------------------------
   Up to three spaces, each a rect given as distances from the viewport
   edges. The nav and page content are placed by these; Frame.svelte's lines
   follow animated copies of them (see .frame below).
   A layout with fewer spaces stacks the spare slots on a neighbour. */
@property --s1-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s1-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s1-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s1-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s2-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s2-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s2-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s2-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s3-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s3-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s3-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --s3-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}

:root {
  /* How long content waits for the frame to open before fading in */
  --reveal-delay: calc(var(--frame-dur) - 200ms);
  /* Space between a space's lines and the content inside it */
  --pad: 16px;
  /* Between media blocks, and between the images within one */
  --gutter: 5px;
  /* The floating cards' width (the bars, the project's info, the bottom
     card): 350px; on narrow screens, see below */
  --card-w-default: 350px;
  --card-w: min(var(--card-w-default), calc(100vw - 4 * var(--gutter)));
  /* One line of text plus its padding: the collapsed nav row and the band */
  --row: calc(1.3 * 12px + 8px);
  /* easeInOutQuint, as the nav */
  --frame-ease: cubic-bezier(0.83, 0, 0.17, 1);
  --frame-dur: 700ms;
}

/* Narrow screens: the cards span the window less a gutter each side, as
   wide as the project's media */
@media (max-width: 640px) {
  :root {
    --card-w: calc(100vw - 2 * var(--gutter));
  }
}

/* Only the frame animates. Content reads the --s vars, which switch
   instantly (it is faded out while the lines move), so nothing re-lays out
   per frame. The frame copies them into --a vars that transition, and moves
   its lines with transform, which the GPU handles without layout. */
@property --a1-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a1-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a1-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a1-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a2-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a2-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a2-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a2-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a3-t {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a3-r {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a3-b {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
@property --a3-l {
  syntax: '<length>';
  inherits: true;
  initial-value: 0px;
}
/* A space can also be turned about its centre (the contact card) */
@property --s1-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
@property --s2-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
@property --s3-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
@property --a1-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
@property --a2-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}
@property --a3-rot {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}

.frame {
  --a1-t: var(--s1-t);
  --a1-r: var(--s1-r);
  --a1-b: var(--s1-b);
  --a1-l: var(--s1-l);
  --a2-t: var(--s2-t);
  --a2-r: var(--s2-r);
  --a2-b: var(--s2-b);
  --a2-l: var(--s2-l);
  --a3-t: var(--s3-t);
  --a3-r: var(--s3-r);
  --a3-b: var(--s3-b);
  --a3-l: var(--s3-l);
  --a1-rot: var(--s1-rot);
  --a2-rot: var(--s2-rot);
  --a3-rot: var(--s3-rot);
  transition:
    --a1-t var(--frame-dur) var(--frame-ease),
    --a1-r var(--frame-dur) var(--frame-ease),
    --a1-b var(--frame-dur) var(--frame-ease),
    --a1-l var(--frame-dur) var(--frame-ease),
    --a2-t var(--frame-dur) var(--frame-ease),
    --a2-r var(--frame-dur) var(--frame-ease),
    --a2-b var(--frame-dur) var(--frame-ease),
    --a2-l var(--frame-dur) var(--frame-ease),
    --a3-t var(--frame-dur) var(--frame-ease),
    --a3-r var(--frame-dur) var(--frame-ease),
    --a3-b var(--frame-dur) var(--frame-ease),
    --a3-l var(--frame-dur) var(--frame-ease),
    --a1-rot var(--frame-dur) var(--frame-ease),
    --a2-rot var(--frame-dur) var(--frame-ease),
    --a3-rot var(--frame-dur) var(--frame-ease);
}

.stage,
.frame,
[data-layout='home'],
[data-layout='index'],
[data-layout='information'] {
  --s1-t: 16px;
  --s1-r: 25vw;
  --s1-b: 16px;
  --s1-l: 25vw;
  --s2-t: 16px;
  --s2-r: 25vw;
  --s2-b: 16px;
  --s2-l: 25vw;
  --s3-t: 16px;
  --s3-r: 25vw;
  --s3-b: 16px;
  --s3-l: 25vw;
}

[data-layout='intro'],
[data-layout='newsletter'] {
  --s1-t: calc(50dvh - var(--row) / 2);
  --s1-r: 33.333vw;
  --s1-b: calc(50dvh - var(--row) / 2);
  --s1-l: 33.333vw;
  --s2-t: calc(50dvh - var(--row) / 2);
  --s2-r: 33.333vw;
  --s2-b: calc(50dvh - var(--row) / 2);
  --s2-l: 33.333vw;
  --s3-t: calc(50dvh - var(--row) / 2);
  --s3-r: 33.333vw;
  --s3-b: calc(50dvh - var(--row) / 2);
  --s3-l: 33.333vw;
}

/* Project: the media alone, one centred space (the page less 398px) */
:root {
  --project-side: 199px;
}

[data-layout='project'] {
  --s1-t: 16px;
  --s1-r: var(--project-side);
  --s1-b: 16px;
  --s1-l: var(--project-side);
  --s2-t: 16px;
  --s2-r: var(--project-side);
  --s2-b: 16px;
  --s2-l: var(--project-side);
  --s3-t: 16px;
  --s3-r: var(--project-side);
  --s3-b: 16px;
  --s3-l: var(--project-side);
}

/* Contact: one space, a business card (85 x 55 mm, landscape) turned 35
   degrees about its centre; no header. Sized so the turned card still fits:
   its upright bounding box is about 1.19 x 1.10 the card's width. */
[data-layout='contact'] {
  --card-w: min(45vw, 72dvh);
  --card-h: calc(var(--card-w) * 55 / 85);
  --card-rot: 35deg;
  --s1-t: calc((100dvh - var(--card-h)) / 2);
  --s1-r: calc((100vw - var(--card-w)) / 2);
  --s1-b: calc((100dvh - var(--card-h)) / 2);
  --s1-l: calc((100vw - var(--card-w)) / 2);
  --s1-rot: var(--card-rot);
  --s2-t: calc((100dvh - var(--card-h)) / 2);
  --s2-r: calc((100vw - var(--card-w)) / 2);
  --s2-b: calc((100dvh - var(--card-h)) / 2);
  --s2-l: calc((100vw - var(--card-w)) / 2);
  --s2-rot: var(--card-rot);
  --s3-t: calc((100dvh - var(--card-h)) / 2);
  --s3-r: calc((100vw - var(--card-w)) / 2);
  --s3-b: calc((100dvh - var(--card-h)) / 2);
  --s3-l: calc((100vw - var(--card-w)) / 2);
  --s3-rot: var(--card-rot);
}

@media (max-width: 575px) {
  [data-layout='contact'] {
    --card-w: min(80vw, 72dvh);
  }
}

/* The default: a cross through the centre, no space open. The page starts
   here and every navigation closes back to it. */
[data-layout='rest'] {
  --s1-t: 50dvh;
  --s1-r: 50vw;
  --s1-b: 50dvh;
  --s1-l: 50vw;
  --s2-t: 50dvh;
  --s2-r: 50vw;
  --s2-b: 50dvh;
  --s2-l: 50vw;
  --s3-t: 50dvh;
  --s3-r: 50vw;
  --s3-b: 50dvh;
  --s3-l: 50vw;
}

/* Content placed in a space */
/* Part of the page, so the page itself scrolls: placed where the space
   is, with its top and bottom offsets added to the padding */
.space {
  margin: 0 var(--s1-r) 0 var(--s1-l);
  /* Clears the header (itself --pad below the top line) by another --pad */
  padding: calc(var(--s1-t) + 2 * var(--pad) + var(--row)) var(--pad)
    calc(var(--s1-b) + var(--pad));
}

/* Narrow screens: one space only */
@media (max-width: 575px) {
  :is(.stage, .frame)[data-layout]:not([data-layout='rest'], [data-layout='contact']) {
    --s1-t: 8px;
    --s1-r: 8px;
    --s1-b: 8px;
    --s1-l: 8px;
    --s2-t: 8px;
    --s2-r: 8px;
    --s2-b: 8px;
    --s2-l: 8px;
    --s3-t: 8px;
    --s3-r: 8px;
    --s3-b: 8px;
    --s3-l: 8px;
  }

  :is(.stage, .frame)[data-layout]:is([data-layout='intro'], [data-layout='newsletter']) {
    --s1-t: calc(50dvh - var(--row) / 2);
    --s1-r: 8px;
    --s1-b: calc(50dvh - var(--row) / 2);
    --s1-l: 8px;
    --s2-t: calc(50dvh - var(--row) / 2);
    --s2-r: 8px;
    --s2-b: calc(50dvh - var(--row) / 2);
    --s2-l: 8px;
    --s3-t: calc(50dvh - var(--row) / 2);
    --s3-r: 8px;
    --s3-b: calc(50dvh - var(--row) / 2);
    --s3-l: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage[data-layout] {
    --reveal-delay: 0ms;
  }

  .stage[data-layout] .frame {
    transition: none;
  }
}
