/* ── Keymono Brand Theme ──────────────────────────────────────────────────
   The single brand stylesheet for both Vaadin applications, served from this
   module's META-INF/resources and loaded via @StyleSheet on each app shell.

   It brands Aura by setting Aura's *base* tokens and letting Aura derive text
   colours, surfaces and borders from them. Derived (unsuffixed) Aura
   properties are read-only and are never assigned here.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Font faces ── */

@font-face {
  font-family: "Jockey One";
  src: url("./fonts/jockeyone/jockeyone-regular-webfont.woff2") format("woff2"),
       url("./fonts/jockeyone/jockeyone-regular-webfont.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Liberation";
  src: url("./fonts/liberation/LiberationSans-Regular.woff2") format("woff2"),
       url("./fonts/liberation/LiberationSans-Regular.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: "Monaco";
  src: url("./fonts/monaco/monaco.woff2") format("woff2"),
       url("./fonts/monaco/monaco.woff") format("woff");
  font-weight: normal;
  font-style: normal;
}

/* ── Brand tokens ──
   Base values are the literals from app/store/frontend/src/app.css; the derived
   shades are that file's relative-OKLCH expressions, not pre-computed copies
   of them. Only the shades these two applications actually use are carried
   over — the storefront's palette is wider, and importing the rest would put
   names here that nothing resolves. */

:root {
  --k-yellow:    oklch(0.8878 0.141 54.32);
  --k-ivory:     oklch(0.9991 0.0407 40.36);
  --k-coral:     oklch(0.6839 0.1525 24.32);
  --k-darkblue:  oklch(0.4248 0.0486 204.68);
  --k-lightblue: oklch(0.8656 0.0221 170.05);
  --k-green:     oklch(0.7772 0.0776 149.33);
  --k-jade:      oklch(0.375 0.0431 183.13);

  /* lightblue family */
  --k-lightblue-bright: oklch(from var(--k-lightblue) calc(l + 0.0293) c h);
  --k-lightblue-soft:   oklch(from var(--k-lightblue) calc(l + 0.0573) c h);
  --k-lightblue-pale:   oklch(from var(--k-lightblue) calc(l + 0.0709) c h);
  --k-lightblue-frost:  oklch(from var(--k-lightblue) calc(l + 0.0919) c h);

  /* darkblue family */
  --k-darkblue-abyss:  oklch(from var(--k-darkblue) calc(l - 0.1933) c h);
  --k-darkblue-deep:   oklch(from var(--k-darkblue) calc(l - 0.061)  c h);
  --k-darkblue-shade:  oklch(from var(--k-darkblue) calc(l - 0.04)   c h);
  --k-darkblue-tint:   oklch(from var(--k-darkblue) calc(l + 0.0369) c h);
  --k-darkblue-bright: oklch(from var(--k-darkblue) calc(l + 0.1606) c h);
  --k-darkblue-sky:    oklch(from var(--k-darkblue) calc(l + 0.24)   c h);

  --font-jockey: "Jockey One", Impact, sans-serif;
  --font-sans:   "Liberation", "Noto Sans", Arial, sans-serif;
  --font-mono:   "Monaco", "Courier New", monospace;
}

/* ── Aura base tokens ──
   These four decide almost everything: Aura computes text colours, surface
   steps, borders and focus rings from them. Both apps are dark-only, so the
   dark variants carry the brand; the light ones are set to a plausible value
   so that adding a light mode later is a colour-scheme switch, not a redesign.
   Aura's light-dark() switching keys off `color-scheme`, which is why it is set
   here rather than expressed per property. */

:root {
  color-scheme: dark;

  --aura-background-color-dark:  var(--k-darkblue);
  --aura-background-color-light: var(--k-lightblue-pale);

  /* Plain brand coral. The primary button's label is black because Aura derives
     it by contrast and coral is light enough for that. Do not darken the accent
     to force a white label: Aura clamps the focus ring at max(l, 0.62), so an
     accent dark enough to flip the label leaves the ring a different coral from
     the surface it surrounds. The two thresholds do not overlap — measured, see
     design.md D8. */
  --aura-accent-color-dark:  var(--k-coral);
  --aura-accent-color-light: var(--k-coral);

  --aura-font-family: var(--font-sans);

  /* The single knob that sets buttons and input fields off against the canvas,
     raised from Aura's default of 1. It governs borders and text only — for
     panel surfaces see --aura-surface-level below. */
  --aura-contrast-level: 2;

  /* How far panels, cards and overlays sit from the canvas, in steps of 0.03
     lightness. Negative goes darker, which is the direction this brand wants:
     Aura's positive default leaves a rendered difference of 0.006 against this
     canvas, which no eye reads as a panel. Surfaces stay translucent at any
     level, so the gradient shows through them. */
  --km-panel-surface-level: -4;
  --aura-surface-level: var(--km-panel-surface-level);

  /* Aura's focus ring is 2px of the coral accent. On an input field that is a
     heavy frame next to the field's own 1px border; one pixel marks focus just
     as clearly. Colour and shape stay Aura's — only the width changes. */
  --vaadin-focus-ring-width: 1px;
}

/* Aura's card sets its own surface level (2, lighter than the canvas) on itself, which wins over the
   value on :root for everything inside it. The card is the panel this brand wants darker than the
   canvas, so it takes the panel level too. The :root prefix keeps this ahead of Aura's own
   `vaadin-card` rule whatever order the stylesheets load in. */
:root vaadin-card {
  --aura-surface-level: var(--km-panel-surface-level);
}

/* A link is its colour, never an underline (Martin, 2026-10-14); the underline comes back under the
   pointer. :where keeps this weaker than any rule that styles a particular link. */
:where(a[href]) { text-decoration: none; }
:where(a[href]):hover { text-decoration: underline; }

/* A link drawn as a button (Buttons.anchor): a way to a page stays an anchor, so it opens in a new
   tab, but one that stands by itself is never an underlined line of text. vaadin-button styles only
   its own element, so the anchor restates its geometry from Aura's tokens, and takes its surface through
   the aura-surface and aura-accent-surface classes Buttons.anchor adds. The kinds and the small size
   compute as vaadin-button's do (default 34 px, small 30 px at 13 px; Aura 25.3).
   The surface level and opacity are Aura's own for vaadin-button. */
a.km-link-button {
  --aura-surface-level: 4;
  --aura-surface-opacity: 0.5;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  gap: var(--vaadin-gap-s);
  padding: var(--vaadin-padding-block-container) var(--vaadin-padding-m);
  border: 1px solid var(--aura-accent-border-color);
  border-radius: var(--vaadin-radius-m);
  background: var(--aura-accent-surface) padding-box;
  box-shadow: var(--aura-shadow-xs);
  color: var(--aura-accent-text-color);
  font-size: var(--aura-font-size-m);
  font-weight: var(--aura-font-weight-medium);
  line-height: var(--aura-line-height-m);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  outline-offset: -1px;
}
/* Small: one pixel less padding on each side and Aura's small type, which makes 30 px. */
a.km-link-button.km-link-button-small {
  padding: calc(var(--vaadin-padding-block-container) - 1px) calc(var(--vaadin-padding-m) - 1px);
  font-size: var(--aura-font-size-s);
  line-height: var(--aura-line-height-s);
}
a.km-link-button.km-link-button-primary {
  border-color: var(--vaadin-border-color-secondary);
  background: var(--aura-accent-color);
  box-shadow: var(--aura-shadow-s);
  color: var(--aura-accent-contrast-color);
  font-weight: var(--aura-font-weight-semibold);
  outline-offset: 2px;
}
/* Tertiary: no surface, no border, no shadow; the inline padding on the label side is Aura's smaller one. */
a.km-link-button.km-link-button-tertiary {
  border-color: transparent;
  background: none;
  box-shadow: none;
  padding-inline: var(--vaadin-padding-s);
}
a.km-link-button.km-link-button-tertiary.km-link-button-small {
  padding-inline: calc(var(--vaadin-padding-s) - 1px);
}
/* Danger is the secondary look on Aura's red accent (the aura-accent-red class), so it needs no rule. */

/* Aura lightens a hovered button by a veil of its own text colour: 3 %, a primary one 12 %. */
a.km-link-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
}
@media (any-hover: hover) {
  a.km-link-button:hover::before { opacity: 0.03; }
  a.km-link-button.km-link-button-primary:hover::before { opacity: 0.12; }
}
a.km-link-button:hover { text-decoration: none; }
a.km-link-button:focus-visible {
  outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
}

/* The popover does the same on its overlay part, and there the lighter surface sits under Aura's
   blur and translucency, which washes the text out against it. It takes the panel level too, ahead
   of Aura's own `vaadin-popover::part(overlay)` rule for the same reason as above. */
:root vaadin-popover::part(overlay) {
  --aura-surface-level: var(--km-panel-surface-level);
}

/* ── Background gradient (matches the storefront's atmosphere) ──
   The page canvas is the brand gradient, painted on :root — not html, which
   would lose the specificity contest against Aura's own :root rule. */

:root {
  background: linear-gradient(0deg, var(--k-darkblue-tint), var(--k-darkblue));
  min-height: 100vh;
}

html::before,
html::after {
  content: "";
  position: fixed;
  width: 100vw;
  height: 30vw;
  pointer-events: none;
  z-index: -1;
}

html::before {
  top: 0;
  background: linear-gradient(169deg,
    oklch(from var(--k-darkblue-deep) l c h / 0.5),
    oklch(from var(--k-darkblue-deep) l c h / 0) 50%);
}

html::after {
  bottom: 0;
  background: linear-gradient(169deg,
    oklch(from var(--k-lightblue-pale) l c h / 0) 50%,
    oklch(from var(--k-lightblue-pale) l c h / 0.3));
}

/* Let the gradient show through Vaadin's layout surfaces */
vaadin-app-layout,
vaadin-app-layout::part(content) {
  background: transparent;
}

/* Vaadin puts grid cell contents in the light DOM, so with a horizontally
   scrolled grid they stick out past the content area's right edge and get
   counted into its scroll width — an 83px scrollbar under a view that has
   nothing to scroll. The grid brings its own scrollbars for its own overflow. */
vaadin-app-layout::part(content) {
  overflow-x: hidden;
}

/* ── Scrollbars ──
   Aura ships no scrollbar styling at all, so they arrive as raw browser
   chrome on a dark canvas. `color-scheme: dark` alone only makes them dark,
   not quiet. Thin, brand-coloured, and transparent tracks so they read as
   part of the surface they sit on rather than as furniture on top of it. */

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--k-lightblue) 25%, transparent) transparent;
}

