/* ==========================================================================
   0. ARCHITECTURE & IMPORTS
   ========================================================================== */

/*
 * This file simulates a modular architecture. In a real build process,
 * these would be separate files imported into layers.
 *
 * @import url(tokens.css) layer(theme);
 * @import url(fonts.css) layer(theme);
 * @import url(reset.css) layer(reset);
 * @import url(base.css) layer(base);
 * @import url(viewer.css) layer(viewer);
 * @import url(layout.css) layer(layout);
 * @import url(components.css) layer(components);
 * @import url(utilities.css) layer(utilities);
 * @import url(print.css) layer(print);
 */

@layer reset, theme, animations, base, viewer, layout,
       tables, cards, timeline, metrics, callouts, products, appendix, process,
       utilities, print;

/* ==========================================================================
   1. FONT DEFINITIONS
   ========================================================================== */

@layer theme {
:root {
    /* Brand - Blue Scale */
    color-scheme: light;
    --arybit-blue-50: #e7f0f9;
    --arybit-blue-100: #d0e1f3;
    --arybit-blue-200: #b8d1ed;
    --arybit-blue-300: #a1c2e7;
    --arybit-blue-400: #89b2e1;
    --arybit-blue-500: #72a3db;
    --arybit-blue-600: #5a93d5;
    --arybit-blue-700: #0B5CAD;
    --arybit-blue-800: #084A8C;
    --arybit-blue-900: #06376B;
    --arybit-blue: var(--arybit-blue-700); /* Alias for main brand color */

    /* Neutral */
    --grey-900: #222;
    --grey-800: #333;
    --grey-700: #555;
    --grey-600: #777;
    --grey-400: #BBB;
    --grey-300: #ddd;
    --grey-200: #f2f2f2;
    --grey-100: #F8F9FA;
    --white: #ffffff;

    /* Brand - Green Scale */
    --arybit-green-50: #e7f4ed;
    --arybit-green-100: #cfe9d9;
    --arybit-green-200: #b7dec6;
    --arybit-green-300: #9fd3b2;
    --arybit-green-400: #87c89f;
    --arybit-green-500: #6fbd8b;
    --arybit-green-600: #57b278;
    --arybit-green-700: #0D8C4A;
    --arybit-green-800: #0a703b;
    --arybit-green-900: #08532c;
    --arybit-green: var(--arybit-green-700);

    /* Brand - Gold Scale */
    --arybit-gold-50: #fdf8e6;
    --arybit-gold-100: #fbf1cd;
    --arybit-gold-200: #f9eab3;
    --arybit-gold-300: #f7e29a;
    --arybit-gold-400: #f5db81;
    --arybit-gold-500: #f3d367;
    --arybit-gold-600: #f1cb4e;
    --arybit-gold-700: #E5B600;
    --arybit-gold-800: #b79200;
    --arybit-gold-900: #896d00;
    --arybit-gold: var(--arybit-gold-700);

    /* --- NEW: Semantic State Colors --- */
    --color-danger: #d32f2f;
    --color-warning: var(--arybit-gold-700);
    --color-success: var(--arybit-green-700);
    --color-info: var(--arybit-blue-700);

    /* --- NEW: Semantic UI Colors --- */
    --color-background: #525659; /* Viewer background */
    --color-surface: var(--white); /* Page background */
    --color-surface-muted: var(--grey-100); /* Card/table-row background */
    --color-text-primary: var(--grey-900);
    --color-text-secondary: var(--grey-700);
    --color-border: var(--grey-300);
    --color-border-muted: var(--grey-200);

    /* Typography */
    --font-heading: "Montserrat", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --font-body: "Source Serif Pro", Georgia, "Times New Roman", Times, serif;

    /* Typography Scale */
    --text-xs: 9pt;
    --text-sm: 10pt;
    --text-base: 11pt;
    --text-lg: 13pt;
    --text-xl: 16pt;
    --text-2xl: 22pt;
    --text-display: 36pt;

    /* Spacing Scale (for components) - use rem for UI scalability */
    --space-1: 0.25rem;  /* ~4px at 16px root */
    --space-2: 0.5rem;   /* ~8px */
    --space-3: 0.75rem;  /* ~12px */
    --space-4: 1rem;     /* ~16px */
    --space-5: 1.25rem;  /* ~20px */
    --space-6: 1.5rem;   /* ~24px */
    --space-7: 2rem;     /* ~32px */
    --space-8: 3rem;     /* ~48px */

    /* Layout Spacing Scale (for page layout in mm) */
    --layout-space-1: 4mm;
    --layout-space-2: 8mm;
    --layout-space-3: 12mm;
    --layout-space-4: 16mm;

    /* --- NEW: Motion Tokens --- */
    --motion-fast: 0.15s;
    --motion-normal: 0.3s;
    --motion-slow: 0.5s;
    --ease-standard: ease;

    /* --- NEW: Print Tokens --- */
    --page-width: 210mm;
    --page-height: 297mm;
    --print-margin: 16mm;
    --print-bleed: 3mm;
    --print-page-number-font: var(--font-heading);
    --print-footer-font: var(--font-heading);
    --watermark-opacity: 0.015;
    --stamp-opacity: 0.025;

    /* --- NEW: Viewer UI Tokens --- */
    --viewer-toolbar-height: 60px;
    --viewer-sidebar-width: 250px;
    --viewer-ai-sidebar-width: 350px;
    --color-viewer-bg-primary: #1a1a1a;
    --color-viewer-bg-secondary: #252526;
    --color-viewer-bg-tertiary: #2d2d2d;
    --color-viewer-bg-hover: #37373d;
    --color-viewer-bg-active: #094771;
    --color-viewer-border: #333;
    --color-viewer-text-primary: #cccccc;
    --color-viewer-text-secondary: #858585;

    /* --- NEW: Z-Index Scale --- */
    --z-index-deep-background: -10;
    --z-index-background: 0;
    --z-index-content: 1;
    --z-index-floating: 100;
    --z-index-sidebar: 1000;
    --z-index-toolbar: 2000;
    --z-index-modal: 3000;
    --z-index-toast: 4000;

    /* --- NEW: Grid Tokens --- */
    --grid-columns: 12;

    /* --- NEW: Document-Specific Theme Tokens --- */
    --cover-background-image: none; /* Fallback: original image 'cover-hero.webp' is missing */
    --cover-overlay: linear-gradient(rgba(11, 92, 173, 0.88), rgba(8, 48, 92, 0.95));
    --page-watermark-image: url("../img/arybit-geoaltersense-icon.svg");
    --page-stamp-image: none;
    --section-divider-color: var(--color-border-muted);
    --header-logo-size: 80px;
    --footer-height: 20mm; /* Example */

    /* --- NEW: Component Tokens --- */
    --card-padding: var(--space-5);
    --card-border: 1px solid var(--color-border);
    --card-background: var(--color-surface-muted);
    --table-padding: var(--space-3) var(--space-4);
    --table-border: 1px solid var(--color-border);
    --callout-padding: var(--space-4) var(--space-5);
    --callout-border-width: 4px;

    /* Layout */
    --page-margin-screen: var(--layout-space-4);
    --page-margin-print: var(--print-margin);
    --section-spacing: var(--layout-space-4);
    --grid-gap: var(--layout-space-3);

    /* Border Radius Tokens */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --card-radius: var(--radius-md); /* Alias */

    /* Elevation Tokens (Shadows) */
    --elevation-1: 0 2px 4px rgba(0,0,0,0.05);
    --elevation-2: 0 5px 18px rgba(0,0,0,.08);
    --elevation-3: 0 10px 25px rgba(0,0,0,0.1);

}

[data-theme="dark"] {
    color-scheme: dark;

    /* Update semantic colors for dark mode */
    --color-background: #2a2a2e;
    --color-surface: #1e1e1e;
    --color-surface-muted: #252526;
    --color-text-primary: #d4d4d4;
    --color-text-secondary: #a0a0a0;
    --color-border: #4a4a4a;
    --color-border-muted: #3a3a3a;
}

/* High Contrast Theme Placeholder */
[data-theme="high-contrast"] {
    /* High contrast token overrides would go here */
}
[data-theme="sepia"] {
    /* Sepia theme overrides */
}
[data-theme="presentation"] {
    /* Presentation theme overrides */
}

}

