/*
  WestabyElectronics Tutorials
  Custom overrides for the VSDocs template

  This file is meant to be loaded after css/style.min.css.
*/

:root {
  /* Top bar is always black */
  --we-topbar-bg: #000000;
  --we-topbar-fg: #ffffff;

  /* Theme defaults (overridden below by html[data-theme]) */
  --we-page-bg: #0f1115;
  --we-text: rgba(255, 255, 255, 0.92);
  --we-muted: rgba(255, 255, 255, 0.78);
  --we-border: rgba(255, 255, 255, 0.18);
  --we-card-bg: rgba(255, 255, 255, 0.06);
  --we-card-bg-hover: rgba(255, 255, 255, 0.10);
  --we-focus: rgba(255, 255, 255, 0.35);
  --we-thumb-bg: rgba(255, 255, 255, 0.06);

  /* Header overlay compensation */
  --we-header-offset: 150px;
}

html[data-theme="dark"] {
  --we-page-bg: #0f1115;
  --we-text: rgba(255, 255, 255, 0.92);
  --we-muted: rgba(255, 255, 255, 0.78);
  --we-border: rgba(255, 255, 255, 0.18);
  --we-card-bg: rgba(255, 255, 255, 0.06);
  --we-card-bg-hover: rgba(255, 255, 255, 0.10);
  --we-focus: rgba(255, 255, 255, 0.35);
  --we-thumb-bg: rgba(255, 255, 255, 0.06);
}

html[data-theme="light"] {
  --we-page-bg: #ffffff;
  --we-text: rgba(0, 0, 0, 0.92);
  --we-muted: rgba(0, 0, 0, 0.72);
  --we-border: rgba(0, 0, 0, 0.16);
  --we-card-bg: rgba(0, 0, 0, 0.03);
  --we-card-bg-hover: rgba(0, 0, 0, 0.06);
  --we-focus: rgba(0, 0, 0, 0.25);
  --we-thumb-bg: rgba(0, 0, 0, 0.03);
}

html,
body {
  background: var(--we-page-bg);
  color: var(--we-text);
}

/* Top bar */
.header.header-over.large {
  background: var(--we-topbar-bg);
  border-bottom: 1px solid var(--we-border);
}

/* Ensure menu links stay white in the top bar */
.header.header-over.large .menu.sf-menu > li > a {
  color: var(--we-topbar-fg);
}

.header.header-over.large .menu.sf-menu > li > a:hover,
.header.header-over.large .menu.sf-menu > li > a:focus {
  color: var(--we-topbar-fg);
  opacity: 0.92;
}

/* Brand: logo + "Tutorials" label */
.header.header-over.large .we-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.we-brand-suffix {
  color: var(--we-topbar-fg);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.logo-image img {
  max-height: 44px;
  width: auto;
}

/* Theme toggle button */
.we-topbar-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 10px;
  vertical-align: middle;
}

.we-theme-toggle {
  background: transparent;
  border: 1px solid var(--we-border);
  border-radius: 6px;
  color: var(--we-topbar-fg);
  cursor: pointer;
  line-height: 1;
  padding: 8px 10px;
}

.we-theme-toggle:focus {
  outline: 2px solid var(--we-focus);
  outline-offset: 2px;
}

/* Mobile header is usually taller because things wrap */
@media (max-width: 767px) {
  :root {
    --we-header-offset: 128px;
  }
}

/* Force content below the overlay header */
body #content {
  padding-top: var(--we-header-offset) !important;
}

/* Sidebar */
.we-sidebar {
  position: sticky;
  top: calc(var(--we-header-offset) + 12px);
  border: 1px solid var(--we-border);
  border-radius: 10px;
  padding: 14px;
  background: var(--we-card-bg);
}

.we-sidebar h4 {
  margin-top: 6px;
  margin-bottom: 10px;
}

/* Search input */
.we-input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--we-border);
  background: transparent;
  color: inherit;
}

.we-input:focus {
  outline: 2px solid var(--we-focus);
  outline-offset: 2px;
}

/* Category list */
.we-category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.we-category-list li {
  margin: 6px 0;
}

.we-category-link {
  display: inline-block;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--we-border);
  text-decoration: none;
  color: inherit;
  background: transparent;
}

.we-category-link:hover,
.we-category-link:focus {
  background: var(--we-card-bg-hover);
}