*:hover {
  scrollbar-color: color-mix(in srgb, var(--k-lightblue) 40%, transparent) transparent;
}

/* ── Body text ──
   Aura derives --vaadin-text-color from the background token; the brand wants
   lightblue rather than that neutral. Components that set the property on
   themselves (buttons, fields, overlays) keep Aura's derived value, which is
   what carries their own contrast. */

:root {
  --vaadin-text-color: var(--k-lightblue);
}

/* ── Headings: Jockey One display font ── */

h1, h2, h3, h4 {
  font-family: var(--font-jockey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--k-ivory);
}

/* ── Input fields: hover affordance ──
   Aura styles hover for field buttons, tabs and select options, but leaves the
   input surface itself unchanged — so a text field gives no sign that it can be
   clicked.

   The element-less `::part(input-field)` selector is Aura's own idiom (it uses
   `:not([readonly],[disabled])::part(field-button):hover`) and covers every
   field type at once — text, password, area, combo box, select, date and number
   pickers — instead of a list of a dozen component names that would go stale. */

::part(input-field) {
  transition: border-color 0.15s;
}

:hover:not([readonly], [disabled])::part(input-field) {
  border-color: color-mix(in srgb, var(--vaadin-text-color) 45%, transparent);
}

/* ── Grid: bold header cells ── */

