/* ==========================================================================
   The light / night theme switch and the parts of the night theme that every page with a night
   version shares: the header's controls, menus, the calendar and the footer. Loaded in <head> by
   Views/Shared/_ThemeHead.cshtml, i.e. only on the winter landing page, the home page (/{lang}), and its bid
   steps (/{lang}/bid/...).

   Night is <html data-theme="dark">. Every night rule starts with html[data-theme="dark"], so it
   outranks the day rule it replaces wherever the two files load. The pages' own night colours are in
   css/pages/landing-winter-night.css and css/pages/flow-winter-night.css.
   ========================================================================== */

/* ---------- The switch (Views/Shared/_ThemeToggle.cshtml) ----------
   A round, borderless icon button the height of the header's other controls. It shows the moon by
   day and the sun at night; the two icons trade places with a quarter turn. */
.theme-toggle {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text, #333136);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  background: rgba(43, 111, 138, 0.1);
}

.theme-toggle:active {
  background: rgba(43, 111, 138, 0.16);
}

/* home.css removes every button's focus outline; the switch keeps one for keyboard users */
.theme-toggle:focus-visible {
  outline: 2px solid currentColor !important;
  outline-offset: 2px !important;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  display: block;
  width: 20px;
  height: 20px;
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle__sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
}

/* The text labels show only where a page lays the switch out as a row (css/pages/winter-app.css) */
.theme-toggle__label {
  display: none;
}

html[data-theme="dark"] .theme-toggle {
  color: #e5ee80;
}

html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(229, 238, 128, 0.12);
}

html[data-theme="dark"] .theme-toggle:active {
  background: rgba(229, 238, 128, 0.2);
}

html[data-theme="dark"] .theme-toggle__moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.4);
}

html[data-theme="dark"] .theme-toggle__sun {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle svg {
    transition: none;
  }
}

/* While js/theme-toggle.js repaints the page from the button outwards, the browser's own
   cross-fade is off: the new theme is revealed by the growing circle alone. */
html.theme-switching::view-transition-old(root),
html.theme-switching::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* ---------- Night: colours ---------- */
html[data-theme="dark"] {
  color-scheme: dark;

  /* The night palette: deep winter blues, snow-white text, ice blue in place of the day's blue.
     The brand lime stays as it is, with dark ink on it. */
  --n-bg: #0b1a2a;
  --n-card: #11253b;
  --n-card-2: #183450;
  --n-field: rgba(255, 255, 255, 0.06);
  --n-field-hover: rgba(255, 255, 255, 0.1);
  --n-line: rgba(160, 205, 235, 0.16);
  --n-line-strong: rgba(160, 205, 235, 0.32);
  --n-text: #e9f2f9;
  --n-muted: rgba(222, 235, 245, 0.7);
  --n-faint: rgba(222, 235, 245, 0.48);
  --n-ice: #9fd4ef;
  --n-ice-soft: rgba(159, 212, 239, 0.14);
  --n-ink: #0d1b2a;

  /* home.css draws its text and page background from these */
  --color-text: #e9f2f9;
  --color-bg: #0b1a2a;
  --color-gray-light: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] ::selection {
  background: #e5ee80;
  color: #0d1b2a;
}

/* Lime buttons keep dark text in every state (home.css takes it from --color-text) */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn-primary:focus,
html[data-theme="dark"] .btn-primary:active,
html[data-theme="dark"] .btn-primary.active {
  color: var(--n-ink) !important;
}

/* ---------- Night: header ---------- */
html[data-theme="dark"] .header-sticky {
  border-bottom-color: var(--n-line);
}

html[data-theme="dark"] .nav-overlay {
  background: rgba(4, 12, 22, 0.6);
}

/* The menu that drops from the header on small screens (and on Armenian pages up to 1400px) */
@media (max-width: 991.98px) {
  html[data-theme="dark"] .navbar-collapse {
    border-color: var(--n-line);
    background: rgba(13, 30, 48, 0.98);
    box-shadow: 0 24px 48px -12px rgba(0, 6, 14, 0.8);
  }
}

@media (min-width: 992px) and (max-width: 1399.98px) {
  html[data-theme="dark"][lang="hy"] .navbar-collapse {
    border-color: var(--n-line);
    background: rgba(13, 30, 48, 0.98);
    box-shadow: 0 24px 48px -12px rgba(0, 6, 14, 0.8);
  }
}

html[data-theme="dark"] .mobile-section-label {
  color: var(--n-faint);
}

html[data-theme="dark"] .mobile-profile-card,
html[data-theme="dark"] .profile-dropdown-header {
  border-bottom-color: var(--n-line);
}

html[data-theme="dark"] .mobile-profile-card .profile-name,
html[data-theme="dark"] .profile-dropdown-header .profile-name,
html[data-theme="dark"] .mobile-profile-links a,
html[data-theme="dark"] .profile-dropdown .dropdown-item {
  color: var(--n-text);
}

html[data-theme="dark"] .mobile-profile-card .profile-email,
html[data-theme="dark"] .profile-dropdown-header .profile-email {
  color: var(--n-muted);
}

html[data-theme="dark"] .mobile-profile-links a svg,
html[data-theme="dark"] .profile-dropdown .dropdown-item svg {
  color: var(--n-ice);
}

html[data-theme="dark"] .mobile-profile-links a.text-danger,
html[data-theme="dark"] .profile-dropdown .dropdown-item.text-danger {
  color: #ff8f8f !important;
}

html[data-theme="dark"] .mobile-profile-links a.text-danger svg,
html[data-theme="dark"] .profile-dropdown .dropdown-item.text-danger svg {
  color: #ff8f8f;
}

