/* ============================================================
   DefCMS – Frontend UX Enhancement Layer
   Additive polish on top of style.css. Conservative, ship-safe.
   Developed by DefenTek Company – Riyadh, Saudi Arabia
   ============================================================ */

/* ── Design tokens (extend, don't replace) ───────────────── */
:root {
    --dx-radius-sm: 6px;
    --dx-radius:    10px;
    --dx-radius-lg: 16px;
    --dx-radius-pill: 999px;

    --dx-shadow-sm: 0 1px 2px rgba(0,0,0,.25);
    --dx-shadow:    0 6px 18px -6px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.25);
    --dx-shadow-lg: 0 20px 40px -12px rgba(0,0,0,.55), 0 6px 12px rgba(0,0,0,.3);
    --dx-glow:      0 0 0 4px rgba(196,160,53,.18);

    --dx-ease: cubic-bezier(.2,.7,.2,1);
    --dx-fast: 140ms;
    --dx-med:  220ms;
    --dx-slow: 380ms;

    --dx-focus: 0 0 0 3px rgba(196,160,53,.45);
}

/* ── Global typography & smoothing ───────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img, svg, video, canvas { max-width: 100%; height: auto; }
::selection { background: rgba(196,160,53,.35); color: #fff; }

/* ── Keyboard focus visibility (a11y) ────────────────────── */
*:focus { outline: none; }
*:focus-visible {
    outline: none !important;
    box-shadow: var(--dx-focus) !important;
    border-radius: var(--dx-radius-sm);
    transition: box-shadow var(--dx-fast) var(--dx-ease);
}
a:focus-visible { border-radius: 4px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    box-shadow: var(--dx-focus), 0 0 0 1px rgba(196,160,53,.6) inset !important;
}

