@layer base, layout, components;

@layer base {
  :root {
    --brand-primary: oklch(65% 0.23 284);
    --brand-secondary: oklch(77% 0.16 323);
    --accent: oklch(84% 0.12 151);
    --bg-main: radial-gradient(circle at top left, oklch(28% 0.09 281), oklch(14% 0.04 281));
    --surface-main: linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.045));
    --surface-strong: rgba(18, 20, 44, 0.72);
    --text-primary: oklch(98% 0.01 280);
    --text-secondary: oklch(86% 0.02 280);
    --line: rgba(255, 255, 255, 0.12);
    --shadow-soft: 0 18px 60px -18px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 0 22px 0 oklch(65% 0.25 285 / 0.34);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-blur: blur(14px);
    --number-bg: oklch(98% 0.01 280 / 0.1);
    --number-border: 1px solid rgba(255, 255, 255, 0.18);
  }

  [data-theme="light"] {
    --bg-main: radial-gradient(circle at top left, oklch(95% 0.02 240), oklch(89% 0.04 260));
    --surface-main: linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.58));
    --surface-strong: rgba(255, 255, 255, 0.74);
    --text-primary: oklch(24% 0.03 280);
    --text-secondary: oklch(41% 0.03 280);
    --line: rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 18px 50px -20px rgba(26, 36, 88, 0.18);
    --shadow-glow: 0 0 18px 0 oklch(65% 0.25 285 / 0.18);
    --glass-border: 1px solid rgba(0, 0, 0, 0.06);
    --number-bg: oklch(0% 0 0 / 0.04);
    --number-border: 1px solid rgba(0, 0, 0, 0.08);
  }

  * {
    box-sizing: border-box;
  }

  html {
    scroll-behavior: smooth;
  }

  body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-main);
    background-attachment: fixed;
    transition: background 0.35s ease, color 0.35s ease;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  h1, h2, h3 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
  }

  p {
    margin: 0;
  }
}