.we-category-link.is-active {
  background: var(--we-card-bg-hover);
  border-color: var(--we-focus);
}

.we-category-hint {
  font-size: 12px;
  margin-top: 10px;
  color: var(--we-muted);
}

/* Tutorial cards grid */
.we-tutorial-grid {
  display: flex;
  flex-wrap: wrap;
  margin-left: -10px;
  margin-right: -10px;
}

.we-card-col {
  width: 100%;
  padding-left: 10px;
  padding-right: 10px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .we-card-col {
    width: 50%;
  }
}

.we-card {
  border: 1px solid var(--we-border);
  border-radius: 12px;
  background: var(--we-card-bg);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: background 120ms ease-in-out;
}

.we-card:hover {
  background: var(--we-card-bg-hover);
}

.we-card-thumb {
  width: 100%;
  height: 170px;
  display: block;
  object-fit: cover;
  background: var(--we-thumb-bg);
}

.we-card-body {
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.we-card-meta {
  font-size: 12px;
  color: var(--we-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.we-card-title {
  font-size: 18px;
  margin: 0;
  line-height: 1.25;
}

.we-card-desc {
  margin: 0;
  color: var(--we-muted);
  line-height: 1.35;
}

.we-card-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 6px;
}

.we-button {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--we-border);
  text-decoration: none;
  color: inherit;
  background: transparent;
}

.we-button:hover,
.we-button:focus {
  background: var(--we-card-bg-hover);
}

/* Status line under the grid */
.we-status {
  margin-top: 10px;
  color: var(--we-muted);
  font-size: 13px;
}

/* Utility */
.we-hidden {
  display: none !important;
}

/* Hide no-JS fallback when JS is present */
.js .no-js-only {
  display: none !important;
}

/* Footer */
.we-footer {
  margin-top: 30px;
  padding: 18px 0;
  border-top: 1px solid var(--we-border);
  color: var(--we-muted);
  font-size: 13px;
}

/* Mobile filters panel */
.we-mobile-filters {
  border: 1px solid var(--we-border);
  border-radius: 10px;
  padding: 14px;
  background: var(--we-card-bg);
  margin-bottom: 18px;
}

.we-page-card {
  background: var(--we-card-bg);
  border: 1px solid var(--we-border);
  border-radius: 10px;
  padding: 18px;
}

/* Guide tables: readable cell spacing and breathing room */
.we-table-wrap {
  margin: 14px 0 22px;
  overflow-x: auto;
}

.we-table {
  width: 100%;
  border-collapse: collapse;
}

.we-table th,
.we-table td {
  padding: 10px 12px;
  vertical-align: top;
  line-height: 1.35;
  border-bottom: 1px solid var(--we-border);
}

.we-table thead th {
  font-weight: 600;
  border-bottom: 2px solid var(--we-border);
}

.we-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Keep headings from sticking to tables */
.we-guide-section h2,
.we-guide-section h3 {
  margin-top: 18px;
}

.we-guide-section .we-table-wrap + h2,
.we-guide-section .we-table-wrap + h3 {
  margin-top: 22px;
}

/* Guide photo rows: text next to photo, stacks on mobile */
.we-photo-rows {
  margin: 14px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.we-photo-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--we-border);
  border-radius: 10px;
  background: var(--we-card-bg);
}

.we-photo-row-text {
  flex: 1 1 52%;
  line-height: 1.5;
}

.we-photo-row-figure {
  flex: 1 1 48%;
  margin: 0;
}

.we-photo-row-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--we-border);
}

@media (max-width: 767px) {
  .we-photo-row {
    flex-direction: column;
  }
}

/* Featured product card: keep images consistent in the sidebar */
.we-featured-product img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--we-border);
}

/* Guide content: never allow images to overflow the content column */
.we-guide img,
.we-guide-content img,
.we-guide-section img,
.we-guide-figure img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Make figures behave nicely and add breathing room */
.we-guide figure,
.we-guide-content figure,
.we-guide-section figure,
.we-guide-figure {
  margin: 14px 0 22px;
}

.we-guide figcaption {
  margin-top: 8px;
  font-size: 0.95em;
  color: var(--we-muted);
}

/* Guide content images: never exceed the content column */
.we-guide-figure {
  display: block;
  width: 100%;
  margin: 14px 0 22px;
}

/* Also cover any other images inside guide content */
#content .we-guide img,
#content .we-guide-section img {
  display: block;
  max-width: 100%;
}
