/*
 * AptSoft — comprehensive theme contrast layer
 * Loaded after all legacy styles. Only affects light mode; dark mode remains unchanged.
 */
html[data-theme="light"] {
  color-scheme: light;
  --bg-base: #f7f8fc;
  --bg-surface: #eef0f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f2f3fa;
  --text-main: #17172b;
  --text-muted: #55566b;
  --text-inverse: #ffffff;
  --border-color: rgba(27, 30, 58, .13);
  --glass-bg: rgba(255,255,255,.88);
  --glass-border: rgba(27,30,58,.12);
  --shadow-subtle: 0 10px 32px rgba(25, 28, 60, .08);
}

/* Default readable ink for legacy pages with hard-coded light text. */
html[data-theme="light"] body,
html[data-theme="light"] #page-wrapper,
html[data-theme="light"] main {
  color: #242438 !important;
}

/* Covers headings, body copy, labels, metadata, list items, table content,
   links and common inline text across Services, Portfolio, Products,
   Automation, Contact, Home and secondary pages. */
html[data-theme="light"] main :is(
  h1,h2,h3,h4,h5,h6,p,li,dt,dd,label,small,strong,b,em,i,
  blockquote,cite,figcaption,legend,summary,td,th,caption,
  .section-tag,.section-label,.section-description,.section-subtitle,
  .hero-subtitle,.hero-description,.card-title,.card-text,
  .text-muted,.description,.subtitle,.eyebrow,.meta,.metadata,
  .feature-text,.feature-description,.service-description,
  .product-description,.project-description,.automation-description
) {
  color: #42445a !important;
  -webkit-text-fill-color: #42445a !important;
  text-shadow: none;
}

/* Headings and title-like content need stronger contrast. */
html[data-theme="light"] main :is(h1,h2,h3,h4,h5,h6,.card-title,.section-title,.hero-title) {
  color: #19192e !important;
  -webkit-text-fill-color: #19192e !important;
}

