/**
 * ========================================
 * TENDERFRAME DESIGN SYSTEM
 * "Warm. Cinematic. Intimate."
 * ========================================
 * 
 * This file contains brand-level tokens and reusable 
 * component styles. Import this first in any new page.
 * 
 * Version: 1.0.0
 * Last Updated: 2025
 */

/* ========================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ======================================== */

:root {
    /* --- COLOR PALETTE --- */
    
    /* The Canvas: A memory you can touch */
    --color-mist: #E4EAED;
    --color-mist-rgb: 228, 234, 237;
    
    /* The Anchor: Confidence & Stability */
    --color-forest: #0B3021;
    --color-forest-rgb: 11, 48, 33;
    
    --color-midnight: #041108;
    --color-midnight-rgb: 4, 17, 8;
    
    /* The Structure: Muted Strength */
    --color-sage: #395648;
    --color-sage-rgb: 57, 86, 72;
    
    /* The Spark: Modern Energy */
    --color-lime: #D1F358;
    --color-lime-rgb: 209, 243, 88;
    
    /* The Heart: Tenderness */
    --color-rose: #F6ADC6;
    --color-rose-rgb: 246, 173, 198;

    /* --- TYPOGRAPHY --- */
    --font-serif: "larken", Georgia, serif;
    --font-sans: "dm-sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-script: "novantique-script", cursive;

    /* --- SPACING SCALE --- */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;

    /* --- SHADOWS --- */
    --shadow-sm: 0 2px 4px rgba(4, 17, 8, 0.05);
    --shadow-md: 0 4px 12px rgba(11, 48, 33, 0.15);
    --shadow-lg: 0 12px 32px rgba(4, 17, 8, 0.08);
    --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.25);

    /* --- TRANSITIONS --- */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    --transition-bounce: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* --- BORDER RADIUS --- */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 50px;
    --radius-circle: 50%;

    /* --- Z-INDEX SCALE --- */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-toast: 400;
}


/* ========================================
   BASE STYLES
   ======================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-mist);
    color: var(--color-midnight);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Typography Base */
h1, h2, h3, h4, h5, h6,
.font-serif {
    font-family: var(--font-serif);
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-top: 0;
}

.font-script {
    font-family: var(--font-script);
    font-weight: 400;
}

p {
    font-weight: 400;
    color: var(--color-midnight);
    max-width: 65ch;
}

/*
 * Centered layout safeguard:
 * If a container centers text (e.g. headings + short intro copy),
 * our global max-width on <p> can otherwise look left-anchored.
 * This keeps readable line-length while centering the block.
 */
:where(.text-center, .usa-prose.text-center, .tender-center) p {
    margin-left: auto;
    margin-right: auto;
}

a {
    color: var(--color-forest);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-lime);
}


/* ========================================
   GRADIENT UTILITIES
   ======================================== */

.bg-gradient-electric {
    background: linear-gradient(135deg, var(--color-midnight) 0%, var(--color-forest) 60%, var(--color-lime) 100%);
}

.bg-gradient-deep {
    background: linear-gradient(180deg, var(--color-forest) 0%, var(--color-midnight) 100%);
}

