@font-face {
  font-family: Inter;
  src: url('/fonts/InterVariable.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

/* Longest principle line ≈ 35.7 font-size widths; icon and gap scale with the text. */
:root {
  --principle-font: 24px;
  --principle-icon: calc(var(--principle-font) * 1.72);
  --principle-gap: calc(var(--principle-font) * 0.78);
}

/* заголовок и вводный абзац для поиска и скринридеров: смысл страницы есть в DOM,
   хотя визуально его несёт анимация знака */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.scene { position: fixed; inset: 0; }

.scene iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

body { color: var(--text-2); font: 12px/1.6 -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, sans-serif; }
.open-dapp {
  position: fixed;
  top: max(28px, env(safe-area-inset-top));
  right: max(32px, env(safe-area-inset-right));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: #ededed;
  color: var(--on-bright);
  text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0;
  transition: background-color .2s, color .2s;
}
@media (hover: hover) {
  .open-dapp:hover { background: #ffffff; }
}
.open-dapp:active { background: #d8d8d8; }
@media (max-width: 720px) {
  .open-dapp { top: max(18px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); height: 32px; padding: 0 12px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .open-dapp { transition: none; }
}
.principles {
  position: fixed;
  top: 50%;
  right: max(48px, env(safe-area-inset-right));
  transform: translateY(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  color: var(--text);
}
.principle { display: flex; align-items: flex-start; gap: var(--principle-gap); }
.principle-icon { flex: none; width: var(--principle-icon); height: var(--principle-icon); margin-top: 1px; color: var(--text); }
.principle p { margin: 0; font-size: var(--principle-font); line-height: 1.6; font-weight: 450; color: var(--text); }

/* Desktop: the animation owns the left half; the text lives in what is left and keeps one line.
   Text column = 48vw − 80px of gutters; a line needs 35.7F, the icon 1.72F, the gap 0.78F. */
@media (min-width: 1000px) {
  :root {
    --anim-width: 52vw;
    --principle-font: clamp(14px, calc((48vw - 80px) / 39.2), 26px);
  }
  .scene { right: calc(100% - var(--anim-width)); }
  .principles {
    left: calc(var(--anim-width) + 40px);
    right: 40px;
    gap: calc(var(--principle-font) * 1.55);
  }
  .principle p { white-space: nowrap; }
}
/* Phone/tablet: the animation owns a full-width band under the button; the text is anchored
   above the footer and grows upward, so extra wrapping never pushes it into the footer. */
@media (max-width: 999px) {
  .scene { top: 7%; bottom: 50%; }
  .principles {
    top: auto;
    bottom: 108px;
    left: 20px;
    right: 20px;
    transform: none;
    width: auto;
    gap: 18px;
  }
}
/* Phone: symmetric side margins, with the text keeping a ~70vw measure.
   Block = icon + gap + text = 2.5F + 0.7vw, so each margin is (100vw − that) / 2. */
@media (max-width: 720px) {
  :root {
    --principle-font: clamp(14px, 4.3vw, 18px);
    --principle-edge: calc(15vw - 1.25 * var(--principle-font));
  }
  .principles { left: var(--principle-edge); right: var(--principle-edge); gap: 16px; }
}
/* Short viewports (SE-sized phones, landscape): trim the band so the text still clears the footer. */
@media (max-width: 999px) and (max-height: 720px) {
  :root { --principle-font: clamp(12px, min(4.3vw, 2.2vh), 18px); }
  .scene { top: 6%; bottom: 54%; }
  .principles { gap: 12px; }
}
.legal-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px max(32px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  background: linear-gradient(transparent, #000d 45%);
  color: var(--text-2);
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', Inter, sans-serif;
  font-weight: 450;
}
.footer-brand { white-space: nowrap; }
/* официальный знак Marg справа от слова: маской, чтобы он брал цвет строки подвала */
.brand-mark {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  margin-left: .45em;
  vertical-align: -0.2em;
  background: currentColor;
  -webkit-mask: url('/assets/icons/marg-mark.svg') center / contain no-repeat;
  mask: url('/assets/icons/marg-mark.svg') center / contain no-repeat;
}
.made-with { justify-self: end; white-space: nowrap; }
/* флаг MTONGA вместо слова: рисунок занимает почти весь свой квадрат (470×500 из 512),
   поэтому размер берём как у эмодзи в строке — чуть выше кегля, без отрицательных полей */
.marg-flag {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.3em;
  margin: 0 .12em;
}
.marg-flag svg { display: block; width: 100%; height: 100%; }
.legal-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; }
.legal-footer a { color: inherit; text-decoration: none; white-space: nowrap; }
.legal-footer a:hover { color: var(--accent-tint); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 5px; }
.dialog-label { font-size: 9px; letter-spacing: 2px; color: var(--text-3); }
.legal-page { min-height: 100%; overflow: auto; background: var(--bg); }
.legal-page-content { width: min(680px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 96px; color: var(--text-2); }
.legal-back { display: inline-block; margin-bottom: 48px; color: var(--text-2); text-decoration: none; font-size: 13px; }
#legal-title { color: var(--text); font-size: 30px; line-height: 1.2; font-weight: 500; margin: 18px 0 28px; }
#legal-content p { font-size: 14px; line-height: 1.85; margin: 0 0 18px; }
.draft-note { border-top: 1px solid var(--line-strong); padding-top: 18px; margin-top: 24px; font-size: 11px; color: var(--text-3); }
@media (max-width: 720px) {
  /* one row: brand · links · credit, never wrapping */
  .legal-footer {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    /* brand + знак + links + credit measure ≈ 37.7 font-widths including the five 1.1em
       gaps — size the text so the row always fits between the 16px paddings, capped at 10px */
    font-size: min(10px, calc((100vw - 32px) / 38.5));
    gap: 1.1em;
    padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  }
  .footer-brand { flex: none; }
  .legal-footer nav { flex: 0 1 auto; flex-wrap: nowrap; justify-content: center; gap: 1.1em; }
  .made-with { flex: none; justify-self: auto; }
  .legal-page-content { width: min(100% - 40px, 680px); padding-top: 32px; }
}