/* ---------- Night: menus ---------- */
html[data-theme="dark"] .dropdown-menu {
  --bs-dropdown-bg: #11253b;
  --bs-dropdown-color: #e9f2f9;
  --bs-dropdown-border-color: rgba(160, 205, 235, 0.16);
  --bs-dropdown-divider-bg: rgba(160, 205, 235, 0.16);
  --bs-dropdown-link-color: #e9f2f9;
  --bs-dropdown-link-hover-color: #fff;
  --bs-dropdown-link-hover-bg: rgba(255, 255, 255, 0.07);
  --bs-dropdown-link-active-color: #fff;
  --bs-dropdown-link-active-bg: rgba(229, 238, 128, 0.16);
  border-color: var(--n-line);
  background-color: var(--n-card);
  color: var(--n-text);
  box-shadow: 0 2px 6px rgba(0, 6, 14, 0.3), 0 28px 56px -20px rgba(0, 6, 14, 0.85);
}

html[data-theme="dark"] .dropdown-item {
  color: var(--n-text);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .profile-dropdown .dropdown-item:hover,
html[data-theme="dark"] .profile-dropdown .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.07);
  color: #fff;
}

html[data-theme="dark"] .dropdown-divider {
  border-top-color: var(--n-line);
}

/* The language switch */
html[data-theme="dark"] .lang-switcher__toggle {
  border-color: var(--n-line);
  background-color: transparent;
  color: var(--n-text);
}

html[data-theme="dark"] .lang-switcher__toggle:hover,
html[data-theme="dark"] .lang-switcher__toggle[aria-expanded="true"] {
  border-color: var(--n-line-strong);
  background-color: var(--n-ice-soft);
}

html[data-theme="dark"] .lang-switcher__item.active,
html[data-theme="dark"] .lang-switcher__item:active {
  background-color: rgba(229, 238, 128, 0.16);
  color: #fff;
}

/* ---------- Night: the calendar (attached to <body>, outside every page wrapper) ----------
   home.css styles it with !important and, on the landing page, behind .home-calendar; each rule
   here repeats those selectors behind html[data-theme="dark"] body. */
html[data-theme="dark"] body .flatpickr-calendar {
  border-color: var(--n-line) !important;
  background: var(--n-card) !important;
  box-shadow: 0 2px 6px rgba(0, 6, 14, 0.3), 0 28px 56px -20px rgba(0, 6, 14, 0.85) !important;
}

html[data-theme="dark"] body .flatpickr-calendar.arrowTop::after {
  border-bottom-color: var(--n-card);
}

html[data-theme="dark"] body .flatpickr-calendar.arrowBottom::after {
  border-top-color: var(--n-card);
}

html[data-theme="dark"] body .flatpickr-calendar.arrowTop::before {
  border-bottom-color: rgba(160, 205, 235, 0.3);
}

html[data-theme="dark"] body .flatpickr-calendar.arrowBottom::before {
  border-top-color: rgba(160, 205, 235, 0.3);
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-current-month,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-monthDropdown-months,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-current-month input.cur-year {
  color: var(--n-text) !important;
}

/* The month list: style.css gives it the page's light background */
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months {
  background-color: transparent;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month {
  background-color: #11253b;
  color: #e9f2f9;
}

html[data-theme="dark"] body .flatpickr-calendar .numInputWrapper span.arrowUp::after {
  border-bottom-color: var(--n-muted);
}

html[data-theme="dark"] body .flatpickr-calendar .numInputWrapper span.arrowDown::after {
  border-top-color: var(--n-muted);
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-weekday {
  color: var(--n-faint) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day {
  color: var(--n-text) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day:hover:not(.selected):not(.startRange):not(.endRange),
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.today:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  border-color: transparent !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.today {
  border-color: var(--n-line-strong) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.inRange {
  background: #1d3b56 !important;
  border-color: transparent !important;
  box-shadow: -5px 0 0 #1d3b56, 5px 0 0 #1d3b56 !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.prevMonthDay,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.nextMonthDay {
  color: rgba(222, 235, 245, 0.38) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.prevMonthDay.inRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.nextMonthDay.inRange {
  color: var(--n-text) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.flatpickr-disabled,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.flatpickr-disabled:hover {
  background: transparent !important;
  color: rgba(222, 235, 245, 0.24) !important;
}

/* The chosen days: brand lime with dark ink. Last, so it also covers the days of the next month. */
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.selected,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.startRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.endRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.prevMonthDay.selected,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.prevMonthDay.startRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.prevMonthDay.endRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.nextMonthDay.selected,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.nextMonthDay.startRange,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-day.nextMonthDay.endRange {
  background: #e5ee80 !important;
  border-color: #e5ee80 !important;
  color: #0d1b2a !important;
  font-weight: 600 !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-prev-month,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-next-month {
  fill: var(--n-text) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-prev-month svg,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-next-month svg {
  fill: var(--n-text) !important;
}

html[data-theme="dark"] body .flatpickr-calendar .flatpickr-prev-month:hover svg,
html[data-theme="dark"] body .flatpickr-calendar .flatpickr-next-month:hover svg {
  fill: #e5ee80 !important;
}

/* ---------- Night: footer ---------- */
html[data-theme="dark"] .site-footer {
  border-top-color: var(--n-line);
}

html[data-theme="dark"] .site-footer__bottom {
  border-top-color: var(--n-line);
}

/* The lime social buttons keep dark icons */
html[data-theme="dark"] .site-footer__social-btn,
html[data-theme="dark"] .site-footer__social-btn svg {
  color: var(--n-ink);
}