/* ── Smoother base motion ────────────────────────────────── */
a, button, .btn, .service-card, .solution-card, .industry-card,
.client-logo, .partner-card, .project-card, .article-card,
input, select, textarea {
    transition:
        background var(--dx-med) var(--dx-ease),
        border-color var(--dx-med) var(--dx-ease),
        color var(--dx-med) var(--dx-ease),
        transform var(--dx-fast) var(--dx-ease),
        box-shadow var(--dx-med) var(--dx-ease) !important;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Refined buttons ─────────────────────────────────────── */
button, .btn, .cta-btn, a.cta-btn,
input[type="submit"], input[type="button"] {
    font-family: inherit;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    border-radius: var(--dx-radius-sm);
    will-change: transform;
}
button:hover, .btn:hover, .cta-btn:hover,
input[type="submit"]:hover, input[type="button"]:hover {
    transform: translateY(-1px);
    box-shadow: var(--dx-shadow);
}
button:active, .btn:active, .cta-btn:active,
input[type="submit"]:active, input[type="button"]:active {
    transform: translateY(0);
    box-shadow: var(--dx-shadow-sm);
}
button:disabled, .btn:disabled, button[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Form fields polish ──────────────────────────────────── */
input[type="text"], input[type="email"], input[type="tel"],
input[type="url"], input[type="number"], input[type="password"],
input[type="search"], input[type="date"], input[type="time"],
input[type="datetime-local"], textarea, select {
    border-radius: var(--dx-radius-sm);
    border: 1px solid var(--border-subtle, rgba(255,255,255,.10));
    background: rgba(255,255,255,.025);
    color: var(--text-primary, #E8E8E8);
    padding: .75rem 1rem;
    font-family: inherit;
    font-size: .95rem;
    line-height: 1.4;
    width: 100%;
    transition: border-color var(--dx-med) var(--dx-ease),
                box-shadow var(--dx-med) var(--dx-ease),
                background var(--dx-med) var(--dx-ease);
}
input:hover, textarea:hover, select:hover {
    border-color: rgba(255,255,255,.18);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-amber, #C4A035);
    background: rgba(255,255,255,.04);
    box-shadow: var(--dx-glow);
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,.35); }
textarea { resize: vertical; min-height: 96px; }
input[aria-invalid="true"], .field-error input, .field-error textarea, .field-error select {
    border-color: #ff5577;
    box-shadow: 0 0 0 4px rgba(255,85,119,.18);
}

/* Custom checkbox / radio look */
input[type="checkbox"], input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent-amber, #C4A035);
    cursor: pointer;
}

/* ── Card hover lift (where applicable) ──────────────────── */
.service-card, .solution-card, .industry-card,
.partner-card, .project-card, .article-card, .pricing-card {
    will-change: transform;
}
.service-card:hover, .solution-card:hover, .industry-card:hover,
.partner-card:hover, .project-card:hover, .article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--dx-shadow-lg);
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert, .alert-success, .alert-error, .alert-warning, .alert-info {
    border-radius: var(--dx-radius);
    padding: .9rem 1.1rem;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .95rem;
    line-height: 1.4;
    animation: dx-slide-in var(--dx-med) var(--dx-ease) both;
}
.alert-success { color: #6fffb1; background: rgba(0,255,136,.07); border-color: rgba(0,255,136,.25); }
.alert-error   { color: #ff8a9c; background: rgba(255,68,68,.08); border-color: rgba(255,68,68,.28); }
.alert-warning { color: #ffd073; background: rgba(255,170,0,.08); border-color: rgba(255,170,0,.28); }
.alert-info    { color: #71d4ef; background: rgba(0,180,216,.08); border-color: rgba(0,180,216,.28); }

@keyframes dx-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar (WebKit + Firefox) ────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(196,160,53,.4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(196,160,53,.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(196,160,53,.6); background-clip: content-box; }

/* ── Link underline that respects motion ─────────────────── */
.prose a, .content a:not(.btn):not(.cta-btn) {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: rgba(196,160,53,.45);
}
.prose a:hover, .content a:hover:not(.btn):not(.cta-btn) {
    text-decoration-color: var(--accent-amber, #C4A035);
}

/* ── Sectional rhythm ────────────────────────────────────── */
section { scroll-margin-top: 88px; }

/* ── Mobile-first responsive tweaks ──────────────────────── */
@media (max-width: 768px) {
    h1, .hero-title  { font-size: clamp(2rem, 6vw, 3rem) !important; line-height: 1.15 !important; }
    h2, .section-title { font-size: clamp(1.5rem, 4.5vw, 2.25rem) !important; }
    h3 { font-size: clamp(1.15rem, 3.8vw, 1.5rem) !important; }
    section { padding-left: 1rem !important; padding-right: 1rem !important; }
    .container { padding-left: 1rem !important; padding-right: 1rem !important; }
    .hero, .hero-section { padding-top: 5rem !important; padding-bottom: 3rem !important; }
    /* prevent off-screen horizontal scroll on small phones */
    body { overflow-x: hidden; }
}

@media (max-width: 480px) {
    .btn, button.btn-primary, .cta-btn {
        width: 100%;
        justify-content: center;
    }
    /* Stack inline form rows */
    .form-row { flex-direction: column !important; }
    .form-row > * { width: 100% !important; }
}

/* ── Skeleton loaders (drop-in) ──────────────────────────── */
.skeleton {
    display: inline-block;
    position: relative;
    background: rgba(255,255,255,.05);
    border-radius: var(--dx-radius-sm);
    overflow: hidden;
}
.skeleton::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,.06),
        transparent
    );
    animation: dx-shimmer 1.4s linear infinite;
}
@keyframes dx-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Toast (drop-in element) ─────────────────────────────── */
.dx-toast-container {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    display: flex; flex-direction: column; gap: .5rem;
    pointer-events: none;
}
html[dir="rtl"] .dx-toast-container { right: auto; left: 20px; }
.dx-toast {
    pointer-events: auto;
    min-width: 260px; max-width: 420px;
    padding: .9rem 1rem;
    background: rgba(18,21,26,.95);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: var(--dx-radius);
    color: #E8E8E8;
    box-shadow: var(--dx-shadow-lg);
    backdrop-filter: blur(10px);
    animation: dx-slide-in var(--dx-med) var(--dx-ease) both;
}
.dx-toast.success { border-left: 3px solid #00ff88; }
.dx-toast.error   { border-left: 3px solid #ff4444; }
.dx-toast.warning { border-left: 3px solid #ffaa00; }

/* ── High contrast preference ────────────────────────────── */
@media (prefers-contrast: more) {
    :root {
        --border-subtle: rgba(255,255,255,.30) !important;
        --text-secondary: #d4d4d4 !important;
    }
    input, textarea, select { border-width: 2px !important; }
}

/* ── Print refinement ────────────────────────────────────── */
@media print {
    .grid-bg, .hud-status-panel, .hud-telemetry,
    nav, .mobile-nav-toggle, .footer-social { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    a { color: #000 !important; text-decoration: underline; }
    section { page-break-inside: avoid; }
}

/* ── Lazy-load image fade-in ─────────────────────────────── */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--dx-slow) var(--dx-ease);
}
img[loading="lazy"].loaded,
img[loading="lazy"][src] { opacity: 1; }
img[loading="lazy"]:not([src=""]):not([src*="data:image/svg"]) { opacity: 1; }

/* ── Tap target sizing on mobile (a11y) ──────────────────── */
@media (pointer: coarse) {
    a, button, .btn, input[type="checkbox"], input[type="radio"] {
        min-height: 44px;
    }
    nav a, .menu a { padding-top: .65rem; padding-bottom: .65rem; }
}

/* ── Subtle scroll-to-top floating button (optional, opt-in) */
.dx-scroll-top {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent-amber, #C4A035);
    color: var(--dark-bg, #0A0C0F);
    border: none;
    display: none;
    align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700;
    cursor: pointer;
    box-shadow: var(--dx-shadow-lg);
    z-index: 999;
}
html[dir="rtl"] .dx-scroll-top { right: auto; left: 1.5rem; }
.dx-scroll-top.show { display: flex; animation: dx-slide-in var(--dx-med) var(--dx-ease) both; }
.dx-scroll-top:hover { transform: translateY(-2px) scale(1.05); }

/* ── Brand logo fix ───────────────────────────────────────────
   The base theme applies `filter: brightness(0) invert(1)` to the
   nav & footer logo — a trick that turns a *transparent* wordmark
   white for the dark UI. The shipped logo.png has a baked WHITE
   background, so the filter turned the whole thing into a solid
   white box. Drop the filter and present the original colour logo
   on a clean white "chip" so it reads as an intentional lockup.
   (Ideal long-term fix: upload a transparent-background logo, then
   this chip can be removed and the original white-wordmark filter
   restored.) ───────────────────────────────────────────────── */
.nav .logo {
    filter: none !important;
    background: #ffffff;
    padding: 5px 11px;
    border-radius: 9px;
    box-shadow: 0 2px 10px rgba(0,0,0,.30);
    box-sizing: content-box;
}
.footer-brand img {
    filter: none !important;
    background: #ffffff;
    padding: 6px 12px;
    border-radius: 9px;
    box-sizing: content-box;
}

/* Hero highlight word: dark olive (#6B6B45) was the lowest-contrast
   element in the headline. Use the brand amber so the brand name in
   the hero actually reads. (Tech preset / default only — other
   presets that set their own highlight colour keep it.) */
.hero-title .highlight { color: var(--accent-amber-bright, #D4B045); }
