/* ==========================================================================
   base.css — shared design system for the generated rulebook pages
   Design tokens, self-hosted fonts, dark mode, and shared components
   (header, footer, typography, buttons, back-to-top).
   NOTE: the token block below is kept identical to the one in the root
   /style.css. If you change a token here, mirror it there.
   ========================================================================== */

/* ---- Self-hosted fonts (Inter) — no external CDN, GDPR-friendly ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/inter-700.woff2") format("woff2");
}

/* ---- Design tokens ------------------------------------------------------- */
:root {
  color-scheme: light dark;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Brand */
  --accent: #dd5533;
  --accent-hover: #b8421f;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(221, 85, 51, 0.10);
  --link: #c1421d;
  --link-hover: #8f2f13;

  /* Surfaces & text */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1c2024;
  --text-muted: #5b6470;
  --border: #e3e6ea;
  --border-strong: #cfd4da;

  /* Header / footer (dark in both themes) */
  --header-bg: #24282c;
  --header-text: #ffffff;
  --header-accent: var(--accent);

  /* Shape & depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 24, 0.06), 0 1px 3px rgba(16, 20, 24, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 20, 24, 0.08), 0 2px 4px rgba(16, 20, 24, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 20, 24, 0.14);

  /* Layout */
  --content-max: 960px;
  --header-h: 84px;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #e56340;
    --accent-hover: #f47c5b;
    --accent-contrast: #ffffff;
    --accent-soft: rgba(229, 99, 64, 0.16);
    --link: #ff8a66;
    --link-hover: #ffab90;

    --bg: #121417;
    --surface: #1b1e22;
    --surface-2: #23272c;
    --text: #e7eaee;
    --text-muted: #9aa3ad;
    --border: #2b3037;
    --border-strong: #3a4048;

    --header-bg: #0f1113;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-sans);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; }

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Shared centered content wrapper */
.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Typography ---------------------------------------------------------- */
h1, h2, h3 {
  color: var(--accent);
  line-height: 1.25;
  font-weight: 700;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}

/* ---- Header -------------------------------------------------------------- */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--header-bg);
  color: var(--header-text);
  border-bottom: 3px solid var(--header-accent);
  box-shadow: var(--shadow-sm);
}

header.site-header .content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

header.site-header #home_ref {
  color: var(--header-text);
  display: inline-flex;
  flex-direction: column;
  line-height: 1.15;
}

header.site-header #header_title {
  display: block;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header.site-header #header_subtitle {
  font-size: 1rem;
  font-weight: 500;
  color: #c9ccd0;
}

header.site-header .brand-logo img {
  height: 3.1em;
  display: block;
}

/* ---- Footer -------------------------------------------------------------- */
footer.site-footer {
  margin-top: var(--space-8);
  padding: var(--space-5) 0;
  background-color: var(--header-bg);
  color: var(--header-text);
  text-align: center;
  border-top: 3px solid var(--header-accent);
}

footer.site-footer .content {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

footer.site-footer a {
  color: var(--link);
  font-weight: 500;
}
footer.site-footer a:hover { color: var(--link-hover); }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }

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

.btn-secondary {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

/* ---- Icon buttons in headings (copy link / open in new) ------------------ */
.h_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.h_button img {
  height: 1.05rem;
  /* Recolor the black SVG icons to the muted text color */
  filter: invert(41%) sepia(9%) saturate(410%) hue-rotate(169deg) brightness(92%) contrast(88%);
}
.h_button:hover {
  background-color: var(--accent-soft);
}
.h_button:hover img {
  /* Recolor to brand accent on hover */
  filter: invert(46%) sepia(66%) saturate(1000%) hue-rotate(333deg) brightness(90%) contrast(89%);
}

@media (prefers-color-scheme: dark) {
  .h_button img {
    filter: invert(72%) sepia(8%) saturate(340%) hue-rotate(178deg) brightness(92%) contrast(87%);
  }
  .h_button:hover img {
    filter: invert(55%) sepia(52%) saturate(900%) hue-rotate(330deg) brightness(97%) contrast(90%);
  }
}

/* ---- Back-to-top button -------------------------------------------------- */
#navTopBtn {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 60;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
#navTopBtn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
}
#navTopBtn img {
  height: 1.4rem;
  /* white arrow */
  filter: brightness(0) invert(1);
}
