/* css/base.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: var(--nav-height);
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

/* Desktop: sidebar-layout aktiveras via JS på body */
@media (min-width: 1024px) {
  body.analyst-desktop #app {
    max-width: none;
    margin-left: 240px;
    padding-bottom: 0;
  }
}

.page { padding: var(--s-5) var(--s-4); }
.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-1);
  margin-bottom: var(--s-6);
}
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.label-sm {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.neutral { color: var(--neutral); }

.form-input {
  display: block;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--bg);
  color: var(--text-1);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent); }

.startup-fallback {
  min-height: calc(100vh - var(--nav-height));
  padding: var(--s-8) var(--s-4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-4);
  color: var(--text-1);
}

.startup-fallback__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.startup-fallback h1 {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.05;
}

.startup-fallback p {
  max-width: 32ch;
  color: var(--text-2);
  line-height: 1.5;
}

.startup-fallback__button {
  width: fit-content;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

/* ─── Knapp-system ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px var(--s-5);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active:not(:disabled) { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { opacity: 0.88; }

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--border);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

/* ─── Auth-sidor: bryt ut ur app-bredden ─────────────────────────── */
/* Landing, login, signup och onboarding ska vara fullbredd och utan
   nav-padding. Klassen sätts av app.js via updateShell(). */
body.is-auth-page #app {
  max-width: none;
  padding-bottom: 0;
}

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

/* ─── Stagger list entry animation ──────────────────────────────── */
.stagger-list > * {
  animation: aicfo-fade-up var(--dur-normal) var(--ease-spring) both;
  animation-delay: calc(var(--stagger-i, 0) * 40ms);
}

/* ─── Skeleton loaders ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--surface-elevated) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: aicfo-shimmer 1.5s infinite linear;
  border-radius: var(--r-sm);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.skeleton--text   { height: 14px; }
.skeleton--title  { height: 20px; }
.skeleton--card   { height: 80px; border-radius: var(--r-lg); }
.skeleton--wide   { width: 90%; }
.skeleton--medium { width: 65%; }
.skeleton--short  { width: 40%; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ── Sapiax wordmark (brand logo) ─────────────────────────── */
.brand-wordmark {
  display: block;
  height: 26px;
  width: auto;
}
.brand-wordmark--sm { height: 22px; }
.brand-wordmark--lg { height: 34px; }
