/* assets/css/base.css */

/* =========================================================
   CORE VARIABLES & DEFAULTS
========================================================= */

/* :root { base color styles are in app/layouts/header.php } */

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden; 
    background-color: #FFFFFF;
}

/* =========================================================
   DYNAMIC COLOR CONTRAST ENGINE (WCAG Automatic Legibility)
========================================================= */
.dynamic-contrast-box {
    /* Dynamic HSL coordinates initialized to White defaults */
    --bg-h: 0;
    --bg-s: 0%;
    --bg-l: 100%; 

    /* Force background using the dynamic coordinates */
    background-color: hsl(var(--bg-h), var(--bg-s), var(--bg-l)) !important;

    /* Math Threshold: Subtract lightness from 50%. Multiply by a massive scalar. */
    --contrast-threshold: calc((var(--bg-l) - 50%) * -100);

    /* Resolves to White (100% Lightness) or Dark Slate (13% Lightness) based on threshold */
    --contrast-text-l: calc(var(--contrast-threshold) * 1%);
    
    /* Dynamic color applied globally to text and inherited by children */
    color: hsl(0, 0%, clamp(13%, var(--contrast-text-l), 100%)) !important;
    
    /* Cascade dynamic colors to nested custom titles and borders */
    --title-text-color: hsl(0, 0%, clamp(13%, var(--contrast-text-l), 100%));
    --title-border-color: hsla(0, 0%, clamp(13%, var(--contrast-text-l), 100%), 0.15);
}

/* =========================================================
   ACCESSIBILITY FONT SYSTEM (Elevated for Legibility)
========================================================= */

/* Elevated from 12px to 14px for widescreen legibility */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-1 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

/* Elevated from 11px to 13px to prevent character clipping */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-2 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.4;
}

/* Elevated from 11px to 13px to ensure character legibility */
.font-family-sfmono-regular-menlo-monaco-consolas-liberation-mono-courier-new-monospace-1 {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
}

/* Elevated from 12px to 14px */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-3 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
}

/* Elevated from 12px to 14px */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-4 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
}

/* Prevent layout overlap by changing collapsed line-height to 1 */
.font-family-font-awesome-7-free-7 {
    font-family: "Font Awesome 7 Free";
    font-size: 23.8px;
    font-weight: 900;
    line-height: 1;
}

/* Scale tiny Font Awesome icons up from 11px to 13px for equal visual weight with body text */
.font-family-font-awesome-7-free-1 {
    font-family: "Font Awesome 7 Free";
    font-size: 13px;
    font-weight: 900;
    line-height: 13px;
}

.font-family-font-awesome-7-free-2 {
    font-family: "Font Awesome 7 Free";
    font-size: 13px;
    font-weight: 400;
    line-height: 13px;
}

/* Scale button/interactive copy from 11.5px to 14px for AAA readability */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-7 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
}

.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-8 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
}

/* Dropdown menu text standard */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-30 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 700;
    line-height: 22.5px;
}

.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-31 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 22.5px;
}

/* Global Nav link standard */
.font-family-system-ui--apple-system-segoe-ui-roboto-sans-serif-32 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
}

/* =========================================================
   GLOBAL THEME CONTEXT SYSTEM [Section 1]
========================================================= */

/* --- 1. LIGHT CONTEXTS (White, Accent Sky Blue) --- */
.context-light,
.context-white {
    --bg-color: #FFFFFF;
    --text-title: var(--primary);
    --text-body: #000000;
    --btn-bg: var(--primary);
    --btn-text: #FFFFFF;
    
    background-color: var(--bg-color) !important;
}

.context-accent {
    --bg-color: var(--accent);
    --text-title: var(--primary);
    --text-body: #000000;
    --btn-bg: var(--primary);
    --btn-text: #FFFFFF;
    
    background-color: var(--bg-color) !important;
}

/* --- 2. DARK CONTEXTS (Primary Kell Blue, Secondary Navy, Black) --- */
.context-dark,
.context-primary {
    --bg-color: var(--primary);
    --text-title: #FFFFFF;
    --text-body: #FFFFFF;
    --btn-bg: #FFFFFF;
    --btn-text: var(--primary);
    
    background-color: var(--bg-color) !important;
}

.context-secondary {
    --bg-color: var(--secondary);
    --text-title: #FFFFFF;
    --text-body: #FFFFFF;
    --btn-bg: #FFFFFF;
    --btn-text: var(--primary);
    
    background-color: var(--bg-color) !important;
}

.context-black {
    --bg-color: #000000;
    --text-title: #FFFFFF;
    --text-body: #FFFFFF;
    --btn-bg: #FFFFFF;
    --btn-text: var(--primary);
    
    background-color: var(--bg-color) !important;
}

/* --- 3. CONTEXTUAL INHERITANCE BINDINGS --- */

/* Apply Context Colors to Base Text */
.context-light, .context-white, .context-accent, 
.context-dark, .context-primary, .context-secondary, .context-black {
    color: var(--text-body);
}

