/**
 * InternalKB theme — HR Analytics visual identity
 *
 * Tokens, palette and type scale are lifted verbatim from the HR Analytics Vue
 * app (/opt/hranalytics/hr-frontend) so the knowledge base reads as part of the
 * same product family. The application name stays "InternalKB".
 *
 * Source tokens: --brand #C73E5A, ink 900..400, paper 0..300, mark gold #ECB23B.
 * Type: Fraunces (display), Hanken Grotesk (body), Spline Sans Mono (code).
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at https://mozilla.org/MPL/2.0/.
 *
 * @package   phpMyFAQ
 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 */

/* Same families, weights and axes the HR Analytics app requests. */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Hanken+Grotesk:wght@400;500;600;700&family=Spline+Sans+Mono:wght@400;500;600&display=swap');

/* Retained from the stock theme: high-contrast a11y mode depends on it. */
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../../fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf') format('truetype-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  src: url('../../fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf') format('truetype-variations');
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

/* ------------------------------------------------------------------ *
 * Brand tokens — copied from the HR Analytics app, not re-invented.
 * ------------------------------------------------------------------ */

:root {
  --hra-brand: #c73e5a;
  --hra-brand-strong: #a52f46;
  --hra-brand-soft: #fce8ec;
  --hra-brand-contrast: #fffdf8;

  --hra-mark-gold: #ecb23b;
  --hra-mark-rose: #d9536e;
  --hra-mark-plum: #765073;

  --hra-ink-900: #2b2018;
  --hra-ink-700: #4a3c30;
  --hra-ink-500: #6b5c4d;
  --hra-ink-400: #8c7d6d;

  --hra-paper-0: #fffcf9;
  --hra-paper-50: #fbf6f1;
  --hra-paper-100: #f5eee6;
  --hra-paper-200: #eae0d4;
  --hra-paper-300: #e0d3c3;

  --hra-shadow-sm: 0 2px 6px rgb(74 47 30 / 8%);
  --hra-shadow-md: 0 6px 18px rgb(74 47 30 / 10%);

  --hra-font-display: Fraunces, 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --hra-font-body: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --hra-font-mono: 'Spline Sans Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ------------------------------------------------------------------ *
 * Light mode
 * ------------------------------------------------------------------ */

:root,
[data-bs-theme='light'] {
  --bs-primary: var(--hra-brand);
  --bs-primary-rgb: 199, 62, 90;
  --bs-secondary: var(--hra-ink-500);
  --bs-info: var(--hra-mark-plum);
  --bs-success: #4a6b2f;
  --bs-warning: var(--hra-mark-gold);
  --bs-danger: var(--hra-brand-strong);
  --bs-light: var(--hra-paper-100);
  --bs-dark: var(--hra-ink-900);

  --bs-pmf-nav: var(--hra-ink-900);
  --bs-pmf-footer: var(--hra-ink-700);
  --bs-pmf-background: var(--hra-paper-100);

  --bs-body-bg: var(--hra-paper-50);
  --bs-body-color: var(--hra-ink-900);
  --bs-secondary-color: var(--hra-ink-500);
  --bs-border-color: var(--hra-paper-200);
  --bs-border-radius: 6px;

  --bs-link-color: var(--hra-brand);
  --bs-link-hover-color: var(--hra-brand-strong);
  --bs-link-color-rgb: 199, 62, 90;

  --bs-emphasis-color: var(--hra-ink-900);
  --bs-tertiary-bg: var(--hra-paper-100);
  --bs-secondary-bg: var(--hra-paper-100);

  /* RGB twins — Bootstrap's .text-bg-* and rgba() utilities read these, not the
     hex vars above. Missing them is why surfaces stay grey. */
  --bs-body-bg-rgb: 251, 246, 241;
  --bs-light-rgb: 245, 238, 230;
  --bs-dark-rgb: 43, 32, 24;
  --bs-secondary-rgb: 107, 92, 77;

  /* phpMyFAQ's own token layer, which sits underneath Bootstrap's. The page
     background and every surface come from here. */
  --pmf-bg: var(--hra-paper-50);
  --pmf-surface: var(--hra-paper-0);
  --pmf-surface-hover: var(--hra-paper-100);
  --pmf-surface-raised: #ffffff;
  --pmf-border: var(--hra-paper-200);
  --pmf-border-strong: var(--hra-paper-300);
  --pmf-accent: var(--hra-brand);
  --pmf-accent-2: var(--hra-mark-plum);
  --pmf-accent-subtle: rgb(199 62 90 / 10%);
  --pmf-focus-ring: rgb(199 62 90 / 45%);

  --pmf-radius-sm: 4px;
  --pmf-radius: 6px;
  --pmf-radius-lg: 10px;
  --pmf-radius-xl: 14px;

  --pmf-shadow-sm: var(--hra-shadow-sm);
  --pmf-shadow-md: var(--hra-shadow-md);
  --pmf-shadow-lg: 0 12px 32px rgb(74 47 30 / 12%), 0 4px 10px rgb(74 47 30 / 8%);
}

/* ------------------------------------------------------------------ *
 * Dark mode — same hues, inverted lightness. Stays warm, never grey.
 * ------------------------------------------------------------------ */

[data-bs-theme='dark'] {
  --bs-primary: #e8637f;
  --bs-primary-rgb: 232, 99, 127;
  --bs-secondary: var(--hra-ink-400);
  --bs-info: #a17c9e;
  --bs-success: #8bab68;
  --bs-warning: var(--hra-mark-gold);
  --bs-danger: #e8637f;
  --bs-light: var(--hra-paper-50);
  --bs-dark: #1a120d;

  --bs-pmf-nav: #1a120d;
  --bs-pmf-footer: #1a120d;
  --bs-pmf-background: #241a14;

  --bs-body-bg: #1f1610;
  --bs-body-color: var(--hra-paper-100);
  --bs-secondary-color: #b9a894;
  --bs-border-color: #3a2c22;
  --bs-border-radius: 6px;

  --bs-link-color: #f08ba1;
  --bs-link-hover-color: #f6b3c2;
  --bs-link-color-rgb: 240, 139, 161;

  --bs-emphasis-color: #fffcf9;
  --bs-tertiary-bg: #241a14;
  --bs-secondary-bg: #241a14;

  --bs-body-bg-rgb: 31, 22, 16;
  --bs-light-rgb: 251, 246, 241;
  --bs-dark-rgb: 26, 18, 13;
  --bs-secondary-rgb: 140, 125, 109;

  --pmf-bg: #1f1610;
  --pmf-surface: #241a14;
  --pmf-surface-hover: #2e2119;
  --pmf-surface-raised: #2e2119;
  --pmf-border: #3a2c22;
  --pmf-border-strong: #4a3a2e;
  --pmf-accent: #e8637f;
  --pmf-accent-2: #a17c9e;
  --pmf-accent-subtle: rgb(232 99 127 / 16%);
  --pmf-focus-ring: rgb(232 99 127 / 50%);

  --pmf-radius-sm: 4px;
  --pmf-radius: 6px;
  --pmf-radius-lg: 10px;
  --pmf-radius-xl: 14px;

  --pmf-shadow-sm: 0 1px 3px rgb(0 0 0 / 45%);
  --pmf-shadow-md: 0 6px 18px rgb(0 0 0 / 50%);
  --pmf-shadow-lg: 0 14px 36px rgb(0 0 0 / 55%);
}

/* ------------------------------------------------------------------ *
 * High contrast — accessibility mode, deliberately NOT re-branded.
 * Brand colour would defeat the purpose of this mode.
 * ------------------------------------------------------------------ */

[data-bs-theme='high-contrast'] {
  --bs-light: #ffffff;
  --bs-dark: #000000;
  --bs-primary: #ffff00;
  --bs-secondary: #00ffff;
  --bs-info: #00ffff;
  --bs-success: #00ff00;
  --bs-warning: #ffff00;
  --bs-danger: #ff0000;
  --bs-pmf-nav: #000000;
  --bs-pmf-footer: #000000;
  --bs-pmf-background: #000000;

  --bs-body-bg: #000000;
  --bs-body-color: #ffffff;
  --bs-border-color: #ffffff;
  --bs-link-color: #ffff00;
  --bs-link-hover-color: #ffff66;

  body {
    font-family: 'Atkinson Hyperlegible Next' !important;
    font-size: 1.3rem;
    font-optical-sizing: auto;
    font-weight: 800;
    font-style: normal;
  }
}

/* ------------------------------------------------------------------ *
 * Typography
 * ------------------------------------------------------------------ */

body {
  font-family: var(--hra-font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
  font-family: var(--hra-font-display);
  font-optical-sizing: auto;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--bs-emphasis-color);
}

h1,
.h1 {
  font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.6rem);
  line-height: 1.15;
}