/* ==========================================================================
   3. RESET
   ========================================================================== */
@layer reset {
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-print-color-adjust: exact;
}
}

/* ==========================================================================
   NEW: 3.5 ANIMATIONS
   ========================================================================== */
@layer animations {
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

@layer base {
/* Accessibility: Visible focus states for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--arybit-blue-700);
    outline-offset: 2px;
    border-radius: 2px;
}
:focus:not(:focus-visible) {
    outline: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

body {
    font-family: var(--font-body);
    background: var(--color-background);
    height: 100vh; /* Use 100% of viewport height */
    overflow: hidden; /* The main body should not scroll */
    display: grid;
    grid-template-columns: var(--viewer-sidebar-width) 1fr var(--viewer-ai-sidebar-width);
    grid-template-rows: var(--viewer-toolbar-height) 1fr;
    grid-template-areas:
        "toolbar toolbar toolbar"
        "sidebar main aipanel";
    color: var(--color-text-primary);
    transition: grid-template-columns var(--motion-normal) var(--ease-standard);
}
}


/* ==========================================================================
   4. WORKSTATION UI (VIEWER)
   ========================================================================== */
@layer viewer {
body.sidebar-hidden {
    grid-template-columns: 0 1fr var(--viewer-ai-sidebar-width);
}
body.ai-hidden {
    grid-template-columns: var(--viewer-sidebar-width) 1fr 0;
}
body.sidebar-hidden.ai-hidden {
    grid-template-columns: 0 1fr 0;
}

.workstation-main {
    grid-area: main;
    overflow-y: auto; /* This container handles the scrolling */
    min-height: 0;      /* CRITICAL for grid item overflow */
    padding: var(--space-6);
}

/* File Explorer Sidebar */
.file-explorer {
    grid-area: sidebar;
    background: var(--color-viewer-bg-secondary);
    color: var(--color-viewer-text-primary);
    font-family: sans-serif;
    font-size: 12px;
    overflow-y: auto;
    z-index: var(--z-index-sidebar);
    border-inline-end: 1px solid var(--color-viewer-border);
    overflow-x: hidden;
}

.explorer-header {
    padding: 12px 15px;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--color-viewer-text-secondary);
    border-bottom: 1px solid var(--color-viewer-border);
}

.explorer-group { padding-top: 5px; }
.explorer-group-title {
    padding: 6px 15px;
    font-weight: 600;
    color: #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-viewer-bg-tertiary);
    font-size: 11px;
}

