/* Fallback design tokens (used when site.css is not loaded, e.g. design preview home page).
   Worker pages override these via site.css for proper light/dark theming. */
:root {
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --bg-canvas: #071a35;
  --bg-surface: #0b2347;
  --bg-elevated: #102d57;
  --bg-muted: #163766;
  --bg-overlay: rgba(7, 26, 53, 0.88);
  --text: #ffffff;
  --muted: #a8bed8;
  --line: rgba(88, 185, 255, 0.12);
  --line-strong: rgba(88, 185, 255, 0.26);
  --accent: #58b9ff;
  --accent-hover: #1769e0;
  --accent-fg: #071a35;
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.14);
  --ok-border: rgba(52, 211, 153, 0.35);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --warn-border: rgba(251, 191, 36, 0.35);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg-canvas: #f4f8ff;
  --bg-surface: #ffffff;
  --bg-elevated: #eaf2ff;
  --bg-muted: #dce9fb;
  --bg-overlay: rgba(244, 248, 255, 0.92);
  --text: #0f172a;
  --muted: #475569;
  --line: rgba(23, 105, 224, 0.14);
  --line-strong: rgba(23, 105, 224, 0.32);
  --accent: #1769e0;
  --accent-hover: #0f56c2;
  --accent-fg: #ffffff;
}

/* ==========================================================================
   TENGRI FUNDING — COOKIE CONSENT
   Локальная система управления согласием на cookies (без реальных трекеров).
   ========================================================================== */

.cc-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(960px, calc(100% - 24px));
  z-index: 1000;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px 20px;
  display: none;
}

.cc-banner.is-open { display: block; }

.cc-banner__title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.cc-banner__text {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.cc-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.cc-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.cc-btn:hover { background: var(--bg-muted); }
.cc-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-btn:active { transform: translateY(1px); }

.cc-btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.cc-btn--primary:hover { background: var(--accent-hover); color: #fff; }

.cc-btn--ghost {
  background: transparent;
}

.cc-link {
  color: var(--accent);
  text-decoration: underline;
  font-size: 0.9rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.cc-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cc-overlay.is-open { display: flex; }

.cc-modal {
  width: min(640px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.cc-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.cc-modal__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.cc-modal__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.cc-modal__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

.cc-modal__text {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.cc-category {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.cc-category:first-of-type { border-top: none; }

.cc-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
  margin-top: 2px;
}

.cc-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  z-index: 2;
}
.cc-toggle__track,
.cc-toggle__knob { pointer-events: none; }

.cc-toggle__track {
  position: absolute;
  inset: 0;
  background: var(--bg-muted);
  border-radius: var(--radius-pill);
  transition: background 0.15s ease;
}

.cc-toggle input:checked + .cc-toggle__track { background: var(--accent); }
.cc-toggle input:disabled + .cc-toggle__track { opacity: 0.6; cursor: not-allowed; }

.cc-toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  pointer-events: none;
}

.cc-toggle input:checked ~ .cc-toggle__knob { transform: translateX(20px); }

.cc-category__body { flex: 1 1 auto; min-width: 0; }
.cc-category__title {
  margin: 0 0 2px;
  font-weight: 600;
  font-size: 0.95rem;
}
.cc-category__desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.cc-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  vertical-align: middle;
}

.cc-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

.cc-status {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.2em;
}

.cookie-settings-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.cookie-settings-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

@media (max-width: 640px) {
  .cc-banner { bottom: 10px; padding: 12px 14px; }
  .cc-banner__title { margin-bottom: 4px; font-size: 1rem; }
  /* Keep the consent bar compact on phones: clamp the explanation and lay the
     actions out in two rows so it does not cover the sign-in card. */
  .cc-banner__text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
    font-size: 0.86rem;
  }
  .cc-banner__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }
  .cc-btn { width: 100%; text-align: center; padding: 9px 12px; }
  .cc-banner__actions .cc-link { grid-column: 1 / -1; justify-self: start; }
  .cc-modal { padding: 18px; }
}
/* Compact banner on tablet landscape (768–1023 px, landscape): keep the sign-in
   card fully visible above the fixed consent bar without scrolling. */
@media (min-width: 768px) and (max-width: 1023px) and (orientation: landscape) {
  .cc-banner { bottom: 8px; padding: 8px 12px; }
  .cc-banner__title { margin-bottom: 2px; font-size: 0.9rem; }
  /* Drop the long explanation on this short viewport; keep only the controls. */
  .cc-banner__text { display: none; }
  .cc-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  .cc-btn { padding: 6px 10px; font-size: 0.8rem; min-height: 32px; }
  .cc-banner__actions .cc-link { font-size: 0.8rem; }
}

/* Safe area: баннер не уходит под домашний индикатор. */
.cc-banner {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: calc(50% + (env(safe-area-inset-right, 0px) - env(safe-area-inset-left, 0px)) / 2);
  width: min(960px, calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}

.cc-banner button {
  min-height: 44px;
}