h2,
.h2 {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 1.95rem);
  line-height: 1.2;
}

h3,
.h3 {
  font-size: 1.35rem;
}

code,
kbd,
pre,
samp,
.font-monospace {
  font-family: var(--hra-font-mono);
  font-size: 0.9em;
}

code:not(pre code) {
  padding: 0.15em 0.4em;
  color: var(--hra-brand-strong);
  background-color: var(--hra-brand-soft);
  border-radius: 4px;
}

[data-bs-theme='dark'] code:not(pre code) {
  color: #f6b3c2;
  background-color: rgb(199 62 90 / 18%);
}

/* ------------------------------------------------------------------ *
 * Navbar — the mark sits against ink-900, wordmark set in Fraunces.
 * ------------------------------------------------------------------ */

.navbar.text-bg-pmf-nav {
  background-color: var(--bs-pmf-nav) !important;
  border-bottom: 1px solid rgb(236 178 59 / 22%) !important;
  box-shadow: var(--hra-shadow-sm);
}

.navbar-brand {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
}

.navbar-brand .pmf-brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
}

.navbar-brand .pmf-brand-name {
  font-family: var(--hra-font-display);
  font-size: 1.28rem;
  font-weight: 600;
  color: var(--hra-paper-0);
  letter-spacing: -0.015em;
}

