@layer reset, tokens, base, components, utilities;

@layer tokens {
  :root {
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #161618;
    --color-text-muted: #5c5c66;
    --color-border: #e4e4ea;
    --color-tag-bg: #f1f1f5;

    --color-accent: #161618;
    --color-accent-hover: #2f2f35;

    --boot-bg: #0b0c0e;
    --boot-surface: #111317;
    --boot-border: #23272f;
    --boot-divider: #1e222a;
    --boot-text: #e4e6eb;
    --boot-muted: #8b919e;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;

    --container-max: 840px;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  }
}

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

  html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-size-adjust: 100%;
  }

  body {
    margin: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-variant-ligatures: none;
    line-height: 1.65;
    font-size: 15px;
  }

  h1, h2, h3, p, ul, dl, dd {
    margin: 0;
  }
}

@layer base {
  .page {
    max-width: var(--container-max);
    margin-inline: auto;
    padding: 24px 20px 64px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.45s var(--ease-out), transform 0.45s var(--ease-out);
  }

  .page.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

@layer components {
  /* Терминальный экран загрузки (boot-log) */
  .boot-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: var(--boot-bg);
    color: var(--boot-text);
    display: grid;
    place-items: center;
    padding: 24px;
    transition: opacity 0.4s var(--ease-out), visibility 0.4s var(--ease-out);
  }

  .boot-screen.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .boot-terminal {
    width: 100%;
    max-width: 580px;
    background: var(--boot-surface);
    border: 1px solid var(--boot-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    font-size: 13px;
    line-height: 1.65;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  }

  .boot-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--boot-divider);
    font-size: 11px;
    color: var(--boot-muted);
    letter-spacing: 0.04em;
  }

  .boot-lines {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .boot-line {
    display: flex;
    gap: 10px;
    white-space: pre-wrap;
  }

  .boot-tag-ok {
    color: #d4d7dd;
    font-weight: 600;
    flex-shrink: 0;
  }

  .boot-tag-ready {
    color: #ffffff;
    font-weight: 700;
    flex-shrink: 0;
  }

  .boot-msg {
    color: var(--boot-muted);
  }

  .boot-msg-bright {
    color: var(--boot-text);
  }

  .boot-prompt-row {
    margin-top: 8px;
    color: var(--boot-muted);
    font-size: 12px;
  }

  .boot-cursor {
    display: inline-block;
    color: var(--boot-text);
    animation: blinkCursor 0.85s steps(2, start) infinite;
  }

  /* Верхняя монохромная статус-панель */
  .status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 48px;
  }

  .status-left,
  .status-right {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .spinner {
    color: var(--color-text);
    font-weight: 600;
    display: inline-block;
    width: 1.2ch;
    text-align: center;
  }

  .uptime-track {
    color: var(--color-text);
    letter-spacing: 1px;
    font-size: 11px;
  }

  /* Hero */
  .hero {
    margin-bottom: 56px;
  }

  .eyebrow {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
  }

  h1 {
    margin-bottom: 18px;
    font-size: clamp(1.9rem, 4.8vw, 2.65rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
  }

  .lead {
    margin-bottom: 32px;
    font-size: 15.5px;
    line-height: 1.65;
    color: var(--color-text-muted);
    max-width: 750px;
  }

  .meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }

  .meta-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .meta-title {
    font-size: 11.5px;
    color: var(--color-text-muted);
  }

  .meta-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.45;
  }

  /* Кнопки CTA */
  .cta-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: var(--color-accent);
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 14px 22px;
    border-radius: var(--radius-md);
    transition: background-color 0.18s ease, transform 0.18s ease;
  }

  .btn-primary:hover {
    background-color: var(--color-accent-hover);
    transform: translateY(-1px);
  }

  .btn-primary:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
  }

  .btn-primary .arrow {
    transition: transform 0.18s ease;
  }

  .btn-primary:hover .arrow {
    transform: translateX(3px);
  }

  .cta-note {
    font-size: 12.5px;
    color: var(--color-text-muted);
  }

  /* Программа */
  .program {
    margin-bottom: 56px;
  }

  .section-header {
    margin-bottom: 24px;
  }

  .section-header h2 {
    margin-bottom: 6px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .section-header p {
    color: var(--color-text-muted);
    font-size: 14px;
  }

  .parts {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .part-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
  }

  .part-head {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
  }

  .part-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    background: var(--color-tag-bg);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
  }

  .part-head h3 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .topic-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .topic-list li {
    position: relative;
    padding-left: 18px;
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.6;
  }

  .topic-list li::before {
    content: "›";
    position: absolute;
    left: 0;
    top: -1px;
    color: var(--color-text);
    font-weight: 600;
  }

  .topic-list strong {
    color: var(--color-text);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
  }

  /* Блок перерыва */
  .break-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 13px 18px;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--color-text);
  }

  .break-scramble {
    color: var(--color-text);
    font-weight: 500;
    letter-spacing: 0.04em;
    min-width: 18ch;
    text-align: center;
  }

  /* Финал */
  .outcome-box {
    margin-top: 16px;
    padding: 18px 22px;
    background: var(--color-tag-bg);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-start;
    gap: 14px;
  }

  .outcome-tag {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    margin-top: 2px;
  }

  .outcome-box p {
    font-size: 13.5px;
    color: var(--color-text);
  }

  /* Нижний CTA */
  .bottom-cta {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    text-align: center;
    margin-bottom: 48px;
  }

  .bottom-cta h2 {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .bottom-cta p {
    margin-bottom: 22px;
    color: var(--color-text-muted);
    font-size: 14px;
  }

  /* Футер */
  .footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    font-size: 12px;
    color: var(--color-text-muted);
  }

  .footer-ascii {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  #footer-pulse {
    color: var(--color-text);
    animation: subtlePulse 1.6s infinite ease-in-out;
  }
}

@layer utilities {
  @keyframes blinkCursor {
    to { opacity: 0; }
  }

  @keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
  }

  @media (max-width: 640px) {
    .status-bar {
      flex-direction: column;
      align-items: flex-start;
      margin-bottom: 32px;
    }

    .meta-grid {
      grid-template-columns: 1fr;
    }

    .part-card {
      padding: 20px 18px;
    }

    .outcome-box {
      flex-direction: column;
      gap: 8px;
    }

    .footer {
      flex-direction: column;
      align-items: flex-start;
    }
  }
}
