/*
 * Lattice bridge for WordPress.
 *
 * The page content of arphost.com was written against the previous theme's
 * styles, which are carried over in legacy.min.css and the page stylesheets.
 * Those styles read a set of custom properties. This file points every one of
 * them at a Lattice token, so all existing content takes the Lattice colors,
 * radii, shadows and type without any page being edited. It loads last.
 */

/* 1. Old variables, now aliases of Lattice tokens */
html:root {
    /* One step darker than the old theme in light mode, so brand colored labels and white text on brand both pass AA. */
    --brand-primary: var(--lt-c-brand-700);
    --brand-primary-dark: var(--lt-c-brand-800);
    --brand-primary-light: var(--lt-c-brand-logo);
    --brand-primary-text: var(--lt-brand-text);
    --brand-secondary: var(--lt-c-warn-700);
    --brand-secondary-dark: var(--lt-c-warn-700);
    --brand-accent: var(--lt-c-brand-600);
    --brand-success: var(--lt-good);
    --brand-warning: var(--lt-warn);
    --brand-danger: var(--lt-bad);
    --bg-body: var(--lt-surface-0);
    --bg-surface: var(--lt-surface-1);
    --bg-surface-elevated: var(--lt-surface-1);
    --bg-surface-hover: var(--lt-surface-2);
    --bg-header: var(--lt-header);
    --bg-footer: var(--lt-surface-1);
    --bg-card: var(--lt-surface-1);
    --bg-card-hover: var(--lt-surface-2);
    --bg-input: var(--lt-surface-0);
    --bg-hero: linear-gradient(180deg, #0a0f1a 0%, #111827 100%);
    --text-primary: var(--lt-ink-1);
    --text-secondary: var(--lt-ink-2);
    --text-muted: var(--lt-ink-2);
    --text-inverse: var(--lt-ink-inverse);
    --text-link: var(--lt-brand-text);
    --text-link-hover: var(--lt-c-brand-800);
    --border-color: var(--lt-line-1);
    --border-color-light: var(--lt-surface-2);
    --border-color-focus: var(--lt-c-brand-logo);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: var(--lt-shadow-1);
    --shadow-lg: var(--lt-shadow-1);
    --shadow-xl: var(--lt-shadow-2);
    --shadow-glow: 0 0 0 rgba(0, 0, 0, 0);
    --shadow-card: var(--lt-shadow-1);
    --transition-fast: var(--lt-motion-fast) ease;
    --transition-base: var(--lt-motion-base) ease;
    --radius-sm: 8px;
    --radius-md: var(--lt-radius-control);
    --radius-lg: var(--lt-radius-card);
    --radius-xl: var(--lt-radius-panel);
    --container-max: var(--lt-layout-content);
    /* The old header was fixed and pages padded themselves by its height. The Lattice header is in the flow. */
    --header-height: 0px;
}
html:root[data-theme="dark"] {
    --brand-primary: var(--lt-c-brand-600);
    --brand-primary-dark: var(--lt-c-brand-700);
    --brand-secondary: var(--lt-c-signal-500);
    --brand-secondary-dark: var(--lt-c-signal-600);
    --brand-accent: var(--lt-c-brand-500);
    --text-link-hover: var(--lt-c-brand-200);
}

/* 2. Type. One family for everything, mono for technical data. */
body.lt,
body.lt button,
body.lt input,
body.lt select,
body.lt textarea { font-family: var(--lt-font-ui); }
body.lt code,
body.lt kbd,
body.lt pre,
body.lt samp { font-family: var(--lt-font-mono); }
body.lt .site-main h1,
body.lt .site-main h2 { font-stretch: 104%; }
body.lt { background: var(--lt-surface-0); color: var(--lt-ink-1); }

/* 3. Buttons take the Lattice look everywhere the old button classes appear. */
body.lt .btn,
body.lt .wp-block-button__link { border-radius: var(--lt-radius-control); font-weight: 600; box-shadow: none; }
body.lt .btn-primary,
body.lt .wp-block-button:not(.is-style-outline) > .wp-block-button__link:not(.has-background) {
    background: var(--lt-c-brand-logo) !important;
    color: var(--lt-c-brand-logo-ink) !important;
    -webkit-text-fill-color: var(--lt-c-brand-logo-ink) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}
body.lt .btn-primary:hover,
body.lt .wp-block-button:not(.is-style-outline) > .wp-block-button__link:not(.has-background):hover {
    background: var(--lt-c-brand-400) !important;
    transform: none;
}
body.lt .btn:hover { transform: none; }

/* 4. Headline accent. A flat brand color in place of the old two color gradient. */
body.lt .gradient-text,
body.lt .hero h1 .gradient-text,
body.lt .gutenberg-page .hero-main-heading .gradient-text {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: var(--lt-c-brand-logo);
    color: var(--lt-c-brand-logo);
}

/* 5. Back to top button */
body.lt .back-to-top { border-radius: var(--lt-radius-control); background: var(--lt-brand); color: var(--lt-brand-ink); box-shadow: var(--lt-shadow-1); }

/* 6. Anchors land below the sticky header */
html { scroll-padding-top: calc(var(--lt-layout-header) + 16px); }

/* 7. Outline buttons that sit on the always dark hero stay light */
body.lt .gutenberg-page .hero-btn-secondary .wp-block-button__link,
body.lt .page-hero .wp-block-button.is-style-outline .wp-block-button__link {
    color: #f1f5f9 !important;
    -webkit-text-fill-color: #f1f5f9 !important;
    border-color: rgba(255, 255, 255, .35) !important;
    background: transparent !important;
}

/* 8. Nothing in page content may push the page sideways on a phone */
body.lt .site-main { overflow-wrap: break-word; }
body.lt .site-main a,
body.lt .site-main strong,
body.lt .site-main h1,
body.lt .site-main h2,
body.lt .site-main h3 { overflow-wrap: anywhere; }
body.lt .site-main img { max-width: 100%; height: auto; }
body.lt .site-main code { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    body.lt .site-main table { width: 100%; max-width: 100%; table-layout: fixed; font-size: 14px; }
    body.lt .site-main th,
    body.lt .site-main td { padding: 8px 6px; overflow-wrap: anywhere; hyphens: auto; }
}

/* 9. Small brand colored labels need a lighter cyan on dark surfaces */
html[data-theme="dark"] body.lt .section-label,
html[data-theme="dark"] body.lt .gutenberg-page .section-label { color: var(--lt-c-brand-300) !important; -webkit-text-fill-color: var(--lt-c-brand-300) !important; }
html[data-theme="light"] body.lt .section-label,
html[data-theme="light"] body.lt .gutenberg-page .section-label { color: var(--lt-c-brand-800) !important; -webkit-text-fill-color: var(--lt-c-brand-800) !important; }

/* 10. Text on a dark cover block stays light in both modes, unless the editor gave it a color */
body.lt .wp-block-cover:not(.is-light) .wp-block-cover__inner-container :is(h1, h2, h3, h4, p):not(.has-text-color) {
    color: #f1f5f9 !important;
    -webkit-text-fill-color: #f1f5f9 !important;
}

/* 9. A button with a pale inline background is drawn as a soft brand button with brand text, so it reads as the second choice next to the main button. The carried over styles force white text on it and the page layer would make it the main cyan. Only the background is matched, because a white text color in the same style attribute is not a pale button. */
body.lt .site-main .wp-block-button__link.has-background:is([style*="background-color:#e0f2fe"], [style*="background:#e0f2fe"]),
body.lt .site-main .wp-block-button__link.has-background:is([style*="background-color:#ecfeff"], [style*="background:#ecfeff"]),
body.lt .site-main .wp-block-button__link.has-background:is([style*="background-color:#f1f5f9"], [style*="background:#f1f5f9"]),
body.lt .site-main .wp-block-button__link.has-background:is([style*="background-color:#ffffff"], [style*="background:#ffffff"]) {
    background: var(--lt-brand-soft) !important;
    color: var(--lt-brand-text) !important;
    -webkit-text-fill-color: currentColor !important;
}

/* 10. Heroes are dark in both modes, so inside them the brand color is the bright logo cyan. */
html:root body.lt .hero-gb,
html:root body.lt .hero-section,
html:root body.lt .page-hero,
html:root body.lt .hero {
    --brand-primary: var(--lt-c-brand-logo);
    --brand-primary-text: var(--lt-c-brand-300);
    --text-link: var(--lt-c-brand-300);
}

/* 11. Some carried over rules raise their weight with an id inside :not(). Buttons on the brand color still need dark text, so this outweighs them. */
body.lt .site-main .wp-block-button:not(.is-style-outline) > .wp-block-button__link:not(.has-background):not(#lattice-x):not(#lattice-y) {
    color: var(--lt-c-brand-logo-ink) !important;
    -webkit-text-fill-color: var(--lt-c-brand-logo-ink) !important;
}

/* 12. The headline accent is only bright inside dark heroes. On a light surface it uses the readable brand text color. */
body.lt .site-main :not(.hero-gb):not(.hero-section):not(.page-hero):not(.hero) > .gradient-text { -webkit-text-fill-color: var(--lt-brand-text); color: var(--lt-brand-text); }
body.lt .hero-gb .gradient-text,
body.lt .hero-section .gradient-text,
body.lt .page-hero .gradient-text,
body.lt .hero .gradient-text { -webkit-text-fill-color: var(--lt-c-brand-logo); color: var(--lt-c-brand-logo); }

/* 13. Links inside running text are underlined so they are not told apart by color alone. */
body.lt .site-main .entry-content p a:not(.wp-block-button__link):not(.btn),
body.lt .site-main .entry-content li a:not(.wp-block-button__link):not(.btn),
body.lt .site-main .entry-content td a { text-decoration: underline; text-underline-offset: 2px; }

/* 14. Order page and plan tables from the CartBridge and PlanSync plugins. Their accent follows the brand cyan with dark text, the same as the cart in the client area. */
.cartbridge, .plansync { --cb-accent: var(--lt-brand); --brand-primary: var(--lt-brand); }
.cartbridge .cb-step__title::before, .cartbridge .cb-tab.is-active, .cartbridge .cb-button:not(.cb-button--ghost), .plansync .plansync__tab.is-active, .plansync .plansync__tab[aria-selected="true"] { color: var(--lt-brand-ink) !important; }
/* Prices are set in the main text color, the same as on the plan card (lattice-pages.css section 12). */
.cartbridge .cb-plan__price { color: var(--lt-ink-1); }
.cartbridge .cb-plan__price small { font: 500 12px/1 var(--lt-font-mono); letter-spacing: .04em; color: var(--lt-ink-3); }

/* 15. Smallest phones. Columns and cards in page content may not be wider than a 320px screen. */
@media (max-width: 400px) {
  .wp-block-columns > .wp-block-column { min-width: 0 !important; max-width: 100% !important; flex-basis: 100% !important; }
  .wp-block-column > .wp-block-group, .vps-app-card { min-width: 0 !important; max-width: 100% !important; box-sizing: border-box; }
}

/* 16. Footer column titles keep their small size on pages whose own styles set every h2 large */
body.lt .lt-footer .lt-footer__title { margin: 0 0 14px !important; font: 500 13px/1.4 var(--lt-font-mono) !important; letter-spacing: .08em !important; text-transform: uppercase; color: var(--lt-ink-3) !important; }

/* 17. Phones. On the order page the chat button sits above the order bar so it never covers Continue. */
@media (max-width: 782px) { body.lt:has(.cartbridge .cb-bar) #chatport-btn { bottom: 176px !important; } body.lt:has(.cartbridge .cb-bar) .back-to-top { display: none !important; } }

/* 18. Text fill follows the text color on buttons and links. The id in :not() only adds weight, so this beats the site's own rules without !important. The site's Additional CSS sets -webkit-text-fill-color on every link in page content in light mode, which painted teal labels on the cyan buttons and white labels on the light custom solution band. Gradient headings keep their transparent fill. */
html body.lt :is(a, button, .btn, .wp-block-button__link, .lt-btn):not(.gradient-text):not(#lt-fill) { -webkit-text-fill-color: currentColor; }
/* 19. The sign in link on the order page used the bright cyan, which is too light on white. */
body.lt .cartbridge .cb-link { color: var(--lt-brand-text); }
/* 20. The ARPHost AI plugin (sign up, client login, application cards) draws with its own color variables, set for a dark page only. Pointing them at the Lattice tokens makes its panels follow the light and dark theme like the rest of the site. */
body.lt { --ai-page: var(--lt-surface-0); --ai-surface: var(--lt-surface-1); --ai-card: var(--lt-surface-1); --ai-card-active: var(--lt-surface-2); --ai-border: var(--lt-line-2); --ai-text: var(--lt-ink-1); --ai-text-secondary: var(--lt-ink-2); --ai-muted: var(--lt-ink-3); --ai-accent: var(--lt-brand); --ai-accent-bright: var(--lt-brand-text); --ai-on-accent: var(--lt-brand-ink); --ai-focus: var(--lt-focus); }
body.lt .ai-button-primary, body.lt .ai-button.ai-button-primary { background: var(--lt-brand) !important; border-color: var(--lt-brand) !important; color: var(--lt-brand-ink) !important; -webkit-text-fill-color: currentColor !important; box-shadow: none; }
body.lt .ai-button-primary:hover, body.lt .ai-button.ai-button-primary:hover { background: var(--lt-brand-hover) !important; }