/* Preserve the brand gradient wherever it is intentionally used. */
html[data-theme="light"] main .text-gradient,
html[data-theme="light"] main .text-gradient *,
html[data-theme="light"] main [class*="gradient-text"] {
  background-image: linear-gradient(100deg,#d927a9 0%,#7546df 53%,#078fcf 100%) !important;
  background-clip: text !important;
  -webkit-background-clip: text !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  text-shadow: none !important;
}

/* Links remain distinguishable from body copy. */
html[data-theme="light"] main a:not(.btn):not([class*="btn-"]):not(.text-gradient) {
  color: #ffff !important;
  -webkit-text-fill-color: #ffff !important;
}
html[data-theme="light"] main a:not(.btn):not([class*="btn-"]):hover {
  color: #b51f91 !important;
  -webkit-text-fill-color: #b51f91 !important;
}

/* Make legacy dark/glass cards light surfaces in light mode so dark text
   never sits on a near-black panel. */
html[data-theme="light"] main :is(
  .glass-card,.glass-panel,.glass-box,.info-card,.feature-card,
  .service-card,.service-box,.service-item,.portfolio-card,.project-card,
  .featured-project-card,.product-card,.product-item,.automation-card,
  .automation-box,.process-card,.step-card,.tech-card,.matrix-card,
  .testimonial-card,.contact-card,.contact-info-card,.hero-contact-card,
  .form-card,.faq-item,.accordion-item,.stat-card,.stats-card,
  .vm-card,.vision-card,.mission-card,.timeline-step,.case-study-card
) {
  color: #242438 !important;
  background-color: #ffffff !important;
  border-color: rgba(27,30,58,.13) !important;
  box-shadow: 0 10px 30px rgba(25,28,60,.06);
}
html[data-theme="light"] main :is(
  .glass-card,.glass-panel,.glass-box,.info-card,.feature-card,
  .service-card,.service-box,.service-item,.portfolio-card,.project-card,
  .featured-project-card,.product-card,.product-item,.automation-card,
  .automation-box,.process-card,.step-card,.tech-card,.matrix-card,
  .testimonial-card,.contact-card,.contact-info-card,.hero-contact-card,
  .form-card,.faq-item,.accordion-item,.stat-card,.stats-card,
  .vm-card,.vision-card,.mission-card,.timeline-step,.case-study-card
) :is(h1,h2,h3,h4,h5,h6,p,span,li,label,small,strong,b,em,a) {
  color: #42445a !important;
  -webkit-text-fill-color: #42445a !important;
}
html[data-theme="light"] main :is(
  .glass-card,.glass-panel,.glass-box,.info-card,.feature-card,
  .service-card,.service-box,.service-item,.portfolio-card,.project-card,
  .featured-project-card,.product-card,.product-item,.automation-card,
  .automation-box,.process-card,.step-card,.tech-card,.matrix-card,
  .testimonial-card,.contact-card,.contact-info-card,.hero-contact-card,
  .form-card,.faq-item,.accordion-item,.stat-card,.stats-card,
  .vm-card,.vision-card,.mission-card,.timeline-step,.case-study-card
) :is(h1,h2,h3,h4,h5,h6,.card-title) {
  color: #19192e !important;
  -webkit-text-fill-color: #19192e !important;
}

/* Hero/intro panels with legacy dark backgrounds become soft light surfaces. */
html[data-theme="light"] main :is(
  .services-hero,.portfolio-hero,.products-hero,.automation-hero,
  .contact-hero,.contact-section,.about-hero,.services-intro,
  .portfolio-intro,.products-intro,.automation-intro
) {
  color: #242438 !important;
  background-color: #f7f8fc !important;
}
html[data-theme="light"] main :is(
  .services-hero,.portfolio-hero,.products-hero,.automation-hero,
  .contact-hero,.contact-section,.services-intro,.portfolio-intro,
  .products-intro,.automation-intro
) :is(h1,h2,h3,h4,h5,h6,p,li,span,small,label) {
  color: #42445a !important;
  -webkit-text-fill-color: #42445a !important;
}
html[data-theme="light"] main :is(
  .services-hero,.portfolio-hero,.products-hero,.automation-hero,
  .contact-hero,.contact-section
) :is(h1,h2,h3,h4,h5,h6) {
  color: #19192e !important;
  -webkit-text-fill-color: #19192e !important;
}

/* Buttons keep their intended foreground/background pairing. */
html[data-theme="light"] main :is(
  .btn-primary,.btn-success,.btn-danger,.btn-dark,.apt-hero-primary,
  .nav-pay-online,.submit-btn,.pay-button,[type="submit"]
) {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="light"] main :is(
  .btn-secondary,.btn-outline,.btn-outline-light,.btn-light,
  .category,.filter-pill
) {
  color: #292640 !important;
  -webkit-text-fill-color: #292640 !important;
  border-color: rgba(40,38,70,.22);
}

/* Form controls and placeholders, particularly Contact page. */
html[data-theme="light"] main :is(input,select,textarea) {
  color: #242438 !important;
  background-color: #ffffff !important;
  border-color: rgba(35,38,65,.22) !important;
}
html[data-theme="light"] main :is(input,textarea)::placeholder {
  color: #77788b !important;
  opacity: 1;
}
html[data-theme="light"] main select option {
  color: #242438;
  background: #ffffff;
}

/* Contact page inline custom properties previously forced a dark card. */
html[data-theme="light"] {
  --card-bg: #ffffff;
  --card-border: rgba(27,30,58,.13);
  --gradient-primary: linear-gradient(135deg,#d927a9,#7546df,#078fcf);
  --gradient-glow: linear-gradient(135deg,rgba(217,39,169,.08),rgba(7,143,207,.08));
}
html[data-theme="light"] main .hero-contact-card,
html[data-theme="light"] main .contact-form,
html[data-theme="light"] main .contact-form-wrapper {
  background: #ffffff !important;
  border-color: rgba(27,30,58,.13) !important;
}
html[data-theme="light"] main .hero-contact-card .contact-item {
  border-bottom-color: rgba(27,30,58,.10) !important;
}

/* Tables, code panels, chips and badges. */
html[data-theme="light"] main :is(table,.table) {
  color: #34354b !important;
  --bs-table-color: #34354b;
  --bs-table-bg: #ffffff;
}
html[data-theme="light"] main :is(.badge,.section-tag,.featured-badge,.automation-badge) {
  color: #5536a8 !important;
  -webkit-text-fill-color: #5536a8 !important;
  background-color: #f0eaff;
  border-color: rgba(117,70,223,.18);
}

/* Footer uses the same readable palette in light mode. */
html[data-theme="light"] footer,
html[data-theme="light"] footer :is(h1,h2,h3,h4,h5,h6,p,li,span,a,small) {
  color: #42445a !important;
  -webkit-text-fill-color: #42445a !important;
}
html[data-theme="light"] footer a:hover {
  color: #b51f91 !important;
  -webkit-text-fill-color: #b51f91 !important;
}

/* Avoid changing the intentional dark hero artwork on the homepage. */
html[data-theme="light"] main .apt-hero,
html[data-theme="light"] main .apt-hero-mobile-copy {
  color: #ffffff !important;
}
html[data-theme="light"] main .apt-hero-mobile-copy :is(h1,p,li,.apt-hero-eyebrow) {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="light"] main .apt-hero-mobile-copy h1 span {
  background-image: linear-gradient(100deg,#ec35c0,#8c53f5,#08b5ee) !important;
  background-clip: text !important;
  -webkit-background-clip: text !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}

/* Ensure native controls and focus states remain usable. */
html[data-theme="light"] :focus-visible {
  outline: 3px solid rgba(117,70,223,.55);
  outline-offset: 2px;
}


/* =========================================================
   PAGE HERO FIX — Services, Portfolio, Products, Automation
   These legacy heroes use dark background-image gradients.
   Override the shorthand (not just background-color), then
   explicitly set all hero copy to high-contrast dark ink.
   ========================================================= */
html[data-theme="light"] .services-hero,
html[data-theme="light"] .portfolio-hero,
html[data-theme="light"] .products-hero,
html[data-theme="light"] .automation-hero {
    background: linear-gradient(135deg, #ffffff 0%, #f5f4fb 54%, #eef7ff 100%) !important;
    background-color: #f7f8fc !important;
    color: #242438 !important;
    isolation: isolate;
}

html[data-theme="light"] .services-hero::before,
html[data-theme="light"] .portfolio-hero::before,
html[data-theme="light"] .products-hero::before,
html[data-theme="light"] .automation-hero::before {
    background: linear-gradient(115deg, rgba(217,39,169,.035), rgba(117,70,223,.025), rgba(7,143,207,.035)) !important;
    opacity: 1 !important;
}

html[data-theme="light"] .services-hero :is(.container,.services-hero-content),
html[data-theme="light"] .portfolio-hero :is(.container,.portfolio-hero-content),
html[data-theme="light"] .products-hero :is(.container,.hero-content),
html[data-theme="light"] .automation-hero :is(.container,.hero-content) {
    color: #292940 !important;
}

html[data-theme="light"] .services-hero h1,
html[data-theme="light"] .portfolio-hero h1,
html[data-theme="light"] .products-hero h1,
html[data-theme="light"] .automation-hero h1 {
    color: #19192e !important;
    -webkit-text-fill-color: #19192e !important;
    text-shadow: none !important;
}

html[data-theme="light"] .services-hero p,
html[data-theme="light"] .portfolio-hero p,
html[data-theme="light"] .products-hero p,
html[data-theme="light"] .automation-hero p {
    color: #4b4d63 !important;
    -webkit-text-fill-color: #4b4d63 !important;
    opacity: 1 !important;
    text-shadow: none !important;
}

html[data-theme="light"] .services-hero .section-tag,
html[data-theme="light"] .portfolio-hero .section-tag,
html[data-theme="light"] .products-hero .section-tag,
html[data-theme="light"] .automation-hero .section-tag {
    color: #6337b5 !important;
    -webkit-text-fill-color: #6337b5 !important;
    background: rgba(117,70,223,.09) !important;
    border: 1px solid rgba(117,70,223,.20) !important;
    box-shadow: none !important;
}

/* Keep AptSoft gradient emphasis vivid inside light hero headings. */
html[data-theme="light"] .services-hero h1 .text-gradient,
html[data-theme="light"] .portfolio-hero h1 .text-gradient,
html[data-theme="light"] .products-hero h1 .text-gradient,
html[data-theme="light"] .automation-hero h1 .text-gradient {
    background: linear-gradient(100deg, #d927a9 0%, #7546df 53%, #078fcf 100%) !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    text-shadow: none !important;
}

/* Ensure all other hero descendants do not inherit legacy white/grey values. */
html[data-theme="light"] .services-hero :is(span:not(.text-gradient),strong,em),
html[data-theme="light"] .portfolio-hero :is(span:not(.text-gradient),strong,em),
html[data-theme="light"] .products-hero :is(span:not(.text-gradient),strong,em),
html[data-theme="light"] .automation-hero :is(span:not(.text-gradient),strong,em) {
    color: #4b4d63 !important;
    -webkit-text-fill-color: #4b4d63 !important;
}
