/*
 * AITHYRA brand stylesheet.
 *
 * Defines @font-face for Denim INK + MD Thermochrome 0.3, the brand
 * colour palette as CSS variables (with dark and light themes), and
 * base typography/UI primitives used across the dashboard.
 *
 * Theme switching is driven by the `data-theme` attribute on <html>,
 * set by static/js/app.js based on localStorage. The default value in
 * base.html.j2 is `dark`.
 *
 * Colours match AITHYRA/AITHYRADesign.md. Primary teal (#0a6478) is
 * the brand identifier; secondary colours are reserved for status
 * accents (good/warn/bad) and must include primary teal nearby.
 */

/* -------------------------------------------------------------------------- */
/* Fonts                                                                      */
/* -------------------------------------------------------------------------- */

@font-face {
  font-family: "Denim INK";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/DenimINK-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Denim INK";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/DenimINK-Medium.woff2") format("woff2");
}

@font-face {
  font-family: "MD Thermochrome";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/MDThermochrome0.3-Regular.otf") format("opentype");
}

@font-face {
  font-family: "MD Thermochrome";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/MDThermochrome0.3-Medium.otf") format("opentype");
}

@font-face {
  font-family: "MD Thermochrome";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/MDThermochrome0.3-Bold.otf") format("opentype");
}

/* -------------------------------------------------------------------------- */
/* Tokens                                                                     */
/* -------------------------------------------------------------------------- */

:root {
  /* Brand palette */
  --aithyra-teal: #0a6478;
  --aithyra-dark-green: #052323;
  --aithyra-grey: #c8c8c8;
  --aithyra-light-grey: #f6f6f6;
  --aithyra-dark-grey: #505050;
  --aithyra-black: #1e1e1e;
  --aithyra-white: #ffffff;

  /* Status accents (secondary palette) */
  --aithyra-good: #37be55;
  --aithyra-warn: #ffff64;
  --aithyra-bad: #ff416e;
  --aithyra-critical: #ff2300;

  /* Typography */
  --font-sans: "Denim INK", "Inter", "Segoe UI", Arial, sans-serif;
  --font-tech: "MD Thermochrome", "JetBrains Mono", Consolas, monospace;
  --font-mono: "JetBrains Mono", Consolas, "Liberation Mono", monospace;

  /* Spacing (5% page margin lives in dashboard.css) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
}

/* Dark theme (default) */
html[data-theme="dark"] {
  --bg: var(--aithyra-dark-green);
  --bg-elev: #0a3535;
  --bg-tile: #093033;
  --fg: var(--aithyra-light-grey);
  --fg-muted: var(--aithyra-grey);
  --border: rgba(200, 200, 200, 0.12);
  --accent: var(--aithyra-teal);
  --accent-fg: var(--aithyra-white);
  --wordmark: url("/static/img/aithyra-wordmark-white.svg");
}

/* Light theme */
html[data-theme="light"] {
  --bg: var(--aithyra-light-grey);
  --bg-elev: var(--aithyra-white);
  --bg-tile: var(--aithyra-white);
  --fg: var(--aithyra-black);
  --fg-muted: var(--aithyra-dark-grey);
  --border: rgba(30, 30, 30, 0.12);
  --accent: var(--aithyra-teal);
  --accent-fg: var(--aithyra-white);
  --wordmark: url("/static/img/aithyra-wordmark-black.svg");
}

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  font-weight: 500;
  margin: 0 0 var(--space-4);
  letter-spacing: -0.01em;
}

h1 {
  font-family: var(--font-tech);
  font-size: 2.25rem;
}
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

.mono,
code {
  font-family: var(--font-mono);
}

.tech {
  font-family: var(--font-sans);
}

/* -------------------------------------------------------------------------- */
/* Navbar                                                                     */
/* -------------------------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-4) 5%;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.nav__brand {
  display: inline-block;
  width: 140px;
  height: 32px;
  background: var(--wordmark) no-repeat left center / contain;
  text-indent: -9999px;
  overflow: hidden;
}

.nav__title {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav__spacer {
  flex: 1;
}

.nav__user {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding: 0 var(--space-3);
}

.nav__user strong {
  color: var(--fg);
  font-weight: 500;
}

.nav__link {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: color 120ms ease, background 120ms ease;
}

.nav__link:hover {
  color: var(--fg);
  background: var(--bg-tile);
}

.nav__link--active {
  color: var(--accent);
  font-weight: 500;
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover {
  background: var(--bg-tile);
  border-color: var(--accent);
  text-decoration: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn--primary:hover {
  background: #0d7a91;
  border-color: #0d7a91;
  color: var(--accent-fg);
}

.btn--ghost {
  background: transparent;
}

.chart-tab--active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* -------------------------------------------------------------------------- */
/* Tile (KPI card)                                                            */
/* -------------------------------------------------------------------------- */

.tile {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.tile__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.tile__title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0;
}

.tile__stamp {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  color: var(--fg-muted);
  opacity: 0.6;
}

.tile__value {
  font-family: var(--font-sans);
  font-size: 2.6rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1;
}

.tile__sub {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.tile__sub strong {
  color: var(--fg);
  font-weight: 500;
}

.tile--accent {
  border-left: 3px solid var(--accent);
}

/* -------------------------------------------------------------------------- */
/* Table                                                                      */
/* -------------------------------------------------------------------------- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tbl th,
.tbl td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.tbl th {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 500;
}

.tbl tbody tr:hover {
  background: var(--bg-elev);
}

.tbl .num {
  font-family: var(--font-sans);
  text-align: right;
  white-space: nowrap;
}

.tbl .tag {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--fg-muted);
}

.tbl .tag--bad { color: var(--aithyra-bad); }
.tbl .tag--good { color: var(--aithyra-good); }

/* -------------------------------------------------------------------------- */
/* Login / dev picker                                                         */
/* -------------------------------------------------------------------------- */

.login {
  max-width: 420px;
  margin: 10vh auto;
  padding: var(--space-8);
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.login h1 {
  margin-bottom: var(--space-6);
  text-align: center;
}

.login__choice {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.login__choice .btn {
  justify-content: space-between;
}

.login__hint {
  margin-top: var(--space-6);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-align: center;
}

/* -------------------------------------------------------------------------- */
/* Utility                                                                    */
/* -------------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
