/* ==========================================================================
   Upper Hand — Base: reset, typography, layout primitives
   Logical properties throughout so RTL (Urdu/Arabic) works later.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: 6rem;
}

body {
  min-block-size: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--lh-md);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-base) ease, color var(--dur-base) ease;
}

img, picture, video, svg { display: block; max-inline-size: 100%; }
img { block-size: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

::selection { background: var(--brand-200); color: var(--brand-950); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- Scrollbars -------------------------------------------------------------
   Slim, rounded thumb floating on a clear track, with no arrow buttons.
   The thumb is inset by a transparent border so it never touches the edge.
   Chromium/Safari use ::-webkit-scrollbar; Firefox uses the standard props. */
:root {
  --scrollbar-thumb: color-mix(in srgb, var(--color-text) 22%, transparent);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--color-text) 40%, transparent);
  --scrollbar-thumb-active: var(--color-primary);
}
::-webkit-scrollbar { inline-size: 12px; block-size: 12px; background: transparent; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 3.5px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  min-block-size: 36px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-thumb-hover); border-width: 2.5px; }
::-webkit-scrollbar-thumb:active { background-color: var(--scrollbar-thumb-active); border-width: 2.5px; }
::-webkit-scrollbar-button, ::-webkit-scrollbar-corner { display: none; background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
}

/* Panels (menus, sheets, tables): the thumb appears only while the pointer is over them */
.scroll-soft::-webkit-scrollbar { inline-size: 10px; }
.scroll-soft::-webkit-scrollbar-thumb { background-color: transparent; border-width: 3px; }
.scroll-soft:hover::-webkit-scrollbar-thumb { background-color: var(--scrollbar-thumb); }
.scroll-soft::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-thumb-hover); border-width: 2px; }
.scroll-soft::-webkit-scrollbar-thumb:active { background-color: var(--scrollbar-thumb-active); }
@media (hover: none) {
  .scroll-soft::-webkit-scrollbar { inline-size: 0; block-size: 0; }
}

/* Scroll edge: content fades out at an edge only while there is more to scroll
   (scroll-driven; browsers without support simply show no fade) */
@property --fade-start { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-end   { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes scroll-edge-fade {
  0%        { --fade-start: 0px;  --fade-end: 28px; }
  8%, 92%   { --fade-start: 28px; --fade-end: 28px; }
  100%      { --fade-start: 28px; --fade-end: 0px; }
}
.scroll-fade {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent 100%);
}
@supports (animation-timeline: scroll()) {
  .scroll-fade { animation: scroll-edge-fade linear both; animation-timeline: scroll(self); }
}

/* ---- Type scale ------------------------------------------------------------ */
.display, .h1, .h2, .h3, h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-variation-settings: "SOFT" 30, "WONK" 0;
  text-wrap: balance;
}
.display { font-size: var(--text-display); line-height: var(--lh-display); letter-spacing: var(--tr-display); }
h1, .h1 { font-size: var(--text-h1); line-height: var(--lh-h1); letter-spacing: var(--tr-h1); }
h2, .h2 { font-size: var(--text-h2); line-height: var(--lh-h2); letter-spacing: var(--tr-h2); }
h3, .h3 { font-size: var(--text-h3); line-height: var(--lh-h3); letter-spacing: var(--tr-h3); }
h4, .h4 {
  font-family: var(--font-sans);
  font-size: var(--text-h4); line-height: var(--lh-h4); letter-spacing: var(--tr-h4);
  font-weight: var(--weight-semibold);
}
h5, h6 { font-size: var(--text-md); font-weight: var(--weight-semibold); }

.lead { font-size: var(--text-lg); line-height: var(--lh-lg); color: var(--color-text-muted); text-wrap: pretty; }
.text-sm { font-size: var(--text-sm); line-height: var(--lh-sm); }
.text-xs { font-size: var(--text-xs); line-height: var(--lh-xs); letter-spacing: var(--tr-xs); }
.muted  { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); }
.num { font-variant-numeric: tabular-nums; }

.eyebrow {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tr-eyebrow);
  text-transform: uppercase;
  color: var(--color-primary);
}

.prose { max-inline-size: 68ch; }
.prose > * + * { margin-block-start: 1em; }
.prose p, .prose li { color: var(--color-text-muted); text-wrap: pretty; }

/* ---- Layout primitives ------------------------------------------------------ */
.container {
  inline-size: 100%;
  max-inline-size: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container-narrow { max-inline-size: calc(var(--container-narrow) + var(--gutter) * 2); }

.section { padding-block: var(--section-y); }
.section-head { display: grid; gap: var(--space-3); max-inline-size: 40rem; margin-block-end: var(--space-10); }
.section-head.center { margin-inline: auto; text-align: center; justify-items: center; }

.stack    { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.cluster  { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }
.split    { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.grid     { display: grid; gap: var(--grid-gap, var(--space-6)); grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 18rem), 100%), 1fr)); }

.visually-hidden {
  position: absolute !important; inline-size: 1px; block-size: 1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; inset-inline-start: var(--space-4); inset-block-start: -4rem;
  z-index: 1000; padding: var(--space-2) var(--space-4);
  background: var(--color-text); color: var(--color-bg); border-radius: var(--radius-sm);
}
.skip-link:focus { inset-block-start: var(--space-4); }

/* ---- Reduced motion: cross-fade, never slide ------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-property: opacity, color, background-color, border-color !important;
    transition-duration: 150ms !important;
  }
}