.explorer-list { list-style: none; }
.explorer-item a {
    padding-block: 5px; padding-inline: 30px;
    display: block;
    color: var(--color-viewer-text-primary);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.explorer-item a:hover {
    background: var(--color-viewer-bg-hover);
    color: white;
}

.explorer-item.active a {
    background: var(--color-viewer-bg-active);
    color: white;
}

/* Toolbar */
.workstation-toolbar {
    grid-area: toolbar;
    background: var(--color-viewer-bg-primary);
    border-bottom: 1px solid var(--color-viewer-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 20px;
    z-index: var(--z-index-toolbar);
    color: white;
}

.toolbar-brand { display: flex; align-items: center; gap: 10px; }
.toolbar-brand img {
    height: 30px;
    width: 30px;
    object-fit: contain;
}
.toolbar-brand span { font-family: sans-serif; font-size: 14px; }

.search-input {
    background: var(--color-viewer-bg-tertiary);
    border: 1px solid var(--color-viewer-border);
    border-radius: 6px;
    padding: 6px 12px;
    color: white;
    font-size: 14px;
    width: var(--viewer-sidebar-width);
}

.toolbar-btn {
    background: var(--color-viewer-border);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--motion-fast) var(--ease-standard);
}

.toolbar-btn.primary { background: #1a5f99; }
.toolbar-btn:hover { background: var(--color-viewer-bg-hover); }

/* Sidebar */
.ai-sidebar {
    grid-area: aipanel;
    background: var(--color-surface-muted);
    border-inline-start: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    z-index: var(--z-index-sidebar);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

.sidebar-header {
    padding: 15px;
    background: var(--color-info);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-history {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-family: sans-serif;
    font-size: 13px;
    color: var(--color-text-primary);
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #dee2e6;
    background: var(--color-surface);
}

.sidebar-footer textarea {
    width: 100%;
    height: 80px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 8px;
    resize: none;
    font-family: sans-serif;
    margin-bottom: 10px;
}

.sidebar-footer button {
    width: 100%;
    padding: 10px;
    background: var(--color-info);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

@media (max-width: 1200px) {
    body {
        grid-template-columns: 0 1fr 0;
        grid-template-areas:
            "toolbar toolbar toolbar"
            "main main main";
    }
    body.sidebar-hidden {
        grid-template-columns: 0 1fr 0;
    }
    body.ai-hidden {
        grid-template-columns: 0 1fr 0;
    }
}
}

/* ==========================================================================
   5. LAYOUT & PAGE TEMPLATES
   ========================================================================== */
@layer layout {
.page { 
    background: var(--color-surface);
    width: var(--page-width);
    min-height: var(--page-height); /* Ensure it's at least A4 height */
    height: auto !important; /* Allow pages to grow based on content */
    position: relative;
    color: var(--color-text-primary);
    background-image: none;
    overflow: visible !important; /* CRITICAL: Don't clip content */
    display: block; /* Use block layout for more reliable page flow */
    break-after: page; /* Modern page break property */
}

@media screen {
    .page {
        margin: 0 auto 20px auto;
        height: auto !important; /* Override any inline styles */
        box-shadow: var(--elevation-3);
        padding: var(--page-margin-screen);
        overflow: visible !important;
        /* Ensure page height adapts to content */
        min-height: 297mm;
    }
}

.page > *:not(.page-footer) {
    position: relative;
    z-index: 1;
}

.page:last-of-type {
    page-break-after: auto;
}

.page::before {
    content: "";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background-image: var(--page-watermark-image);
    background-repeat: no-repeat;
    background-size: 70%;
    opacity: var(--watermark-opacity);
    filter: grayscale(100%);
    pointer-events: none;
    z-index: var(--z-index-deep-background);
}

.page::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: var(--page-stamp-image);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 120mm;
    opacity: var(--stamp-opacity);
    pointer-events: none;
    z-index: var(--z-index-background);
}

/* New Page Layouts */
.page--cover h1, .page--cover h2, .page--cover h3, .page--cover p {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.page--divider {
    background-color: var(--color-surface-muted);
    justify-content: center;
    align-items: flex-start;
}
.page--divider .divider-content {
    padding-inline-start: var(--layout-space-4);
    border-inline-start: var(--callout-border-width) solid var(--color-info);
}

/* Page template placeholders */
.page--editorial { /* Standard content page. */ }
.page--infographic { /* For data-heavy pages, often uses .page-grid and metric components. */ }
.page--products { /* For product showcases, could use a grid for .product-card components. */ }
.page--case-study { /* For case studies */ }
.page--atlas { padding: 10mm !important; } /* Atlas pages have tighter padding */
.page--appendix { /* For appendix content */ }
.page--contact { /* For contact page */ }


/* Header Section */
.header {
    padding-bottom: var(--space-5);
    margin-bottom: var(--space-3);
}

.header-top {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
}

.header-logo {
    width: var(--header-logo-size);
    height: var(--header-logo-size);
    object-fit: contain;
    opacity: 0.9; /* Slightly reduce for formal tone */
}

.header-info {
    text-align: center;
    flex: 1;
    padding: 0;
}

.header-title {
    font-size: var(--text-2xl);
    font-weight: bold;
    color: var(--color-info);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: var(--font-heading);
    margin-bottom: var(--spacing-1);
}

.header-subtitle {
    font-size: var(--text-base);
    letter-spacing: 0.5px;
    margin-top: var(--spacing-1);
    margin-bottom: var(--spacing-2);
}

.header-meta {
    font-size: var(--text-sm);
    margin-bottom: 4px;
}

.header-divider {
    border: none;
    border-top: 1px solid #000;
    margin: 6px 0 4px 0;
}

.doc-title {
    font-size: var(--text-xl);
    font-weight: bold;
    text-transform: uppercase;
    background-color: #eee;
    padding: 5px;
    border: 1px solid #000;
    display: block;
    text-align: center;
    margin-top: 5px;
}

/* New Atlas Page Layout */
.page--atlas .content-body {
    display: grid;
    grid-template-columns: 1fr 260px; /* Main content and a sidebar */
    grid-template-rows: auto 1fr auto; /* Top charts, main map, bottom dashboard */
    grid-template-areas:
        "top-charts top-charts"
        "main-map   sidebar"
        "bottom-dash bottom-dash";
    height: calc(297mm - 20mm); /* Full page height minus padding */
    gap: 12px;
    padding: 0 !important; /* content-body itself has no padding on this page */
}

.atlas-top-charts { grid-area: top-charts; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.atlas-main-map { grid-area: main-map; position: relative; }
.atlas-sidebar { grid-area: sidebar; display: flex; flex-direction: column; background: var(--color-surface-muted); border-radius: var(--radius-md); padding: var(--space-3); }
.atlas-bottom-dashboard { grid-area: bottom-dash; }

.chart-container { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); background: var(--color-surface); }
.chart-title { font-family: var(--font-heading); font-size: 9pt; font-weight: 600; color: var(--color-text-secondary); margin-bottom: var(--space-2); text-align: center; }
.chart-container .chart { margin: 0; padding: 0; height: 100px; }
.chart-container .atlas-chart {
    min-height: 160px;
    border: 0;
    background: transparent;
}

.atlas-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-size: 8pt;
    z-index: 10;
}
.atlas-legend .legend-title { font-family: var(--font-heading); font-weight: 600; margin-bottom: 4px; }
.atlas-legend .legend-symbol {
    display: inline-block;
    width: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 1.2em;
    margin-right: 4px;
}
.atlas-legend ul { list-style: none; padding: 0; margin: 0; }
.atlas-legend li { display: flex; align-items: center; margin-bottom: 3px; }
.atlas-legend .legend-icon { width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
.atlas-legend .legend-line { width: 20px; height: 3px; margin-right: 6px; }

.atlas-sidebar .sidebar-title { font-family: var(--font-heading); font-weight: 700; font-size: 11pt; color: var(--arybit-blue-800); padding-bottom: 5px; border-bottom: 1px solid var(--color-border); margin-bottom: 10px; }
.atlas-sidebar .sidebar-content { overflow-y: auto; font-size: 9pt; }
.atlas-sidebar .project-group { margin-bottom: 15px; }
.atlas-sidebar .project-country { font-weight: 600; margin-bottom: 10px; font-size: 10pt; }

/* New Project Card styles for sidebar */
.atlas-sidebar .project-card {
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    border-left: 3px solid var(--color-info);
    box-shadow: var(--elevation-1);
}
.atlas-sidebar .project-card h4 {
    font-family: var(--font-heading);
    font-size: 9pt;
    font-weight: 700;
    margin: 0 0 var(--space-2) 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.atlas-sidebar .project-capacity {
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 8pt;
}
.atlas-sidebar .project-meta {
    font-size: 8pt;
    color: var(--color-text-secondary);
    display: flex;
    justify-content: space-between;
}

.atlas-bottom-dashboard .metric-card {
    padding: var(--space-2) !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.atlas-bottom-dashboard .metric-label {
    font-size: 7pt !important;
    margin: 0 !important;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.atlas-bottom-dashboard .metric-number { font-size: 16pt !important; }
.atlas-bottom-dashboard .metric-sparkline {
    font-size: 12pt;
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
    font-family: monospace;
    line-height: 1;
}

@media print {
    .atlas-legend { background: white !important; backdrop-filter: none; }
}

.atlas-map {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-md);
    background: #1d262d; /* Dark background for tiles to load on */
}

.chart.has-map {
    padding: 0;
    border: 1px solid var(--color-border);
    overflow: hidden; /* to clip the map's corners */
}

/* Dark theme for Leaflet tiles, similar to usgs.css */
.leaflet-tile-pane {
    filter: brightness(0.85) saturate(0.7) hue-rotate(180deg) invert(1) hue-rotate(180deg);
}

.leaflet-control-layers-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px; /* Space for scrollbar */
}

.leaflet-control-layers-selector {
    margin-top: 0 !important;
    accent-color: var(--accent);
}

.leaflet-container {
    background: #1d262d; /* Match map background */
    font-family: sans-serif; /* Prevent serif fonts on map controls */
}

.map-marker-label {
    text-align: center;
    font-weight: bold;
    line-height: 1;
}
}

@layer base {
/* Main Content Body */
.content-body {
    padding-top: var(--space-3);
    line-height: 1.5;
    font-size: var(--text-base);
    display: block; /* Ensure it behaves as a standard block */
}

.content-body h2 {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--arybit-blue-700);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--section-divider-color);
    page-break-after: avoid;
    break-inside: avoid;
}

.content-body h3 {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-top: var(--space-4);
    margin-bottom: var(--space-2);
    break-inside: avoid;
    page-break-after: avoid;
}

.content-body p {
    margin-bottom: var(--space-3);
    text-align: justify;
    orphans: 3;
    widows: 3;
}

.content-body ul {
    list-style-position: outside;
    padding-inline-start: var(--space-6);
    margin-bottom: var(--space-3);
}

.content-body li {
    margin-bottom: var(--space-2);
    text-align: justify;
    orphans: 3;
    widows: 3;
}

.content-body figure {
    margin: var(--space-5) 0;
    break-inside: avoid;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--elevation-2);
    border: 1px solid var(--color-border);
}

.content-body figure img {
    width: 100%;
    display: block;
}

.content-body figcaption {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
    font-style: italic;
    color: var(--color-text-secondary);
    background-color: var(--color-surface-muted);
    text-align: center;
    border-top: 1px solid var(--color-border);
}

/* Ensure content within pages doesn't clip during capture */
.page {
    min-height: 297mm !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Table fixes */
.page table {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: table !important;
}

/* Flex container fixes */
.page .card-grid,
.page .flex-container {
    height: auto !important;
    max-height: none !important;
    flex-wrap: wrap !important;
}

/* Quick fix for specific tall pages */
.page--editorial:nth-child(20) {
    /* Allow this page to break naturally */
    page-break-after: always;
    break-after: page;
}
}

@layer tables {
/* --- Tables --- */
.content-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: var(--space-5) 0;
    font-size: var(--text-sm);
    break-inside: auto; /* Allow tables to break across pages */
    border: var(--table-border);
    border-radius: var(--card-radius); /* Keep radius for screen */
    overflow: hidden;
    caption-side: bottom; /* For table notes */

}
.content-body table th,
.content-body table td {
    border: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--table-padding);
    text-align: start;
}
.content-body table thead {
    display: table-header-group; /* Repeat headers on print */
}
.content-body table tr {
    break-inside: avoid;
    page-break-inside: avoid; /* Fallback for older engines */
}
.content-body table tr:last-child td {
    border-bottom: none;
}
.content-body table th {
    background-color: var(--color-surface-muted);
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.5px;
}
.content-body table tbody tr:nth-child(even) {
    background-color: var(--color-surface-muted);
}
@media screen {
    .content-body table tbody tr:hover {
        background-color: #e9ecef; /* Zebra hover */
    }
}
.content-body table caption {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--space-3);
    text-align: start;
}
}