/* Apply Context Colors to All Heading Levels */
.context-light h1, .context-light h2, .context-light h3, .context-light h4, .context-light h5, .context-light h6,
.context-white h1, .context-white h2, .context-white h3, .context-white h4, .context-white h5, .context-white h6,
.context-accent h1, .context-accent h2, .context-accent h3, .context-accent h4, .context-accent h5, .context-accent h6,
.context-dark h1, .context-dark h2, .context-dark h3, .context-dark h4, .context-dark h5, .context-dark h6,
.context-primary h1, .context-primary h2, .context-primary h3, .context-primary h4, .context-primary h5, .context-primary h6,
.context-secondary h1, .context-secondary h2, .context-secondary h3, .context-secondary h4, .context-secondary h5, .context-secondary h6,
.context-black h1, .context-black h2, .context-black h3, .context-black h4, .context-black h5, .context-black h6 {
    color: var(--text-title) !important;
}

/* Apply Context Colors to Rich-Text Title Spans */
.context-light .rich-text-title span,
.context-white .rich-text-title span,
.context-accent .rich-text-title span,
.context-dark .rich-text-title span,
.context-primary .rich-text-title span,
.context-secondary .rich-text-title span,
.context-black .rich-text-title span {
    color: var(--text-title) !important;
}

/* Apply Context Colors to All Nested Buttons (.btn) */
.context-light .btn,
.context-white .btn,
.context-accent .btn,
.context-dark .btn,
.context-primary .btn,
.context-secondary .btn,
.context-black .btn {
    background-color: var(--btn-bg) !important;
    color: var(--btn-text) !important;
    border: 1px solid var(--btn-bg) !important;
    transition: all 0.2s ease-in-out !important;
}

/* --- 4. DYNAMIC ICON COLOR MATCHING ENGINE [Section 1] --- */
.context-light i, .context-light .fa-solid, .context-light .fa-regular, .context-light .fa-brands,
.context-white i, .context-white .fa-solid, .context-white .fa-regular, .context-white .fa-brands,
.context-accent i, .context-accent .fa-solid, .context-accent .fa-regular, .context-accent .fa-brands,
.context-dark i, .context-dark .fa-solid, .context-dark .fa-regular, .context-dark .fa-brands,
.context-primary i, .context-primary .fa-solid, .context-primary .fa-regular, .context-primary .fa-brands,
.context-secondary i, .context-secondary .fa-solid, .context-secondary .fa-regular, .context-secondary .fa-brands,
.context-black i, .context-black .fa-solid, .context-black .fa-regular, .context-black .fa-brands {
    color: inherit !important; /* Forces icons to dynamically match parent text context [Section 1] */
}

/* --- 5. ADAPTIVE HOVER STATES --- */

/* Light Context Button Hover (Subtle darkening) */
.context-light .btn:hover,
.context-white .btn:hover,
.context-accent .btn:hover {
    filter: brightness(0.9) !important;
    border-color: var(--accent) !important;
	background-color: var(--accent) !important;
	color: var(--primary) !important;
}

/* Dark Context Button Hover (Inverted background outline transition) */
.context-dark .btn:hover,
.context-primary .btn:hover,
.context-secondary .btn:hover,
.context-black .btn:hover {
	border-color: var(--accent) !important;
    background-color: var(--accent) !important;
    color: var(--primary) !important;
}

/* =========================================================
   STANDARD PRIMARY BUTTONS (Light Background Context)
========================================================= */
.btn-primary {
    border-color: var(--primary) !important;
    background-color: var(--primary) !important;
    color: #FFFFFF !important;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.btn-primary:hover { 
    border-color: var(--accent) !important;
    background-color: var(--accent) !important; 
    color: var(--primary) !important;

}
.btn-primary:active {
    filter: brightness(0.85) !important;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #fff;
}

/* =========================================================
   TYPOGRAPHY ENGINE
========================================================= */

.rich-text-title {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100%;
    font-size: clamp(1.4rem, 3vw, 1.85rem);
    font-weight: 700;
    color: var(--title-text-color, var(--secondary)); /* Dynamically inherits contrast color if present */
    line-height: 1.2;
    margin-top: 0 !important; /* Ensure titles at the top of a column sit at the very top */
    margin-bottom: 1rem !important;
    padding-top: 1rem !important;
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid var(--title-border-color, rgba(var(--primary-rgb), 0.15)); /* Dynamically inherits contrast border if present */
    text-align: left; /* Left align everything for consistency */
    min-height: 42px !important; /* Standardizes height for headers with or without buttons */
}

/* Ensure the title text doesn't shrink when buttons are present */
.rich-text-title span {
    flex: 1;
}

/* Button sizing within titles */
.rich-text-title .btn {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.rich-text-body {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #333;
}

.rich-text-body p { margin-bottom: 1.5rem; }
.rich-text-body p:last-child { margin-bottom: 0; }

.rich-text-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.rich-text-block h1,
.rich-text-block h2,
.rich-text-block h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.debug-hidden { display: none; }