# va-themes/seglo

Seglo — theme for the **`accounting`** environment (finance reconciliation
product). Namespace `ViartasThemes\Seglo\`.

## Status

Skeleton (task-3): brand tokens, three OFL variable fonts, per-package Vite
build, DB `themes` row seeder, and `seglo:activate` / `seglo:deactivate`
helpers. The app-shell layout (`theme::layouts.app`) arrives in task-4.

Seglo is the **sole** accounting theme, so it is seeded `is_default=true` in the
`accounting` environment (no other theme to compete with). Its assets are scoped
to the `accounting.*` route pattern and never leak into web/admin.

## Structure

- `src/Providers/ThemeServiceProvider.php` — extends BaseThemeServiceProvider (`env='accounting'`)
- `src/Console/Commands/{Activate,Deactivate}Command.php` — theme switch helpers
- `Resources/assets/css/{tokens,fonts,seglo}.css` — brand tokens + `@font-face` + base
- `Resources/assets/js/seglo.js` — single Vite entry (imports seglo.css + all modules)
- `Resources/assets/js/seglo-{ajax,table,drawer,pool,reconcile}.js` — task-23 named
  module layer (`window.SegloAjax/SegloTable/SegloDrawer/SegloPool/SegloReconcile`):
  AJAX+toast helper, client-side grid (search/sort/paginate/keyboard), detail
  drawer, pool modal, reconciliation state machine + undo. Vanilla JS (no Alpine —
  the theme does not bundle it). `cockpit.js` composes them onto `/accounting/nesusegta`.
- `Resources/assets/fonts/*.woff2` — Manrope / Inter / JetBrains Mono variable (OFL 1.1, licences alongside)
- `Database/Seeders/SegloThemeSeeder.php` — DB row seeder
- `theme.json` — admin `themes:sync` metadata
- `public/build/` — Vite build output (published to host via `vendor:publish`)

## Fonts

Three SIL OFL 1.1 variable web fonts ship in the package
(`Resources/assets/fonts/`), each with its licence text (`*-OFL.txt`):

| Font | Axis (wght) | Role |
|---|---|---|
| Manrope | 200–800 | UI / headings (`--font-ui`) |
| Inter | 100–900 | body copy (`--font-body`) |
| JetBrains Mono | 100–800 | figures / IBAN / txid (`--font-mono`) |

> ⚠️ The original prototype token/logo/font sources
> (`packages/viartas-design/seglo/…`) are not present in this repo. The tokens
> in `tokens.css` were reconstructed from `SEGLO-PLANAS.md` §1 / `SEGLO-ANALIZE.md`
> §2.1, and the fonts fetched fresh from their upstream OFL distributions. When
> the prototype resurfaces, replace the token VALUES 1:1 — the token NAMES are
> the stable contract downstream tasks consume.

## Build & publish

```bash
cd packages/va-themes/seglo && npm install && npm run build   # → public/build/assets/seglo.{js,css} + fonts
# or from repo root, the discovery build picks the source up too
php artisan themes:publish-assets      # → public/vendor/va-themes/seglo/build/
php artisan db:seed --class='ViartasThemes\Seglo\Database\Seeders\SegloThemeSeeder' --force
```

## Landing pages (task-49) — public marketing site

The public marketing landing (`/seglo`, `/seglo/kaina`, `/seglo/firmoms`, …) is a
set of **CMS Pages in the `web` environment**, rendered through the Pages
`webPageTemplates()` mechanism — NOT the `accounting` app-shell.

**web-vs-accounting split (the key decision).** Seglo is registered as the
`accounting` theme (`environment=accounting`), so `ResolveTheme` never prepends
its views onto a `web` request — the active web theme is Protera/Cleverphant.
PageSlugResolver renders `pages::web.{template}`. To make the Seglo landing blades
reachable on ANY active web theme, the provider registers this package's
`Resources/views/pages` dir into the `pages` view namespace **unconditionally**
(`ThemeServiceProvider::registerLandingPagesViews()`), outside the active-theme
gate. It only adds `seglo-*` view names and never defines `pages::web.default`,
so Protera's default rendering is untouched.

- **Templates:** `webPageTemplates()` declares 10 `seglo-*` options (5 Verslui +
  5 Firmoms). They surface in the admin Pages "Šablonas" dropdown while Seglo is
  the active accounting theme (always). Blades live at
  `Resources/views/pages/web/seglo-*.blade.php` and `@extends('pages::web.seglo._layout')`
  (a self-contained landing layout with header/footer/audience-toggle partials).
  ⚠️ Deviation from the task's `theme::pages.templates.{key}` path: the resolver
  contract is `pages::web.{template}`, so the blades live under `pages/web/` and
  the template value IS the view name suffix (e.g. `seglo-kaina` → `pages::web.seglo-kaina`).
- **landing.css/js:** a SECOND Vite entry (`landing.js` imports `landing.css`) →
  `landing.{js,css}`, separate from the app-shell `seglo.{js,css}`. Linked
  **directly** in the landing layout `<head>` (NOT via `@assets`, which is
  route-pattern gated and would leak the bundle onto every Protera web page). The
  `.lp-*` / `.lp-vkaina-*` / `.lp-sauga-*` / `.lp-kontra-*` classes are the
  landing layer (reconstructed from `SEGLO-PLANAS.md` §1 — the prototype is gone).
- **Seeder:** `SegloLandingSeeder` creates a `seglo` parent + 9 children (URLs
  namespace under `/seglo/*`), idempotent via a `(slug, parent_id)`-scoped lookup
  (collision-safe even if another theme seeded a bare-slug `duk`/`index`).
  Registered in the host `DatabaseSeeder` (runs on every `db:seed` / `deploy:sync`).

```bash
php artisan db:seed --class='ViartasThemes\Seglo\Database\Seeders\SegloLandingSeeder' --force
```

## i18n LT/EN/PL + dark mode + font size + switch commands (task-50)

The theme's "liveness" layer — three persisted presentation controls plus the
DB switch helpers.

- **i18n:** `Resources/lang/{lt,en,pl}/messages.php` (namespace `seglo::`).
  Registered **UNCONDITIONALLY** in `ThemeServiceProvider::boot()`
  (`loadTranslationsFrom(..., 'seglo')`) — outside the active-theme gate — so
  `__('seglo::messages.*')` resolves under BOTH switch mechanisms (config-driven
  active state AND a pure DB `is_default` flip). The app-shell chrome (skip link,
  sidebar/topbar aria, group headers, control labels) is wired to these keys;
  LT values stay byte-identical to the pre-wiring literals. MVP scope: the
  per-screen nav item labels + landing marketing copy remain LT literals pending
  a full UI translation pass (honest partial i18n).
- **`<x-language-switcher>`:** LT/EN/PL pill row in the topbar. Renders one link
  per ACTIVE Locale (self-hides while only one is active). Accounting-aware path
  rewrite: the `/{tag}` infix sits after the `/accounting` prefix
  (`/accounting/en/…`), unlike the web switcher which infixes at the root.
- **Dark mode (`<x-theme-toggle>`):** flips `<html data-theme="light|dark">`,
  persisted to `localStorage('seglo-theme')`. An inline `<head>` FOUC guard
  stamps it before first paint (anti-flash).
- **Font size (`<x-font-size-toggle>`):** S/M/L levels stamp
  `<html data-font-size="s|m|l">` → `--sg-font-scale` (tokens.css) scales the base
  body font, so the whole ramp grows/shrinks. Persisted to
  `localStorage('seglo-font-size')`; same `<head>` FOUC guard.
- **`theme-mode.js`:** single owner of the two `<html>` presentation attributes
  (dark mode + font size), imported in `seglo.js`. Lifted out of `app-shell.js`
  (which kept the dark-mode logic through task-4).
- **`seglo:activate` / `seglo:deactivate`:** flip DB `themes.is_default` for the
  `accounting` env (+ `ThemeManager::clearCache()`). `deactivate` restores the
  previous default (or the one named by `--default-slug`) and **refuses** when
  Seglo is not the current default OR there is no replacement to restore
  (accounting must always keep exactly one default). Seglo is the sole accounting
  theme today, so `deactivate` blocks on a bare install — a clear error, never a
  silent no-op. TESTING/DEMO helpers; production switching goes through the admin
  Themes UI. ⚠️ Dual ThemeManager: the DB flip re-points view namespaces, but the
  `@assets` gate reads `config('themes.default_*')` (no `default_accounting` key)
  — which is why Seglo's assets register unconditionally in `boot()`.

```bash
php artisan seglo:activate
php artisan seglo:deactivate --default-slug=<other-accounting-theme>
```
