/* ============================================================
   CARET SOLUTIONS — RESPONSIVE / MOBILE STYLESHEET
   ------------------------------------------------------------
   Loaded on every page AFTER the Tailwind CDN. Most rules use
   !important so they reliably win over Tailwind's runtime-
   injected utilities regardless of stylesheet order.
   Desktop layout is untouched — everything lives behind the
   mobile media query or only activates on touch devices.
   ============================================================ */

/* ── Hamburger button + mobile menu (injected by main.js) ──── */
.nav-toggle { display: none; }
.mobile-menu { display: none; }

/* ── Mobile services grid (injected by main.js on the home page) */
.svc-mgrid { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-top: 1.25rem; }
.svc-mcard {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px; padding: 1.05rem 1.15rem; display: flex; gap: .85rem; align-items: flex-start;
}
.svc-mcard .ic { color: #2dd4f5; flex-shrink: 0; width: 22px; height: 22px; margin-top: 2px; stroke-width: 1.75; }
.svc-mcard h3 { font-family: 'Outfit', sans-serif; font-size: .94rem; font-weight: 600; color: #e0eaf5; margin-bottom: .25rem; }
.svc-mcard p { font-size: .78rem; color: rgba(255,255,255,.42); line-height: 1.55; }

/* ── Team card flip on tap (touch devices) ─────────────────── */
.team-card.flipped .tc-inner { transform: rotateY(180deg); }

/* ── Mobile hero logo (injected by main.js; hidden on desktop) ── */
.hero-logo-m { display: none; }

/* ============================================================
   THEME TOGGLE + LOGO SWAP (works in both light & dark)
   ------------------------------------------------------------
   The toggle button is injected into the nav by main.js. The
   logo <img> pairs live in the markup; CSS shows the right one.
   ============================================================ */
.nav-right { display: flex; align-items: center; gap: 1.5rem; }

.theme-toggle {
  width: 38px; height: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
  background: transparent; color: #556070;
  border: 1px solid rgba(0,0,0,0.12);
  transition: color .2s, border-color .2s, background .2s, transform .2s;
}
.theme-toggle:hover { color: #2dd4f5; border-color: #2dd4f5; transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; stroke-width: 1.9; display: block; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }

/* Logo pairs — light logo (dark ink art) by default */
.logo-dark { display: none; }

/* ============================================================
   DARK MODE
   ------------------------------------------------------------
   Toggled by `html.dark` (set by an inline head script + the
   nav toggle). The site already has dark "ink" sections, so
   dark mode mainly flips the light surfaces, text & borders.
   Rules use !important to win over Tailwind's runtime utilities.
   ============================================================ */
html.dark {
  --dk-page: #070d18;
  --dk-card: #111f36;
  --dk-text: #e3ebf4;
  --dk-muted: #9fb1c6;
  --dk-border: rgba(255,255,255,0.10);
  --dk-cyan-bg: rgba(45,212,245,0.12);
  --dk-cyan-border: rgba(45,212,245,0.30);
  color-scheme: dark;
}

/* logo + toggle icon swap */
html.dark .logo-light { display: none; }
html.dark .logo-dark { display: inline-block; }
html.dark .theme-toggle { color: var(--dk-muted); border-color: rgba(255,255,255,0.16); }
html.dark .theme-toggle:hover { color: #2dd4f5; border-color: #2dd4f5; }
html.dark .theme-toggle .ico-sun { display: block; }
html.dark .theme-toggle .ico-moon { display: none; }

/* base text */
html.dark body { color: var(--dk-text) !important; }

/* page surfaces */
html.dark body,
html.dark .bg-cream,
html.dark #s0,
html.dark #s2 { background-color: var(--dk-page) !important; }

/* card / panel surfaces */
html.dark .bg-white { background-color: var(--dk-card) !important; }

/* nav + mobile menu */
html.dark nav { background-color: rgba(8,13,24,0.90) !important; border-bottom-color: rgba(255,255,255,0.08) !important; }
html.dark .mobile-menu { background: rgba(8,13,24,0.98) !important; }
html.dark .mobile-menu a { color: var(--dk-text) !important; border-bottom-color: rgba(255,255,255,0.08) !important; }
html.dark .nav-toggle span { background: var(--dk-text) !important; }

/* footers + home closing strip */
html.dark footer { border-top-color: rgba(255,255,255,0.08) !important; }
html.dark #s4 .cta-row { border-top-color: rgba(255,255,255,0.08) !important; }

/* text greys that sit on light surfaces → light muted */
html.dark .text-ink,
html.dark .text-\[\#777\],
html.dark .text-\[\#666\],
html.dark .text-\[\#555\],
html.dark .text-\[\#888\],
html.dark .text-\[\#999\],
html.dark .text-\[\#aaa\],
html.dark .text-\[\#bbb\],
html.dark .text-\[\#444\],
html.dark .text-\[\#556878\],
html.dark .text-\[\#667080\] { color: var(--dk-muted) !important; }

/* headings / strong copy a touch brighter */
html.dark .text-ink { color: var(--dk-text) !important; }

/* borders */
html.dark .border-\[\#e0deda\] { border-color: var(--dk-border) !important; }

/* cyan-tinted chips & icon tiles */
html.dark .bg-\[\#e0f9fd\] { background-color: var(--dk-cyan-bg) !important; }
html.dark .border-\[\#a5e8f5\] { border-color: var(--dk-cyan-border) !important; }

/* modal */
html.dark .bg-\[\#f5f4f0\] { background-color: #1a2942 !important; }

/* per-page inline-style components */
html.dark .tc-front { background: var(--dk-card) !important; border-color: var(--dk-border) !important; }
html.dark .svc-num { color: #ffffff !important; }
html.dark .resume-drop { background: var(--dk-card) !important; border-color: var(--dk-border) !important; }
html.dark .resume-drop.has-file { background: var(--dk-cyan-bg) !important; }
html.dark .resume-drop.has-file .resume-placeholder { color: var(--dk-text) !important; }

/* form inputs/selects/textarea (they use bg-white + border-[#e0deda], handled above,
   but ensure the typed value text is light) */
html.dark .cf input,
html.dark .cf select,
html.dark .cf textarea { color: var(--dk-text) !important; }

/* Process steps — force all five into a single row (set the template
   explicitly so it doesn't depend on the compiled Tailwind build) */
.proc-grid { grid-template-columns: repeat(5, 1fr); }
/* Brand-blue accent bar on top of each step (real element so it can
   cascade-animate its width) */
.proc-bar { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: #2dd4f5; transform-origin: left center; }
/* Flow arrow sits between columns, aligned with the heading row, pointing right */
.proc-head { display: flex; align-items: center; }
.proc-arrow { position: absolute; top: 0.7rem; right: -0.875rem; z-index: 2; }
.proc-arrow-ic { width: 1.5rem; height: 1.5rem; }
/* Compress the steps vertically */
.proc-step { padding-top: .85rem; }
.proc-step h3 { margin-bottom: .25rem; }
.proc-step p { line-height: 1.5; }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .marquee-track { animation: none !important; }
}

/* ============================================================
   MOBILE / TABLET  (≤ 1024px)
   ------------------------------------------------------------
   The home page's wheel-snap engine only works with a mouse
   wheel, so every touch device (phones AND tablets up to the
   iPad-landscape width) needs the simplified layout. Real
   desktops (> 1024px) keep the original design untouched.
   ============================================================ */
@media (max-width: 1024px) {

  /* ── Hamburger ─────────────────────────────────────────── */
  .nav-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 42px; height: 42px; padding: 9px; background: none; border: none;
    cursor: pointer; z-index: 90;
  }
  .nav-toggle span {
    display: block; width: 100%; height: 2px; background: #0d1f3c;
    border-radius: 2px; transition: transform .3s ease, opacity .2s ease;
  }
  .nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { opacity: 0; }
  .nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* hide desktop nav links, slim the bar */
  .nav-links { display: none !important; }
  nav.fixed, nav { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }

  /* ── Mobile menu panel ─────────────────────────────────── */
  .mobile-menu {
    display: block; position: fixed; inset: 0; z-index: 70;
    background: rgba(245,244,240,.98); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    padding: 5.5rem 1.5rem 2rem;
    transform: translateY(-100%); opacity: 0; pointer-events: none;
    transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .3s ease;
  }
  .mobile-menu.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .mobile-menu ul { list-style: none; display: flex; flex-direction: column; gap: .25rem; }
  .mobile-menu a {
    display: block; font-family: 'Outfit', sans-serif; font-size: 1.45rem !important;
    letter-spacing: 0 !important; text-transform: none !important; padding: .65rem 0;
    color: #0d1f3c !important; text-decoration: none; border-bottom: 1px solid rgba(0,0,0,.06);
  }
  .mobile-menu a.active { color: #18c2e0 !important; }
  html.menu-open { overflow: hidden; }

  /* ── Generic horizontal padding (every .px-16 region) ──── */
  .px-16 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }

  /* ── Generic grid collapse ─────────────────────────────── */
  .grid-cols-5, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr !important; }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* process: single column with the flow arrow pointing DOWN between steps */
  .proc-grid { grid-template-columns: 1fr !important; gap: 1.75rem !important; }
  .proc-step { padding-bottom: 2.25rem; }
  .proc-arrow { top: auto; right: auto; left: calc(50% - 0.75rem); bottom: 0.4rem; }
  .proc-arrow-ic { transform: rotate(90deg); }

  /* trim oversized card paddings */
  .p-14 { padding: 1.75rem !important; }
  .p-12 { padding: 1.6rem !important; }

  /* CTA strips: stack copy above button */
  .cta-row { flex-direction: column !important; align-items: flex-start !important; gap: 1.4rem !important; }
  /* About CTA button (long label): full-width + centered so it looks intentional, not crowded */
  .cta-btn-block { width: 100% !important; justify-content: center !important; white-space: normal !important; text-align: center; }

  /* footers: stacked, with wrapping link rows and readable copy */
  footer { flex-direction: column !important; align-items: flex-start !important; gap: 1.25rem !important; padding: 2.5rem 1.25rem !important; }
  footer ul, .cta-row ul { flex-wrap: wrap !important; gap: .55rem 1.35rem !important; width: 100%; }
  footer ul a, .cta-row ul a { font-size: .78rem !important; display: inline-block; padding: .1rem 0; }
  footer > div:last-child, .cta-row > div:last-child { font-size: .72rem !important; line-height: 1.6; word-break: break-word; }

  /* job card meta row wraps instead of overflowing */
  .job-card .gap-6 { flex-wrap: wrap; gap: .4rem 1rem !important; }

  /* page heroes (inner pages) */
  .page-hero { padding-top: 5rem !important; padding-bottom: 2.5rem !important; }
  .page-h1 { font-size: 2.5rem !important; }
  .cl-h1 { font-size: 2.3rem !important; }

  /* services hero stat strip: drop out of absolute, flow normally */
  .stat-strip { position: static !important; margin-top: 2rem; }

  /* services cards: always reveal the inquire CTA (no hover on touch) */
  .svc-card-cta { opacity: 1 !important; transform: none !important; }

  /* ── HOME PAGE ─────────────────────────────────────────── */
  body.page-home { height: auto !important; overflow-x: hidden !important; overflow-y: visible !important; }
  #scroller { height: auto !important; overflow: visible !important; scroll-snap-type: none !important; }
  .section { height: auto !important; min-height: 0 !important; scroll-snap-align: none !important; }

  /* hide desktop-only home chrome */
  #ndots { display: none !important; }
  .hero-scroll { display: none !important; }

  /* hero — the CARET logo is a real element stacked UNDER the copy */
  #s0 {
    background-image: none !important;
    justify-content: center !important;
    min-height: 90svh;
    padding: 6.5rem 1.25rem 3.5rem !important;
  }
  .hero-h1 { font-size: clamp(2.6rem, 9vw, 3.6rem) !important; }
  .hero-sub { max-width: 100% !important; }
  .hero-logo-m { display: block !important; width: 100vw; max-width: none; height: auto; margin: 2.5rem -1.25rem 0; }

  /* why */
  #s1 { padding: 4.5rem 1.25rem !important; }

  /* portfolio: vertical stack — reliable on every touch device */
  #s2 { padding: 0 !important; }
  #s2 .hpin { height: auto !important; padding: 4.5rem 0 3.5rem !important; }
  #s2 .hpin-top { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .track-wrap { overflow: visible !important; padding: 0 1.25rem !important; }
  .htrack { flex-direction: column !important; transform: none !important; gap: 1rem !important; padding: 0 !important; }
  .pc { flex: 0 0 auto !important; width: 100% !important; height: auto !important; min-height: 200px; }
  .hprog, #portCount { display: none !important; }

  /* services: hide constellation, show injected grid */
  #s3 { display: block !important; height: auto !important; padding: 4.5rem 1.25rem !important; }
  #svcCv, #svcHub { display: none !important; }
  .svc-eyebrow {
    position: static !important; transform: none !important; opacity: 1 !important;
    white-space: normal; text-align: left; margin-bottom: 1.25rem;
  }

  /* contact CTA section */
  #s4 { padding: 5rem 1.25rem 3rem !important; }
  #s4 > .absolute { position: static !important; margin-top: 3rem; padding-left: 0 !important; padding-right: 0 !important; }

  /* contact page split → stacked */
  .contact-wrap { grid-template-columns: 1fr !important; }
  .contact-left, .contact-right { padding-top: 3rem !important; padding-bottom: 3rem !important; }

  /* generic: keep big rounded feature blocks from hugging edges */
  .max-w-\[1400px\] { padding-top: 3.5rem !important; padding-bottom: 3.5rem !important; }
}