.certification {
    font-size: var(--text-sm);
    text-align: center;
    margin-top: var(--space-5);
    padding-top: var(--space-1);
    /* page-break-before: always; Removed, relying on page structure */
    line-height: 1.4;
}

.cert-note {
    margin-top: var(--spacing-2);
    font-style: italic;
}

.cert-lines {
    display: flex;
    justify-content: center;
    gap: var(--space-7);
    margin-top: var(--space-3);
}

.cert-lines span {
    display: inline-block;
    width: 220px;
    padding-top: var(--space-1);
}

/* Footer / Official Seal */
.footer {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.page-footer {
    padding-top: var(--spacing-3);
    border-top: 1px solid var(--grey-400);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.sign-title {
    font-size: var(--text-xs);
    text-align: center;
    margin-top: 2px;
}

.seal {
    width: 100px;
    height: 100px;
    display: block;
}

/* --- Page Footer --- */

.page-footer .footer-brand {
    font-weight: bold;
}

@layer timeline {
/* New Timeline Component */
.timeline {
    position: relative;
    padding: var(--space-5) 0;
    list-style: none;
}
.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    inset-inline-start: 20px;
    height: 100%;
    width: 2px;
    background: var(--color-border-muted);
}
.timeline-item {
    position: relative;
    padding-inline-start: var(--space-8);
    margin-bottom: var(--space-6);
}
.timeline-item::before {
    content: '';
    position: absolute;
    inset-inline-start: 14px;
    top: 5px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--arybit-blue-700);
    z-index: 1;
}
.timeline-year {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--color-info);
    margin-bottom: var(--space-1);
}
.timeline-content {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}
}

