/**
 * Any CSS included here will be global. The classic template
 * bundles Infima by default. Infima is a CSS framework designed to
 * work well for content-centric websites.
 */

/* ── EntityRef component ──────────────────────────────────────── */

/* The link wrapping the entity name */
.entity-ref {
  text-decoration: none;
  color: inherit;
  border-bottom: 1.5px dotted var(--ifm-color-primary);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.entity-ref:hover {
  border-bottom-style: solid;
  color: var(--ifm-color-primary);
  text-decoration: none;
}

/* Small arrow indicator after the name */
.entity-ref::after {
  content: '\2197'; /* ↗ */
  display: inline-block;
  font-size: 0.6em;
  vertical-align: super;
  margin-left: 0.15em;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.entity-ref:hover::after {
  opacity: 1;
}

/* Inside tables, keep the indicator subtle */
td .entity-ref::after {
  font-size: 0.55em;
}

/* ── EntitySearch component ────────────────────────────────────── */

.entity-search {
  position: sticky;
  top: calc(var(--ifm-navbar-height) + 0.5rem);
  z-index: 10;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--ifm-background-surface-color);
  border: 1px solid var(--ifm-color-emphasis-200);
  border-radius: var(--ifm-global-radius);
  box-shadow: var(--ifm-global-shadow-md);
  backdrop-filter: blur(12px);
}

[data-theme='dark'] .entity-search {
  background: rgba(36, 36, 36, 0.92);
  border-color: var(--ifm-color-emphasis-300);
}

.entity-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.entity-search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--ifm-color-emphasis-500);
  pointer-events: none;
  flex-shrink: 0;
}

.entity-search-input {
  width: 100%;
  padding: 0.6rem 2.5rem 0.6rem 2.5rem;
  border: 1.5px solid var(--ifm-color-emphasis-300);
  border-radius: calc(var(--ifm-global-radius) - 2px);
  background: var(--ifm-background-color);
  color: var(--ifm-font-color-base);
  font-size: 0.95rem;
  font-family: var(--ifm-font-family-base);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.entity-search-input::placeholder {
  color: var(--ifm-color-emphasis-500);
}

.entity-search-input:focus {
  border-color: var(--ifm-color-primary);
  box-shadow: 0 0 0 3px rgba(0, 185, 231, 0.15);
}

[data-theme='dark'] .entity-search-input:focus {
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.entity-search-clear {
  position: absolute;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--ifm-color-emphasis-200);
  color: var(--ifm-color-emphasis-700);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.entity-search-clear:hover {
  background: var(--ifm-color-emphasis-300);
  color: var(--ifm-color-emphasis-900);
}

.entity-search-status {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--ifm-color-emphasis-600);
  padding-left: 0.25rem;
}

.entity-search-no-results {
  color: var(--ifm-color-danger);
}

/* ── Results dropdown ─────────────────────────────────────────── */

.entity-search-results-container {
  margin-top: 0.5rem;
}

.entity-search-results {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  max-height: 24rem;
  overflow-y: auto;
  border: 1px solid var(--ifm-color-emphasis-200);
  border-radius: calc(var(--ifm-global-radius) - 2px);
  background: var(--ifm-background-color);
}

[data-theme='dark'] .entity-search-results {
  border-color: var(--ifm-color-emphasis-300);
}

.entity-search-result-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s ease;
  flex-wrap: wrap;
}

.entity-search-result-item:hover,
.entity-search-result-item.active {
  background: var(--ifm-color-primary-lightest);
  color: var(--ifm-font-color-base);
}

[data-theme='dark'] .entity-search-result-item:hover,
[data-theme='dark'] .entity-search-result-item.active {
  background: rgba(0, 212, 255, 0.12);
}

.entity-search-result-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.entity-search-result-key {
  font-size: 0.75rem;
  opacity: 0.6;
  white-space: nowrap;
}

.entity-search-result-translation {
  font-size: 0.8rem;
  color: var(--ifm-color-emphasis-600);
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

.entity-search-more {
  color: var(--ifm-color-emphasis-500);
}

/* ── Jump highlight (triggered by clicking a result) ──────────── */

tr.entity-search-jump-highlight {
  animation: entity-jump-flash 1.8s ease forwards;
}

@keyframes entity-jump-flash {
  0%   { background-color: rgba(0, 185, 231, 0.45); }
  30%  { background-color: rgba(0, 185, 231, 0.25); }
  100% { background-color: rgba(0, 185, 231, 0.13); }
}

[data-theme='dark'] tr.entity-search-jump-highlight {
  animation: entity-jump-flash-dark 1.8s ease forwards;
}

@keyframes entity-jump-flash-dark {
  0%   { background-color: rgba(0, 212, 255, 0.40); }
  30%  { background-color: rgba(0, 212, 255, 0.20); }
  100% { background-color: rgba(0, 212, 255, 0.13); }
}

/* Row filtering states */
tr.entity-search-hidden {
  opacity: 0.08;
  transition: opacity 0.2s ease;
}

tr.entity-search-match {
  transition: opacity 0.2s ease;
}

/* Dim sections with no matches */
.entity-search-section-hidden {
  opacity: 0.15;
  transition: opacity 0.2s ease;
}

/* ── Filter chips ─────────────────────────────────────────────── */

.entity-search-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  align-items: center;
}

