/* Estate child theme, network layer (wordpress/estate/layer). Values come only from the --es-* tokens (tokens.css).
   Logical properties throughout, so every rule holds right to left. Phone first: the base rules are for 390 px, the
   wider rules come after. */

/* ---------- The page: canvas, ink, type ---------- */
body.pf-estate { background: var(--es-canvas); color: var(--es-ink); font-family: var(--es-font); line-height: var(--es-leading); }
body.pf-estate :where(h1, h2, h3, h4) { font-family: var(--es-font-head); font-weight: var(--es-weight-head); line-height: var(--es-leading-tight); color: var(--es-ink); }
body.pf-estate :where(a) { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
body.pf-estate :where(.site-content a:not([class])) { text-decoration-line: underline; }
body.pf-estate :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--es-focus); outline-offset: 2px; }
body.pf-estate .site-wrapper, body.pf-estate .site-content, body.pf-estate #page { background: var(--es-canvas); }
body.pf-estate .site-header-wrapper, body.pf-estate #masthead, body.pf-estate .site-footer, body.pf-estate #colophon { background: var(--es-canvas); color: var(--es-ink); border-color: var(--es-line); box-shadow: var(--es-shadow); }
body.pf-estate .site-sub-header, body.pf-estate .buddyx-sub-header { background: var(--es-raised); color: var(--es-ink); border-block-end: 1px solid var(--es-line); }
body.pf-estate .site-sub-header :where(h1, .entry-title, .page-title) { color: var(--es-ink); font-size: var(--es-text-xl); }

/* ---------- BuddyX Pro's own tokens read ours: one palette for the theme, its colour switch and its components ---------- */
body.pf-estate {
  --bx-color-bg: var(--es-canvas); --bx-color-bg-page: var(--es-canvas); --bx-color-bg-elevated: var(--es-raised); --bx-color-bg-muted: var(--es-muted); --bx-color-bg-subtle: var(--es-muted); --bx-color-bg-overlay: var(--es-canvas);
  --bx-color-fg: var(--es-ink); --bx-color-fg-muted: var(--es-ink-3); --bx-color-fg-subtle: var(--es-ink-3); --bx-color-fg-inverse: var(--es-primary-ink);
  --bx-color-border: var(--es-line); --bx-color-border-strong: var(--es-line-strong); --bx-color-divider: var(--es-line); --bx-color-shadow: transparent;
  --bx-color-accent: var(--es-accent); --bx-color-button-bg: var(--es-primary); --bx-color-button-bg-hover: var(--es-primary-hover); --bx-color-button-border: var(--es-primary); --bx-color-button-border-hover: var(--es-primary-hover);
  --bx-color-input-bg: var(--es-surface); --bx-color-input-border: var(--es-line-strong);
  --bx-color-success: var(--es-ok); --bx-color-warning: var(--es-warn); --bx-color-error: var(--es-crit); --bx-color-info: var(--es-info);
  --button-background-color: var(--es-primary); --button-background-hover-color: var(--es-primary-hover); --button-border-color: var(--es-primary); --button-border-hover-color: var(--es-primary-hover);
  --color-theme-primary: var(--es-primary); --color-theme-secondary: var(--es-ink-2); --color-site-title-hover: var(--es-ink-2); --color-topbar-bg: var(--es-canvas); --color-topbar-content: var(--es-ink-3); --color-topbar-link: var(--es-ink); --color-topbar-link-hover: var(--es-ink-2);
  --color-subheader-background: var(--es-raised); --color-subheader-title: var(--es-ink); --color-bp-count: var(--es-ink-3); --focus-outline-color: var(--es-focus);
}
body.pf-estate .bx-color-mode-toggle__btn { background: var(--es-primary); color: var(--es-primary-ink); border-radius: var(--es-radius-button); }

