/*
 * Invariant Machines — design tokens.
 *
 * A plain reading page: one narrow serif column on white, a wide-set
 * wordmark in international orange, and nothing else competing with the
 * words. On load the fixed-point mark makes a quarter turn into place while the
 * wordmark "develops" like a photographic print; that one moment is the only
 * motion on the page.
 *
 *   --paper       page surface
 *   --ink         body text
 *   --muted       secondary text (AA on paper)
 *   --orange      wordmark
 *   --orange-ink  link underlines, hover, focus (AA for body sizes)
 *   --wash        undeveloped state of the wordmark, tag background
 *   --tint        hover surface in the Companies menu
 *   --line        hairlines between companies and around the menu
 */

:root {
  --paper: #ffffff;
  --ink: #1f1c1a;
  --muted: #6a625c;
  --orange: #f24a00;
  --orange-light: #ff8040;
  --orange-ink: #bf3e0a;
  --wash: #fde6d8;
  --tint: #fff5ee;
  --line: #ece5df;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Archivo", ui-sans-serif, system-ui, sans-serif;

  color-scheme: light;
}

@property --dev {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 150%;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  /* viewport-fit=cover: keep content clear of notches in landscape */
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--orange) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--orange-ink);
  text-decoration-color: var(--orange-ink);
}

:focus-visible {
  outline: 2px solid var(--orange-ink);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.875rem;
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* ---------- top navigation ---------- */

.topnav {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 26px;
  padding: 14px 28px 0;
  font-family: var(--sans);
  font-size: 0.875rem;
}

.topnav > a,
.menu summary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}

.topnav > a:hover {
  text-decoration: underline;
  text-decoration-color: var(--orange-ink);
}

/* ---------- companies menu ---------- */

.menu {
  position: relative;
}

.menu summary {
  gap: 6px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary:hover,
.menu[open] summary {
  color: var(--orange-ink);
}

.chev {
  width: 12px;
  height: 12px;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.menu[open] .chev {
  transform: rotate(180deg);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: -14px;
  width: 22rem;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 20px 44px -20px rgb(31 28 26 / 0.3),
    0 3px 10px -4px rgb(31 28 26 / 0.1);
  transform-origin: top right;
  animation: menu-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

.menu-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu-item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--tint);
  color: inherit;
}

.menu-item:active {
  background: var(--wash);
}

.menu-name {
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: var(--ink);
}

.menu-line {
  grid-column: 1;
  margin-top: 1px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--muted);
}

