/* ============================================================================
   INKARA LABS — shared UI layer
   Loaded on every page AFTER the design-system styles.css. It only refines and
   extends the Modernist system (never forks its tokens): responsive behaviour,
   fluid type, WCAG 2.2 focus/target-size, and the reusable mobile navigation.
   All classes are namespaced `ink-` so they never collide with page markup.
   ========================================================================== */

/* --- 1. Global safety: never let a page scroll sideways on a phone --------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; height: auto; }

/* --- 2. Responsive container ---------------------------------------------- */
/* The pages define `.wrap { max-width:1280px; padding:0 40px }` inline. We only
   tighten the side padding on smaller screens (same specificity, loaded later). */
@media (max-width: 900px) { .wrap { padding-left: 28px !important; padding-right: 28px !important; } }
@media (max-width: 560px) { .wrap { padding-left: 20px !important; padding-right: 20px !important; } }

/* --- 3. Fluid type -------------------------------------------------------- */
/* styles.css sets fixed heading px. Give the base scale a fluid floor so long
   display headings don't overflow narrow screens. Inline per-page font-sizes
   (e.g. hero 56px) are tuned individually in the page phase. */
/* !important so oversized inline display headings (e.g. a 56px hero) are reined
   in on phones and can't overflow; normal headings sit at or below these caps. */
@media (max-width: 640px) {
  h1 { font-size: clamp(28px, 8.5vw, 44px) !important; }
  h2 { font-size: clamp(24px, 7vw, 40px) !important; }
  h3 { font-size: clamp(20px, 5.5vw, 26px) !important; }
}
@media (max-width: 400px) {
  h1 { font-size: clamp(24px, 8vw, 34px) !important; }
  h2 { font-size: clamp(21px, 7vw, 30px) !important; }
}

/* --- 4. Accessibility: focus + target size (WCAG 2.2) --------------------- */
/* Consistent keyboard focus everywhere, including inside the React tree. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}
/* WCAG 2.2 (2.5.8) minimum target size for the on-screen touch controls. */
@media (pointer: coarse) {
  .btn, .navlink, .nav a, .footcol a, .ink-foot a { min-height: 24px; }
}

/* --- 5. Responsive grids (global, reusable) ------------------------------- */
/* The pages lay out with inline `grid-template-columns`. Rather than override
   each one per page, degrade them by column count: many-column grids fold to
   two on tablet, and every multi-column grid folds to one on a phone. Any grid
   that must keep its columns opts out with class `ink-fixed-grid`. */
@media (max-width: 900px) {
  [style*="repeat(3"]:not(.ink-fixed-grid),
  [style*="repeat(4"]:not(.ink-fixed-grid),
  [style*="repeat(5"]:not(.ink-fixed-grid),
  [style*="repeat(6"]:not(.ink-fixed-grid) {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 560px) {
  [style*="grid-template-columns"]:not(.ink-fixed-grid) {
    grid-template-columns: 1fr !important;
  }
}
/* Opt-in helper for grids in markup we control. */
@media (max-width: 720px) {
  .ink-stack { grid-template-columns: 1fr !important; }
}
.ink-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ============================================================================
   7. Reusable mobile navigation (built by inkara-ui.js, styled here)
   ========================================================================== */
.ink-burger {
  display: none;                       /* shown only on small screens */
  position: fixed; top: 10px; right: 16px; z-index: 60;
  width: 44px; height: 44px;           /* full 44px touch target */
  align-items: center; justify-content: center;
  background: var(--color-bg); color: var(--color-text);
  border: 2px solid var(--color-divider); cursor: pointer;
  padding: 0;
}
.ink-burger:hover { border-color: var(--color-accent); }
.ink-burger svg { display: block; width: 22px; height: 22px; }
@media (max-width: 900px) { .ink-burger { display: inline-flex; } }

.ink-drawer-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, var(--color-neutral-900) 55%, transparent);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease;
}
.ink-drawer-backdrop.open { opacity: 1; visibility: visible; }

.ink-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 71;
  width: min(340px, 86vw);
  display: flex; flex-direction: column;
  background: var(--color-bg);
  border-left: 2px solid var(--color-divider);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.ink-drawer.open { transform: translateX(0); }

.ink-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 2px solid var(--color-divider);
}
.ink-drawer-brand {
  font: 800 18px/1 var(--font-heading); letter-spacing: -.01em;
  color: var(--color-text); text-decoration: none;
}
.ink-drawer-brand span { color: var(--color-accent); }
.ink-drawer-close {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer; color: var(--color-text); padding: 0;
}
.ink-drawer-close svg { width: 24px; height: 24px; display: block; }

.ink-drawer-links { display: flex; flex-direction: column; padding: 8px 0; }
.ink-drawer-links a {
  display: flex; align-items: center; min-height: 52px;
  padding: 0 24px;
  font: 600 17px/1.2 var(--font-heading);
  color: var(--color-text); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--color-divider) 55%, transparent);
}
.ink-drawer-links a:hover,
.ink-drawer-links a[aria-current="page"] { color: var(--color-accent); }

.ink-drawer-cta { margin-top: auto; padding: 20px 24px calc(20px + env(safe-area-inset-bottom)); }
.ink-drawer-cta .btn { width: 100%; justify-content: center; padding: 14px 20px; font-size: 15px; }

body.ink-nav-open { overflow: hidden; }
