/*
 * theme.css — PezilloWeb color system
 *
 * Source of truth: SPEC.md Sections 1 ("Colors") and 2 ("Themes").
 *
 * Android mechanism being ported: every Activity pins a full style
 * (Theme.PoolTracker.Light / .Dark) synchronously based on a saved user
 * preference (Prefs.loadThemeMode()) — NOT system dark mode / prefers-color-scheme.
 * The CSS equivalent is a `data-theme="light"` or `data-theme="dark"` attribute
 * set on <html> by an inline <script> in <head>, BEFORE first paint, by each page
 * (see SPEC.md 2.3). This file does not set that attribute — it only supplies the
 * variable values for each state. CONTRACT: every HTML page must include, in
 * <head>, a synchronous inline script that reads the stored theme preference
 * (mirroring Prefs.loadThemeMode()) and sets document.documentElement.dataset.theme
 * to "light" or "dark" before any CSS paints, to avoid a flash of the wrong theme.
 * prefers-color-scheme may be consulted ONLY as the default on first-ever load
 * before the user has picked anything (SPEC.md 2.3) — once a preference is stored,
 * it must always win, exactly like the Android app deliberately ignores system
 * dark mode after ThemedActivity pins its own style.
 *
 * Naming: legacy Android names like `aqua`/`sky`/`coral`/`gold` are historical
 * leftovers from an earlier, more colorful design (SPEC.md intro) — in the
 * current "pencil sketch" redesign they all resolve to muted graphite/chalk
 * grays. Only danger_red and warning_yellow are "real" intentional colors.
 * Kept the historical names here 1:1 with the Android ?attr/colorXxx names
 * (translated to kebab-case) so this file stays a direct, auditable mapping.
 */

