/* ————————————————————————————————————————————————
   Tokens
   ———————————————————————————————————————————————— */
:root {
  --paper:   #ffffff;
  --paper-lo:#f1f0ee;
  --ink:     #161410;
  --muted:   #6c665c;
  --faint:   #9a9387;

  --card-hair:   rgba(22, 20, 16, .07);  /* hairline, so white pages don't melt into the white background */
  --card-shade1: rgba(22, 20, 16, .04);
  --card-shade2: rgba(22, 20, 16, .14);
  --underline:   rgba(22, 20, 16, .28);

  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --sans:  "Inter Tight", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(18px, 2.3vw, 34px);
}

/* Dark when the system is dark (left.html sets its own palette further down) */
@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0b0b0b;
    --paper-lo:#161616;
    --ink:     #f2f2f0;
    --muted:   rgba(242, 242, 240, .72);
    --faint:   rgba(242, 242, 240, .45);

    --card-hair:   rgba(255, 255, 255, .08);
    --card-shade1: rgba(0, 0, 0, .35);
    --card-shade2: rgba(0, 0, 0, .6);
    --underline:   rgba(242, 242, 240, .4);
  }
}

/* ————————————————————————————————————————————————
   Base — one screen, no scroll
   ———————————————————————————————————————————————— */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--ink); color: var(--paper); }

.hero {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
}

/* ————————————————————————————————————————————————
   Title + subtext
   ———————————————————————————————————————————————— */
.center {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 var(--gutter);
  pointer-events: none;
}

.title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.85rem, 7.2vw, 8.6rem);
  line-height: .92;
  letter-spacing: -0.012em;
  font-kerning: normal;
  text-wrap: balance;
  pointer-events: auto;
}

.title em,
.title .word--italic {
  font-style: italic;
}

/* CEATE: grotesk, all caps, set big — the blunter sibling.
   Letter spacing is set pair by pair in main.js (NAMES.ceate.pairs). */
.title--sans {
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(3.6rem, 10.5vw, 12rem);
  line-height: .8;
  letter-spacing: 0;
  text-transform: uppercase;
}

.word { display: inline-block; white-space: nowrap; }
.char { display: inline-block; }

.sub {
  margin: clamp(16px, 2.4vh, 26px) 0 0;
  max-width: 34ch;
  font-size: clamp(13px, 1.02vw, 15.5px);
  line-height: 1.55;
  letter-spacing: .004em;
  color: var(--muted);
  text-wrap: balance;
  pointer-events: auto;
}

.sub .line { display: block; }
.sub--para { max-width: 44ch; text-wrap: pretty; } /* a paragraph rather than a two-line tagline */

/* Portrait screens: stack the name onto two balanced lines */
@media (max-aspect-ratio: 4/5) {
  .title       { font-size: clamp(2.85rem, 15vw, 5.5rem); max-width: 4.4em; line-height: .9; }
  .title--sans { font-size: clamp(3.4rem, 18vw, 6.75rem); max-width: none; line-height: .8; }
  .sub         { max-width: 30ch; }
  .sub--para   { max-width: 36ch; }
}

/* ————————————————————————————————————————————————
   Ring of work
   ———————————————————————————————————————————————— */
.ring {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.card {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  border-radius: 1px;
  background: var(--paper-lo);
  pointer-events: auto;
  transform-origin: 50% 50%;
  will-change: transform;
  box-shadow:
    0 0 0 1px var(--card-hair),
    0 1px 2px var(--card-shade1),
    0 6px 16px -10px var(--card-shade2);
}

.card a { display: block; height: 100%; }

.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  color: transparent; /* if a photo ever fails, show a quiet blank card, not alt text */
  user-select: none;
  -webkit-user-drag: none;
}

/* ————————————————————————————————————————————————
   Corner details
   ———————————————————————————————————————————————— */
.corners { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

.corner {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: .7em;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  pointer-events: auto;
  white-space: nowrap;
}

.corner--bl { bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); left:  calc(var(--gutter) + env(safe-area-inset-left)); }
.corner--br { bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); right: calc(var(--gutter) + env(safe-area-inset-right)); }

.mark {
  width: 20px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
}

.link {
  color: var(--muted);
  text-decoration: none;
}

