/* jpreilly.me. One page: the visitor's sky, JP's mark, and four corners of small type. */

@font-face {
  font-family: Geist;
  src: url("/fonts/geist.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

/* The sky and the inks are set by theme.js from the visitor's sun and weather; registered so they
   can animate. */
@property --sky-top { syntax: "<color>"; inherits: true; initial-value: #F5F3EE; }
@property --sky-bottom { syntax: "<color>"; inherits: true; initial-value: #F5F3EE; }
@property --ink { syntax: "<color>"; inherits: true; initial-value: #141821; }
@property --ink-top { syntax: "<color>"; inherits: true; initial-value: #141821; }
@property --ink-bottom { syntax: "<color>"; inherits: true; initial-value: #141821; }

:root {
  --sky-top: #F5F3EE;
  --sky-bottom: #F5F3EE;
  --ink: #141821;
  --ink-top: #141821;
  --ink-bottom: #141821;
  /* The mark's height (src/scene reads it). */
  --mark: clamp(170px, min(40vh, 60vw), 360px);
  /* The open globe (src/globe.js sets it, to a whole number of pixels). */
  --globe: clamp(240px, min(56vh, 88vw), 560px);
  --edge: clamp(18px, 2.3vw, 32px);
  --quiet: 0.64;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* theme.js eases the sky itself; the inks, which flip at dusk and dawn, ease here. */
.settled { transition: --ink 3s ease, --ink-top 3s ease, --ink-bottom 3s ease; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--sky-bottom); }
/* The sky. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(var(--sky-top), var(--sky-bottom));
}
body {
  color: var(--ink);
  font: 500 11px/1.35 Geist, "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  font-feature-settings: "tnum", "case";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}
::selection { background: var(--ink); color: var(--sky-top); }
h1, p { margin: 0; font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── The layers, back to front: the sky's dome, the night's layer, the clouds, the birds, the flat
   mark or the sculpture, what falls, lightning's flash, the type, the globe. (Where two share a
   z-index, the later in the page is in front.) ── */
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* The dome (src/scene/dome.js): the sky as light in air, over the two-color sky above, which stays
   as the first paint and for a browser without WebGL. It comes in softly once the scene is running. */
#scene-sky { z-index: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s ease; }
.live #scene-sky { opacity: 1; }
/* The night's layer (src/weather/): the stars, the moon, wind you can see. */
#weather-back { z-index: 0; pointer-events: none; }
/* The scene (src/scene/): its clouds first, then the birds far off, the sculpture, and what falls. */
#scene-vapor, #scene-particles, #scene-sculpture, #scene-fall { z-index: 1; pointer-events: none; }
/* The flat mark. Without JavaScript or WebGL, or if the sculpture can't be made, it is the mark, in
   ink (.flat: src/main.js). Otherwise it isn't shown: the sculpture hangs where it would be. */
.still {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1;
  height: var(--mark);
  width: auto;
  transform: translate(-50%, -50%);
  fill: var(--ink);
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.js:not(.flat) .still { opacity: 0; }

/* ── The four corners. ── */
.frame {
  position: fixed;
  z-index: 3;
  inset:
    max(var(--edge), env(safe-area-inset-top))
    max(var(--edge), env(safe-area-inset-right))
    max(var(--edge), env(safe-area-inset-bottom))
    max(var(--edge), env(safe-area-inset-left));
  display: grid;
  grid-template: "name clock" auto ". ." 1fr "links caption" auto / 1fr auto;
  align-items: start;
  pointer-events: none;
}
.frame > * { transition: opacity 1s ease, transform 1s var(--ease-out); }
/* The corners fade in once the page is ready (only with JavaScript; without it they're simply there). */
.js:not(.ready) .frame > * { opacity: 0; transform: translateY(5px); animation: corners 1s ease 3s forwards; }
@keyframes corners { to { opacity: 1; transform: none; } }
.ready .frame > :nth-child(1) { transition-delay: 0.35s; }
.ready .frame > :nth-child(2) { transition-delay: 0.45s; }
.ready .frame > :nth-child(3) { transition-delay: 0.6s; }
.ready .frame > :nth-child(4) { transition-delay: 0.7s; }

/* Tracking adds space after the last letter; pull right-aligned text back to the edge. */
.clock, .caption { margin-right: -0.055em; }
/* (Without JavaScript there is no time to tell. The 404's "404" has no id, and stays.) */
:root:not(.js) #clock { visibility: hidden; }

.name { grid-area: name; color: var(--ink-top); }

.clock {
  grid-area: clock;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.62em;
  color: var(--ink-top);
  text-align: right;
  cursor: default;
}
.clock-text { position: relative; display: block; white-space: nowrap; pointer-events: auto; }
.clock .where { opacity: var(--quiet); }
/* At home the small globe stands for the word; gone somewhere else, the place is named. */
.clock:not(.away) .clock-now .where { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.clock-now, .clock-alt { display: block; transition: opacity 0.35s ease, transform 0.35s var(--ease-out); }
.clock-alt {
  position: absolute;
  right: 0;
  top: 0;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none; /* it is wider than the time, and lies over the globe: never in the pointer's way */
}
/* (Its credit, below, can be reached from the time without letting go of the hover.) */
.clock-alt small::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 8px; }
/* Hovering the time shows JP's weather in Austin in its place; the globe steps aside for it. */
.clock.has-alt .clock-text:hover .clock-now, .clock.has-alt .clock-text:focus-within .clock-now { opacity: 0; transform: translateY(-3px); }
.clock.has-alt .clock-text:hover .clock-alt, .clock.has-alt .clock-text:focus-within .clock-alt { opacity: 1; transform: none; }
.clock.has-alt:has(.clock-text:hover) :is(.seed, .back), .clock.has-alt:has(.clock-text:focus-within) :is(.seed, .back) { opacity: 0; }
@supports not selector(:has(*)) {
  .clock.has-alt .clock-text .clock-now { opacity: 1; transform: none; }
  .clock.has-alt .clock-text .clock-alt { display: none; }
}

/* The small globe (src/seed.js), the size of a capital and a half, centered on the capitals. */
.seed, .back { all: unset; position: relative; pointer-events: auto; cursor: pointer; transition: opacity 0.35s ease, transform 0.35s var(--ease-out); }
.seed[hidden], .back[hidden] { display: none; }
.seed { display: block; flex: none; width: 1.36em; height: 1.36em; top: -0.03em; border-radius: 50%; }
.seed canvas { position: static; }
.seed::after, .back::after { content: ""; position: absolute; inset: -13px -9px; border-radius: 50%; }
.seed:hover { transform: scale(1.14); }
.seed:focus-visible, .back:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
/* The way back from somewhere else. */
.back { opacity: var(--quiet); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; margin-right: 0.5em; }
.back:hover, .back:focus-visible { opacity: 1; }
/* The colon breathes, softly, every two seconds. */
.colon { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.5; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.links {
  grid-area: links;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 1.55em;
  color: var(--ink-bottom);
}
.links a {
  position: relative;
  display: block;
  white-space: nowrap;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}
.links .quiet { opacity: var(--quiet); margin-right: 0.52em; }
/* The marks. Base's letters are the height of the page's capitals and sit on their baseline; the
   others are centered on its frame, each sized to weigh about the same to the eye. */
.mark { display: inline-block; width: auto; height: 1.2em; vertical-align: -0.245em; fill: currentColor; overflow: visible; }
.mark.base { height: 1.31em; vertical-align: -0.3em; }
.mark.x { height: 1.16em; vertical-align: -0.225em; }
.mark.in { height: 1.18em; vertical-align: -0.235em; }
.mark.mail { height: 1.1em; vertical-align: -0.195em; }
.mark .line { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
/* A finger needs more room than the marks take. */
@media (pointer: coarse) {
  .links { column-gap: 2.6em; }
  .links a::before { content: ""; position: absolute; inset: -14px -1.2em; }
}
/* Hovering one link quiets the others and shows where it goes. */
.links:hover a:not(:hover), .links:focus-within a:not(:focus-visible) { opacity: 0.4; }
.links small {
  position: absolute;
  left: 0;
  bottom: calc(100% + 7px);
  font-size: inherit;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-out);
  pointer-events: none;
}
.links a:hover small, .links a:focus-visible small, .links a.copied small { opacity: var(--quiet); transform: none; }
a:focus-visible { outline: 1px solid currentColor; outline-offset: 5px; border-radius: 1px; }

/* The 404's own line ("Turned around · nothing here"). The home page says nothing about its sky. */
.caption {
  grid-area: caption;
  align-self: end;
  color: var(--ink-bottom);
  text-align: right;
  white-space: nowrap;
}
.caption .quiet { opacity: var(--quiet); }
/* Credit for the weather, under Austin's: shown on hover, like the links' details. */
.clock-alt small {
  position: absolute;
  right: 0;
  font-size: inherit;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-out);
  pointer-events: none;
}
.clock-alt small { top: calc(100% + 7px); }
.clock-text:hover .clock-alt small, .clock-text:focus-within .clock-alt small { opacity: var(--quiet); transform: none; pointer-events: auto; }
.clock-alt small a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* Phones: the 404's line moves up under its "404", so the links have the bottom to themselves. */
@media (max-width: 600px) {
  .frame { grid-template: "name clock" auto "caption caption" auto ". ." 1fr "links links" auto / 1fr auto; }
  .caption { align-self: start; margin-top: 6px; color: var(--ink-top); white-space: normal; text-wrap: balance; max-width: 78vw; justify-self: end; }
}

@media (min-width: 1700px) and (min-height: 900px) {
  body { font-size: 12px; }
  :root { --edge: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .frame > *, .still, .clock-now, .clock-alt, .links small, .seed, .back, .globe, .globe canvas { transition: none; }
  .js:not(.ready) .frame > * { animation-duration: 0s; }
  .colon { animation: none; }
}

/* Printed, the page is a calling card. */
@media print {
  @page { size: 3.5in 2in; margin: 0; }
  html, body { background: #fff !important; height: auto; overflow: visible; }
  body { color: #141821; font-size: 7pt; }
  body::before, canvas { display: none; }
  /* (On screen the flat mark is hidden while the sculpture is up; on the card it is the mark.) */
  .still { position: absolute; top: 0.32in; left: 0.32in; transform: none; height: 0.62in; fill: #14213D; opacity: 1 !important; }
  .frame { position: absolute; inset: 0.3in; display: block; }
  *, .frame > * { transition: none !important; animation: none !important; }
  .frame > * { opacity: 1 !important; transform: none !important; }
  .name { position: absolute; left: 0; bottom: 0; font-weight: 600; color: #141821; }
  .clock, .caption { display: none; }
  .links { position: absolute; right: 0; top: 0; bottom: 0; flex-direction: column; justify-content: flex-end; align-items: flex-end; gap: 2pt; color: #141821; }
  .links a span, .links .mark, .globe { display: none; }
  .links small { position: static; opacity: 0.62 !important; transform: none; line-height: 1.35; }
  .lost .still { display: none; }
}

/* ── The globe, open (src/globe.js): the Earth where the JP hangs, and a few places by name. ── */
.globe {
  position: fixed;
  inset: 0;
  z-index: 4;
  color: var(--ink);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0s 0.45s;
}
[data-globe="open"] .globe { opacity: 1; visibility: visible; transition-delay: 0s; }
.globe:focus { outline: none; }
.globe canvas {
  inset: auto;
  left: calc(50% - var(--globe) / 2);
  top: calc(50% - var(--globe) / 2);
  width: var(--globe);
  height: var(--globe);
  border-radius: 50%;
  transform: scale(0.94);
  transition: transform 0.7s var(--ease-out);
  touch-action: none;
  cursor: grab;
}
[data-globe="open"] .globe canvas { transform: none; }
.globe canvas.aim { cursor: pointer; }
.globe canvas.held { cursor: grabbing; }
.globe canvas:focus-visible { outline: 1px solid currentColor; outline-offset: -3px; }
.globe-foot {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  top: calc(50% + var(--globe) / 2 - 2px);
  display: grid;
  justify-items: center;
  gap: 11px;
  text-align: center;
}
/* With no globe to show (no WebGL), the names stand under the flat mark. */
.globe.plain .globe-foot { top: calc(50% + var(--mark) / 2 + 26px); }
.globe-label { min-height: 1.35em; transition: opacity 0.3s ease; }
.globe-label.hint { opacity: var(--quiet); }
.globe-places { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px 1.5em; max-width: 70em; margin: 0; padding: 0; list-style: none; }
.globe-ways { display: flex; justify-content: center; gap: 1.8em; }
.globe button { all: unset; position: relative; cursor: pointer; opacity: var(--quiet); transition: opacity 0.25s ease; }
.globe button[hidden] { display: none; }
.globe button::after { content: ""; position: absolute; inset: -6px -0.7em; }
.globe button:hover, .globe button:focus-visible, .globe button[aria-current] { opacity: 1; }
.globe button:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
.globe-ways button { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* While it is open the corners step back. */
[data-globe="open"] .frame > * { opacity: 0.38; transition-delay: 0s; }
@media (pointer: coarse) { .globe-places { gap: 14px 1.9em; } .globe-foot { gap: 16px; } }

/* Lightning: the sky brightens for a moment, most at the top. */
.flash {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(120% 90% at 50% -10%, rgba(240, 244, 255, 0.9), rgba(240, 244, 255, 0) 70%);
}
@media print { .flash { display: none; } }

/* Not found: the same sky, the mark upside down. (No page script here, so no fade.) */
.js:not(.ready) .lost .frame > * { opacity: 1; transform: none; }
.lost .still, .js:not(.flat) .lost .still { transform: translate(-50%, -50%) rotate(180deg); height: calc(var(--mark) * 0.6); fill: var(--ink); opacity: 1; }
.lost .name a, .lost .links a { pointer-events: auto; }
