/*
 * BASE: reset, global element styles, a few utilities. Fonts are declared in brand/brand.css.
 * Component styles live next to their components (*.razor.css).
 */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

/* iOS: inherit the user's Dynamic Type size, then restore our font family. */
@supports (font: -apple-system-body) {
  html.oc-native { font: -apple-system-body; }
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-feature-settings: var(--font-features);
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
.oc-display { font-family: var(--font-display); }
ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }
img, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--color-primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection { background: var(--color-primary-soft-strong); }

/* ---------- App chrome: no selection, no callouts, no tap flash ---------- */
.oc-chrome,
.oc-chrome * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.tabular { font-variant-numeric: tabular-nums; }

.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }

.oc-eyebrow {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

/* Staggered entrance for lists: set style="--i: n" on children. */
.oc-stagger > * {
  animation: oc-rise var(--dur-slow) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

@keyframes oc-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes oc-fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes oc-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(3px); }
}

/* ---------- View Transitions (where supported) ---------- */
@view-transition { navigation: none; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--dur-base);
  animation-timing-function: var(--ease-out);
}
::view-transition-old(oc-page) { animation: oc-page-out var(--dur-fast) var(--ease-in) both; }
::view-transition-new(oc-page) { animation: oc-page-in var(--dur-slow) var(--ease-spring) both; }
@keyframes oc-page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes oc-page-in { from { opacity: 0; transform: translateY(10px); } }
/* The tab bar and + stay put above the moving page (oncue.js names them during a transition). */
::view-transition-group(oc-tabbar),
::view-transition-group(oc-fab),
::view-transition-new(oc-tabbar),
::view-transition-new(oc-fab) { animation: none; }
::view-transition-old(oc-tabbar),
::view-transition-old(oc-fab) { display: none; }
/* A snapshot can't blur what is behind it: the tab bar is solid while a transition runs. */
html.oc-vt .oc-tabbar { background: var(--color-chrome-solid); }

/* ---------- Reduced motion: keep fades, drop movement ---------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
    --dur-slower: 1ms;
    --stagger: 0ms;
  }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto var(--space-4) calc(var(--safe-bottom) + var(--space-4)) var(--space-4);
  z-index: 1000;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-danger);
  color: var(--oc-midnight); /* Midnight on the danger red is 4.6:1; Paper would be 3.6:1 */
  box-shadow: var(--shadow-lg);
  font-size: var(--text-subhead);
}
#blazor-error-ui .reload { color: inherit; font-weight: var(--weight-semibold); text-decoration: underline; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- Boot splash (static, shown until Blazor renders) ---------- */
.oc-boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--color-bg);
}
.oc-boot img {
  width: 88px;
  height: 88px; /* the SVG animates itself */
}
.oc-boot-dark { display: none; }
:root[data-theme="dark"] .oc-boot-light { display: none; }
:root[data-theme="dark"] .oc-boot-dark { display: block; }

/* Hide the boot splash as soon as the app shell has rendered. */
body:has(.oc-app) .oc-boot { display: none; }
