/* Romanson Invest — FT-like re-theme of the two apps we proxy (OwnIt Deals /ipo/, 1WIN Sale /1win/).
   Variables only (plus two small tweaks at the end); the apps keep their markup and layout.

   Cascade note. The apps declare their palette as
     :root{…}                                                         (0,1,0)  light
     @media dark { :root:not([data-theme=light]):not([data-theme=gray]){…} }  (0,3,0)  OS dark
     :root[data-theme=dark]{…}  :root[data-theme=gray]{…}             (0,2,0)
   This sheet is injected before </head>, but OwnIt's <style> sits inside <body> (its page is built
   from a fragment), so there it comes AFTER us. Order therefore cannot be relied on: every selector
   below carries :not(#ri-none) — an always-true test with ID weight (1,0,0) — which outranks all of
   the apps' selectors whichever sheet comes last. Among our own rules:
     A  light      :root:not(#ri-none):not([data-theme=gray])                         (1,2,0)
     B  dark       :root:not(#ri-none)[data-theme=dark]                               (1,2,0) later than A
     C  OS dark    @media dark :root:not(#ri-none):not([data-theme=light]):not([data-theme=gray])  (1,3,0)
   so OS-dark without an explicit theme gets OUR dark (C beats A), explicit light stays light (C does
   not match), and the gray theme matches none of them and keeps the app's own palette. */

/* A — light: paper */
:root:not(#ri-none):not([data-theme="gray"]) {
  --bg: #FFF1E5;
  --surface: #FFF9F4;
  --sunk: #F2DFCE;
  --line: #CCC1B7;
  --line-soft: #E6D8CB;
  --ink: #33302E;
  --muted: #66605C;
  --faint: #8C847E;
  --accent: #0F7862;
  --accent-soft: #F4D9DD;
  --gain: #08704F;
  --gain-bg: #DDEEE2;
  --loss: #C00000;
  --loss-bg: #F9DCD3;
  --warn: #8A5300;
  --warn-bg: #F7E4C6;
  --lock: #0F5499;
  --lock-bg: #DCE5EF;
  --row-hover: #FBEADD;
  --c1: #0D7680;
  --c2: #0F7862;
  --f-display: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 4px;
  color-scheme: light;
}

/* B — explicit dark theme chosen in the app */
:root:not(#ri-none)[data-theme="dark"] {
  --bg: #1A1817;
  --surface: #24211F;
  --sunk: #2C2825;
  --line: #433D38;
  --line-soft: #332F2B;
  --ink: #F2E9E1;
  --muted: #B3A79D;
  --faint: #8C8179;
  --accent: #6BC9A0;
  --accent-soft: #3D1F2A;
  --gain: #3FBF8C;
  --gain-bg: #163327;
  --loss: #FF6E61;
  --loss-bg: #3E1F1B;
  --warn: #E8B45C;
  --warn-bg: #3A2D16;
  --lock: #8DB4EA;
  --lock-bg: #1F2A3B;
  --row-hover: #2A2623;
  --c1: #3CB6C0;
  --c2: #6BC9A0;
  color-scheme: dark;
}

/* C — OS dark, no explicit theme (or theme=dark): our dark, not our light */
@media (prefers-color-scheme: dark) {
  :root:not(#ri-none):not([data-theme="light"]):not([data-theme="gray"]) {
    --bg: #1A1817;
    --surface: #24211F;
    --sunk: #2C2825;
    --line: #433D38;
    --line-soft: #332F2B;
    --ink: #F2E9E1;
    --muted: #B3A79D;
    --faint: #8C8179;
    --accent: #6BC9A0;
    --accent-soft: #3D1F2A;
    --gain: #3FBF8C;
    --gain-bg: #163327;
    --loss: #FF6E61;
    --loss-bg: #3E1F1B;
    --warn: #E8B45C;
    --warn-bg: #3A2D16;
    --lock: #8DB4EA;
    --lock-bg: #1F2A3B;
    --row-hover: #2A2623;
    --c1: #3CB6C0;
    --c2: #6BC9A0;
    color-scheme: dark;
  }
}

/* The gray theme is deliberately left alone (palette and fonts are the app's own). */

/* Tweak — the apps' wordmark ("OwnIt", "1WIN") gets the green -> blue gradient of the A2DAO logo,
   deepened on paper, as is on the dark theme. Gray theme untouched. */
:root:not(#ri-none):not([data-theme="gray"]) .brand-a {
  background-image: linear-gradient(100deg, #1E9E64 0%, #1C9A6A 50%, #2F8E96 75%, #4F78C4 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not(#ri-none):not([data-theme="light"]):not([data-theme="gray"]) .brand-a { background-image: linear-gradient(100deg, #5FCF8E 0%, #5ECB8B 55%, #7CBFB8 78%, #96B3E0 100%); }
}
:root:not(#ri-none)[data-theme="dark"] .brand-a { background-image: linear-gradient(100deg, #5FCF8E 0%, #5ECB8B 55%, #7CBFB8 78%, #96B3E0 100%); }

/* The theme is chosen once for the whole site, on the main page (top chrome); the apps follow it
   (ri-theme.js mirrors it into their own keys), so their own switches are hidden. */
[data-theme-sw], #themeSw { display: none !important; }

/* Gray is a site-wide theme now: the apps keep their own gray palette but take our type and wordmark. */
:root:not(#ri-none)[data-theme="gray"] {
  --f-display: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
:root:not(#ri-none)[data-theme="gray"] .brand-a {
  background-image: linear-gradient(100deg, #5FCF8E 0%, #5ECB8B 55%, #7CBFB8 78%, #96B3E0 100%);
}