@layer cards {
/* --- Cards --- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-5);
    margin: var(--space-5) 0;
}
.card {
    background: var(--card-background);
    border-radius: var(--radius-md);
    padding: var(--card-padding);
    border: var(--card-border);
    transition: box-shadow var(--motion-normal) var(--ease-standard), transform var(--motion-normal) var(--ease-standard);
}
}

@layer callouts {
/* --- Callouts --- */
.callout {
    padding: var(--callout-padding);
    margin: var(--space-5) 0;
    border-inline-start: var(--callout-border-width) solid var(--color-border);
    background-color: var(--color-surface-muted);
    border-radius: 0 var(--card-radius) var(--card-radius) 0; /* Needs logical equivalent if we want it to flip */
    page-break-inside: avoid;
}
.callout p:last-child {
    margin-bottom: 0;
}
.callout-info {
    border-inline-start-color: var(--color-info);
    background-color: var(--arybit-blue-50);
}
.callout-success {
    border-inline-start-color: var(--color-success);
    background-color: var(--arybit-green-50);
}
.callout-warning {
    border-inline-start-color: var(--color-warning);
    background-color: var(--arybit-gold-50);
}
.callout-quote {
    border-left-style: dashed;
    font-style: italic;
    color: var(--grey-700);
}
}

@layer metrics {
/* --- Metrics & KPIs --- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-5);
    margin: var(--space-5) 0;
}
.metric-card {
    text-align: center;
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    background-color: var(--color-surface);
    break-inside: avoid;
}
.metric-card .metric-number {
    font-family: var(--font-heading);
    font-size: var(--text-display);
    font-weight: 700;
    color: var(--color-info);
}
.metric-card .metric-label {
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 600;
    margin: var(--space-1) 0 var(--space-3) 0;
    color: var(--color-text-primary);
}
.metric-card .metric-sparkline {
    font-size: 14pt;
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
    font-family: monospace;
}
.metric-card .metric-sublabel {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    border-top: 1px solid var(--grey-300);
    padding-top: 10px;
    margin-top: 10px;
}
/* Modifiers */
.metric-card.success .metric-number { color: var(--color-success); }
.metric-card.warning .metric-number { color: var(--color-warning); }
.metric-card.info .metric-number { color: var(--color-info); }
.metric-card.highlight {
    background-color: var(--arybit-blue-50);
    border-color: var(--arybit-blue-200);
}
}

@layer appendix {
/* --- Appendix --- */
.page--appendix .appendix-item {
    border: 1px solid var(--color-border);
    border-radius: var(--card-radius);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
    background-color: var(--color-surface-muted);
    break-inside: avoid;
}
.page--appendix .appendix-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-4);
}
.page--appendix .appendix-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-info);
}
.page--appendix .appendix-meta {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-family: monospace;
}
.page--appendix .appendix-content {
    text-align: center;
    padding: var(--space-5) 0;
}
.page--appendix .appendix-content img {
    max-width: 100%;
    box-shadow: var(--elevation-2);
}
}

@layer process {
/* --- Process Flow --- */
.process-flow {
    display: flex;
    justify-content: space-between;
    list-style: none;
    padding: 0;
    margin: var(--space-7) 0;
    position: relative;
    break-inside: avoid;
}
.process-flow::before {
    content: '';
    position: absolute;
    top: 12px; /* Vertically center on the circle */
    inset-inline-start: 5%;
    width: 90%;
    height: 2px;
    background-color: var(--color-border);
    z-index: 0;
}
.process-flow-step {
    text-align: center;
    width: 100px; /* Adjust as needed */
    position: relative;
    background-color: var(--color-surface); /* To cover the line */
    padding: 0 5px;
}
.process-flow-step::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--color-surface);
    border: 2px solid var(--color-info);
    margin: 0 auto 10px auto;
    z-index: 1; 
    position: relative;
}
.process-flow-step .step-name {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-primary);
}
}

@layer products {
/* --- Product Card --- */
.product-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--color-surface);
    box-shadow: var(--elevation-1);
    break-inside: avoid;
}
.product-card .product-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background-color: var(--grey-200);
}
.product-content {
    padding: var(--space-5);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.product-card .product-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-text-primary);
}
.product-card .product-description {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin: var(--space-2) 0 var(--space-4) 0;
    flex-grow: 1;
}
.product-card .product-footer {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-muted);
}
}