.pmf-nav-link {
  font-weight: 500;
  color: rgb(255 252 249 / 82%);
  border-radius: 5px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.pmf-nav-link:hover,
.pmf-nav-link:focus-visible {
  color: var(--hra-mark-gold);
  background-color: rgb(255 252 249 / 8%);
}

/* ------------------------------------------------------------------ *
 * Surfaces — cards, list groups, wells
 * ------------------------------------------------------------------ */

.card,
.list-group-item,
.accordion-item {
  background-color: var(--hra-paper-0);
  border-color: var(--bs-border-color);
}

[data-bs-theme='dark'] .card,
[data-bs-theme='dark'] .list-group-item,
[data-bs-theme='dark'] .accordion-item {
  background-color: #241a14;
}

.card {
  border-radius: 8px;
  box-shadow: var(--hra-shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  box-shadow: var(--hra-shadow-md);
}

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

.btn {
  font-weight: 500;
  border-radius: 6px;
}

.btn-primary {
  --bs-btn-bg: var(--hra-brand);
  --bs-btn-border-color: var(--hra-brand);
  --bs-btn-color: var(--hra-brand-contrast);
  --bs-btn-hover-bg: var(--hra-brand-strong);
  --bs-btn-hover-border-color: var(--hra-brand-strong);
  --bs-btn-hover-color: var(--hra-brand-contrast);
  --bs-btn-active-bg: var(--hra-brand-strong);
  --bs-btn-active-border-color: var(--hra-brand-strong);
}

.btn-outline-primary {
  --bs-btn-color: var(--hra-brand);
  --bs-btn-border-color: var(--hra-brand);
  --bs-btn-hover-bg: var(--hra-brand);
  --bs-btn-hover-border-color: var(--hra-brand);
  --bs-btn-hover-color: var(--hra-brand-contrast);
}

/* ------------------------------------------------------------------ *
 * Forms — 6px radius and the brand focus ring from the source app.
 * ------------------------------------------------------------------ */

.form-control,
.form-select {
  background-color: var(--hra-paper-0);
  border-color: var(--hra-paper-200);
  border-radius: 6px;
}

[data-bs-theme='dark'] .form-control,
[data-bs-theme='dark'] .form-select {
  background-color: #241a14;
  border-color: #3a2c22;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--hra-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hra-brand) 30%, transparent);
}

/* Keyboard focus must stay visible everywhere, not just in forms. */
a:focus-visible,
.btn:focus-visible,
.pmf-nav-link:focus-visible {
  outline: 2px solid var(--hra-mark-gold);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Footer
 * ------------------------------------------------------------------ */

footer.text-bg-pmf-footer,
.text-bg-pmf-footer {
  color: var(--hra-paper-100) !important;
  background-color: var(--bs-pmf-footer) !important;
  border-top: 1px solid rgb(236 178 59 / 22%);
}

.text-bg-pmf-footer a {
  color: var(--hra-paper-200);
  text-decoration-color: rgb(236 178 59 / 55%);
}

.text-bg-pmf-footer a:hover {
  color: var(--hra-mark-gold);
}

/* Minimal footer: a closing rule, not a slab. Sized to its one line of content
   instead of keeping the tall multi-column padding it no longer fills. */
.pmf-footer-minimal {
  padding-block: 1.1rem;
  margin-top: 3rem;
}

.pmf-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.pmf-footer-brand {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-family: var(--hra-font-display);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--hra-paper-50);
}

.pmf-footer-brand img {
  opacity: 0.9;
}

.pmf-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  align-items: center;
  justify-content: center;
}

.pmf-footer-links a {
  font-size: 0.9rem;
  color: var(--hra-paper-200);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.pmf-footer-links a:hover,
.pmf-footer-links a:focus-visible {
  color: var(--hra-mark-gold);
  border-bottom-color: var(--hra-mark-gold);
}

/* Current page: marked with the gold rule rather than a colour change alone. */
.pmf-footer-links a.active {
  color: var(--hra-mark-gold);
  border-bottom-color: rgb(236 178 59 / 45%);
}

.pmf-footer-year {
  font-size: 0.85rem;
  color: var(--hra-paper-200);
  opacity: 0.75;
}

@media (max-width: 48rem) {
  .pmf-footer-inner {
    flex-direction: column;
    gap: 0.85rem;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pmf-footer-links a {
    transition: none;
  }
}

/* ------------------------------------------------------------------ *
 * Start-page heading — stock phpMyFAQ fills it with a primary→secondary
 * gradient. Secondary is a muted brown here, which reads as a smudge, so
 * the gradient runs brand → plum: both are colours from the mark itself.
 * ------------------------------------------------------------------ */

.pmf-start-page,
.pmf-start-page.h1 {
  font-family: var(--hra-font-display);
  font-size: clamp(2rem, 1.4rem + 2.2vw, 2.9rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  background: linear-gradient(105deg, var(--hra-brand) 0%, var(--hra-mark-plum) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ------------------------------------------------------------------ *
 * Cover cards — the stock overlay is a black scrim intended for cards
 * with photographic backgrounds. Without an image it greys out the warm
 * palette, so it becomes a soft brand-tinted wash instead.
 * ------------------------------------------------------------------ */

.card-cover {
  background-color: var(--hra-paper-100);
  border: 1px solid var(--hra-paper-200);
  border-radius: var(--pmf-radius-lg);
}

/* Must match the stock selector's specificity: styles.css ships
   `.card.card-cover:after`, so `.card-cover:after` alone never wins. */
.card.card-cover:after {
  background: linear-gradient(180deg, rgb(199 62 90 / 0%) 45%, rgb(74 47 30 / 14%) 100%);
}

.card-cover .card-title,
.card-cover h2,
.card-cover h3 {
  font-family: var(--hra-font-display);
  color: var(--hra-ink-900);
}

[data-bs-theme='dark'] .card-cover {
  background-color: #2e2119;
  border-color: #3a2c22;
}

[data-bs-theme='dark'] .card-cover .card-title,
[data-bs-theme='dark'] .card-cover h2,
[data-bs-theme='dark'] .card-cover h3 {
  color: var(--hra-paper-50);
}

/* ------------------------------------------------------------------ *
 * Login page — standalone, no navigation, search or footer.
 * The card is the only thing on the page, so it centres in the viewport
 * rather than sitting under a header.
 * ------------------------------------------------------------------ */

.pmf-login-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.pmf-login-panel {
  width: 100%;
  max-width: 25rem;
}

.pmf-login-brand {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  font-family: var(--hra-font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--hra-ink-900);
  letter-spacing: -0.015em;
}

[data-bs-theme='dark'] .pmf-login-brand {
  color: var(--hra-paper-50);
}

.pmf-login-page .card {
  background-color: var(--hra-paper-0);
  border: 1px solid var(--hra-paper-200);
  box-shadow: var(--hra-shadow-md);
}

[data-bs-theme='dark'] .pmf-login-page .card {
  background-color: #241a14;
  border-color: #3a2c22;
}

.pmf-login-page .card-header h1 {
  font-family: var(--hra-font-display);
  font-weight: 600;
}

/* Short viewports: let the page scroll instead of clipping the card. */
@media (max-height: 44rem) {
  .pmf-login-shell {
    align-items: flex-start;
  }
}

/* ------------------------------------------------------------------ *
 * Odds and ends
 * ------------------------------------------------------------------ */

.badge.bg-primary {
  background-color: var(--hra-brand) !important;
}

.table {
  --bs-table-border-color: var(--bs-border-color);
}

.table > thead {
  font-family: var(--hra-font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--hra-ink-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-bs-theme='dark'] .table > thead {
  color: #b9a894;
}

blockquote {
  padding-left: 1rem;
  border-left: 3px solid var(--hra-mark-gold);
}

hr {
  border-top-color: var(--bs-border-color);
  opacity: 1;
}

::selection {
  color: var(--hra-ink-900);
  background: var(--hra-brand-soft);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .pmf-nav-link {
    transition: none;
  }
}
