@font-face {
  font-family: "Comfortaa";
  src: url("assets/Comfortaa-wght.ttf") format("truetype");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}

:root {
  /* Leave room for the parent-only 3% enlargement, including touch activation. */
  --logo-size: min(97vw, 97vh);
  --intro-height: 100vh;
  --connection-viewport-height: var(--intro-height);
  /* From the viewport boundary: quarter connector + third-size child. */
  --tree-reach: calc(var(--logo-size) * 7 / 12);
}

* { box-sizing: border-box; }

/* Reserve symmetric scrollbar space before expansion, so clicking cannot recenter the logo. */
html { scrollbar-gutter: stable both-edges; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #ffffff;
}

.scene {
  min-height: 100vh;
  min-height: 100svh;
  background: #ffffff;
}

.scene.is-expanded {
  /* Reserve the full tree and enough trailing space to align the line at the top. */
  min-height: max(100vh, calc(var(--connection-viewport-height) + var(--tree-reach) + 24px), var(--scroll-min-height, 0px), var(--description-min-height, 0px));
  min-height: max(100svh, calc(var(--connection-viewport-height) + var(--tree-reach) + 24px), var(--scroll-min-height, 0px), var(--description-min-height, 0px));
}

.logo-screen {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100svh;
}

.logo-node {
  /* Cancel this centered node's top offset: the line starts at the viewport boundary. */
  --connection-top: calc(var(--connection-viewport-height) - var(--intro-height) / 2 + 50%);
  position: relative;
  width: var(--logo-size);
  max-width: 100%;
  line-height: 0;
}

.logo-button {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
  color: #000000;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  transform: scale(1);
  transform-origin: center;
  transition: transform 250ms ease;
  pointer-events: none;
}

/* Activation keeps only the parent enlarged, for mouse, keyboard, and touch. */
.logo-button[aria-expanded="true"] {
  transform: scale(1.03);
}

.logo-button:focus-visible {
  outline: 2px solid #000000;
  outline-offset: -6px;
}

.logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

/* The opaque PNG has wide white margins. Hit-test only its artwork bounds plus ~1%. */
.logo-hit-area {
  position: absolute;
  inset: 13% 17.8% 9.2% 18.1%;
  pointer-events: auto;
}

.connector {
  position: absolute;
  top: var(--connection-top);
  left: 50%;
  width: 2px;
  height: 25%;
  background: #000000;
  pointer-events: none;
  transform: translateX(-50%) scaleY(1);
  transform-origin: 50% 0;
  animation: draw-connector 1000ms linear both;
}

.digital-node {
  position: absolute;
  display: block;
  top: calc(var(--connection-top) + 25%);
  left: 50%;
  width: calc(100% / 3);
  height: auto;
  aspect-ratio: 1 / 1;
  /* The PNG is opaque: contain its enlarged white canvas below the line endpoint. */
  overflow: hidden;
  transform: translateX(-50%);
  opacity: 1;
  animation: fade-digital 1000ms linear both;
}

.digital-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  transform: scale(1);
  transform-origin: center;
  transition: transform 250ms ease;
}

.digital-button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.digital-button:disabled { cursor: default; }
.digital-button:focus-visible { outline: 2px solid #000000; outline-offset: -6px; }
.digital-button[aria-expanded="true"] .digital-logo { transform: scale(1.03); }

.digital-description {
  position: absolute;
  top: calc(var(--connection-top) + 100% * 7 / 12 + 24px);
  left: 50%;
  /* Keep the line measure proportional to the font, avoiding sparse justified lines. */
  width: min(37.8em, calc(100vw - 48px));
  margin: 0;
  transform: translateX(-50%);
  color: #000000;
  font-family: "Comfortaa", "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(1rem, calc((100vw - 48px) / 37.8), 1.2rem);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: normal;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-word;
  -webkit-hyphens: none;
  hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}

/* Keep each animated word intact; only the ordinary spaces may wrap. */
.description-word { display: inline; white-space: nowrap; opacity: 0; }
.digital-description.is-revealed .description-word {
  animation: reveal-word 600ms ease-in-out both;
  animation-delay: calc(var(--word-index) * (5000ms - 600ms) / (var(--word-count) - 1));
}
.digital-description.is-complete .description-word { animation: none; opacity: 1; }

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

.connector[hidden],
.digital-node[hidden],
.digital-description[hidden] {
  display: none;
}

@keyframes draw-connector {
  from { transform: translateX(-50%) scaleY(0); }
  to { transform: translateX(-50%) scaleY(1); }
}

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

@keyframes reveal-word {
  from { opacity: 0; }
  to { opacity: 1; }
}

@supports (height: 100svh) {
  :root { --logo-size: min(97vw, 97svh); --intro-height: 100svh; }
}

@media (hover: hover) and (pointer: fine) {
  .logo-button:hover { transform: scale(1.03); }
  .digital-button:not(:disabled):hover .digital-logo { transform: scale(1.03); }
}

@media (prefers-reduced-motion: reduce) {
  .logo-button,
  .digital-logo { transition: none; }
  .connector,
  .digital-node { animation: none; }
  .digital-description.is-revealed .description-word { animation: none; opacity: 1; }
}