@layer diagrams {
    /* --- Org Chart --- */
    .org-chart {
        text-align: center;
        margin: var(--space-7) 0;
    }
    .org-chart ul {
        padding-top: var(--space-5);
        position: relative;
        transition: all 0.5s;
        list-style: none;
    }
    .org-chart li {
        float: left;
        text-align: center;
        list-style-type: none;
        position: relative;
        padding: var(--space-5) var(--space-2) 0 var(--space-2);
        transition: all 0.5s;
    }
    .org-chart li::before, .org-chart li::after {
        content: '';
        position: absolute;
        top: 0;
        right: 50%;
        border-top: 1px solid var(--color-border);
        width: 50%;
        height: var(--space-5);
    }
    .org-chart li::after {
        right: auto;
        left: 50%;
        border-left: 1px solid var(--color-border);
    }
    .org-chart li:only-child::after, .org-chart li:only-child::before {
        display: none;
    }
    .org-chart li:only-child {
        padding-top: 0;
    }
    .org-chart li:first-child::before, .org-chart li:last-child::after {
        border: 0 none;
    }
    .org-chart li:last-child::before {
        border-right: 1px solid var(--color-border);
        border-radius: 0 var(--radius-md) 0 0;
    }
    .org-chart li:first-child::after {
        border-radius: var(--radius-md) 0 0 0;
    }
    .org-chart ul ul::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        border-left: 1px solid var(--color-border);
        width: 0;
        height: var(--space-5);
    }
    .org-chart li a {
        border: 1px solid var(--color-border);
        padding: var(--space-3) var(--space-4);
        text-decoration: none;
        color: var(--color-text-primary);
        font-family: var(--font-heading);
        font-size: var(--text-sm);
        display: inline-block;
        border-radius: var(--radius-md);
        background-color: var(--color-surface-muted);
        transition: all 0.3s;
    }
    .org-chart li a:hover, .org-chart li a:hover+ul li a {
        background: var(--arybit-blue-50);
        color: var(--arybit-blue-800);
        border-color: var(--arybit-blue-200);
    }

    /* --- Logo Grid --- */
    .logo-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: var(--space-6);
        margin: var(--space-6) 0;
    }
    .logo-item {
        text-align: center;
    }
    .logo-placeholder {
        height: 80px;
        background-color: var(--color-surface-muted);
        border: 1px dashed var(--color-border);
        border-radius: var(--radius-md);
        display: grid;
        place-items: center;
        color: var(--color-text-secondary);
        font-family: var(--font-heading);
        font-size: var(--text-sm);
    }
    .logo-label {
        margin-top: var(--space-3);
        font-family: var(--font-heading);
        font-weight: 600;
        font-size: var(--text-sm);
    }

    /* --- Roadmap Timeline --- */
    .roadmap-timeline { list-style: none; padding: 0; margin: var(--space-7) 0; position: relative; }
    .roadmap-timeline::before { content: ''; position: absolute; top: 0; left: 50%; width: 2px; height: 100%; background: var(--color-border); }
    .roadmap-item { padding: var(--space-3) var(--space-7); position: relative; width: 50%; }
    .roadmap-item::after { content: ''; position: absolute; width: 20px; height: 20px; right: -10px; background-color: white; border: 4px solid var(--color-info); top: 20px; border-radius: 50%; z-index: 1; }
    .roadmap-item:nth-child(odd) { left: 0; text-align: right; }
    .roadmap-item:nth-child(even) { left: 50%; }
    .roadmap-item:nth-child(even)::after { left: -10px; }
    .roadmap-year { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 700; color: var(--color-info); }
    .roadmap-content { padding: var(--space-4); background: var(--color-surface-muted); border-radius: var(--radius-md); margin-top: var(--space-2); }
    .roadmap-content h4 { margin: 0 0 var(--space-2) 0; font-size: var(--text-base); }
    .roadmap-content p { margin: 0; font-size: var(--text-sm); text-align: left; }
    .roadmap-item:nth-child(odd) .roadmap-content p { text-align: right; }

    /* --- Deployment Diagram --- */
    .deployment-diagram { display: flex; justify-content: space-around; text-align: center; margin: var(--space-6) 0; }
    .deployment-option .icon { font-size: 2.5em; margin-bottom: var(--space-2); }
    .deployment-option h4 { font-family: var(--font-heading); font-size: var(--text-base); margin-bottom: var(--space-1); }
    .deployment-option p { font-size: var(--text-sm); color: var(--color-text-secondary); margin: 0; }

    /* --- Deployment Models Infographic --- */
    .deployment-models-svg {
        display: block;
        width: 100%;
        margin: var(--space-5) 0;
        aspect-ratio: 1500 / 520;
        height: auto;
    }

    .deployment-models-svg .title {
        font-family: var(--font-heading);
        font-size: 28px;
        font-weight: 700;
        fill: var(--arybit-blue-800);
    }
    .deployment-models-svg .subtitle {
        font-family: var(--font-body);
        font-size: 18px;
        fill: var(--color-text-secondary);
    }
    .deployment-models-svg .header {
        font-family: var(--font-heading);
        font-size: 24px;
        font-weight: 700;
        fill: var(--white);
    }
    .deployment-models-svg .body {
        font-family: var(--font-body);
        font-size: 16px;
        fill: var(--color-text-primary);
    }
    .deployment-models-svg .body--light {
        font-family: var(--font-body);
        font-size: 16px;
        fill: var(--white);
    }
    .deployment-models-svg .small {
        font-family: var(--font-body);
        font-size: 12px;
        fill: var(--color-text-secondary);
    }
    .deployment-models-svg .footer {
        font-family: var(--font-heading);
        font-size: 14px;
        font-weight: 600;
        fill: var(--white);
    }
    .deployment-models-svg .check{fill:#2E7D32}
    .deployment-models-svg .box{fill:var(--white);stroke:var(--color-border);stroke-width:1.5}

    /* --- Illustration SVG --- */
    .illustration-svg {
        display: block;
        width: 100%;
        margin: var(--space-5) 0;
        aspect-ratio: 1200 / 500;
        height: auto;
    }
    .illustration-svg .bg { fill: var(--arybit-blue-50); }
    .illustration-svg .card { fill: var(--white); stroke: var(--color-border); stroke-width: 2; }
    .illustration-svg .person { fill: var(--arybit-blue-800); }
    .illustration-svg .text { font-family: var(--font-body); fill: var(--color-text-primary); }
    .illustration-svg .title {
        font-family: var(--font-heading);
        font-size: 32px;
        font-weight: 700;
        fill: var(--arybit-blue-800);
    }
    .illustration-svg .label {
        font-family: var(--font-heading);
        font-size: 20px;
        font-weight: 600;
        fill: var(--color-text-primary);
    }
    .illustration-svg .small {
        font-family: var(--font-body);
        font-size: 16px;
        fill: var(--color-text-secondary);
    }
    .illustration-svg .green { fill: var(--arybit-green-700); }
    .illustration-svg .blue { fill: var(--arybit-blue-700); }
    .illustration-svg .icon-text {
        font-family: var(--font-heading);
        font-size: 36px;
        font-weight: 700;
    }

    /* --- Tech Ecosystem SVG --- */
    .tech-ecosystem-svg {
        display: block;
        width: 100%;
        margin: var(--space-5) 0;
        aspect-ratio: 1500 / 260;
        height: auto;
    }
    .tech-ecosystem-svg .title {
        font-family: var(--font-heading);
        font-size: 28px;
        font-weight: 700;
        fill: var(--arybit-blue-800);
    }
    .tech-ecosystem-svg .subtitle {
        font-family: var(--font-body);
        font-size: 16px;
        fill: var(--color-text-secondary);
    }
    .tech-ecosystem-svg .name {
        font-family: var(--font-heading);
        font-size: 16px;
        font-weight: 600;
        fill: var(--color-text-primary);
    }
    .tech-ecosystem-svg .card { fill: var(--color-surface); stroke: var(--color-border); stroke-width: 1.5; }

    /* --- Process Flow Step Circle --- */
    .step-circle { border: 2px solid var(--arybit-blue-200); background: var(--arybit-blue-50); color: var(--arybit-blue-800); border-radius: 50%; width: 50px; height: 50px; display: grid; place-items: center; margin: 0 auto 10px; font-weight: bold; }
    .step-circle.active { border-color: var(--arybit-blue-700); background: var(--arybit-blue-100); color: var(--arybit-blue-900); }
    .step-circle.complete { border-color: var(--arybit-green-700); background: var(--arybit-green-100); color: var(--arybit-green-900); }
}

