/* ═══════════════════════════════════════════════════════════════════════════
   CHIKARA OS · core.css
   Reset · typography scale · base elements · focus · motion primitives
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 1 · RESET ─────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100%;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  overflow: hidden; /* App shell — screens scroll internally */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { user-select: none; -webkit-user-drag: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a { color: inherit; text-decoration: none; }

input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  outline: 0;
}
input::placeholder, textarea::placeholder { color: var(--text-stone); }

ul, ol { list-style: none; }

/* Kill iOS input zoom-on-focus when font size >= 16px is not desirable */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
}

/* ─── 2 · TYPOGRAPHY SCALE ──────────────────────────────────────────────── */

:root {
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Fluid type — tuned so nothing breaks from iPhone SE to iPad Pro */
  --t-hero:    clamp(2.4rem, 6.4vw, 3.8rem);
  --t-h1:      clamp(1.7rem, 4.4vw, 2.4rem);
  --t-h2:      clamp(1.35rem, 3.2vw, 1.75rem);
  --t-h3:      clamp(1.05rem, 2.2vw, 1.22rem);
  --t-body-lg: 1.02rem;
  --t-body:    .925rem;
  --t-small:   .84rem;
  --t-tiny:    .72rem;
  --t-micro:   .62rem;
  --t-nano:    .54rem;

  --tracking-eyebrow: .28em;
  --tracking-label:   .14em;
  --tracking-mono:    .06em;
}

.serif    { font-family: var(--font-display); }
.mono     { font-family: var(--font-mono); }

.t-hero   { font-family: var(--font-display); font-size: var(--t-hero); font-weight: 500; line-height: 1.06; letter-spacing: -.012em; }
.t-h1     { font-family: var(--font-display); font-size: var(--t-h1); font-weight: 500; line-height: 1.14; letter-spacing: -.008em; }
.t-h2     { font-family: var(--font-display); font-size: var(--t-h2); font-weight: 500; line-height: 1.2; }
.t-h3     { font-family: var(--font-body);    font-size: var(--t-h3); font-weight: 600; line-height: 1.3; letter-spacing: -.004em; }
.t-body-lg{ font-size: var(--t-body-lg); line-height: 1.62; }
.t-body   { font-size: var(--t-body);    line-height: 1.6; }
.t-small  { font-size: var(--t-small);   line-height: 1.55; }
.t-tiny   { font-size: var(--t-tiny);    line-height: 1.5; }

/* Eyebrow — small caps with a gold dash. */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .75;
  flex: 0 0 auto;
}

/* Numeric display — clock, timestamps, coordinates */
.numeric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-mono);
}

/* ─── 3 · HEADINGS (default mapping) ────────────────────────────────────── */

h1 { font-family: var(--font-display); font-size: var(--t-h1); font-weight: 500; line-height: 1.14; letter-spacing: -.008em; }
h2 { font-family: var(--font-display); font-size: var(--t-h2); font-weight: 500; line-height: 1.2; }
h3 { font-size: var(--t-h3); font-weight: 600; line-height: 1.3; }
h4 { font-size: var(--t-small); font-weight: 600; letter-spacing: .01em; }

/* ─── 4 · FOCUS ─────────────────────────────────────────────────────────── */

:focus { outline: 0; }

:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--surface-bg),
    0 0 0 4px var(--accent),
    0 0 24px -4px var(--accent-glow);
  border-radius: var(--r-sm);
  transition: box-shadow var(--dur-fast) var(--ease-material);
}

/* When the element itself has a mat-gold background, invert the ring */
.mat-gold:focus-visible {
  box-shadow:
    0 0 0 2px var(--surface-bg),
    0 0 0 4px var(--gold-0);
}

/* ─── 5 · SELECTION ─────────────────────────────────────────────────────── */

::selection {
  background: var(--accent);
  color: #241A0A;
}

/* ─── 6 · SCROLLBARS ────────────────────────────────────────────────────── */

/* Custom, thin, warm scrollbars — aligned to the material system. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(201,151,58,.35) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(201,151,58,.32);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(201,151,58,.55); background-clip: padding-box; }

html[data-theme="obsidian"] *::-webkit-scrollbar-thumb {
  background: rgba(229,190,106,.30);
  background-clip: padding-box;
}
html[data-theme="obsidian"] *::-webkit-scrollbar-thumb:hover {
  background: rgba(229,190,106,.55);
  background-clip: padding-box;
}

/* Hide scrollbars in horizontal chip rails */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ─── 7 · MOTION PRIMITIVES ─────────────────────────────────────────────── */

/* Entrance — used by .fade-up and views mounting into place. */
@keyframes ch-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ch-rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ch-scale-in {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes ch-blur-in {
  from { opacity: 0; filter: blur(10px); }
  to   { opacity: 1; filter: blur(0); }
}

.fade-up {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 640ms var(--ease-architect),
    transform 640ms var(--ease-architect);
}
.fade-up.is-visible { opacity: 1; transform: translateY(0); }

/* Press feedback — tactile, spring-like. Applied to interactive elements. */
.pressable {
  transition:
    transform var(--dur-fast) var(--ease-material),
    box-shadow var(--dur-fast) var(--ease-material),
    background-color var(--dur-fast) var(--ease-material);
}
.pressable:active {
  transform: scale(.965);
  transition-duration: 90ms;
}

/* ─── 8 · SAFE AREA ─────────────────────────────────────────────────────── */

:root {
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

/* ─── 9 · UTILITIES ─────────────────────────────────────────────────────── */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

.stack > * + * { margin-top: var(--gap, .75rem); }
.row { display: flex; align-items: center; }
.row--between { justify-content: space-between; }
.row--gap { gap: var(--gap, .75rem); }

.scroll-y {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ─── 10 · REDUCED MOTION MASTER SWITCH ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .fade-up { opacity: 1; transform: none; }
}

html[data-reduced-motion="true"] *,
html[data-reduced-motion="true"] *::before,
html[data-reduced-motion="true"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

/* ─── 11 · PRINT ────────────────────────────────────────────────────────── */

@media print {
  body::before, body::after { display: none; }
  body { background: #fff; color: #000; overflow: visible; }
}