@font-face {
  font-family: 'LT Colored Pencil';
  src: url('../assets/fonts/lt_colored_pencil.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ---- Light theme (Theme.PoolTracker.Light, SPEC.md 2.2) ---- */
:root[data-theme="light"],
html[data-theme="light"] {
  --color-bg-top: #F7F5EF;
  --color-bg-bottom: #F7F5EF;
  --color-card-bg: #F7F5EF;
  --color-card-bg-dark: #ECE8DD;
  --color-card-border: #57534A;
  --color-aqua: #17160F;
  --color-aqua-dark: #1C1B18;
  --color-sky: #57534A;
  --color-coral: #3D3A33;
  --color-gold: #6B5A3E;
  /* pencil_line_faint/soft are ARGB in Android (alpha-first hex); expressed here
     as rgba() since CSS hex-with-alpha is alpha-LAST (#RRGGBBAA) and easy to get
     backwards — rgba() keeps the alpha value unambiguous and matches the SPEC's
     "~16%"/"~35% alpha of #2B2A26" description directly. */
  --color-pencil-line-faint: rgba(43, 42, 38, 0.16);
  --color-pencil-line-soft: rgba(43, 42, 38, 0.35);
  --color-danger-red: #A13B2E;
  --color-warning-yellow: #8A6A12;
  --color-text-primary: #17160F;
  --color-text-secondary: #4A473D;
  --color-text-muted: #6E6A59;

  /* RGB triplets for colors used inside rgba() (status-dot halo, etc.) */
  --color-aqua-rgb: 23, 22, 15;
  --color-coral-rgb: 61, 58, 51;
  --color-text-muted-rgb: 110, 106, 89;

  /* bg_gradient_light.xml -> paper_texture_tile_light (SPEC.md 4,
     "bg_gradient_light.xml"). Served as .webp, not the original .png (code
     audit, 2026-09-29): the source PNG was ~1.2MB for a 1124x1999 grain
     texture with no transparency (plain RGB, no alpha channel) — re-encoded
     losslessly-enough at WebP q90 to ~130KB (~89% smaller) with no visible
     quality loss on a noisy paper-grain image, cutting real weight from
     both the initial load and the service worker's precache install. Every
     browser this PWA targets (Brave/Chrome on Android) supports WebP. */
  --bg-texture-image: url('../assets/images/paper_texture_tile_light.webp');
}

/* ---- Dark theme (Theme.PoolTracker.Dark, SPEC.md 2.2) — app default ---- */
:root[data-theme="dark"],
html[data-theme="dark"] {
  --color-bg-top: #121210;
  --color-bg-bottom: #121210;
  --color-card-bg: #121210;
  --color-card-bg-dark: #1D1C18;
  --color-card-border: #C9C4B4;
  --color-aqua: #F2EEE2;
  --color-aqua-dark: #D8D3C4;
  --color-sky: #C9C4B4;
  --color-coral: #E4DFD0;
  --color-gold: #D3BD85;
  --color-pencil-line-faint: rgba(242, 238, 226, 0.20);
  --color-pencil-line-soft: rgba(242, 238, 226, 0.35);
  --color-danger-red: #E0685A;
  --color-warning-yellow: #D9A62E;
  --color-text-primary: #F2EEE2;
  --color-text-secondary: #C4BFAF;
  --color-text-muted: #837E6E;

  --color-aqua-rgb: 242, 238, 226;
  --color-coral-rgb: 228, 223, 208;
  --color-text-muted-rgb: 131, 126, 110;

  /* bg_gradient_dark.xml -> paper_texture_tile_dark (slate/chalkboard
     grain). Served as .webp — see the light-theme rule above for the
     2026-09-29 size-optimization writeup (~986KB PNG -> ~79KB WebP here). */
  --bg-texture-image: url('../assets/images/paper_texture_tile_dark.webp');
}

/*
 * Fallback (no data-theme attribute set yet, e.g. this stylesheet loaded before
 * the inline theme script runs, or a page that forgot to set it). SPEC.md states
 * the app's default is dark theme, so the un-attributed :root mirrors the dark
 * values above rather than light, to match that default and to fail toward the
 * least-surprising state if the inline script contract above is ever broken.
 */
/*
 * Fixed (theme-INDEPENDENT) text-primary constants — used only by the
 * Ajustes theme-swatch icons (css/pages.css .theme-swatch__icon). Unlike
 * every other --color-* variable in this file, these two do NOT change
 * value when data-theme flips: each settings.html swatch tints the app
 * logo mask with the text color THAT THEME would use, regardless of which
 * theme is actually active right now (SPEC.md 7.6 / activity_settings.xml
 * android:tint="@color/text_primary_theme_light" / "_dark"). Values copied
 * 1:1 from PezilloV2/app/src/main/res/values/colors.xml
 * (text_primary_theme_light / text_primary_theme_dark) — read-only
 * reference, not edited.
 */
:root {
  --color-text-primary-theme-light: #17160F;
  --color-text-primary-theme-dark: #F2EEE2;
}

:root {
  --color-bg-top: #121210;
  --color-bg-bottom: #121210;
  --color-card-bg: #121210;
  --color-card-bg-dark: #1D1C18;
  --color-card-border: #C9C4B4;
  --color-aqua: #F2EEE2;
  --color-aqua-dark: #D8D3C4;
  --color-sky: #C9C4B4;
  --color-coral: #E4DFD0;
  --color-gold: #D3BD85;
  --color-pencil-line-faint: rgba(242, 238, 226, 0.20);
  --color-pencil-line-soft: rgba(242, 238, 226, 0.35);
  --color-danger-red: #E0685A;
  --color-warning-yellow: #D9A62E;
  --color-text-primary: #F2EEE2;
  --color-text-secondary: #C4BFAF;
  --color-text-muted: #837E6E;
  --color-aqua-rgb: 242, 238, 226;
  --color-coral-rgb: 228, 223, 208;
  --color-text-muted-rgb: 131, 126, 110;
  --bg-texture-image: url('../assets/images/paper_texture_tile_dark.webp');
}