@layer components {
/* --- Chart & Gallery Placeholders --- */
.chart, .gallery {
    margin: var(--space-6) 0;
    padding: var(--space-5);
    border: 1px dashed var(--color-border);
    background-color: var(--color-surface-muted);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--color-text-secondary);
    font-family: var(--font-heading);
    break-inside: avoid;
}
.chart-caption, .gallery-caption {
    font-size: var(--text-xs);
    font-style: italic;
    color: var(--color-text-secondary);
    text-align: center;
    margin-top: var(--space-3);
}

/* --- Enterprise Component Placeholders --- */
.toc, .team-card, .signature-block {
    margin: var(--space-6) 0;
    padding: var(--space-5);
    border: 1px dashed var(--color-border);
    background-color: var(--color-surface-muted);
    border-radius: var(--radius-md);
    break-inside: avoid;
}
.toc { list-style: none; }
.team-card { display: flex; align-items: center; gap: var(--spacing-5); }
.signature-block { display: flex; justify-content: space-around; }

/* --- NEW: Alert Component --- */
.alert {
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
}
.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}
/* ... other alert variants ... */

/* --- NEW: Badge Component --- */
.badge {
    display: inline-block;
    padding: .25em .4em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
}
.badge-primary {
    color: #fff;
    background-color: var(--color-info);
}

/* --- Container Query Example --- */
.card-grid-container {
    container-type: inline-size;
}

@container (width < 600px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

pre.bar-chart-viz {
    font-family: monospace;
    font-size: 10pt;
    line-height: 1.6;
    text-align: left;
    background: var(--color-surface);
    padding: var(--space-3);
    white-space: pre;
    overflow-x: auto;
}
pre.bar-chart-viz .bar {
    background: var(--color-info);
    color: var(--color-info);
    border-radius: 2px;
}
}

/* ==========================================================================
   8. UTILITIES
   ========================================================================== */
@layer utilities {
#submitConcept {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: var(--space-3) var(--space-6);
    background-color: #1a5f99;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: sans-serif;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: var(--z-index-floating);
}
#submitConcept + .app-link--atlas,
.app-link--atlas {
    position: fixed;
    bottom: 20px;
    right: 185px;
    padding: var(--space-3) var(--space-5);
    background-color: var(--color-viewer-bg-secondary);
    color: white;
    border: 1px solid var(--color-viewer-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    z-index: var(--z-index-floating);
}
.app-link--atlas:hover {
    background-color: var(--color-viewer-bg-hover);
}
#submitConcept:hover {
    background-color: #144a7a;
}
#submitConcept:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Grid System */
.page-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gap);
}
.u-col-1 { grid-column: span 1; }
.u-col-2 { grid-column: span 2; }
.u-col-3 { grid-column: span 3; }
.u-col-4 { grid-column: span 4; }
.u-col-5 { grid-column: span 5; }
.u-col-6 { grid-column: span 6; }
.u-col-7 { grid-column: span 7; }
.u-col-8 { grid-column: span 8; }
.u-col-9 { grid-column: span 9; }
.u-col-10 { grid-column: span 10; }
.u-col-11 { grid-column: span 11; }
.u-col-12 { grid-column: span 12; }

/* Spacing Utilities */
.u-mt-1 { margin-top: var(--layout-space-1); }
.u-mt-2 { margin-top: var(--layout-space-2); }
.u-mt-3 { margin-top: var(--layout-space-3); }
.u-mb-1 { margin-bottom: var(--layout-space-1); }
.u-mb-2 { margin-bottom: var(--layout-space-2); }
.u-mb-3 { margin-bottom: var(--layout-space-3); }

/* Text Utilities */
.u-text-center { text-align: center; }
.u-text-right { text-align: end; }

/* State Classes */
.is-hidden { display: none !important; }
.is-loading { /* styles for loading state */ }
.is-active { /* styles for active state */ }
.is-selected { /* styles for selected state */ }
.is-disabled { cursor: not-allowed; opacity: 0.6; }
.is-error { /* styles for error state */ }
.is-success { /* styles for success state */ }

/* Icon System Placeholders */
.icon { /* base icon styles */ }
.icon-sm { font-size: 0.8em; }
.icon-lg { font-size: 1.2em; }
}

/* PDF Generation Quick Wins for Height Reduction */
@media screen {
    .page {
        padding: 10mm !important; /* Reduce from 12mm */
    }
}

.content-body {
    padding-top: var(--space-2) !important; /* Reduce from --space-3 */
    /* Further reductions from feedback */
    font-size: 10pt !important; /* Reduce from --text-base (11pt) */
    line-height: 1.4 !important; /* Reduce from 1.5 */
}

.content-body h2 {
    /* Further reductions from feedback */
    margin-top: var(--space-3) !important;
    margin-bottom: var(--space-2) !important;
    /* Further reductions from feedback */
    font-size: var(--text-base) !important; /* Reduce from --text-lg */
}

.content-body h3 {
    margin-top: var(--space-3) !important; /* Reduce from --space-4 */
    margin-bottom: var(--space-2) !important;
    /* Further reductions from feedback */
    font-size: 10pt !important; /* Reduce from --text-lg (13pt) */
}

.content-body p {
    margin-bottom: var(--space-2) !important; /* Reduce from --space-3 */
}

.content-body ul,
.content-body ol {
    margin-bottom: var(--space-2) !important; /* Reduce from --space-3 */
    /* Further reductions from feedback */
    padding-inline-start: var(--space-5) !important; /* Reduce from --space-6 */
}

.content-body li {
    margin-bottom: var(--space-1) !important; /* Reduce from --space-2 */
}

.card {
    /* Further reductions from feedback */
    padding: var(--space-3) !important; /* Reduce from --space-4 */
}

.card h4 {
    font-size: 10pt !important;
    margin-bottom: var(--space-1) !important;
}
.card ul {
    margin-bottom: var(--space-1) !important;
}
.card li {
    font-size: 9pt !important;
}

.content-body table th,
.content-body table td {
    padding: var(--space-2) var(--space-3) !important; /* Reduce from --space-3 var(--space-4) */
}

/* Further reductions from feedback */
.content-body table {
    font-size: 8pt !important; /* Reduce from --text-sm (10pt) */
}

.card-grid {
    gap: var(--space-4) !important; /* Reduce from --space-5 */
}

/* Final optimizations from feedback */
.header {
    padding-bottom: var(--space-3) !important;
    margin-bottom: var(--space-2) !important;
}

.header-title {
    font-size: var(--text-xl) !important; /* Reduce from --text-2xl */
}