.bg-gradient-morning {
    background: linear-gradient(135deg, var(--color-mist) 0%, #fcecf2 50%, var(--color-rose) 100%);
}

.bg-gradient-organic {
    background: linear-gradient(135deg, var(--color-sage) 0%, var(--color-forest) 100%);
}

/* ========================================
   CINEMATIC UTILITIES (Opt-in)
   ======================================== */


/* Soft “glass” surface for legible copy on cinematic backgrounds */
.tf-glass {
    background: rgba(var(--color-midnight-rgb), 0.22);
    border: 1px solid rgba(var(--color-mist-rgb), 0.10);
    box-shadow: 0 18px 60px rgba(var(--color-midnight-rgb), 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
}

/* Calm entrance motion (optional) */
@keyframes tf-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tf-animate-in {
    animation: tf-fade-up 700ms var(--transition-bounce) both;
}


/* ========================================
   COLOR UTILITIES
   ======================================== */

/*
 * CONTRAST GUIDELINES (WCAG AA Compliance):
 * 
 * ✅ SAFE TEXT COLORS ON LIGHT BACKGROUNDS (white, mist):
 *    - forest (#0B3021) - 15:1 contrast ✓
 *    - midnight (#041108) - 19:1 contrast ✓
 *    - sage (#395648) - 7:1 contrast ✓
 * 
 * ⚠️ AVOID AS TEXT ON LIGHT BACKGROUNDS:
 *    - lime (#D1F358) - 1.4:1 contrast ✗ FAILS
 *    - rose (#F6ADC6) - 2.1:1 contrast ✗ FAILS
 * 
 * ✅ SAFE TEXT COLORS ON DARK BACKGROUNDS (forest, midnight):
 *    - white (#FFFFFF) - 15:1+ contrast ✓
 *    - mist (#E4EAED) - 13:1+ contrast ✓
 *    - lime (#D1F358) - 10:1+ contrast ✓
 *    - rose (#F6ADC6) - 7:1+ contrast ✓
 * 
 * RULE: Only use lime/rose as text on dark backgrounds or as accents.
 */

.text-rose { color: var(--color-rose); }
.text-lime { color: var(--color-lime); }
.text-sage { color: var(--color-sage); }
.text-forest { color: var(--color-forest); }
.text-mist { color: var(--color-mist); }
.text-midnight { color: var(--color-midnight); }
.text-white { color: #ffffff; }

.bg-forest { background-color: var(--color-forest); }
.bg-midnight { background-color: var(--color-midnight); }
.bg-mist { background-color: var(--color-mist); }
.bg-white { background-color: #ffffff; }

/* Safety: Prevent lime text on light backgrounds */
.bg-white .text-lime,
.bg-mist .text-lime {
    /* Override lime to forest on light backgrounds for accessibility */
    color: var(--color-forest);
}

/* ========================================
   THEME-AWARE ACCENTS (Safe by default)
   ======================================== */

/*
 * Use these instead of `.text-lime` / `.text-rose` when the background
 * might be light in one mode and dark in another (e.g., sections that
 * change with dark mode).
 */
.tf-accent {
    color: var(--color-forest);
}

body.dark-mode .tf-accent {
    color: var(--color-lime);
}

.tf-accent-script {
    color: var(--color-sage);
}

body.dark-mode .tf-accent-script {
    color: var(--color-rose);
}


/* ========================================
   BUTTON COMPONENTS
   ======================================== */

.usa-button {
    font-family: var(--font-sans);
    background-color: var(--color-lime);
    color: var(--color-forest);
    border-radius: var(--radius-full);
    padding: 0.75rem 2rem;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
    border: 1px solid transparent;
    cursor: pointer;
}

.usa-button:hover {
    background-color: #c3e645;
    color: var(--color-midnight);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.usa-button--secondary {
    background-color: var(--color-forest);
    color: var(--color-mist);
}

.usa-button--secondary:hover {
    background-color: var(--color-midnight);
    color: var(--color-lime);
}

.usa-button--outline {
    background: transparent !important;
    box-shadow: inset 0 0 0 1px var(--color-sage) !important;
    color: var(--color-sage) !important;
}

.usa-button--outline:hover {
    box-shadow: inset 0 0 0 1px var(--color-forest) !important;
    color: var(--color-forest) !important;
}

.usa-button--inverse-outline {
    background: transparent !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6) !important;
    color: #ffffff !important;
}

.usa-button--inverse-outline:hover {
    box-shadow: inset 0 0 0 1px #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}


/* ========================================
   DARK MODE TOGGLE
   ======================================== */

.dark-mode-toggle {
    background: transparent;
    border: 1px solid var(--color-sage);
    border-radius: var(--radius-circle);
    width: 40px;
    height: 40px;
    display: none !important; /* Hide toggle - always dark mode */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    padding: 0;
    flex-shrink: 0;
    /* No absolute positioning - let it flow naturally */
}

.dark-mode-toggle:hover {
    border-color: var(--color-forest);
    background-color: rgba(var(--color-sage-rgb), 0.1);
}

.dark-mode-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--color-sage);
    transition: all var(--transition-base);
}

.dark-mode-toggle:hover svg {
    color: var(--color-forest);
}


/* ========================================
   TOAST / SUCCESS MESSAGE
   ======================================== */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--color-forest);
    color: #ffffff;
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    z-index: var(--z-toast);
    transform: translateY(150%);
    opacity: 0;
    transition: transform var(--transition-bounce), opacity var(--transition-base);
}

.toast.toast--visible {
    transform: translateY(0);
    opacity: 1;
}

.toast.toast--success {
    border-left: 4px solid var(--color-lime);
}

.toast__icon {
    width: 24px;
    height: 24px;
    color: var(--color-lime);
    flex-shrink: 0;
}

.toast__content {
    flex: 1;
}

.toast__title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
}