vaadin-grid::part(header-cell) {
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--aura-font-size-s);
  letter-spacing: 0.05em;
}

/* ── App shell branding ──
   Drawer and navbar carry brand colours rather than Aura's derived surfaces;
   they are chrome, not content. */

vaadin-scroller[slot="drawer"] {
  padding: var(--vaadin-gap-s);
}

[slot="drawer"]:is(header, footer) {
  display: flex;
  align-items: center;
  gap: var(--vaadin-gap-s);
  padding: var(--vaadin-gap-s) var(--vaadin-gap-l);
  min-height: 3rem;
  box-sizing: border-box;
}

[slot="drawer"]:is(header, footer):is(:empty) {
  display: none;
}

vaadin-app-layout::part(drawer) {
  background: var(--k-jade);
  color: var(--k-lightblue);
  /* Aura insets the content area and gives the drawer a matching padding on the
     side facing it. Painting the drawer part fills that inset too, so the
     content's border ends up flush against the jade with no gap, while the far
     side keeps its inset — the asymmetry reads as a mistake. Clipping the paint
     to the content box leaves Aura's gap where Aura put it. */
  background-clip: content-box;
}

/* The page gutter, set here once for both apps: the space between the content area's edge and the
   sections, Aura's large padding token and never less than 16px. */
vaadin-app-layout::part(content) {
  box-sizing: border-box;
  padding: max(var(--vaadin-padding-l), 1rem);
}

vaadin-app-layout::part(navbar) {
  background: var(--k-darkblue);
}

[slot="drawer"] h1,
[slot="drawer"] .km-app-title {
  font-family: var(--font-jockey);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--k-ivory);
}

vaadin-side-nav-item[active] {
  color: var(--k-coral);
}

/* ── Shared layout helpers ── */

.km-view-title {
  font-size: var(--aura-font-size-l);
  margin: 0;
}

.app-header {
  padding-block: 0;
  padding-inline: var(--vaadin-gap-l);
}

/* Phones: the header gives its padding to the content, the log-out and action-bar buttons shrink to
   their icons, a table toolbar wraps, and the drawer leaves a strip of the page visible. */
@media (max-width: 767px) {
  .app-header {
    padding-inline: 0 !important;
  }

  .app-header vaadin-drawer-toggle {
    margin-left: 2px;
  }

  .logout-btn::part(label),
  .action-bar vaadin-button::part(label) {
    display: none;
  }

  .logout-btn,
  .action-bar vaadin-button {
    min-width: 0;
    padding-inline: 0.25em;
  }

  .logout-btn {
    margin-right: 8px;
  }

  .logout-btn::part(prefix),
  .action-bar vaadin-button::part(prefix) {
    margin: 0;
  }

  .table-toolbar {
    flex-wrap: wrap;
  }

  vaadin-app-layout::part(drawer) {
    max-width: 70vw;
  }
}

