/* Формат v30 — one viewport, official icons, dense craft */

@layer reset, tokens, base, stage, board, motion, a11y;

@layer tokens {
  :root {
    --bg: #07090d;
    --panel: #121821;
    --ink: #f5f7fa;
    --mute: rgba(245, 247, 250, 0.64);
    --line: rgba(245, 247, 250, 0.12);
    --word: #2b7cd3;
    --xls: #21a366;
    --pdf: #e5252a;
    --cta: #f4f7fb;
    --cta-ink: #0a0e14;

    --font-d: "Outfit", system-ui, sans-serif;
    --font-t: "Source Sans 3", system-ui, sans-serif;
    --pad: clamp(1rem, 4.6vw, 1.45rem);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --max: 26.5rem;
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; }
  a { color: inherit; text-decoration: none; }
  p, h1, ul { margin: 0; }
  ul { list-style: none; padding: 0; }
  img { display: block; max-width: 100%; height: auto; }
}

@layer base {
  body {
    font-family: var(--font-t);
    color: var(--ink);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }

  .skip { position: absolute; left: -999px; }
  .skip:focus {
    left: 12px; top: 12px; z-index: 30;
    background: var(--ink); color: var(--bg);
    padding: 0.5rem 0.7rem;
  }
}

@layer stage {
  .stage {
    position: relative;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    width: min(100%, calc(var(--max) + 2 * var(--pad)));
    margin-inline: auto;
    padding:
      calc(var(--pad) + env(safe-area-inset-top))
      var(--pad)
      calc(0.85rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: clamp(0.7rem, 2.2vh, 1.1rem);
  }

  .stage__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background:
      linear-gradient(180deg, #0d121a 0%, #07090d 48%, #05070a 100%);
  }

  .stage__grain {
    position: absolute;
    inset: 0;
    opacity: 0.09;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  .stage__wash {
    position: absolute;
    border-radius: 50%;
    filter: blur(48px);
    opacity: 0.4;
  }
  .stage__wash--blue {
    width: 14rem; height: 14rem;
    top: -3rem; left: -4rem;
    background: #1a4f9c;
  }
  .stage__wash--red {
    width: 12rem; height: 12rem;
    top: 8%; right: -4rem;
    background: #8b1e24;
  }
  .stage__wash--green {
    width: 10rem; height: 10rem;
    bottom: 18%; left: 20%;
    background: #14663d;
    opacity: 0.22;
  }

  .top,
  .hero,
  .board,
  .foot {
    position: relative;
    z-index: 1;
  }

  .top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
  }

  .brand-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }

  .brand {
    margin: 0;
    font-family: var(--font-d);
    font-weight: 800;
    font-size: clamp(1.75rem, 7vw, 2.25rem);
    letter-spacing: -0.055em;
    line-height: 0.95;
  }

  .brand-logo {
    width: clamp(1.85rem, 7vw, 2.35rem);
    height: clamp(1.85rem, 7vw, 2.35rem);
    border-radius: 0.55rem;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  }

  .brand-sub {
    margin-top: 0.25rem;
    font-size: 0.92rem;
    color: var(--mute);
    font-weight: 500;
  }

  .top-note {
    display: none;
  }

  .hero h1 {
    font-family: var(--font-d);
    font-weight: 750;
    font-size: clamp(1.45rem, 5.6vw, 1.85rem);
    letter-spacing: -0.04em;
    line-height: 1.18;
    max-width: 18ch;
  }

  .c-word { color: var(--word); }
  .c-xls { color: var(--xls); }
  .c-pdf { color: var(--pdf); }

  .lead {
    margin-top: 0.55rem;
    color: var(--mute);
    font-size: clamp(0.95rem, 3.2vw, 1.05rem);
    line-height: 1.4;
    max-width: 30ch;
  }

  .foot {
    display: grid;
    gap: 0.45rem;
  }

  .cta {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 19rem;
    margin-inline: auto;
    min-height: 3.2rem;
    padding: 0 1.2rem;
    border-radius: 999px;
    background: rgba(192, 57, 43, 0.92);
    color: #fff7f4;
    font-family: var(--font-d);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    border: 1.5px solid rgba(255, 210, 200, 0.35);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.12) inset,
      0 10px 26px rgba(0, 0, 0, 0.38);
    transition: transform 160ms var(--ease), filter 160ms var(--ease), opacity 0.2s ease;
  }
  .cta:hover { filter: brightness(1.04); }
  .cta:active { transform: scale(0.988); }
  .cta:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
  }
  .cta.is-busy { opacity: 0.72; pointer-events: none; }
}