button.link {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

/* Contact, centred under the subtext */
.center .contact {
  margin-top: clamp(22px, 3.4vh, 34px);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  text-decoration-color: var(--underline);
  pointer-events: auto;
}
.link:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

/* ————————————————————————————————————————————————
   Intro choreography
   Everything waits (hidden) until fonts + photos are ready,
   then main.js adds .is-ready to <html>.
   ———————————————————————————————————————————————— */
.no-js .ring { display: none; }

.js .title,
.js .char,
.js .sub,
.js .contact,
.js .corner,
.js .card { opacity: 0; }

.js.is-ready .title,
.js.is-ready .contact,
.js.is-ready .char,
.js.is-ready .sub,
.js.is-ready .corner { opacity: 1; }

/* Each letter pulls into focus, converging from the outside in */
.is-ready .char {
  animation: focus-in 1.9s var(--ease-out) backwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes focus-in {
  from {
    opacity: 0;
    filter: blur(16px);
    transform: translate3d(calc(var(--d, 0) * .55em), .1em, 0) scale(1.08);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: none;
  }
}

.is-ready .sub {
  animation: rise-in 1.5s var(--ease-out) 1.25s backwards;
}

.is-ready .contact {
  animation: rise-in 1.5s var(--ease-out) 1.55s backwards;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); filter: blur(6px); }
  to   { opacity: 1; transform: none;             filter: blur(0); }
}

.is-ready .corner {
  animation: fade-in 1.4s ease 2.7s backwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .is-ready .char,
  .is-ready .sub,
  .is-ready .contact,
  .is-ready .corner {
    animation: fade-in .9s ease .1s backwards;
  }
}

/* ————————————————————————————————————————————————
   Left-aligned version (left.html)
   Just the text, top left, with the email under it, with no intro, on a faint square grid whose lines
   run along the text's left edge (its size comes from gridLayout()). Light or
   dark with the system. A veil of the page colour builds up from the left, so
   the grid dissolves towards the right.
   ———————————————————————————————————————————————— */
[data-layout="grid"] {
  --paper: #ffffff;
  --paper-rgb: 255 255 255; /* same colour, for the veil */
  --ink: #161410;
  --line: rgba(22, 20, 16, .065);
  --cell: max(56px, 6vw); /* replaced by gridLayout() so the lines meet the margins */
  --pad: clamp(20px, 4vw, 72px);
  --inset: clamp(14px, 1.5vw, 28px); /* room between the first grid lines and the text */
}

@media (prefers-color-scheme: dark) {
  [data-layout="grid"] {
    --paper: #090b0b; /* near black with a cool cast */
    --paper-rgb: 9 11 11;
    --ink: #f6f7f7;
    --line: rgba(255, 255, 255, .06);
  }
}

[data-layout="grid"] .hero {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: var(--pad) var(--pad); /* a line exactly at the margins */
}

/* The veil: clear over the left quarter, then the page colour builds up until
   only a trace of the grid is left. It lies over the text too, so the far end
   of a long line dims a touch (clicks pass straight through it). */
[data-layout="grid"] .hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(to right,
    rgb(var(--paper-rgb) / 0) 24%,
    rgb(var(--paper-rgb) / .89) 63%);
}

[data-layout="grid"] .center {
  inset: auto;
  top: calc(var(--pad) + env(safe-area-inset-top));
  left: calc(var(--pad) + env(safe-area-inset-left));
  width: calc(clamp(340px, 31vw, 600px) + var(--inset));
  padding: var(--inset) 0 0 var(--inset); /* the box (and so the grid) stays on the margin; only the text moves in */
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
}

/* The title is a sentence, set like text: sans, regular, a size up from the paragraph */
[data-layout="grid"] .title {
  text-box: trim-start cap alphabetic; /* cap height sits on the top grid line (where supported) */
  font-family: var(--sans);
  font-weight: 400;
  font-size: clamp(18px, 1.45vw, 27px);
  line-height: 1.33;
  letter-spacing: 0;
  max-width: none;
  text-wrap: pretty;
  color: var(--ink);
}

[data-layout="grid"] .sub {
  margin-top: 2em;
  max-width: none;
  font-size: clamp(14px, 1vw, 17px);
  line-height: 1.43;
  letter-spacing: 0;
  text-wrap: pretty;
  color: var(--ink); /* same colour as the title, no grey */
}

/* Email, right under the paragraph, written out and underlined; clicking copies it. */
[data-layout="grid"] .contact {
  margin-top: 1.43em; /* one blank line under the paragraph */
  padding-left: 0;
  font-size: clamp(14px, 1vw, 17px);
  font-weight: 400;
  line-height: 1.43;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: currentColor; /* a solid underline, same colour as the text */
}

/* No intro here: the text is simply there once the font has loaded */
[data-layout="grid"].is-ready .sub,
[data-layout="grid"].is-ready .contact { animation: none; }

@media (max-aspect-ratio: 4/5) {
  [data-layout="grid"] .center { width: calc(100vw - var(--pad) * 2); }
  [data-layout="grid"] { --inset: 12px; }
  [data-layout="grid"] .title  { font-size: clamp(19px, 5.1vw, 22px); }
  [data-layout="grid"] .sub,
  [data-layout="grid"] .contact { font-size: 15px; }

  /* Phones: the text runs the full width, so the veil goes under it and only
     fades the grid. */
  [data-layout="grid"] .hero::after {
    z-index: 1;
    background: linear-gradient(to right,
      rgb(var(--paper-rgb) / 0) 30%,
      rgb(var(--paper-rgb) / .85) 100%);
  }
}