.header-logo {
    width: 60px !important; /* Reduce from 80px */
    height: 60px !important;
}

.page-footer {
    padding-top: var(--space-2) !important;
    font-size: 7pt !important;
}
.page-footer span:nth-child(2) {
    flex: 1;
    padding: 0 10px;
}

.timeline {
    padding: var(--space-3) 0 !important;
}
.timeline-item {
    margin-bottom: var(--space-4) !important;
}
.timeline-content {
    font-size: var(--text-xs) !important;
}

.metric-card {
    padding: var(--space-3) !important;
}
.metric-card .metric-number {
    font-size: var(--text-2xl) !important; /* Reduce from --text-display */
}

/* Reduce spacing in appendix items */
.page--appendix .appendix-item {
    padding: var(--space-3) !important;
    margin-bottom: var(--space-3) !important;
}

.page--appendix .appendix-header {
    padding-bottom: var(--space-1) !important;
    margin-bottom: var(--space-2) !important;
}

.page--appendix .appendix-content {
    padding: var(--space-1) 0 !important;
}

/* Reduce image sizes in appendix */
.page--appendix .appendix-content img {
    max-height: 280px !important;
    width: auto; /* Allow max-width to constrain wide images */
}

/* Reduce table spacing in document control */
.page--appendix table {
    font-size: 6pt !important;
}

.page--appendix table td {
    padding: 2px 4px !important;
}

.workflow-diagram {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--color-surface-muted);
    margin-top: var(--space-4);
}
.workflow-phase {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    padding: var(--space-3);
}
.workflow-phase .phase-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 10pt;
    color: var(--color-info);
    margin-bottom: var(--space-2);
}
.workflow-phase .phase-content ul {
    font-size: 9pt;
    margin: 0;
    padding-left: var(--space-5);
}
.workflow-arrow {
    text-align: center;
    font-size: 16pt;
    color: var(--color-text-secondary);
    padding: var(--space-2) 0;
    font-weight: bold;
}

.page--appendix h3 {
    margin-top: var(--space-2) !important;
    margin-bottom: var(--space-1) !important;
}

/* Reduce Contact section spacing */
.page--appendix .content-body > div:first-of-type {
    margin-bottom: 15px !important;
}

/* Fixes for PDF Generation Issues */

/* 1. Fix Cover Page Background Rendering */
.page--cover {
    background-color: var(--color-info);
    background-image: var(--cover-overlay), var(--cover-background-image);
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
    color: white;
    padding: 40mm var(--page-margin-screen);
    justify-content: space-between;
    text-align: start;
}
.page--cover * {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
@media print {
    .page--cover {
        background: #0B5CAD !important; /* Fallback for print */
    }
}

/* 2. Fix Page Footer & SVG Rendering Issues */
.page {
    /* Reverting from flex to block. Flexbox layout was causing rendering issues with html2canvas, especially with SVGs. */
    display: block !important;
    min-height: 297mm !important;
    position: relative; /* Needed for absolute positioning of the footer. */
    padding-bottom: 25mm; /* Add space at the bottom to prevent content from overlapping with the absolute footer. */
}

.page-footer {
    /* Using absolute positioning to keep the footer at the bottom, which is more reliable for canvas rendering than flexbox. */
    position: absolute !important;
    bottom: 10mm; /* Position from the bottom edge of the page padding. */
    left: 10mm;   /* Align with the page padding. */
    right: 10mm;  /* Align with the page padding. */
    width: calc(100% - 20mm); /* Ensure it spans the content area inside the padding. */
    padding-top: var(--space-2) !important;
    border-top: 1px solid var(--grey-400) !important;
    font-size: 7pt !important;
    color: var(--color-text-secondary) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
}

/* For pages with very little content, ensure footer stays at bottom */
.page .content-body {
    min-height: 200px !important; /* Adjust as needed */
}

/* PDF Preview Styles */
#pdfPreviewContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 20px;
    background: var(--color-background, #525659);
    position: relative;
    z-index: 1;
}

#pdfPreviewWrapper {
    position: relative;
    width: 210mm;
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s ease;
    transform: scale(0.95);
    transform-origin: center center;
}

#pdfPreviewWrapper .page {
    margin: 0 !important;
    box-shadow: none !important;
    padding: 16mm !important;
}

/* Preview loading overlay */
.preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading, Montserrat, sans-serif);
    color: #666;
    font-size: 14px;
    text-align: center;
    z-index: 10;
    background: rgba(255,255,255,0.9);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Responsive preview */
@media (max-width: 1200px) {
    #pdfPreviewWrapper {
        width: 100%;
        max-width: 210mm;
        transform: scale(0.85);
    }
}

@media (max-width: 768px) {
    #pdfPreviewWrapper {
        transform: scale(0.7);
    }
}

/* ==========================================================================
   9. PRINT STYLES
   ========================================================================== */
@layer print {
@page {
    size: A4;
    /* Use page margin instead of page padding for better print consistency */
    margin: var(--print-margin);

    /* @bottom-left is not supported in most browsers, but is useful for dedicated PDF engines. */
    @bottom-left { 
            content: "ARYBIT TECHNOLOGIES // Building Africa's Sovereign AI Infrastructure";
            font-family: var(--font-heading);
            font-size: 8pt; /* Explicit size for print */
            color: #555;
    }

    @bottom-right {
            content: "Page " counter(page);
            font-family: var(--font-heading);
            font-size: 8pt; /* Explicit size for print */
            color: #555;
    }
}

@media print {
    body { background: none; padding: 0; display: block; }
    .page {
        box-shadow: none;
        width: 100%; /* Fill the area within @page margins */
        min-height: 100%;
        height: auto !important;
        margin: 0;
        border: none;
        page-break-after: always; /* Fallback for older engines */
        display: block;
        /* Padding removed, handled by @page margin */
        padding: 0;
        overflow: visible !important;
        /* Remove any fixed height constraints */
        max-height: none !important;
    }
    .page-footer {
        display: none;
    }
    .page::before { opacity: var(--watermark-opacity); }
    .page::after { opacity: var(--stamp-opacity); }
    
    /* Prevent page breaks inside important elements */
    .card-grid,
    .metric-grid,
    .timeline,
    table,
    .callout,
    .appendix-item {
        break-inside: avoid;
        page-break-inside: avoid; /* Fallback */
    }
    
    /* Ensure images render correctly in print */
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
    }

}
}
