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

:root {
  color-scheme: light dark;
  --root-font-size: 100%;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --bg: #fff;
  --fg: #000;
  --muted: rgba(0, 0, 0, 0.25);
  --link-underline: rgba(0, 0, 0, 0.25);
  --logo-gap: 1.25rem;
  --logo-io-h: 2.5rem;
  --logo-io-w: calc(var(--logo-io-h) * 76.08 / 40);
  --logo-type-h: 2.5rem;
  --transition: 1.2s ease;
  --contact-gap: 2ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #fff;
    --muted: rgba(255, 255, 255, 0.5);
    --link-underline: rgba(255, 255, 255, 0.25);
  }
}

html {
  font-size: var(--root-font-size);
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.stage__panel {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity var(--transition),
    visibility var(--transition);
}

.stage__panel.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scene--instant .stage__panel {
  transition: none;
}

.stage__panel--logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage__panel--contact {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Horizontal: I/O on center of stage (above lang switch); vertical: whole mark centered */
.logo {
  position: relative;
  user-select: none;
  pointer-events: none;
}

.logo__mark {
  --type-h: var(--logo-type-h);
  position: relative;
  width: 0;
  height: 0;
  transform-origin: center center;
}

html.logo-vertical-init .logo__mark,
.logo--vertical .logo__mark {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--logo-gap);
  width: auto;
  height: auto;
  transform: rotate(-90deg);
}

html.logo-vertical-init .logo__io,
.logo--vertical .logo__io {
  position: static;
  transform: none;
}

html.logo-vertical-init .logo__type,
.logo--vertical .logo__type {
  position: static;
  transform: none;
}

html[lang="bg"] .logo__mark {
  --type-h: var(--logo-type-h);
}

.logo__io {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  height: var(--logo-io-h);
  width: auto;
  transform: translate(-50%, -50%);
}

.logo__type {
  position: absolute;
  left: calc(var(--logo-io-w) * 0.5 + var(--logo-gap));
  top: 0;
  display: block;
  height: var(--type-h);
  width: auto;
  transform: translateY(-50%);
}

html:not([lang="bg"]) .logo__type--bg,
html[lang="bg"] .logo__type--en {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .logo__io,
  .logo__type {
    filter: invert(1);
  }
}

/* Contact row: 3 intervals only between items on the same line */
.contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  align-content: center;
  column-gap: var(--contact-gap);
  row-gap: 0;
  font-size: 1.25rem;
  text-align: center;
  padding-inline: 1rem;
}

.contact__link {
  color: inherit;
  letter-spacing: 5%;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.contact__nowrap {
  white-space: nowrap;
}

.contact__link:hover,
.contact__link:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 0.0625rem;
  text-underline-offset: 25%;
}

.contact__link:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

@media (max-width: 640px) {
  .contact {
    flex-direction: column;
    gap: 0.5rem;
  }
}

.lang-switch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem 1.5rem;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.lang-switch__btn {
  font: inherit;
  color: var(--fg);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.lang-switch__btn:not([aria-pressed="true"]):hover {
  opacity: 0.75;
}

.lang-switch__btn[aria-pressed="true"] {
  color: var(--muted);
  pointer-events: none;
}

.lang-switch__sep {
  flex-shrink: 0;
  align-self: center;
  width: 1px;
  height: 1.35em;
  background-color: var(--muted);
}

@media (max-width: 380px) {
  :root {
    /* 16px at 380px; scales with viewport below */
    --root-font-size: calc(100vw * 16 / 380);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage__panel {
    transition: none;
  }
}