/* ---------- Mixed scripts: an untranslated English string inside a right-to-left screen keeps its own punctuation ---------- */
[dir="rtl"] body.pf-estate :is(#buddypress, .nxn, .nxc-hub, .tutor-wrap, .pf-login) :is(p, h1, h2, h3, h4, li, dt, dd, label, td, th, figcaption, summary) { unicode-bidi: plaintext; }

/* ---------- One header (D37): the network chrome sits under the theme header; the theme's menus print nothing ---------- */
body.pf-chromed .main-navigation, body.pf-chromed .menu-toggle, body.pf-chromed .buddyx-mobile-menu > .menu-toggle { display: none; }
body.pf-chromed .pf-chrome--header { position: relative; z-index: 20; }
body.pf-chromed .pf-chrome--footer { margin-block-start: var(--es-space-12); }

/* ---------- Controls ---------- */
body.pf-estate :where(.button, button:not(.pf *):not(.nxn *):not([class*="nx"]):not([class*="nf-"]), input[type="submit"], input[type="button"], .bp-button, .generic-button a, .tutor-btn, .wp-element-button) {
  border-radius: var(--es-radius-button); min-block-size: var(--es-target); padding-inline: var(--es-space-4);
  font-family: var(--es-font); font-size: var(--es-text-sm); font-weight: 500; box-shadow: none; transition: background-color var(--es-motion-fast) var(--es-ease);
}
body.pf-estate :where(input[type="submit"], .button-primary, .tutor-btn-primary, #buddypress .standard-form [type="submit"], .bp-login-widget-register-link a) {
  background: var(--es-primary); color: var(--es-primary-ink); border: 1px solid var(--es-primary);
}
body.pf-estate :where(input[type="submit"], .button-primary, .tutor-btn-primary):hover { background: var(--es-primary-hover); }
body.pf-estate :where(.generic-button a, .bp-button, .tutor-btn-outline-primary, .button:not(.button-primary)) { background: transparent; color: var(--es-ink); border: 1px solid var(--es-line-strong); }
body.pf-estate :where(input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], select, textarea) {
  background: var(--es-surface); color: var(--es-ink); border: 1px solid var(--es-line-strong); border-radius: var(--es-radius); min-block-size: var(--es-target); padding-inline: var(--es-space-3); font-family: var(--es-font);
}

/* ---------- BuddyPress: directories, items, profile and group headers, navigation ---------- */
body.pf-estate #buddypress :where(.item-list > li, .activity-list > li, .bp-list > li) { border-color: var(--es-line); background: var(--es-surface); }
body.pf-estate #buddypress :where(.item-title, .list-title) a { color: var(--es-ink); }
body.pf-estate #buddypress :where(.item-meta, .activity-header, .meta, .last-activity, time) { color: var(--es-ink-3); font-size: var(--es-text-xs); }
body.pf-estate #buddypress :where(.bp-navs, .item-list-tabs) { border-block-end: 1px solid var(--es-line); background: transparent; }
body.pf-estate #buddypress :where(.bp-navs li a, .item-list-tabs li a) { color: var(--es-ink-2); border-radius: 0; }
body.pf-estate #buddypress :where(.bp-navs li.current a, .bp-navs li.selected a, .item-list-tabs li.current a, .item-list-tabs li.selected a) { color: var(--es-ink); box-shadow: inset 0 -2px 0 var(--es-rule); background: transparent; }
body.pf-estate #buddypress :where(.count, .bp-navs .count) { background: var(--es-muted); color: var(--es-ink-2); border-radius: var(--es-radius-chip); }
body.pf-estate #buddypress :where(#item-header, .single-headers, #cover-image-container) { background: var(--es-raised); color: var(--es-ink); }
body.pf-estate #buddypress :where(.avatar) { border-radius: var(--es-radius); }
body.pf-estate #buddypress :where(.bp-feedback, .bp-messages, #message) { background: var(--es-raised); color: var(--es-ink); border-inline-start: 2px solid var(--es-rule); border-radius: var(--es-radius); }
body.pf-estate .pf-es-grouptype { font-family: var(--es-font-mono); font-size: var(--es-text-xs); color: var(--es-ink-3); margin: 0; }
:root:lang(fa) .pf-es-grouptype, :root:lang(ar) .pf-es-grouptype, :root:lang(ckb) .pf-es-grouptype { font-family: var(--es-font); }

/* ---------- Tutor LMS ---------- */
body.pf-estate :where(.tutor-wrap, .tutor-course-details-page, .tutor-dashboard) { color: var(--es-ink); font-family: var(--es-font); }
body.pf-estate :where(.tutor-card, .tutor-course-card, .tutor-dashboard-content, .tutor-course-details-widget) { background: var(--es-surface); border: 1px solid var(--es-line); border-radius: var(--es-radius); box-shadow: none; }
body.pf-estate :where(.tutor-color-black, .tutor-course-name a, .tutor-course-details-title) { color: var(--es-ink); }
body.pf-estate :where(.tutor-color-muted, .tutor-color-secondary, .tutor-meta) { color: var(--es-ink-3); }
body.pf-estate :where(.tutor-progress-bar) { background: var(--es-muted); }
body.pf-estate :where(.tutor-progress-value) { background: var(--es-ink); }
body.pf-estate { --tutor-color-primary: var(--es-primary); --tutor-color-primary-hover: var(--es-primary-hover); --tutor-body-color: var(--es-ink); --tutor-border-color: var(--es-line); }

