/**
 * Base styles — переменные, сброс, типографика
 * Neuronis — ИИ-тренажёр ЕГЭ по информатике
 */

:root,
[data-theme="dark"] {
  --bg: #23282d;
  --white: #ffffff;
  --green: #05b87d;
  --text-muted: rgba(255, 255, 255, 0.6);
  --text-footer: rgba(255, 255, 255, 0.5);
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Playfair Display", Georgia, "Times New Roman", serif;
  --header-premium-border: rgba(5, 184, 125, 0.22);
  --header-premium-inset: rgba(255, 255, 255, 0.045);
  --header-premium-shadow: 0 3px 18px rgba(0, 0, 0, 0.22);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --white: #1d1d1f;
  --green: #05b87d;
  --text-muted: rgba(0, 0, 0, 0.6);
  --text-footer: rgba(0, 0, 0, 0.5);
  --header-premium-border: rgba(5, 184, 125, 0.2);
  --header-premium-inset: rgba(255, 255, 255, 0.98);
  --header-premium-shadow: 0 2px 14px rgba(26, 36, 48, 0.06);
}

/* Theme cycle toggle — тёмная / светлая / розовая */
.theme-cycle-toggle {
  --theme-toggle-seg: 3.35rem;
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, var(--theme-toggle-seg));
  align-items: stretch;
  gap: 0;
  padding: 0.18rem;
  border-radius: 999px;
  border: 1px solid rgba(5, 184, 125, 0.28);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

[data-theme="light"] .theme-cycle-toggle {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(5, 184, 125, 0.22);
  box-shadow: 0 2px 10px rgba(26, 36, 48, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.theme-cycle-toggle__slider {
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: var(--theme-toggle-seg);
  height: calc(100% - 0.36rem);
  border-radius: 999px;
  background: linear-gradient(165deg, #2d3748 0%, #1a202c 100%);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition:
    transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1),
    background 0.28s ease,
    box-shadow 0.28s ease;
  pointer-events: none;
  z-index: 0;
}

.theme-cycle-toggle[data-appearance="light"] .theme-cycle-toggle__slider {
  transform: translateX(100%);
  background: linear-gradient(165deg, #fffef8 0%, #fef3c7 100%);
  box-shadow:
    0 2px 10px rgba(245, 158, 11, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.theme-cycle-toggle[data-appearance="pink"] .theme-cycle-toggle__slider {
  transform: translateX(200%);
  background: linear-gradient(165deg, #fbcfe8 0%, #f472b6 52%, #db2777 100%);
  box-shadow:
    0 2px 12px rgba(236, 72, 153, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

[data-theme="light"][data-palette="pink"] .theme-cycle-toggle[data-appearance="pink"] .theme-cycle-toggle__slider,
[data-theme="light"] .theme-cycle-toggle[data-appearance="pink"] .theme-cycle-toggle__slider {
  background: linear-gradient(165deg, #fdf2f8 0%, #fbcfe8 55%, #f9a8d4 100%);
  box-shadow:
    0 2px 10px rgba(219, 39, 119, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.theme-cycle-toggle__option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.14rem;
  width: var(--theme-toggle-seg);
  min-height: 2.55rem;
  padding: 0.28rem 0.2rem 0.22rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.18s ease;
  opacity: 0.62;
}

.theme-cycle-toggle__option:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.theme-cycle-toggle__option--active {
  opacity: 1;
}

.theme-cycle-toggle__preview {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.theme-cycle-toggle__preview--dark {
  background: linear-gradient(145deg, #3d4a5c 0%, #1e2630 100%);
}

.theme-cycle-toggle__preview--light {
  background: linear-gradient(145deg, #ffffff 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.35);
}

.theme-cycle-toggle__preview--pink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #fce7f3 0%, #f472b6 100%);
  border-color: rgba(244, 114, 182, 0.45);
}

.theme-cycle-toggle__preview-crown {
  display: block;
  width: 0.72rem;
  height: 0.72rem;
  object-fit: contain;
  pointer-events: none;
}

.theme-cycle-toggle__label {
  font-size: 0.58rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}

.theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  color: var(--white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.theme-cycle-toggle[data-appearance="light"] .theme-cycle-toggle__option--light.theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  color: #78350f;
  text-shadow: none;
}

.theme-cycle-toggle[data-appearance="pink"] .theme-cycle-toggle__option--pink.theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  color: #831843;
  text-shadow: none;
}

[data-theme="dark"] .theme-cycle-toggle[data-appearance="pink"] .theme-cycle-toggle__option--pink.theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  color: #fff5f9;
  text-shadow: 0 1px 3px rgba(88, 28, 56, 0.45);
}

[data-theme="light"] .theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  text-shadow: none;
}

[data-palette="pink"] .theme-cycle-toggle {
  border-color: var(--accent-border);
}

[data-palette="pink"] .theme-cycle-toggle__option--active .theme-cycle-toggle__label {
  color: var(--white);
}

@media (max-width: 720px) {
  .theme-cycle-toggle {
    --theme-toggle-seg: 2.65rem;
  }

  .theme-cycle-toggle__label {
    font-size: 0.52rem;
  }

  .theme-cycle-toggle__option {
    min-height: 2.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-cycle-toggle__slider,
  .theme-cycle-toggle__option {
    transition: none;
  }
}

/* Legacy single-button theme toggle (страницы без theme-cycle-toggle) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.125rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(5, 184, 125, 0.28);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.18s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(5, 184, 125, 0.22);
  box-shadow: 0 2px 10px rgba(26, 36, 48, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.theme-toggle:hover {
  border-color: rgba(5, 184, 125, 0.55);
  background: rgba(5, 184, 125, 0.1);
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

[data-theme="light"] .theme-toggle:hover {
  background: rgba(245, 252, 249, 0.98);
}

.theme-toggle__icon {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--light {
  display: block;
}

[data-theme="light"] .theme-toggle__icon--dark {
  display: block;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--white);
  min-height: 100vh;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}