.entity-search-chip {
  padding: 0.25rem 0.7rem;
  border: 1.5px solid var(--ifm-color-emphasis-300);
  border-radius: 2rem;
  background: transparent;
  color: var(--ifm-color-emphasis-700);
  font-size: 0.8rem;
  font-family: var(--ifm-font-family-base);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.entity-search-chip:hover {
  border-color: var(--ifm-color-primary);
  color: var(--ifm-color-primary);
  background: rgba(0, 185, 231, 0.06);
}

.entity-search-chip.active {
  border-color: var(--ifm-color-primary);
  background: var(--ifm-color-primary);
  color: white;
}

[data-theme='dark'] .entity-search-chip.active {
  background: var(--ifm-color-primary-dark);
}

.entity-search-shortcut-hint {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--ifm-color-emphasis-400);
  white-space: nowrap;
}

.entity-search-shortcut-hint kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--ifm-color-emphasis-300);
  border-radius: 0.25rem;
  background: var(--ifm-color-emphasis-100);
  font-family: var(--ifm-font-family-monospace);
  font-size: 0.75rem;
  color: var(--ifm-color-emphasis-600);
  line-height: 1.4;
  vertical-align: baseline;
}

/* ── Copy entity ID button ────────────────────────────────────── */

.entity-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-left: 0.35rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--ifm-color-emphasis-400);
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  vertical-align: middle;
}

tr:hover .entity-copy-btn {
  opacity: 1;
}

/* Always visible on touch devices (no hover) */
@media (hover: none) {
  .entity-copy-btn {
    opacity: 0.6;
  }
}

.entity-copy-btn:hover {
  background: var(--ifm-color-emphasis-200);
  color: var(--ifm-color-emphasis-700);
}

.entity-copy-btn.copied {
  color: var(--ifm-color-success);
  opacity: 1;
}

/* ── Doc back-links ───────────────────────────────────────────── */

.entity-back-links {
  margin-left: 0.25rem;
  white-space: nowrap;
}

.entity-back-link {
  display: inline-block;
  font-size: 0.7rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  margin-left: 0.1rem;
  vertical-align: middle;
}

tr:hover .entity-back-link {
  opacity: 0.7;
}

.entity-back-link:hover {
  opacity: 1 !important;
}

@media (hover: none) {
  .entity-back-link {
    opacity: 0.5;
  }
}

/* ── Match highlighting ──────────────────────────────────────── */

mark.entity-match {
  background-color: rgba(255, 184, 0, 0.35);
  color: inherit;
  padding: 0.05em 0.1em;
  border-radius: 2px;
}

[data-theme='dark'] mark.entity-match {
  background-color: rgba(255, 184, 0, 0.3);
}

/* ── Mobile responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  .entity-search {
    position: relative;
    top: auto;
  }

  .entity-search-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.2rem;
  }

  .entity-search-shortcut-hint {
    display: none;
  }

  .entity-search-results {
    max-height: 16rem;
  }
}

/* ── Sensor-reference :target highlighting ────────────────────── */

/* Scroll offset so the targeted row isn't hidden behind the navbar */
.entity-anchor {
  scroll-margin-top: 5rem;
}

/* Highlight the table row that was navigated to (stays visible) */
tr:has(.entity-anchor:target) {
  animation: entity-highlight-pulse 2s ease forwards;
}

@keyframes entity-highlight-pulse {
  0%   { background-color: rgba(0, 185, 231, 0.35); }
  100% { background-color: rgba(0, 185, 231, 0.13); }
}

[data-theme='dark'] tr:has(.entity-anchor:target) {
  animation: entity-highlight-pulse-dark 2s ease forwards;
}

@keyframes entity-highlight-pulse-dark {
  0%   { background-color: rgba(0, 212, 255, 0.30); }
  100% { background-color: rgba(0, 212, 255, 0.13); }
}

/* Smooth scrolling for anchor navigation */
html {
  scroll-behavior: smooth;
}

