/* ---------- Fonts (put your licensed files in assets/fonts/) ---------- */
@font-face {
  font-family: "Bradford Mono LL";
  src: local("Bradford Mono LL"), local("BradfordMonoLL-Regular"),
       url("../assets/fonts/BradfordMonoLL-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Grey LL";
  src: local("Grey LL Medium"), local("GreyLL-Medium"),
       url("../assets/fonts/GreyLL-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --stripe-white: #e2e2e2;
  --paper: rgb(243, 243, 234);
  --ink: #101010;
  --hover: #cacaca;             /* teal: hover colour */
}

* { box-sizing: border-box; }

html { background-color: var(--stripe-white); }   /* fallback while images load / if they fail */

/* ---------- Background: full-screen flashing images ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bg .pane {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 100%;
  overflow: hidden;
}
.bg.two .pane { width: 50%; }                 /* landscape: two columns */
.bg.two .pane + .pane { left: 50%; }
.bg img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: .96;                    /* same 96% on every image, to even out the tones */
  visibility: hidden;              /* hard cut, no fade: a flash */
  -webkit-user-drag: none;
  user-select: none;
}
.bg img.on { visibility: visible; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Bradford Mono LL", ui-monospace, Menlo, monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
h1, h2 { font-family: "Grey LL", Helvetica, Arial, sans-serif; font-weight: 500; }
h1, h2, p { margin: 0; }

/* ---------- Screensaver ship: drifts behind the card, bounces off the screen edges ---------- */
.drifter {
  position: fixed;
  left: 0; top: 0;
  z-index: 0;
  width: clamp(44px, 9vw, 88px);
  height: auto;
  opacity: 0;                      /* shown by JS once it has a position */
  /* mix-blend-mode: multiply;        the white of the png disappears into the background */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.drifter.on { opacity: 1; }

/* ---------- Home: the flipping card ---------- */
.stage {
  position: relative;
  z-index: 1;                      /* above the ship */
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  perspective: 2400px;
  overflow: hidden;               /* the card grows a little mid-flip: never let it widen the page */
  overflow: clip;
}
@media (hover: none) {
  .stage, .card-flip { cursor: pointer; }   /* iOS only reports taps on "clickable" things */
}

.card-flip {
  position: relative;
  --w: min(88vw, 760px);
  --u: calc(var(--w) / 100);      /* 1% of the card width (replaces cqw, safer on iOS) */
  width: var(--w);
  aspect-ratio: 7 / 4;            /* 3.5 × 2 in business card */
  will-change: transform;
  transform-style: preserve-3d;
  transform: rotate(-1.5deg);      /* placed slightly off-square, like on a scanner bed */
  transition: transform .9s cubic-bezier(.3, .1, .2, 1);
  cursor: default;
}
/* flip: click / tap adds .is-flipped; keyboard focus also flips */
.card-flip.is-flipped,
.card-flip:has(.back-face :focus-visible) {
  transform: rotate(-1.2deg) rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(7 * var(--u));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: calc(.4 * var(--u));
  background-color: var(--paper);
  box-shadow:
    0 calc(.3 * var(--u)) calc(.6 * var(--u)) rgba(40, 10, 50, .1),
    0 calc(0.4 * var(--u)) calc(1 * var(--u)) rgba(10, 10, 10, .1);
}
/* never show the mirrored text of the other side */
.face,
.face * {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* iOS Safari can leak the mirrored text through backface-visibility while the card is turning,
   so each face is also switched off by hand at the moment the card is edge-on (~30% of the .9s flip).
   Same delay in both directions: front -> back and back -> front. */
.front { transition: visibility 0s linear .29s; }
.card-flip.is-flipped .front,
.card-flip:has(.back-face :focus-visible) .front { visibility: hidden; }

.back-face { opacity: 0; transition: opacity 0s linear .29s; }   /* opacity (not visibility) so the links stay focusable by keyboard */
.card-flip.is-flipped .back-face,
.card-flip:has(.back-face :focus-visible) .back-face { opacity: 1; }

/* faint scanner streak */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  /* background: linear-gradient(100deg, transparent 40%, rgba(255,255,255,.2) 48%, transparent 55%); */
}

/* front: name | details in two columns, small, top left (turns teal on hover; click the card to flip) */
.front {
  justify-content:center;
  align-items: stretch;
  padding: calc(8 * var(--u));
  transform: translateZ(1px);
  cursor: grab;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.info {
  display: grid;
  grid-template-columns: 1fr max-content;   /* name | details */
  column-gap: calc(4 * var(--u));
  font-size: calc(2.5 * var(--u));
  line-height: 1.2;
  transition: color .15s;
}
.info p { font-family: "Bradford Mono LL", 'Times New Roman', Times, serif}
.info .name {
  font-family: "Bradford Mono LL", 'Times New Roman', Times, serif;
  font-weight: 500;
  font-size: calc(3.2 * var(--u));
}
.info a { transition: color .15s; }
@media (hover: hover) {
  .front:hover .info { color: var(--hover); }
}
.front-img { pointer-events: none; -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.front-img {
  position: absolute;
  top: calc(2 * var(--u));
  left: calc(2 * var(--u));
  width: calc(100% - calc(4 * var(--u)));
  height: calc(100% - calc(4 * var(--u)));
  object-fit: cover;
  display: block;
}

/* back: about on top, P I R A T E straight along the bottom */
.back-face {
  transform: rotateY(180deg) translateZ(1px);
  justify-content: space-between;
  padding: calc(3 * var(--u));
  pointer-events: none;           /* the hidden side must not catch taps */
}
.card-flip.is-flipped .back-face,
.card-flip:has(.back-face :focus-visible) .back-face { pointer-events: auto; }

.back-face .about { text-align: left; }
.quote {
  font-family: 'Times New Roman', Times, serif;
  font-size: calc(2.76 * var(--u));      /* smaller than before: the text now shares the card with P I R A T E */
  line-height: 1.2;
  /* letter-spacing: -.01em; */
}

/* big letters + dots spread across the full width of the card */
.back-face nav {
  --pirate: calc(9 * var(--u));
  display: flex;
  justify-content: space-between;
  font-family: "Bradford Mono LL", 'Times New Roman', Times, serif;
  font-weight: 500;
  font-size: var(--pirate);
  line-height: .8;
  letter-spacing: -.03em;
}
.back-face nav a {
  display: inline-block;
  text-decoration: underline;               /* so phone users can see the letters are links */
  text-decoration-thickness: .05em;
  text-underline-offset: .08em;
}

/* hover: only the colour changes, the underline stays */
.back-face a {
  text-decoration: none;
  transition: color .15s;
}
.back-face a:focus-visible { color: var(--hover); }
@media (hover: hover) {
  .back-face a:hover { color: var(--hover); }
}

/* ---------- Footer: credit left, live clocks right ---------- */
.site-foot {
  font-family:Arial, Helvetica, sans-serif;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 0 max(200px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom)) max(200px, env(safe-area-inset-left));
  font-size: 14px;
  line-height: 1;
  pointer-events: none;
  color: #fff;
  mix-blend-mode: difference;      /* stays readable on light and dark images */
}
.site-foot .clocks { text-align: left; }
.site-foot time { font-variant-numeric: tabular-nums; }

/* ---------- Phones: card stays a 7:4 business card, text sizes tuned to stay readable ---------- */
@media (max-width: 800px) {
  .stage { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
                    max(40px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .card-flip { --w: min(96vw, calc((100dvh - 80px) * 1.75)); }
  .front { padding: calc(6 * var(--u)); }
  .info { font-size: max(12px, calc(3.5 * var(--u))); column-gap: calc(3 * var(--u)); }
  .info .name { font-size: max(13px, calc(3.8 * var(--u))); }
  .back-face { padding: calc(3 * var(--u)); }
  .quote { font-size: max(11.5px, calc(3.3 * var(--u))); line-height: 1.17; }
  .back-face nav { --pirate: calc(8 * var(--u)); }
  .site-foot { font-size: 11px; padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .card-flip { transition-duration: .02s; }
  .front, .back-face { transition-delay: .01s; }
}