@layer layout {
  .site-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
  }

  .inner-page-shell {
    width: min(940px, calc(100% - 32px));
  }

  .site-header,
  .hero-panel,
  .tool-card,
  .info-card,
  .editorial-panel,
  .stats-panel,
  .faq-panel,
  .site-footer,
  .doc-card {
    background: var(--surface-main);
    border: var(--glass-border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .page-stack {
    display: grid;
    gap: 24px;
  }

  .content-grid,
  .editorial-grid,
  .faq-list {
    display: grid;
    gap: 20px;
  }

  .content-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .editorial-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .doc-layout {
    margin-top: 24px;
  }
}

@layer components {
  .site-header {
    position: sticky;
    top: 16px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 20px;
    margin-bottom: 24px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: white;
    box-shadow: var(--shadow-glow);
  }

  .brand-name {
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .main-nav {
    display: flex;
    gap: 16px;
    margin-left: auto;
    flex-wrap: wrap;
  }

  .main-nav a,
  .footer-nav a {
    color: var(--text-secondary);
  }

  .theme-toggle {
    margin-left: 4px;
    background: var(--number-bg);
    border: var(--number-border);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--text-primary);
  }

  [data-theme="light"] .sun-icon { display: none; }
  [data-theme="dark"] .moon-icon { display: none; }
  body:not([data-theme]) .moon-icon { display: none; }

  .hero-panel,
  .tool-card,
  .info-card,
  .editorial-panel,
  .stats-panel,
  .faq-panel,
  .doc-card,
  .site-footer {
    border-radius: 28px;
    padding: 28px;
  }

  .hero-panel {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    align-items: start;
  }

  .eyebrow,
  .section-kicker {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: var(--brand-secondary);
  }

  .hero-copy h1 {
    font-size: clamp(2.8rem, 6vw, 4.8rem);
    line-height: 0.94;
    letter-spacing: -0.05em;
    max-width: 11ch;
  }

  .subtitle,
  .section-copy,
  .doc-card p,
  .faq-item p,
  .editor-card p,
  .hero-note li,
  .micro-copy,
  .footer-copy {
    color: var(--text-secondary);
    line-height: 1.72;
  }

  .subtitle {
    margin-top: 18px;
    max-width: 60ch;
    font-size: 1.04rem;
  }

  .hero-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
  }

  .hero-pills span,
  .updated-label,
  .micro-copy {
    font-size: 0.92rem;
  }

  .hero-pills span,
  .updated-label {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--number-bg);
    border: var(--number-border);
    color: var(--text-secondary);
  }

  .hero-note {
    display: grid;
    gap: 16px;
    padding: 20px;
    border-radius: 22px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
  }

  .hero-note ul,
  .doc-list,
  .insight-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
  }

  .section-heading {
    margin-bottom: 16px;
  }

  .section-heading.wide {
    margin-bottom: 20px;
  }

  .section-heading h2,
  .doc-card h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    letter-spacing: -0.04em;
  }

  .tool-card,
  .info-card,
  .editor-card,
  .faq-item {
    overflow: hidden;
  }

  .last-result {
    margin-top: 22px;
    margin-bottom: 18px;
  }

  .last-result h3,
  .editor-card h3,
  .faq-item h3,
  .doc-card h2 {
    margin-bottom: 10px;
    font-size: 1.05rem;
  }

  .mini-numbers,
  .lotto-numbers {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .lotto-numbers {
    margin: 18px 0 22px;
  }

  .mini-numbers span,
  .number,
  .stat-ball {
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--number-bg);
    border: var(--number-border);
  }

  .mini-numbers span {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
    font-weight: 600;
  }

  .number {
    width: 56px;
    height: 56px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.28rem;
    font-weight: 700;
    transition: all 0.35s ease;
  }

  .number.bonus,
  .mini-numbers .bonus {
    border-color: var(--accent);
  }

  .number.active {
    transform: translateY(-4px) scale(1.08);
    background: var(--brand-primary);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-glow);
  }

  .number.active.bonus {
    background: var(--brand-secondary);
  }

  .controls {
    display: flex;
    justify-content: center;
  }

  .primary-btn {
    border: 0;
    border-radius: 16px;
    padding: 1rem 1.4rem;
    font-weight: 700;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    box-shadow: var(--shadow-glow);
  }

  .primary-btn:disabled {
    opacity: 0.7;
    cursor: wait;
  }

  .info-card,
  .editor-card,
  .faq-item {
    padding: 24px;
    border-radius: 24px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
  }

  .editorial-panel,
  .stats-panel,
  .faq-panel {
    display: grid;
    gap: 14px;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .stat-ball {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
    font-weight: 700;
  }

  .stat-ball.hot {
    background: var(--brand-primary);
    color: white;
    border-color: transparent;
  }

  .stat-ball.cold {
    opacity: 0.42;
  }

  .stat-count {
    font-size: 0.65rem;
    color: var(--text-secondary);
  }

  .faq-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-footer {
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
  }

  .footer-title {
    font-weight: 800;
    margin-bottom: 6px;
  }

  .footer-nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
  }

  .doc-card {
    display: grid;
    gap: 18px;
  }

  .contact-form {
    display: grid;
    gap: 16px;
    margin-top: 12px;
  }

  .contact-form label {
    display: grid;
    gap: 8px;
    font-weight: 600;
  }

  .contact-form input,
  .contact-form select,
  .contact-form textarea {
    width: 100%;
    padding: 14px 16px;
    font: inherit;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text-primary);
  }

  .contact-form textarea {
    min-height: 180px;
    resize: vertical;
  }

  .form-actions {
    display: grid;
    gap: 10px;
  }
}

@media (max-width: 980px) {
  .hero-panel,
  .content-grid,
  .editorial-grid,
  .faq-list,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .site-footer {
    display: grid;
  }
}

@media (max-width: 760px) {
  .site-shell,
  .inner-page-shell {
    width: min(100% - 20px, 1200px);
  }

  .site-header {
    position: static;
    flex-wrap: wrap;
  }

  .main-nav {
    order: 3;
    margin-left: 0;
    width: 100%;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: 2.8rem;
  }

  .stats-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
