/*
 * Ibtikar Tech — UI/UX System V1
 * Final, frontend-only refinement layer.
 * Scope: presentation, responsive behavior, interaction states and accessibility.
 * No backend contracts, routes, form actions, template variables or business logic.
 */

:root {
  --ibt-ux-gutter: clamp(18px, 3vw, 28px);
  --ibt-ux-reading: 68ch;
  --ibt-ux-radius-sm: 10px;
  --ibt-ux-radius-md: 16px;
  --ibt-ux-radius-lg: 22px;
  --ibt-ux-control-h: 46px;
  --ibt-ux-border: color-mix(in srgb, var(--ibt-border) 82%, transparent);
  --ibt-ux-hover: color-mix(in srgb, var(--ibt-blue) 7%, var(--ibt-bg-soft));
}

/* ---------- Baseline / typography ---------- */
html {
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
}

main :where(p, li) {
  text-wrap: pretty;
}

main :where(h1, h2, h3) {
  text-wrap: balance;
}

main :where(p) {
  max-width: var(--ibt-ux-reading);
}

:where(button, a, input, textarea, select, summary) {
  -webkit-tap-highlight-color: transparent;
}

:where(button, [role="button"], input, textarea, select, summary, a[href]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ibt-cyan) 58%, transparent);
  outline-offset: 3px;
  box-shadow: none !important;
}

:where(input, textarea, select) {
  min-height: var(--ibt-ux-control-h);
  border-radius: var(--ibt-ux-radius-sm);
}

textarea {
  min-height: 132px;
  resize: vertical;
}

::placeholder {
  opacity: .72;
}

/* ---------- Shared layout rhythm ---------- */
:where(.container, .ibtx-container) {
  width: min(calc(100% - (var(--ibt-ux-gutter) * 2)), var(--ibt-container));
  margin-inline: auto;
}

:where(.section, .platform-section, .service-detail-section, .svc-section) {
  scroll-margin-top: calc(var(--ibt-header-h) + 24px);
}

:where(.section-heading, .platform-heading, .service-detail-heading, .svc-heading, .heading) {
  max-width: 760px;
}

:where(.section-heading, .platform-heading, .service-detail-heading, .svc-heading, .heading) > p {
  max-width: 64ch;
}

/* ---------- Header / navigation ---------- */
.ibt-shell-header,
.header.ibt-shell-header,
.site-header.ibt-shell-header {
  background: color-mix(in srgb, var(--ibt-bg) 90%, transparent) !important;
  border-block-end: 1px solid transparent !important;
  transition: background-color .22s ease, border-color .22s ease, transform .3s var(--ibt-ease), opacity .3s var(--ibt-ease);
}

.ibt-shell-header.scrolled,
.ibt-shell-header.is-scrolled {
  background: color-mix(in srgb, var(--ibt-bg) 96%, transparent) !important;
  border-block-end-color: var(--ibt-ux-border) !important;
}

.ibt-shell-nav::after {
  display: none !important;
}

.ibt-shell-brand {
  min-height: 48px;
}

.ibt-shell-brand-copy strong {
  letter-spacing: -.015em;
}

.ibt-shell-desktop-nav {
  gap: 2px !important;
}

.ibt-shell-nav-link,
.ibt-shell-desktop-nav > a {
  min-height: 44px !important;
  padding-inline: 12px;
  border-radius: var(--ibt-ux-radius-sm) !important;
}

.ibt-shell-nav-link:hover,
.ibt-shell-nav-link.is-active,
.ibt-shell-nav-link[aria-current="page"],
.ibt-shell-desktop-nav > a:hover,
.ibt-shell-desktop-nav > a.is-active,
.ibt-shell-desktop-nav > a[aria-current="page"] {
  background: var(--ibt-ux-hover) !important;
  box-shadow: none !important;
}

.ibt-shell-nav-link::before {
  bottom: 3px;
  height: 2px;
}

.ibt-shell-mega-toggle {
  min-width: 36px;
  min-height: 44px;
}

.ibt-shell-cta {
  min-height: 46px;
  padding-inline: 20px;
  border-radius: 12px !important;
  box-shadow: 0 10px 24px rgba(79, 125, 243, .18) !important;
}

.ibt-shell-cta:hover {
  transform: translateY(-1px);
}

