/* Shared layer for the Momentum and Meridian themes.
   Maps each theme's tokens onto the variables the base stylesheet already reads,
   then restyles the components that inner pages share. */

body[class*="jn-theme-"] {
  --clr-primary: rgb(var(--clr-primary-code));
  --clr-primary-deep: color-mix(in srgb, rgb(var(--clr-primary-code)) 72%, #000);
  --bg-white: var(--th-bg);
  --bg-white-2: var(--th-surface);
  --bg-white-3: var(--th-soft);
  --bg-white-4: var(--th-soft);
  --clr-bg-2: var(--th-soft);
  --clr-black: var(--th-ink);
  --clr-body-text: var(--th-muted);
  --clr-border: var(--th-line);
  --clr-from-border: var(--th-line);
  --clr-border-2: var(--th-line);
  --th-accent: rgb(var(--clr-primary-code));
  --th-accent-soft: rgba(var(--clr-primary-code), .1);
  --th-accent-text: var(--th-accent);
  --clr-gradient-3: var(--th-soft);
  --clr-gradient-4: var(--th-soft);
  --hero-gradient: var(--th-soft);
  background: var(--th-bg);
  color: var(--th-ink);
  font-family: var(--normal-font);
  -webkit-font-smoothing: antialiased;
}

/* A brand colour dark enough for white buttons is too dark as text on a dark page. */
body[class*="jn-theme-"].dark-mode {
  --th-accent-text: color-mix(in srgb, var(--th-accent) 50%, #fff);
}

body[class*="jn-theme-"] .container {
  padding-inline: clamp(16px, 3vw, 32px);
}

body[class*="jn-theme-"] :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--heading-font);
  color: var(--th-ink);
}

body[class*="jn-theme-"] :is(.text-body, .text-muted) {
  color: var(--th-muted) !important;
}

/* Lowest specificity, so any section can set its own colour on dark panels. */
:where(body[class*="jn-theme-"]) :where(small) {
  color: var(--th-muted);
}

/* The base stylesheet colours every span. Class rules still win over this. */
:where(body[class*="jn-theme-"]) span {
  color: inherit;
}

/* Buttons */
.th-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .18s, color .18s, border-color .18s, transform .18s;
}

.th-btn-sm {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}

.th-btn-primary {
  background: var(--th-accent);
  color: #fff;
}

.th-btn-primary:hover {
  background: var(--clr-primary-deep);
  color: #fff;
}

.th-btn-ink {
  background: var(--th-ink);
  color: var(--th-bg);
}

.th-btn-ink:hover {
  background: var(--th-accent);
  color: #fff;
}

.th-btn-ghost {
  background: transparent;
  border-color: var(--th-line);
  color: var(--th-ink);
}

.th-btn-ghost:hover {
  border-color: var(--th-ink);
  color: var(--th-ink);
}

.th-arrow {
  flex: none;
  transition: transform .18s;
}

a:hover > .th-arrow {
  transform: translate(2px, -2px);
}

[dir="rtl"] .th-arrow {
  transform: scaleX(-1);
}

[dir="rtl"] a:hover > .th-arrow {
  transform: scaleX(-1) translate(2px, -2px);
}

.th-link-plain {
  color: var(--th-ink);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}

.th-link-plain:hover,
.th-link-more:hover {
  color: var(--th-accent-text);
}

.th-link-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--th-accent-text);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.th-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--th-ink);
  cursor: pointer;
}

.th-icon-btn:hover {
  background: var(--th-soft);
}

.th-tools {
  display: flex;
  align-items: center;
}

/* Navigation */
.th-logo {
  display: inline-flex;
  flex: none;
}

.th-logo img {
  display: block;
  height: 34px;
  width: auto;
}

.th-links > ul {
  display: flex;
  align-items: center;
  gap: 2px;
}

.th-links .nav-item {
  position: relative;
}

.th-links .nav-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 13px;
  color: var(--th-ink);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

.th-links .nav-link:hover,
.th-links .nav-link.active {
  color: var(--th-accent-text);
}

.th-sub {
  position: absolute;
  inset-block-start: 100%;
  inset-inline-start: 0;
  z-index: 10;
  min-width: 180px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--th-line);
  border-radius: 12px;
  background: var(--th-surface);
  box-shadow: 0 16px 40px rgba(16, 24, 40, .14);
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s;
}

.th-has-sub:hover > .th-sub,
.th-has-sub:focus-within > .th-sub {
  opacity: 1;
  visibility: visible;
}

.th-sub .dropdown-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--th-ink);
}

.th-sub .dropdown-item:hover {
  background: var(--th-soft);
  color: var(--th-accent);
}

.th-offcanvas {
  background: var(--th-surface);
  color: var(--th-ink);
}

.dark-mode .th-offcanvas .btn-close {
  filter: invert(1);
}