/* Modern font stack */
:root {
  --ifm-font-family-base: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ifm-heading-font-family: 'Space Grotesk', var(--ifm-font-family-base);
  --ifm-font-family-monospace: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* Tibber-inspired electric color scheme */
:root {
  /* Primary: Electric blue */
  --ifm-color-primary: #00b9e7;
  --ifm-color-primary-dark: #00a7d0;
  --ifm-color-primary-darker: #009ec4;
  --ifm-color-primary-darkest: #0082a2;
  --ifm-color-primary-light: #00cbfe;
  --ifm-color-primary-lighter: #19d1ff;
  --ifm-color-primary-lightest: #4dddff;

  /* Accent: Energy green */
  --ifm-color-success: #00ffa3;

  /* Warning: Price orange */
  --ifm-color-warning: #ffb800;

  --ifm-code-font-size: 95%;
  --docusaurus-highlighted-code-line-bg: rgba(0, 185, 231, 0.1);

  /* Modern border radius */
  --ifm-global-radius: 0.75rem;
  --ifm-button-border-radius: 0.75rem;
  --ifm-card-border-radius: 1rem;
  --ifm-code-border-radius: 0.5rem;

  /* Subtle shadows for depth */
  --ifm-global-shadow-lw: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --ifm-global-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --ifm-global-shadow-tl: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Hero background gradient */
  --ifm-hero-background-color: linear-gradient(135deg, #00b9e7 0%, #00ffa3 100%);
}

/* Dark mode with electric theme */
[data-theme='dark'] {
  --ifm-color-primary: #00d4ff;
  --ifm-color-primary-dark: #00c0e6;
  --ifm-color-primary-darker: #00b5d9;
  --ifm-color-primary-darkest: #0095b3;
  --ifm-color-primary-light: #19ddff;
  --ifm-color-primary-lighter: #33e1ff;
  --ifm-color-primary-lightest: #66e9ff;

  /* Accent: Brighter green in dark mode */
  --ifm-color-success: #00ffb3;

  --docusaurus-highlighted-code-line-bg: rgba(0, 212, 255, 0.15);

  /* Darker background for better contrast */
  --ifm-background-color: #1a1a1a;
  --ifm-background-surface-color: #242424;

  /* Darker shadows for dark mode */
  --ifm-global-shadow-lw: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --ifm-global-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --ifm-global-shadow-tl: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Hero section styling */
.hero--primary {
  background: linear-gradient(135deg, #00b9e7 0%, #0099cc 50%, #ffb800 100%);
  color: white;
  position: relative;
  padding: 4rem 0 6rem 0;
}

.hero--primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(0, 185, 231, 0.95) 0%, rgba(0, 153, 204, 0.95) 50%, rgba(255, 184, 0, 0.85) 100%);
  z-index: 0;
}

.hero--primary .container {
  position: relative;
  z-index: 1;
}

[data-theme='dark'] .hero--primary {
  background: linear-gradient(135deg, #00506b 0%, #003d52 50%, #665000 100%);
}

[data-theme='dark'] .hero--primary::before {
  background: linear-gradient(135deg, rgba(0, 80, 107, 0.95) 0%, rgba(0, 61, 82, 0.95) 50%, rgba(102, 80, 0, 0.85) 100%);
}

/* Unreleased version banner styling */
[data-theme='light'] .theme-doc-version-banner {
  background-color: #fff4e6;
  border-color: #ffb800;
}

[data-theme='dark'] .theme-doc-version-banner {
  background-color: #2d2000;
  border-color: #ffb800;
}

/* Make code blocks stand out */
.docusaurus-highlight-code-line {
  background-color: rgba(0, 185, 231, 0.2);
  display: block;
  margin: 0 calc(-1 * var(--ifm-pre-padding));
  padding: 0 var(--ifm-pre-padding);
}

[data-theme='dark'] .docusaurus-highlight-code-line {
  background-color: rgba(0, 212, 255, 0.2);
}

/* Sidebar customization */
.theme-doc-sidebar-container {
  border-right: 1px solid var(--ifm-toc-border-color);
}

/* Table of contents highlighting */
.table-of-contents__link--active {
  color: var(--ifm-color-primary);
  font-weight: bold;
}

/* Admonition styling */
.admonition {
  border-left-width: 4px;
}

.admonition-note {
  border-left-color: var(--ifm-color-primary);
}

.admonition-tip {
  border-left-color: var(--ifm-color-success);
}

.admonition-warning {
  border-left-color: var(--ifm-color-warning);
}

/* Features section on homepage */
.features {
  padding: 4rem 0;
}

.features h3 {
  color: var(--ifm-color-primary);
}

[data-theme='dark'] .features h3 {
  color: var(--ifm-color-primary-lighter);
}

/* Card styling with modern shadows */
.card {
  border-radius: var(--ifm-card-border-radius);
  box-shadow: var(--ifm-global-shadow-md);
  transition: box-shadow 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.card:hover {
  box-shadow: var(--ifm-global-shadow-tl);
  transform: translateY(-2px);
}

/* Navbar with subtle shadow */
.navbar {
  box-shadow: var(--ifm-global-shadow-lw);
}

/* Code blocks with modern styling */
code {
  border-radius: var(--ifm-code-border-radius);
}

/* Buttons with modern feel */
.button {
  font-weight: 600;
  letter-spacing: 0.025em;
  transition: all 0.2s ease-in-out;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--ifm-global-shadow-md);
}

/* Headings with Space Grotesk */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--ifm-heading-font-family);
  letter-spacing: -0.02em;
}

/* Smooth transitions everywhere */
* {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Buy Me a Coffee logo theme switching */
.bmc-logo-dark {
  display: none;
}

[data-theme='dark'] .bmc-logo-light {
  display: none;
}

[data-theme='dark'] .bmc-logo-dark {
  display: block;
}

/* ── Mermaid diagram zoom / lightbox ──────────────────────────── */

/* Wrapper — entire diagram is the click target */
.mermaid-zoom-wrapper {
  position: relative;
  display: block;
  cursor: zoom-in;
  border-radius: var(--ifm-card-border-radius, 0.5rem);
  /* Clip the hover overlay to the same rounded corners */
  overflow: hidden;
  /* Solid background so the SVG is never transparent against the page */
  background: var(--ifm-background-color);
}

/* Ensure the SVG itself also has a solid background (covers Mermaid inline styles) */
.mermaid-zoom-wrapper svg {
  display: block;
  background: var(--ifm-background-color);
  border-radius: inherit;
}

/* Semi-transparent tint that fades in on hover */
.mermaid-zoom-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  background: rgba(0, 0, 0, 0);
  transition: opacity 0.2s ease, background 0.2s ease;
  z-index: 1;
}

.mermaid-zoom-wrapper:hover .mermaid-zoom-hint,
.mermaid-zoom-wrapper:focus-visible .mermaid-zoom-hint {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

[data-theme='dark'] .mermaid-zoom-wrapper:hover .mermaid-zoom-hint,
[data-theme='dark'] .mermaid-zoom-wrapper:focus-visible .mermaid-zoom-hint {
  background: rgba(255, 255, 255, 0.06);
}

/* Centered pill badge inside the tint */
.mermaid-zoom-hint-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  background: var(--ifm-background-surface-color);
  border: 1px solid var(--ifm-color-emphasis-300);
  border-radius: 2rem;
  color: var(--ifm-color-emphasis-800);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  transform: translateY(4px);
  transition: transform 0.2s ease;
}

.mermaid-zoom-wrapper:hover .mermaid-zoom-hint-badge,
.mermaid-zoom-wrapper:focus-visible .mermaid-zoom-hint-badge {
  transform: translateY(0);
}

/* Focus ring for keyboard users */
.mermaid-zoom-wrapper:focus-visible {
  outline: 2px solid var(--ifm-color-primary);
  outline-offset: 2px;
}

/* Touch devices: no hover state — show badge permanently so users know it's tappable */
@media (hover: none) {
  .mermaid-zoom-hint {
    opacity: 1;
    background: transparent;
  }

  .mermaid-zoom-hint-badge {
    transform: translateY(0);
    /* Slightly more opaque so it reads well without hover context */
    opacity: 0.85;
  }
}

/* Full-screen backdrop */
.mermaid-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
  animation: mermaid-fadein 0.15s ease;
}