.menu-host {
  grid-column: 1;
  margin-top: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.menu-item .out {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  color: var(--muted);
  transition: color 0.15s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.menu-item:hover .out {
  color: var(--orange-ink);
  transform: translate(1px, -1px);
}

.menu-foot {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin: 6px 6px 0;
  padding: 4px 6px 0;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
}

.menu-foot:hover {
  color: var(--orange-ink);
}

.out {
  width: 12px;
  height: 12px;
  flex: none;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(28px, 6vw, 56px) 20px 0;
  text-align: center;
}

/* The fixed-point mark. On load the square makes a quarter turn into place,
   leaving its trail behind; a square turned 90 degrees is the same square,
   and the centre point never moves. */
.mark {
  /* the drawing fills about the middle 60% of its 64-unit box */
  width: clamp(76px, 10vw, 100px);
  height: auto;
  margin: -8px 0 clamp(4px, 1vw, 10px);
  color: var(--orange);
  overflow: visible;
}

.mark rect {
  transform-box: view-box;
  transform-origin: 32px 32px;
  animation: 1.9s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.mark-trail-1 {
  opacity: 0.16;
  transform: rotate(-36deg);
  animation-name: trail-1;
}

.mark-trail-2 {
  opacity: 0.42;
  transform: rotate(-18deg);
  animation-name: trail-2;
}

.mark-square {
  animation-name: turn;
}

@keyframes trail-1 {
  from {
    opacity: 0;
    transform: rotate(-90deg);
  }
}

@keyframes trail-2 {
  from {
    opacity: 0;
    transform: rotate(-90deg);
  }
}

@keyframes turn {
  from {
    transform: rotate(-90deg);
  }
}

.wordmark {
  margin: 0;
  font-family: var(--sans);
  font-variation-settings: "wdth" 125;
  font-weight: 300;
  font-size: clamp(2.25rem, 6.4vw, 4rem);
  line-height: 1.04;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  /* The develop: a pale veil clears from the centre outward, leaving the
     orange gradient underneath. */
  background-image:
    radial-gradient(
      140% 160% at 50% 55%,
      transparent calc(var(--dev) - 30%),
      var(--wash) var(--dev)
    ),
    linear-gradient(115deg, var(--orange) 25%, var(--orange-light) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--orange);
  animation: develop 2.2s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.wordmark span {
  display: block;
  /* letter-spacing adds trailing space after the last letter; pull it back
     so each line stays optically centred */
  margin-right: -0.07em;
}

@keyframes develop {
  from {
    --dev: 0%;
  }
  to {
    --dev: 150%;
  }
}

.news {
  margin-top: 30px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-family: var(--sans);
  font-size: 0.875rem;
  text-decoration: none;
}

.news-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange-ink);
  background: var(--wash);
  border-radius: 999px;
  padding: 3px 9px;
}

.news:hover span:last-child {
  text-decoration: underline;
  text-decoration-color: var(--orange-ink);
  text-underline-offset: 0.2em;
}

/* ---------- reading column ---------- */

.column {
  max-width: 36rem;
  margin: 0 auto;
  padding: clamp(36px, 6vw, 56px) 20px 0;
}

.column p {
  margin: 0 0 1.25em;
  text-wrap: pretty;
}

.column section {
  margin-top: 2.6em;
}

.column h2 {
  margin: 0 0 0.75em;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.3125rem;
  line-height: 1.3;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

/* ---------- companies ---------- */

/* Each company is a <details>: the summary row shows the name and a
   one-line description, and opening it reveals the link and the write-up. */

:root {
  interpolate-size: allow-keywords;
}

.company {
  border-top: 1px solid var(--line);
  scroll-margin-top: 24px;
}

.company:last-of-type {
  border-bottom: 1px solid var(--line);
}

.company summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 16px;
  padding: 16px 0;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.company summary::-webkit-details-marker {
  display: none;
}

.column h3 {
  grid-column: 1;
  margin: 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.35;
  text-wrap: balance;
  transition: color 0.15s ease;
}

.company-line {
  grid-column: 1;
  margin-top: 2px;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--muted);
}

.company .chev {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), color 0.15s ease;
}

.company summary:hover h3,
.company[open] h3 {
  color: var(--orange-ink);
}

.company summary:hover .chev,
.company[open] .chev {
  color: var(--orange-ink);
}

.company[open] .chev {
  transform: rotate(180deg);
}

/* Smooth open and close where the browser can animate to auto height;
   elsewhere the panel simply appears. */
.company::details-content {
  block-size: 0;
  overflow: hidden;
  transition:
    block-size 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    content-visibility 0.32s allow-discrete;
}

.company[open]::details-content {
  block-size: auto;
}

.company-body {
  padding-bottom: 0.6em;
}

.company-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  margin: -4px 0 0.6em;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
}

.company-link:hover {
  color: var(--orange-ink);
}

.company-link .out {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.company-link:hover .out {
  transform: translate(1px, -1px);
}

/* ---------- footer ---------- */

.footer {
  max-width: 36rem;
  margin: 0 auto;
  padding: 40px 20px 56px;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

.footer p {
  margin: 0;
}

/* Phones: the nav centres, and the menu becomes a full-width panel that
   hangs from the nav inside the 16px gutters. */
@media (max-width: 560px) {
  body {
    font-size: 1.0625rem;
  }

  .topnav {
    justify-content: center;
    padding: 8px 16px 0;
    gap: 0 22px;
  }

  .menu {
    position: static;
  }

  .menu-panel {
    top: 100%;
    left: 16px;
    right: 16px;
    width: auto;
    transform-origin: top center;
  }

  .masthead {
    padding-left: 16px;
    padding-right: 16px;
  }

  .column,
  .footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Touch and phone widths: every control gets a full 44px target. */
@media (pointer: coarse), (max-width: 560px) {
  .topnav > a,
  .menu summary,
  .menu-foot,
  .company-link,
  .news {
    min-height: 44px;
  }

  .menu-item {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .wordmark {
    animation: none;
    --dev: 150%;
  }

  .menu-panel,
  .mark rect {
    animation: none;
  }

  .company::details-content {
    transition: none;
  }

  a,
  .chev,
  .out,
  .menu summary,
  .menu-item,
  .column h3 {
    transition: none;
  }
}