.th-mobile-links .nav-link {
  display: block;
  padding: 13px 0;
  border-bottom: 1px solid var(--th-line);
  color: var(--th-ink);
  font-size: 17px;
  font-weight: 500;
}

.th-mobile-links .th-sub {
  position: static;
  opacity: 1;
  visibility: visible;
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 4px 0 8px 12px;
}

.th-mobile-search {
  margin: 18px 0;
}

.th-mobile-search input {
  min-height: 46px;
}

.th-mobile-auth {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
}

/* Small shared pieces */
.th-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.th-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 100px;
  background: var(--th-soft);
  color: var(--th-ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.th-chip-link:hover {
  background: var(--th-ink);
  color: var(--th-bg);
}

.th-bookmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--th-line);
  border-radius: 50%;
  color: var(--th-ink);
  text-decoration: none;
}

.th-bookmark:hover,
.th-bookmark.active {
  border-color: var(--th-accent);
  background: var(--th-accent);
  color: #fff;
}

.th-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  color: var(--th-muted);
}

.th-field svg {
  flex: none;
}

.th-field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--th-ink);
  font-size: 16px;
  outline: 0;
}

.th-field input::placeholder {
  color: var(--th-muted);
}

.th-field:focus-within {
  color: var(--th-accent);
}

.th-subscribe {
  display: flex;
  gap: 8px;
}

.th-subscribe input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--th-line);
  background: var(--th-surface);
  color: var(--th-ink);
  font-size: 16px;
}

.th-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.th-store {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 16px;
  background: #fff;
  color: #15140f;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.15;
  text-decoration: none;
}

.th-store:hover {
  color: #15140f;
  opacity: .88;
}

.th-store small {
  display: block;
  color: #6b6960 !important;
  font-size: 11px;
  font-weight: 500;
}

.th-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.th-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
}

.th-socials a:hover {
  background: var(--th-accent);
  border-color: var(--th-accent);
  color: #fff;
}

/* Inner pages: the existing markup, in the theme's language */
body[class*="jn-theme-"] .appearance-card {
  border-color: var(--th-line);
}

body[class*="jn-theme-"] :is(.custom-btn, .btn-4, .apply-btn, .custom-btn-2) {
  background: var(--th-accent);
  border-color: var(--th-accent);
  color: #fff;
  box-shadow: none;
}

body[class*="jn-theme-"] :is(.custom-btn, .btn-4, .apply-btn, .custom-btn-2):hover {
  background: var(--clr-primary-deep);
  border-color: var(--clr-primary-deep);
  color: #fff;
}

body[class*="jn-theme-"] .page-link {
  min-width: 42px;
  min-height: 42px;
  border-color: var(--th-line);
  background: var(--th-surface);
  color: var(--th-ink);
}

body[class*="jn-theme-"] .page-item.active .page-link {
  background: var(--th-accent);
  border-color: var(--th-accent);
  color: #fff;
}

body[class*="jn-theme-"] :is(.form-control, .form-select) {
  border-color: var(--th-line);
  background-color: var(--th-surface);
  color: var(--th-ink);
}

body[class*="jn-theme-"] :is(.form-control, .form-select):focus {
  border-color: var(--th-accent);
  box-shadow: 0 0 0 3px var(--th-accent-soft);
}

body[class*="jn-theme-"] .form-check-input:checked {
  background-color: var(--th-accent);
  border-color: var(--th-accent);
}

body[class*="jn-theme-"] .box-style {
  border: 1px solid var(--th-line);
  background: var(--th-surface);
  box-shadow: none;
}

body[class*="jn-theme-"] .text-primary {
  color: var(--th-accent-text) !important;
}

/* Forms and modal shared by both themes */
.th-form-field {
  display: grid;
  gap: 6px;
  margin: 0;
}

.th-form-field > span {
  font-size: 14px;
  font-weight: 600;
}

.th-form-field :is(input, textarea) {
  min-height: 48px;
  font-size: 16px;
}

/* Modal */
.th-modal .modal-content {
  padding: clamp(20px, 3vw, 32px);
  border: 0;
  background: var(--th-surface);
  color: var(--th-ink);
}

.th-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.th-modal-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.th-modal-title small {
  display: block;
  margin-top: 4px;
  color: var(--th-muted);
  font-family: var(--normal-font);
  font-size: 15px;
  font-weight: 500;
}

.th-form {
  display: grid;
  gap: 16px;
}


/* Screen reader and motion */
.th-btn:focus-visible,
.th-icon-btn:focus-visible,
.th-bookmark:focus-visible,
.th-socials a:focus-visible,
.th-links .nav-link:focus-visible {
  outline: 2px solid var(--th-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  body[class*="jn-theme-"] *,
  body[class*="jn-theme-"] *::before,
  body[class*="jn-theme-"] *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 575.98px) {
  .th-subscribe {
    flex-direction: column;
  }
}