/* Desktop mega menu: reduce nested-card feeling and sharpen hierarchy. */
@media (min-width: 1181px) {
  .ibt-shell-mega {
    width: min(900px, calc(100vw - 48px));
    padding: 12px;
    border-radius: 20px;
    border-color: var(--ibt-ux-border);
    box-shadow: 0 24px 70px rgba(7, 16, 43, .18);
  }

  .ibt-shell-mega-grid {
    gap: 6px;
  }

  .ibt-shell-mega-lead,
  .ibt-shell-mega-link {
    min-height: 108px;
    padding: 15px;
    border-radius: 14px;
  }

  .ibt-shell-mega-link {
    border-color: transparent;
    background: transparent;
  }

  .ibt-shell-mega-link:hover,
  .ibt-shell-mega-link:focus-visible {
    transform: none;
    border-color: color-mix(in srgb, var(--ibt-blue) 16%, var(--ibt-border));
    background: var(--ibt-ux-hover);
  }
}

/* ---------- Mobile navigation drawer ---------- */
.ibt-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2240;
  border: 0;
  padding: 0;
  background: rgba(4, 8, 20, .48);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease;
}

.ibt-mobile-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.ibt-mobile-menu-head {
  display: none;
}

@media (max-width: 1180px) {
  .ibt-shell-header {
    z-index: 2230;
  }

  .ibt-shell-menu-toggle {
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 10px !important;
  }

  .ibt-shell-menu-toggle:hover,
  .ibt-shell-menu-toggle:focus-visible {
    background: var(--ibt-ux-hover) !important;
  }

  .ibt-shell-mobile-menu,
  .mobile-menu.ibt-shell-mobile-menu {
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    z-index: 2260;
    width: min(390px, calc(100vw - 12px));
    height: 100dvh;
    max-height: none;
    display: grid !important;
    grid-template-rows: auto;
    align-content: start;
    gap: 4px;
    padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    border-inline-start: 1px solid var(--ibt-ux-border);
    border-radius: 0;
    background: color-mix(in srgb, var(--ibt-bg) 98%, transparent);
    box-shadow: -24px 0 70px rgba(4, 8, 24, .18);
    backdrop-filter: blur(22px) saturate(1.2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(104%);
    transition: transform .28s var(--ibt-ease), opacity .2s ease, visibility .28s;
  }

  .ibt-shell-mobile-menu.open,
  .ibt-shell-mobile-menu.is-open,
  .mobile-menu.ibt-shell-mobile-menu.open,
  .mobile-menu.ibt-shell-mobile-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  .ibt-mobile-menu-head {
    min-height: 62px;
    margin-bottom: 8px;
    padding: 4px 4px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--ibt-ux-border);
  }

  .ibt-mobile-menu-head > span {
    display: grid;
    gap: 2px;
  }

  .ibt-mobile-menu-head strong {
    color: var(--ibt-text);
    font-size: 16px;
    font-weight: 900;
  }

  .ibt-mobile-menu-head small {
    color: var(--ibt-muted);
    font-size: 10px;
    line-height: 1.5;
  }

  .ibt-mobile-menu-close {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    border: 1px solid var(--ibt-ux-border);
    border-radius: 10px;
    color: var(--ibt-text);
    background: var(--ibt-bg-soft);
    font-size: 24px;
    line-height: 1;
  }

  .ibt-shell-mobile-menu > a,
  .ibt-shell-mobile-group > summary {
    min-height: 48px !important;
    border-radius: 10px !important;
  }

  .ibt-shell-mobile-menu > a:not(.ibt-shell-mobile-cta):hover,
  .ibt-shell-mobile-menu > a:not(.ibt-shell-mobile-cta):focus-visible,
  .ibt-shell-mobile-menu > a.is-active,
  .ibt-shell-mobile-menu > a[aria-current="page"] {
    background: var(--ibt-ux-hover) !important;
  }

  .ibt-shell-mobile-group {
    border-radius: 12px !important;
    border-color: var(--ibt-ux-border) !important;
    background: transparent !important;
  }

  .ibt-shell-mobile-group[open] {
    background: color-mix(in srgb, var(--ibt-bg-soft) 74%, transparent) !important;
  }

  .ibt-shell-mobile-group a {
    min-height: 44px !important;
  }

  .ibt-shell-mobile-cta {
    margin-top: 10px !important;
  }
}

/* ---------- Buttons / calls to action ---------- */
:where(.btn, .button, .platform-button, .service-cta, .scene-link) {
  touch-action: manipulation;
}

:where(.btn, .button, .platform-button) {
  min-height: 46px;
}

:where(.btn, .button, .platform-button):hover {
  transform: translateY(-1px);
}

/* ---------- Cards and content blocks ---------- */
:where(.goal, .route-card, .service-item, .library-card) {
  border-radius: var(--ibt-ux-radius-lg) !important;
}