@keyframes mermaid-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* The white/dark card containing the diagram */
.mermaid-lightbox-inner {
  position: relative;
  width: min(90vw, 1200px);
  max-height: 85vh;
  overflow: auto;
  padding: 1.5rem;
  background: var(--ifm-background-color);
  border-radius: var(--ifm-card-border-radius);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  cursor: default;
  animation: mermaid-scalein 0.15s ease;
}

@keyframes mermaid-scalein {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.mermaid-lightbox-inner > svg {
  display: block;
  width: 100%;
  height: auto;
  /* !important: overrides any inline background Mermaid bakes into the SVG */
  background: var(--ifm-background-color) !important;
  border-radius: calc(var(--ifm-card-border-radius, 0.5rem) - 2px);
}

/*
 * Override Mermaid's hardcoded background rects.
 * Mermaid uses several class names depending on diagram type and version:
 *   .background  — sequence diagrams
 *   .bb          — class/state diagrams
 * The first <rect> child is used as a background fill by all diagram types.
 */
.mermaid-lightbox-inner svg .background,
.mermaid-lightbox-inner svg .bb,
.mermaid-lightbox-inner svg > rect:first-child {
  fill: var(--ifm-background-color) !important;
}

/* Close button (top-right corner of the card) */
.mermaid-lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: var(--ifm-background-surface-color);
  border: 1px solid var(--ifm-color-emphasis-300);
  border-radius: 0.4rem;
  color: var(--ifm-color-emphasis-700);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mermaid-lightbox-close:hover {
  background: var(--ifm-color-danger);
  border-color: var(--ifm-color-danger);
  color: #fff;
}