.toast__message {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
}

.toast__close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.toast__close:hover {
    color: #ffffff;
}

/* Mobile toast positioning */
@media (max-width: 480px) {
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}


/* ========================================
   TABLE COMPONENT (Responsive)
   ======================================== */

.usa-table--tender th {
    background-color: var(--color-forest);
    color: #ffffff;
    font-family: var(--font-serif);
    font-weight: 400;
    border: none;
}

.usa-table--tender td {
    font-family: var(--font-sans);
    color: var(--color-midnight);
    border-bottom: 1px solid rgba(var(--color-sage-rgb), 0.1);
}

.usa-table--tender tr:nth-child(even) td {
    background-color: rgba(var(--color-mist-rgb), 0.3);
}

/* Responsive table wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-md);
}

/* Card-style table for mobile */
@media (max-width: 768px) {
    .usa-table--responsive {
        border: 0;
    }
    
    .usa-table--responsive thead {
        display: none;
    }
    
    .usa-table--responsive tr {
        display: block;
        margin-bottom: var(--space-lg);
        background: #ffffff;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        border: 1px solid rgba(var(--color-sage-rgb), 0.1);
        overflow: hidden;
    }
    
    .usa-table--responsive td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: var(--space-md);
        text-align: right;
        border-bottom: 1px solid rgba(var(--color-sage-rgb), 0.05);
        color: var(--color-midnight); /* Ensure dark text for values */
    }
    
    /* CONTRAST FIX: Labels must use high-contrast color */
    .usa-table--responsive td::before {
        content: attr(data-label);
        font-weight: 700;
        font-family: var(--font-serif);
        color: var(--color-forest) !important; /* Forest green - 15:1 contrast on white */
        text-align: left;
        flex-shrink: 0;
        margin-right: var(--space-md);
    }
    
    .usa-table--responsive td:first-child {
        background-color: var(--color-forest);
        color: #ffffff;
        font-family: var(--font-serif);
        font-weight: 600;
        font-size: 1.1rem;
        justify-content: flex-start;
    }
    
    .usa-table--responsive td:first-child::before {
        display: none;
    }
    
    .usa-table--responsive td:last-child {
        border-bottom: none;
    }
}


/* ========================================
   ICON LIST COMPONENT
   ======================================== */

.usa-icon-list--tender .usa-icon-list__icon {
    background-color: transparent;
}

.usa-icon-list--tender .usa-icon-list__content {
    font-family: var(--font-sans);
    color: inherit;
}

