/* Sahody: one page, one big idea.
   The logo's six letters are the hero. Choosing a site floods the page with that person's colour. */

:root {
  color-scheme: dark light;

  --bg: #000;
  --fg: #fff;
  --muted: #b8b8b8;
  --line: rgba(255, 255, 255, 0.28);

  --vishal: rgb(0, 0, 0);
  --vishal-fg: rgb(255, 255, 255);
  --emma: rgb(245, 240, 234);
  --emma-fg: rgb(109, 64, 86);

  --focus: #ffc21a;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font: ui-sans-serif, "Helvetica Neue", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --pad: clamp(1.25rem, 4vw, 3rem);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fff;
    --fg: #000;
    --muted: #4d4d4d;
    --line: rgba(0, 0, 0, 0.3);
    --focus: #2b50ff;
  }
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--fg);
  background: transparent;
  overflow-x: hidden;
  transition: color 0.45s var(--ease);
}

/* When a site is previewed the flood changes the text colour so contrast always holds */
body[data-flood="vishal"] { --fg: var(--vishal-fg); --muted: #d0d0d0; --line: rgba(255, 255, 255, 0.5); --focus: #fff; }
body[data-flood="emma"]   { --fg: var(--emma-fg);   --muted: rgb(109, 64, 86); --line: rgba(109, 64, 86, 0.45); --focus: rgb(109, 64, 86); }

/* ---------- Accessibility helpers ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0.75rem; left: 0.75rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: #fff;
  color: #000;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid #000;
  border-radius: 4px;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

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

/* ---------- Flood layer ---------- */

.flood {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--flood, transparent);
  clip-path: circle(0px at var(--x, 50%) var(--y, 50%));
  transition: clip-path 0.75s var(--ease);
}
body[data-flood="vishal"] .flood { --flood: var(--vishal); }
body[data-flood="emma"]   .flood { --flood: var(--emma); }
body[data-flood] .flood { clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%)); }
body[data-leaving] .flood { transition-duration: 0.5s; }

/* ---------- Layout ---------- */

.page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 1fr auto auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--pad);
  padding-bottom: calc(var(--pad) * 0.6);
  max-width: 90rem;
  margin: 0 auto;
}

.masthead {
  display: grid;
  align-items: center;
  padding-block: 2rem;
}

/* ---------- Wordmark: the logo, rebuilt in type ---------- */

.wordmark {
  margin: 0;
  font-weight: 500;
  line-height: 1;
}

.wordmark__grid {
  display: grid;
  grid-template-columns: repeat(3, 1.05em);
  justify-content: start;
  column-gap: 0.12em;
  row-gap: 0.04em;
  font-size: clamp(4.5rem, min(24vw, 27vh), 15rem);
  letter-spacing: 0;
  text-align: center;
}

.ltr {
  display: block;
  /* pointer-driven offsets are set from JS */
  transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) scale(var(--s, 1));
  transition: transform 0.35s var(--ease-out);
  will-change: transform;
  animation: rise 0.9s var(--ease-out) both;
  animation-delay: calc(var(--i) * 90ms + 150ms);
}

.ltr:nth-child(1) { --i: 0; }
.ltr:nth-child(2) { --i: 1; }
.ltr:nth-child(3) { --i: 2; }
.ltr:nth-child(4) { --i: 3; }
.ltr:nth-child(5) { --i: 4; }
.ltr:nth-child(6) { --i: 5; }

@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 0.35em, 0) rotate(3deg); }
  to   { opacity: 1; transform: translate3d(var(--tx, 0px), var(--ty, 0px), 0) scale(var(--s, 1)); }
}

/* ---------- Intro ---------- */

.intro {
  margin: 0 0 1.5rem;
  max-width: 44ch;
  color: var(--muted);
  transition: color 0.45s var(--ease);
  animation: fade 0.8s ease both;
  animation-delay: 1000ms;
}

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

/* ---------- Site links ---------- */

.sites__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  transition: border-color 0.45s var(--ease);
}

.site {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 7.5rem;
  padding: 1.25rem 1.25rem 1.25rem 0;
  color: inherit;
  text-decoration: none;
  animation: fade 0.8s ease both;
  animation-delay: 1150ms;
}
.sites__list li + li .site { padding-left: 1.25rem; border-left: 1px solid var(--line); }

.site__name {
  font-size: clamp(2.25rem, 7vw, 5rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.site__host {
  position: relative;
  width: fit-content;
  color: var(--muted);
  transition: color 0.45s var(--ease);
}

/* The arrow draws itself in when the link is hovered or focused */
.site__name::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-left: 0.2em;
  border-top: 0.09em solid currentColor;
  border-right: 0.09em solid currentColor;
  transform: translate(-0.25em, 0.2em) rotate(45deg) scale(0);
  transform-origin: center;
  transition: transform 0.4s var(--ease-out);
}
.site:hover .site__name::after,
.site:focus-visible .site__name::after {
  transform: translate(0, 0.1em) rotate(45deg) scale(1);
}

.site:hover .site__host,
.site:focus-visible .site__host { color: var(--fg); text-decoration: underline; text-underline-offset: 0.25em; }

.footer {
  padding-top: 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
  transition: color 0.45s var(--ease);
}
.footer p { margin: 0; }

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  .sites__list { grid-template-columns: 1fr; }
  .sites__list li + li .site { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .site { min-height: 6.5rem; }
  .masthead { padding-block: 1rem; }
}

@media (pointer: coarse) {
  .site { min-height: 8rem; }
}

/* ---------- Respect people who want less motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .ltr { transform: none !important; }
  .flood { clip-path: none; opacity: 0; transition: opacity 0.2s linear !important; }
  body[data-flood] .flood { clip-path: none; opacity: 1; }
}

/* ---------- Forced colours (Windows High Contrast) ---------- */

@media (forced-colors: active) {
  .flood { display: none; }
  .site:focus-visible { outline: 3px solid Highlight; }
  .site__name::after { border-color: LinkText; }
}

@media print {
  .flood, .skip-link { display: none; }
  body { color: #000; background: #fff; }
}
