/* Public navigation, header controls and privacy page. */

/* Keep the VPN header/control cluster visible while the page scrolls. */
.brand {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: 12px;
  padding-bottom: 12px;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}

.header-switchers {
  flex: 0 0 252px;
  width: 252px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  background: var(--segment-background);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}

.header-switchers .language-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: transparent;
  border: 0;
  border-radius: 0;
}

.platform-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
}

.platform-button {
  min-height: 32px;
  padding: 6px 10px;
  gap: 6px;
  background: transparent;
  color: var(--secondary);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 600;
  cursor: pointer;
}

.platform-icon {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.platform-button.active {
  background: var(--language-active-background);
  color: var(--language-active-text);
  border-color: var(--language-active-border);
}

.platform-button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.site-nav {
  display: grid;
  grid-template-columns: minmax(0, 168px);
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.site-nav a[href="privacy.html"] {
  display: none;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.header-actions-row {
  display: flex;
  width: 100%;
  margin-top: 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.header-actions-row .site-nav {
  width: 100%;
  margin-top: 0;
  grid-template-columns: minmax(0, 1fr);
}

.header-promo {
  display: none;
  margin: 0;
}

body:has(#vpnCard:not(.hidden)) .header-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

body:has(#vpnCard:not(.hidden)) .header-actions-row .site-nav {
  width: auto;
}

body:has(#vpnCard:not(.hidden))
.header-promo:not(:has(#promoForm.hidden)) {
  display: block;
}

.header-promo .promo-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.header-promo .promo-input,
.header-promo .promo-actions > button {
  width: 100%;
  min-width: 0;
  max-width: none;
  min-height: 44px;
  height: 44px;
  border-radius: 11px;
  padding: 8px 10px;
  font-size: 15px;
}

.header-promo .promo-message:not(:empty) {
  margin: 8px 2px 0;
  text-align: right;
}

.entry-point-note {
  margin: 8px 4px 0;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
}

.site-nav a:hover {
  border-color: var(--secondary);
}

.site-nav a:focus-visible,
.privacy-page a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 24px;
  margin-top: 24px;
  font-size: 14px;
  line-height: 1.5;
}

.site-footer a {
  color: var(--secondary);
  text-underline-offset: 3px;
}

.site-label {
  display: none;
}

html[lang="en"] .site-label[lang="en"],
html[lang="ru"] .site-label[lang="ru"],
html[lang="lv"] .site-label[lang="lv"] {
  display: inline;
}

.privacy-page [hidden] {
  display: none !important;
}

.privacy-page article {
  font-size: 16px;
  line-height: 1.65;
}

.privacy-page article > h2 {
  font-size: 28px;
}

.privacy-lead {
  margin: 16px 0;
  font-size: 18px;
  line-height: 1.55;
}

.privacy-page section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.privacy-page h3 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.35;
}

.privacy-page p {
  margin: 12px 0 0;
}

.privacy-page dl {
  margin: 0;
}

.privacy-page dt {
  margin-top: 16px;
  font-weight: 650;
}

.privacy-page dd {
  margin: 4px 0 0;
}

.privacy-page a {
  color: var(--text);
  text-underline-offset: 3px;
}

.privacy-page code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--code-background);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.privacy-page .privacy-date {
  margin-top: 24px;
  color: var(--secondary);
  font-size: 14px;
}

@media (max-width: 520px) {
  .brand-top {
    flex-direction: column;
    align-items: stretch;
  }

  .header-switchers {
    flex-basis: auto;
    width: 100%;
  }

  body:has(#vpnCard:not(.hidden)) .header-actions-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .header-actions-row .site-nav {
    width: 100%;
  }

  .site-nav {
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
  }

  .site-nav a {
    padding-left: 12px;
    padding-right: 12px;
  }

  .header-actions-row {
    padding: 12px;
  }

  .header-promo .promo-input,
  .header-promo .promo-actions > button,
  .header-actions-row .site-nav a {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 14px;
  }
}

/* Equal language/platform segments, with room for the Windows label. */
.header-switchers.three-platform-switchers {
  flex-basis: 300px;
  width: 300px;
}
.three-platform-switchers .platform-switcher:has(#platformWindows:not(.hidden)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.three-platform-switchers .platform-button {
  min-width: 0;
  padding: 6px 4px;
  gap: 4px;
  white-space: nowrap;
}
@media (min-width: 760px) {
  .header-switchers.three-platform-switchers {
    flex-basis: 336px;
    width: 336px;
  }
}
@media (max-width: 520px) {
  .header-switchers.three-platform-switchers {
    flex-basis: auto;
    width: 100%;
  }
}

/* Keep only language/platform selectors visible while scrolling. */
.brand {
  position: static;
  top: auto;
  z-index: auto;
  padding-top: 0;
  padding-bottom: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.brand-copy p {
  display: none;
}

.brand-top {
  min-height: 76px;
  padding-right: 324px;
}

.header-switchers,
.header-switchers.three-platform-switchers {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(24px, calc((100vw - 760px) / 2 + 24px));
  z-index: 50;
  flex-basis: auto;
  background: color-mix(in srgb, var(--background) 94%, var(--segment-background));
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 1px 8px rgba(0,0,0,.08);
}

@media (min-width: 760px) {
  .brand-top {
    padding-right: 360px;
  }
}

@media (max-width: 520px) {
  .brand-top {
    min-height: 0;
    padding-top: 86px;
    padding-right: 0;
  }

  .header-switchers,
  .header-switchers.three-platform-switchers {
    top: max(8px, env(safe-area-inset-top));
    left: 16px;
    right: 16px;
    width: auto;
  }
}

/* Final sticky cluster: TOLF VPN title + language/platform selectors only. */
.brand {
  position: static;
  padding-top: 104px;
  background: transparent;
}

.brand-top {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(calc(100% - 48px), 712px);
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: color-mix(in srgb, var(--background) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.brand-copy {
  flex: 0 0 auto;
}

.brand-copy p {
  display: none;
}

.header-switchers,
.header-switchers.three-platform-switchers {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
  flex: 0 0 336px;
  width: 336px;
  background: var(--segment-background);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

@media (max-width: 759px) {
  .header-switchers,
  .header-switchers.three-platform-switchers {
    flex-basis: 300px;
    width: 300px;
  }
}

@media (max-width: 520px) {
  .brand {
    padding-top: 142px;
  }

  .brand-top {
    top: max(8px, env(safe-area-inset-top));
    width: calc(100% - 32px);
    padding: 8px 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .brand h1 {
    font-size: 26px;
  }

  .header-switchers,
  .header-switchers.three-platform-switchers {
    flex-basis: auto;
    width: 100%;
  }
}

/* Protocol selector: two slots now, second reserved for a future protocol. */
.brand {
  padding-top: 114px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.brand-copy::after {
  content: "IKEv2";
  width: 92px;
  height: 64px;
  box-sizing: border-box;
  padding-top: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background:
    linear-gradient(
      to bottom,
      color-mix(in srgb, var(--success) 84%, #1d1d1f 16%) 0,
      color-mix(in srgb, var(--success) 84%, #1d1d1f 16%) calc(50% - .5px),
      var(--border) calc(50% - .5px),
      var(--border) calc(50% + .5px),
      var(--card) calc(50% + .5px),
      var(--card) 100%
    );
  color: #ffffff;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 520px) {
  .brand {
    padding-top: 112px;
  }

  .brand-copy {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
  }

  .brand-copy::after {
    width: 148px;
    height: 30px;
    padding: 0 0 0 19px;
    align-items: center;
    justify-content: flex-start;
    background:
      linear-gradient(
        to right,
        color-mix(in srgb, var(--success) 84%, #1d1d1f 16%) 0,
        color-mix(in srgb, var(--success) 84%, #1d1d1f 16%) calc(50% - .5px),
        var(--border) calc(50% - .5px),
        var(--border) calc(50% + .5px),
        var(--card) calc(50% + .5px),
        var(--card) 100%
      );
  }
}

/* Static final VPN header — rendered in its final geometry before deferred JS runs. */
.brand-copy::after {
  content: none !important;
  display: none !important;
}

.brand {
  padding-top: 0 !important;
  margin-bottom: 16px !important;
}

.brand-copy {
  display: block !important;
  width: 100%;
}

.brand-copy > p {
  display: none !important;
}

.brand-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  white-space: nowrap;
}

.brand-title-row h1 {
  grid-column: 2;
  margin: 0;
  text-align: center;
}

.brand-title-row .home-navigation {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 42px;
  justify-self: start;
  padding: 0;
  color: var(--text-secondary, #6e6e73);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  line-height: 1.2;
}

.brand-title-row .help-navigation {
  grid-column: 3;
  justify-self: end;
  color: #1f4180;
  font-weight: 600;
}

.home-navigation:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 4px;
}

.brand-top {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  transform: none !important;
  z-index: 60 !important;
  width: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box;
  padding-top: max(10px, env(safe-area-inset-top)) !important;
  padding-bottom: 10px !important;
  padding-left: max(24px, calc((100vw - 712px) / 2)) !important;
  padding-right: max(24px, calc((100vw - 712px) / 2)) !important;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 8px;
  background: color-mix(in srgb, var(--background) 90%, transparent) !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
  box-shadow: none !important;
}

.header-control-cluster {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 12px;
}

.header-control-cluster .header-switchers,
.header-control-cluster .header-switchers.three-platform-switchers {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
  flex: 0 0 336px;
  width: 336px;
  background: var(--segment-background);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}

.protocol-selector {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 28px;
  align-items: stretch;
  gap: 8px;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

.protocol-label {
  align-self: start;
  margin-top: 8px;
  font-size: 13px;
  line-height: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.protocol-column {
  width: 28px;
  min-height: 100%;
  box-sizing: border-box;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}

.protocol-dot {
  width: 12px;
  height: 12px;
  box-sizing: border-box;
  display: block;
  border-radius: 50%;
}

.protocol-dot-active {
  background: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 76%, #1d1d1f 24%);
}

.protocol-dot-reserve {
  background: #ffffff;
  border: 1px solid var(--border);
}

/* Wide iPad: title and protocol/platform controls share one row from first paint. */
@media (min-width: 768px) and (orientation: landscape) {
  html.tolf-ipad .brand-top {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 42px auto;
    column-gap: 12px;
    row-gap: 8px;
    align-items: center;
  }

  html.tolf-ipad .brand-copy,
  html.tolf-ipad .brand-title-row {
    display: contents !important;
  }

  html.tolf-ipad .brand-title-row .home-navigation {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  html.tolf-ipad .brand-title-row .help-navigation {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  html.tolf-ipad .brand-title-row h1 {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    margin: 0;
    text-align: left;
    font-size: 42px;
    line-height: 1.04;
  }

  html.tolf-ipad .header-control-cluster {
    grid-column: 2 / 4;
    grid-row: 2;
    justify-self: end;
    margin-left: 0;
  }
}

@media (max-width: 759px) {
  .brand-top {
    padding-left: 24px !important;
    padding-right: 24px !important;
  }

  .header-control-cluster .header-switchers,
  .header-control-cluster .header-switchers.three-platform-switchers {
    flex-basis: 300px;
    width: 300px;
  }
}

@media (max-width: 520px) {
  .brand-top {
    padding-top: max(8px, env(safe-area-inset-top)) !important;
    padding-bottom: 8px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .header-control-cluster {
    width: 100%;
    margin-left: 0;
    gap: 8px;
  }

  .header-control-cluster .header-switchers,
  .header-control-cluster .header-switchers.three-platform-switchers {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .protocol-selector {
    grid-template-columns: auto 26px;
    gap: 6px;
  }

  .protocol-label {
    font-size: 12px;
  }

  .protocol-column {
    width: 26px;
  }

  .brand-title-row {
    gap: 4px;
  }

  .brand-title-row h1 {
    font-size: 20px;
  }

  .brand-title-row .home-navigation {
    font-size: 12px;
  }
}

@media (max-width: 350px) {
  .brand-title-row h1 {
    font-size: 18px;
  }

  .brand-title-row .home-navigation {
    font-size: 11px;
  }
}

@media (prefers-color-scheme: dark) {
  .brand-title-row .help-navigation {
    color: #9dbbff;
  }
}