.usa-icon-list--tender .usa-icon-list__title {
    font-family: var(--font-serif);
    color: inherit;
    margin-bottom: 0.25rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.usa-icon-list__icon svg {
    width: 2rem;
    height: 2rem;
}

.icon-tender-lime { color: var(--color-lime); }
.icon-tender-forest { color: var(--color-forest); }
.icon-tender-rose { color: var(--color-rose); }


/* ========================================
   DARK MODE OVERRIDES
   ======================================== */

body.dark-mode {
    background-color: var(--color-midnight);
    color: var(--color-mist);
}

/* Header */
body.dark-mode .usa-header {
    background-color: rgba(var(--color-forest-rgb), 0.75);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid rgba(var(--color-lime-rgb), 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

body.dark-mode .usa-navbar {
    background-color: transparent;
}

body.dark-mode .usa-logo__text {
    color: var(--color-lime);
}

body.dark-mode .usa-nav {
    background-color: var(--color-forest);
}

body.dark-mode .usa-nav__primary-item {
    border-top-color: rgba(var(--color-lime-rgb), 0.1);
}

body.dark-mode .usa-nav__primary button,
body.dark-mode .usa-nav__link {
    color: var(--color-mist) !important;
}

body.dark-mode .usa-nav__primary button:hover,
body.dark-mode .usa-nav__link:hover {
    color: var(--color-lime) !important;
}

body.dark-mode .dark-mode-toggle {
    border-color: var(--color-lime);
}

body.dark-mode .dark-mode-toggle:hover {
    border-color: var(--color-lime);
    background-color: rgba(var(--color-lime-rgb), 0.1);
}

body.dark-mode .dark-mode-toggle svg {
    color: var(--color-lime);
}

/* Buttons - ensure proper text color in dark mode */
body.dark-mode .usa-button {
    color: var(--color-forest) !important; /* Dark green text on lime background */
}

body.dark-mode .usa-button:hover {
    color: var(--color-midnight) !important; /* Darker text on hover */
}

/* Outline button in dark mode - use lighter colors for contrast */
body.dark-mode .usa-button--outline {
    color: var(--color-mist) !important; /* Light text for contrast on dark backgrounds */
    box-shadow: inset 0 0 0 1px var(--color-mist) !important; /* Light border for visibility */
}

body.dark-mode .usa-button--outline:hover {
    color: var(--color-lime) !important; /* Lime text on hover for better visibility */
    box-shadow: inset 0 0 0 1px var(--color-lime) !important; /* Lime border on hover */
    background-color: rgba(var(--color-lime-rgb), 0.1) !important; /* Subtle lime background on hover */
}

/* Inverse outline button - ensure bright white text on dark backgrounds */
body.dark-mode .usa-button--inverse-outline {
    color: #ffffff !important; /* Pure white for maximum contrast */
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7) !important; /* More visible border */
}

body.dark-mode .usa-button--inverse-outline:hover {
    color: #ffffff !important;
    box-shadow: inset 0 0 0 1px #ffffff !important; /* Solid white border on hover */
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Typography */
body.dark-mode p {
    color: var(--color-mist);
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
    color: var(--color-lime);
}

body.dark-mode .text-forest {
    color: var(--color-lime);
}

body.dark-mode .text-sage {
    color: var(--color-mist);
}

/* Backgrounds */
body.dark-mode .bg-white {
    background-color: var(--color-forest) !important;
}

body.dark-mode .text-base-light {
    color: var(--color-mist) !important;
}

/* Tables */
body.dark-mode .usa-table--tender td {
    color: var(--color-mist);
    background-color: transparent;
}

body.dark-mode .usa-table--tender tr:nth-child(even) td {
    background-color: rgba(var(--color-sage-rgb), 0.2);
}

body.dark-mode .usa-table--tender th[scope="row"] {
    color: var(--color-lime) !important;
}

@media (max-width: 768px) {
    body.dark-mode .usa-table--responsive tr {
        background: var(--color-forest) !important;
        border-color: rgba(var(--color-lime-rgb), 0.2) !important;
    }
    
    body.dark-mode .usa-table--responsive td,
    body.dark-mode .usa-table--responsive tbody td,
    body.dark-mode .usa-table--tender.usa-table--responsive td {
        color: #ffffff !important; /* Pure white for maximum contrast */
        background-color: transparent !important;
        border-bottom-color: rgba(255, 255, 255, 0.1) !important;
    }
    
    /* CONTRAST FIX: Labels must be light on dark background */
    body.dark-mode .usa-table--responsive td::before,
    body.dark-mode .usa-table--tender.usa-table--responsive td::before {
        color: var(--color-lime) !important; /* Lime on dark - 10:1 contrast */
    }
    
    body.dark-mode .usa-table--responsive td:first-child,
    body.dark-mode .usa-table--tender.usa-table--responsive td:first-child {
        background-color: var(--color-midnight) !important;
        color: #ffffff !important;
    }
}

/* CTA Section */
body.dark-mode .bg-gradient-morning {
    background: linear-gradient(135deg, var(--color-forest) 0%, var(--color-sage) 100%) !important;
}

body.dark-mode .text-midnight {
    color: var(--color-lime) !important;
}

/* Secondary button in dark mode - use lime background for contrast on dark backgrounds */
body.dark-mode .usa-button--secondary {
    background-color: var(--color-lime) !important;
    color: var(--color-forest) !important;
}

body.dark-mode .usa-button--secondary:hover {
    background-color: #c3e645 !important; /* Slightly darker lime on hover */
    color: var(--color-midnight) !important;
}

/* Toast in dark mode */
body.dark-mode .toast {
    background-color: var(--color-sage);
}