/* ---------- Participation recognition (GamiPress; never a qualification) ---------- */
body.pf-estate :where(.nx-recognition, .nxp-plate) { border: 1px solid var(--es-line); border-radius: var(--es-radius); background: var(--es-surface); padding: var(--es-space-4); color: var(--es-ink); }
body.pf-estate :where(.nxp-plate__label, .nxp-caption, .nx-recognition-line) { color: var(--es-ink-3); font-size: var(--es-text-xs); }
body.pf-estate :where(.gamipress-achievement, .gamipress-rank, .gamipress-points) { border-color: var(--es-line); color: var(--es-ink); }

/* ---------- The estate plugins' kit regions: their --nx-* tokens and the community gradient read ours ---------- */
body.pf-estate, body.pf-estate :is(.nxn, .nxn[data-theme], .nxc-hub, .nxc-bp, .nxd, .nexus-dashboard, #nexus-app, .nf-form, .nexus-forms) {
  --nx-bg-canvas: var(--es-canvas); --nx-bg-surface: var(--es-surface); --nx-bg-elevated: var(--es-raised); --nx-bg-muted: var(--es-muted);
  --nx-bg-hover: var(--es-hover); --nx-bg-pressed: var(--es-hover); --nx-bg-overlay: var(--es-canvas);
  --nx-border-hairline: var(--es-line); --nx-border-hairline-strong: var(--es-line-strong); --nx-border-subtle: var(--es-line); --nx-border-default: var(--es-line-strong); --nx-border-strong: var(--es-line-strong);
  --nx-text-primary: var(--es-ink); --nx-text-secondary: var(--es-ink-2); --nx-text-muted: var(--es-ink-3); --nx-text-disabled: var(--es-ink-3);
  --nx-accent: var(--es-accent); --nx-accent-strong: var(--es-accent); --nx-accent-soft: var(--es-accent-soft); --nx-accent-glow: transparent;
  --nx-primary-bg: var(--es-primary); --nx-primary-hover: var(--es-primary-hover); --nx-primary-active: var(--es-primary-hover); --nx-primary-ink: var(--es-primary-ink);
  --nx-info: var(--es-info); --nx-positive: var(--es-ok); --nx-caution: var(--es-warn); --nx-critical: var(--es-crit); --nx-quantum: var(--es-ink-2);
  --nx-info-soft: var(--es-accent-soft); --nx-positive-soft: var(--es-accent-soft); --nx-caution-soft: var(--es-accent-soft); --nx-critical-soft: var(--es-accent-soft); --nx-quantum-soft: var(--es-accent-soft);
  --nx-focus: var(--es-focus);
  --nx-font-sans: var(--es-font); --nx-font-mono: var(--es-font-mono);
  --nx-radius-xs: var(--es-radius-chip); --nx-radius-sm: var(--es-radius); --nx-radius-md: var(--es-radius); --nx-radius-lg: var(--es-radius); --nx-radius-xl: var(--es-radius); --nx-radius-chip: var(--es-radius-chip);
  --nx-shadow-sm: var(--es-shadow); --nx-shadow-md: var(--es-shadow); --nx-shadow-lg: var(--es-shadow); --nx-shadow-glow: var(--es-shadow);
  --nx-motion-fast: var(--es-motion-fast); --nx-motion-base: var(--es-motion); --nx-ease-standard: var(--es-ease);
  --nx-vis-cat-1: var(--es-series-1); --nx-vis-cat-2: var(--es-series-2); --nx-vis-cat-3: var(--es-series-3); --nx-vis-cat-4: var(--es-series-4); --nx-vis-cat-5: var(--es-ink-3);
  --nxc-g1: var(--es-series-1); --nxc-g2: var(--es-series-2); --nxc-g3: var(--es-series-3); --nxc-g4: var(--es-series-4);
  --nxc-grad: linear-gradient(90deg, var(--es-rule), var(--es-rule)); --nxc-grad-v: linear-gradient(180deg, var(--es-rule), var(--es-rule));
  color-scheme: inherit;
}
:root[data-bx-mode="dark"] body.pf-estate .nxn, :root.dark-mode body.pf-estate .nxn { color-scheme: dark; }

/* ---------- Wider screens ---------- */
@media (min-width: 960px) {
  body.pf-estate .site-sub-header :where(h1, .entry-title, .page-title) { font-size: var(--es-text-2xl); }
}