@layer board {
  .board {
    display: grid;
    align-content: center;
    gap: 0.85rem;
    min-height: 0;
  }

  .board__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    padding: 0.85rem;
    border-radius: 1.35rem;
    border: 1px solid var(--line);
    background:
      linear-gradient(165deg, rgba(255,255,255,0.055), rgba(255,255,255,0.015)),
      color-mix(in oklab, var(--panel) 90%, #000);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.04) inset,
      0 26px 48px rgba(0, 0, 0, 0.42);
  }

  .tile {
    display: grid;
    justify-items: center;
    gap: 0.28rem;
    padding: 0.7rem 0.45rem 0.65rem;
    border-radius: 0.95rem;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .tile.is-blink,
  .tile:active {
    animation: tileBlink 0.55s var(--ease);
  }

  .tile__icon {
    width: clamp(3.8rem, 16vw, 4.6rem);
    height: clamp(3.8rem, 16vw, 4.6rem);
    display: grid;
    place-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .tile.is-blink .tile__icon,
  .tile:active .tile__icon {
    animation: tileIconBlink 0.55s var(--ease);
  }

  .tile__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: transparent;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
    pointer-events: none;
  }

  .tile__name {
    font-family: var(--font-d);
    font-weight: 750;
    font-size: 0.92rem;
    letter-spacing: -0.02em;
  }

  .tile__hint {
    font-size: 0.72rem;
    color: var(--mute);
    letter-spacing: -0.01em;
  }

  .board__line {
    text-align: center;
    font-family: var(--font-d);
    font-size: clamp(0.78rem, 2.8vw, 0.88rem);
    font-weight: 600;
    letter-spacing: -0.015em;
    color: rgba(245, 247, 250, 0.55);
    line-height: 1.35;
  }

  .rail {
    position: relative;
    height: 3.35rem;
    margin-top: 0.15rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.28);
    overflow: hidden;
  }

  .rail__line {
    position: absolute;
    left: 0.9rem;
    right: 0.9rem;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: linear-gradient(
      90deg,
      transparent,
      rgba(43, 124, 211, 0.55) 18%,
      rgba(229, 37, 42, 0.7) 50%,
      rgba(33, 163, 102, 0.45) 82%,
      transparent
    );
  }

  .rail__mid {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    width: 1.55rem;
    height: 1.55rem;
    transform: translate(-50%, -50%);
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #1a2230;
    border: 1px solid rgba(229, 37, 42, 0.55);
    color: #ff8f86;
    font-size: 0.75rem;
    box-shadow: 0 0 0 4px rgba(229, 37, 42, 0.08);
    animation: midPulse 1.8s var(--ease) infinite;
  }

  .rail__stream {
    position: absolute;
    inset: 0;
    z-index: 2;
  }

  .rail__item {
    position: absolute;
    top: 50%;
    left: -12%;
    width: 1.85rem;
    height: 1.85rem;
    transform: translateY(-50%);
    animation: railTravel 8.5s linear infinite;
    animation-delay: var(--d, 0s);
  }

  .rail__from,
  .rail__to {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
  }

  .rail__from {
    animation: railFrom 8.5s linear infinite;
    animation-delay: var(--d, 0s);
  }

  .rail__to {
    opacity: 0;
    animation: railTo 8.5s linear infinite;
    animation-delay: var(--d, 0s);
  }
}
@layer motion {
  @keyframes railTravel {
    0% { left: -14%; transform: translateY(-50%); }
    100% { left: 108%; transform: translateY(-50%); }
  }

  @keyframes railFrom {
    0%, 46% { opacity: 1; transform: scale(1); }
    52%, 100% { opacity: 0; transform: scale(0.86); }
  }

  @keyframes railTo {
    0%, 46% { opacity: 0; transform: scale(0.86); }
    52%, 100% { opacity: 1; transform: scale(1); }
  }

  @keyframes midPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(229, 37, 42, 0.08); }
    50% { box-shadow: 0 0 0 7px rgba(229, 37, 42, 0.14); }
  }

  @keyframes tileBlink {
    0%, 100% {
      border-color: transparent;
      background: rgba(0, 0, 0, 0.18);
    }
    30%, 55% {
      border-color: rgba(255, 255, 255, 0.16);
      background: rgba(255, 255, 255, 0.04);
    }
  }

  @keyframes tileIconBlink {
    0%, 100% { transform: none; }
    30%, 55% { transform: translateY(-9px) scale(1.06); }
  }
}

@layer a11y {
  @media (prefers-reduced-motion: reduce) {
    .tile,
    .tile__icon {
      animation: none !important;
    }
    .cta { transition: none; }
    .rail__item,
    .rail__from,
    .rail__to,
    .rail__mid {
      animation: none !important;
    }
    .rail__item { left: 50%; opacity: 0; }
    .rail__item:nth-child(1) { opacity: 1; left: 18%; }
    .rail__item:nth-child(1) .rail__from { opacity: 1; }
    .rail__item:nth-child(1) .rail__to { opacity: 0; }
    .rail__item:nth-child(3) { opacity: 1; left: 72%; }
    .rail__item:nth-child(3) .rail__from { opacity: 0; }
    .rail__item:nth-child(3) .rail__to { opacity: 1; }
  }


  @media (min-width: 720px) {
    .stage { max-width: 30rem; }
  }

  @media (max-height: 700px) {
    .brand { font-size: 1.75rem; }
    .hero h1 { font-size: 1.35rem; }
    .board__grid { gap: 0.5rem; padding: 0.55rem; }
    .tile { padding: 0.5rem 0.35rem; }
    .tile__icon {
      width: 3.1rem;
      height: 3.1rem;
    }
    .cta { min-height: 3.15rem; }
  }

  @media (max-height: 600px) {
    .brand-sub,
    .board__line,
    .tile__hint { display: none; }
    .rail { height: 2.8rem; }
    .stage { gap: 0.45rem; }
  }
}
