/* Page rules of the web app. A file, not an inline <style>, so the page's Content-Security-Policy allows no
   inline styles for it. The html, body and #root rules are the root setup react-native-web recommends (Expo's
   default page has them inline). */

/* Onest, the app's one typeface (SIL Open Font License, /fonts/OFL.txt; where the files come from:
   apps/mobile/assets/fonts/README.md). The site serves the files itself, so no request goes to a font host. One
   variable font for every weight, in subsets: a browser loads a subset only when the page has its letters. */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-latin-wght-normal.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-cyrillic-wght-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-cyrillic-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* Arrows and a few symbols ("↗" after a link that leaves the site). */
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/onest-symbols-wght-normal.woff2') format('woff2');
  unicode-range: U+2190, U+2192, U+2194-2199, U+21AF, U+21E6-21F0, U+21F3;
}

/* The app's colours (src/presentation/palette.ts, which palette.test.ts keeps in step with this file). */
:root {
  --page: #f7f7f4;
  --surface: #ffffff;
  --surface-muted: #efefea;
  --header: #0e1b2c;
  --on-header: #ffffff;
  --on-header-muted: #b8c1cc;
  --text: #0f172a;
  --secondary: #5b6472;
  --hairline: #e2e2dc;
  --control: #7c838e;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #d5ece8;
  --on-accent-soft: #115e59;
  --on-accent: #ffffff;
  --live: #c81e1e;
  --on-live: #ffffff;
  --live-hover: #a51717;
  --live-soft: #fcebea;
  --focus: #0f766e;
  --focus-on-header: #5eead4;
  --font-sans:
    'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b1220;
    --surface: #121b2b;
    --surface-muted: #1a2537;
    --header: #070d18;
    --on-header: #e8ecf2;
    --on-header-muted: #9aa4b2;
    --text: #e8ecf2;
    --secondary: #9aa4b2;
    --hairline: #233044;
    --control: #64728a;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: #134e4a;
    --on-accent-soft: #5eead4;
    --on-accent: #04201c;
    --live: #f05252;
    --on-live: #000000;
    --live-hover: #f47878;
    --live-soft: #3b1719;
    --focus: #2dd4bf;
    --focus-on-header: #5eead4;
  }
}

/* The theme chosen in Više ("Tema") over the device's: public/init.js and the app set data-theme on the root
   element, and nothing while it is Automatski. The same colours as above (palette.test.ts checks them). */
:root[data-theme='light'] {
  --page: #f7f7f4;
  --surface: #ffffff;
  --surface-muted: #efefea;
  --header: #0e1b2c;
  --on-header: #ffffff;
  --on-header-muted: #b8c1cc;
  --text: #0f172a;
  --secondary: #5b6472;
  --hairline: #e2e2dc;
  --control: #7c838e;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #d5ece8;
  --on-accent-soft: #115e59;
  --on-accent: #ffffff;
  --live: #c81e1e;
  --on-live: #ffffff;
  --live-hover: #a51717;
  --live-soft: #fcebea;
  --focus: #0f766e;
  --focus-on-header: #5eead4;
  color-scheme: only light;
}

:root[data-theme='dark'] {
  --page: #0b1220;
  --surface: #121b2b;
  --surface-muted: #1a2537;
  --header: #070d18;
  --on-header: #e8ecf2;
  --on-header-muted: #9aa4b2;
  --text: #e8ecf2;
  --secondary: #9aa4b2;
  --hairline: #233044;
  --control: #64728a;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #134e4a;
  --on-accent-soft: #5eead4;
  --on-accent: #04201c;
  --live: #f05252;
  --on-live: #000000;
  --live-hover: #f47878;
  --live-soft: #3b1719;
  --focus: #2dd4bf;
  --focus-on-header: #5eead4;
  color-scheme: only dark;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* Screens scroll inside their own scroll views. */
  overflow: hidden;
  /* The app's page colour, also before the script runs (no white flash in dark mode). */
  background-color: var(--page);
  color: var(--text);
  font-family: var(--font-sans);
}

#root {
  display: flex;
  flex: 1;
  height: 100%;
}

/* The page's text for readers without JavaScript (build/site-pages.mts), as a plain readable column. On a page
   that runs scripts, init.js has marked the root element before the first paint and the app replaces this text as
   it starts, so it stays hidden there and never flashes. */
.prerender {
  box-sizing: border-box;
  flex: 1;
  overflow-y: auto;
  padding: 16px max(16px, calc((100% - 46rem) / 2));
  line-height: 1.5;
}

.prerender a {
  color: var(--accent);
}

.js .prerender {
  display: none;
}

/* Every text and text field of the app in Onest. react-native-web gives each one the system font in a class of its
   own (and only a text or a field has a dir attribute), which this rule outranks. A text that needs another family
   (an icon font, a code sample) sets it as an inline style, and an inline style still wins. */
#root [dir] {
  font-family: var(--font-sans);
}

/* A clear focus ring for keyboard users, in the app's accent colour. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* A tab sits in a container that clips anything outside it, so its ring is drawn inside. */
[role='tab']:focus-visible {
  outline-offset: -3px;
}

/* On the ink header band the accent is too dark for a ring. */
#site-header :focus-visible {
  outline-color: var(--focus-on-header);
}

/* Nothing slides or fades for someone who asked the system for less motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