:where(.goal, .route-card, .service-item, .library-card):hover {
  transform: translateY(-3px) !important;
}

:where(.proof-chip, .platform-proof span) {
  border-radius: 10px !important;
}

/* ---------- Forms ---------- */
:where(form) :where(label) {
  font-weight: 700;
}

:where(form) :where(input, textarea, select) {
  width: 100%;
  border-color: var(--ibt-ux-border);
  transition: border-color .18s ease, background-color .18s ease;
}

:where(form) :where(input, textarea, select):focus {
  border-color: color-mix(in srgb, var(--ibt-blue) 58%, var(--ibt-border));
}

/* ---------- Footer ---------- */
.ibt-shell-footer {
  padding-top: clamp(64px, 6vw, 84px) !important;
}

.ibt-shell-footer::after {
  opacity: .55;
}

.ibt-shell-footer a {
  min-height: 32px;
  display: inline-flex !important;
  align-items: center;
  margin-block: 4px !important;
}

.ibt-shell-footer a:hover {
  transform: none !important;
}

.ibt-shell-footer-bottom {
  margin-top: 40px !important;
}

/* ---------- Homepage and approved-source readability ---------- */
body.source-home .hero__content > p,
body.source-services .hero-copy > p,
body.approved-source-page .platform-heading > p {
  line-height: 1.9;
}

body.source-home .hero__actions,
body.source-services .hero-actions {
  gap: 10px;
}

body.source-services .goal-grid {
  gap: clamp(12px, 1.6vw, 18px);
}

body.source-services .goal {
  padding: clamp(20px, 2.2vw, 26px);
}

body.source-services .goal-icon {
  border-radius: 12px !important;
}

/* ---------- Inner pages ---------- */
.inner-page:not(.approved-source-page) .platform-hero h1 {
  max-width: 800px;
}

.inner-page:not(.approved-source-page) .platform-heading p,
.service-detail-page .service-detail-heading p {
  max-width: 65ch;
}

.category-hub #capabilities .route-card {
  border-radius: 20px !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .07) !important;
}

.category-hub #capabilities .route-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 18px 46px rgba(0, 0, 0, .1) !important;
}

/* ---------- Mobile-first corrections ---------- */
@media (max-width: 760px) {
  :root {
    --ibt-ux-gutter: 16px;
  }

  .ibt-shell-nav,
  .nav.ibt-shell-nav,
  .nav-shell.ibt-shell-nav {
    width: min(calc(100% - 32px), var(--ibt-container)) !important;
  }

  .ibt-shell-brand-copy small {
    margin-top: 2px;
  }

  :where(.section, .platform-section, .service-detail-section, .svc-section) {
    scroll-margin-top: calc(var(--ibt-header-h) + 14px);
  }

  :where(.hero__actions, .hero-actions, .platform-actions, .service-actions) {
    gap: 8px;
  }

  :where(.hero__actions, .hero-actions, .platform-actions, .service-actions) > :where(a, button) {
    min-height: 48px;
  }

  body.source-home .hero__content > p,
  body.source-services .hero-copy > p {
    font-size: 16px !important;
    line-height: 1.85 !important;
  }

  .ibt-shell-footer {
    padding-top: 56px !important;
  }

  .ibt-shell-footer .ibt-shell-footer-grid {
    gap: 26px !important;
  }
}

@media (max-width: 520px) {
  .ibt-shell-brand-copy small {
    display: none;
  }

  :where(.hero__actions, .hero-actions, .platform-actions, .service-actions) {
    display: grid !important;
    grid-template-columns: 1fr;
    width: 100%;
  }

  :where(.hero__actions, .hero-actions, .platform-actions, .service-actions) > :where(a, button) {
    width: 100%;
  }

  .ibt-shell-footer .ibt-shell-footer-grid {
    grid-template-columns: 1fr !important;
  }

  .ibt-shell-footer-bottom {
    text-align: start !important;
  }

  .ibt-shell-footer-bottom div {
    justify-content: flex-start !important;
  }
}

/* ---------- Motion accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  .ibt-mobile-backdrop,
  .ibt-shell-mobile-menu,
  .ibt-shell-header,
  .ibt-shell-brand,
  .ibt-shell-cta,
  :where(.goal, .route-card, .service-item, .library-card) {
    transition: none !important;
    animation: none !important;
  }

  :where(.btn, .button, .platform-button, .ibt-shell-cta):hover,
  :where(.goal, .route-card, .service-item, .library-card):hover {
    transform: none !important;
  }
}
