/*
Theme Name: HaitaiSmart
Theme URI: https://haitaismart.com/
Author: HaitaiSmart
Author URI: https://haitaismart.com/
Description: HaitaiSmart corporate theme — Vision Gear modules and HT-Edge NUC980 gateways. Dark UI with cyan accent.
   Version: 1.2.2
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: haitai
Tags: business, custom-colors, custom-menu, featured-images, full-width-template, translation-ready
*/

:root {
  --h-bg: #121214;
  --h-surface: #1a1a1e;
  --h-surface-2: #222228;
  --h-border: #2e2e36;
  --h-text: #e4e4e7;
  --h-muted: #a1a1aa;
  --h-accent: #55d4d6;
  --h-accent-dim: rgba(85, 212, 214, 0.12);
  --h-accent-hover: #7ee0e2;
  --h-danger: #f87171;
  --h-radius: 12px;
  --h-radius-sm: 8px;
  --h-max: 1120px;
  --h-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--h-font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--h-text);
  background: var(--h-bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

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

h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  font-weight: 700;
  color: var(--h-text);
  margin: 0 0 0.6em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; color: var(--h-muted); }

/* Layout */
.site-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-main {
  flex: 1;
  width: 100%;
}

.container {
  width: min(100% - 2rem, var(--h-max));
  margin-inline: auto;
}

/* Header — Arduino-style fixed bar */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(18, 18, 20, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--h-border);
}

.site-header .container,
.header-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 84px;
}

.header-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.header-logo .custom-logo-link {
  display: flex;
  align-items: center;
}
.header-logo img.custom-logo {
  max-height: 48px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--h-text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.site-brand:hover { color: var(--h-text); }

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--h-accent), #3aa8af);
  display: grid;
  place-items: center;
  color: #0a0a0c;
  font-weight: 800;
  font-size: 0.85rem;
}

/* Primary nav — Arduino-like compact bold links + chevrons */
.primary-nav {
  flex: 1 1 auto;
  min-width: 0;
}

.primary-nav ul {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.primary-nav li {
  position: relative;
}

.primary-nav li > a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.98rem 0.75rem;
  color: var(--h-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.primary-nav li > a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current_page_item > a,
.primary-nav .current-menu-ancestor > a {
  color: var(--h-accent);
  background: transparent;
}

/* Arduino-style chevron for parents */
.primary-nav li.menu-item-has-children > a::after {
  content: '';
  width: 0.4em;
  height: 0.4em;
  margin-left: 0.15rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  opacity: 0.75;
  flex-shrink: 0;
}

/* Submenus (level 2+) */
.primary-nav ul ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 230px;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 8px;
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: 0 0 var(--h-radius-sm) var(--h-radius-sm);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  z-index: 200;
}

.primary-nav li:hover > ul,
.primary-nav li:focus-within > ul {
  display: flex;
}

/* Level 3: flyout to the right */
.primary-nav ul ul ul {
  top: 0;
  left: 100%;
  margin-left: 4px;
  border-radius: var(--h-radius-sm);
}

.primary-nav ul ul a {
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: normal;
  color: var(--h-text);
}
.primary-nav ul ul a:hover {
  background: var(--h-surface-2);
  color: var(--h-accent);
}

/* Right-side CTA (Arduino Shop/Cloud pattern) */
.header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background: var(--h-accent);
  color: #0a0a0c;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 4px;
  border: 1px solid var(--h-accent);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.header-cta:hover {
  background: var(--h-accent-hover);
  border-color: var(--h-accent-hover);
  color: #0a0a0c;
}

/* If menu still has nav-cta item, align with header button */
.primary-nav .nav-cta a {
  background: var(--h-accent);
  color: #0a0a0c;
  font-weight: 700;
  border-radius: 4px;
  margin-left: 0.35rem;
}
.primary-nav .nav-cta a:hover {
  background: var(--h-accent-hover);
  color: #0a0a0c;
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: 1px solid var(--h-border);
  color: var(--h-text);
  border-radius: 6px;
  cursor: pointer;
  place-items: center;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  position: relative;
  margin: 0 auto;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

@media (max-width: 960px) {
  .nav-toggle {
    display: grid;
  }
  .header-actions { display: none; }
  .header-bar { flex-wrap: wrap; }
  .primary-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--h-surface);
    border-bottom: 1px solid var(--h-border);
    padding: 0.75rem 1rem 1rem;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
  }
  .primary-nav.is-open { display: block; }
  .primary-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
  }
  .primary-nav li > a {
    padding: 0.7rem 0.5rem;
    white-space: normal;
    font-size: 0.9rem;
  }

  /* Always show nested levels on mobile */
  .primary-nav ul ul {
    display: flex;
    position: static;
    min-width: 0;
    margin: 0 0 0 0.75rem;
    padding: 0 0 0 0.75rem;
    border: 0;
    border-left: 2px solid var(--h-border);
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  .primary-nav ul ul ul { margin-left: 0.5rem; }
  .primary-nav li.menu-item-has-children > a::after { display: none; }

  .header-actions {
    display: none;
  }
  .primary-nav.is-open .mobile-cta {
    display: flex;
  }
}

.mobile-cta {
  display: none;
  margin-top: 0.75rem;
  padding: 0.7rem 0.75rem;
  background: var(--h-accent);
  color: #0a0a0c;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  border-radius: 4px;
  justify-content: center;
}
.mobile-cta:hover {
  background: var(--h-accent-hover);
  color: #0a0a0c;
}

/* Offset page under fixed header */
body {
  padding-top: 84px;
}

/* Breadcrumbs (RPi-style) */
.breadcrumbs {
  padding: 0.85rem 0 0;
  font-size: 0.82rem;
  color: var(--h-muted);
}
.breadcrumbs a {
  color: var(--h-muted);
  text-decoration: none;
}
.breadcrumbs a:hover { color: var(--h-accent); }
.breadcrumbs .bc-sep {
  margin: 0 0.4rem;
  opacity: 0.45;
}
.breadcrumbs [aria-current="page"] {
  color: var(--h-text);
  font-weight: 500;
}

/* Page content chrome */
.page-hero {
  padding: 3rem 0 1.5rem;
  border-bottom: 1px solid var(--h-border);
  background:
    radial-gradient(ellipse 80% 60% at 10% -20%, rgba(85, 212, 214, 0.08), transparent),
    var(--h-bg);
}

.page-hero h1 { margin-bottom: 0.4em; }
.page-hero .lead {
  font-size: 1.1rem;
  color: var(--h-muted);
  max-width: 48rem;
  margin: 0;
}

.entry-content {
  padding: 2.5rem 0 3.5rem;
}

.entry-content > * + * { margin-top: 1.25rem; }

.entry-content h2 {
  margin-top: 2.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--h-border);
}

.entry-content h2:first-child {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

/* Inline content helpers (page builder HTML) */
.entry-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1.5rem 0;
}
.entry-content th,
.entry-content td {
  border: 1px solid var(--h-border);
  padding: 0.7rem 0.9rem;
  text-align: left;
  vertical-align: top;
}
.entry-content th {
  background: var(--h-surface-2);
  color: var(--h-text);
  font-weight: 600;
}
.entry-content td { background: var(--h-surface); color: var(--h-muted); }

.entry-content ul, .entry-content ol {
  color: var(--h-muted);
  padding-left: 1.25rem;
}
.entry-content li + li { margin-top: 0.35rem; }

.entry-content blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--h-accent);
  background: var(--h-accent-dim);
  border-radius: 0 var(--h-radius-sm) var(--h-radius-sm) 0;
  color: var(--h-text);
}

.entry-content pre {
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius-sm);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  color: var(--h-text);
  font-size: 0.9rem;
}

.entry-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--h-surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  color: var(--h-accent);
}
.entry-content pre code { background: none; padding: 0; color: inherit; }

.entry-content img {
  border-radius: var(--h-radius);
  border: 1px solid var(--h-border);
}

.entry-content hr {
  border: 0;
  border-top: 1px solid var(--h-border);
  margin: 2rem 0;
}

/* Buttons (if used in content) */
.entry-content .wp-block-button__link,
.entry-content .button,
.entry-content button[type="submit"],
.entry-content input[type="submit"] {
  display: inline-block;
  background: var(--h-accent);
  color: #0a0a0c !important;
  font-weight: 600;
  border: 0;
  border-radius: var(--h-radius-sm);
  padding: 0.7rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.entry-content .wp-block-button__link:hover,
.entry-content button[type="submit"]:hover {
  background: var(--h-accent-hover);
  color: #0a0a0c !important;
}

/* Forms in content */
.entry-content input[type="text"],
.entry-content input[type="email"],
.entry-content input[type="tel"],
.entry-content input[type="url"],
.entry-content input[type="number"],
.entry-content select,
.entry-content textarea {
  width: 100%;
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius-sm);
  color: var(--h-text);
  padding: 0.65rem 0.85rem;
  font: inherit;
  margin-bottom: 0.75rem;
}
.entry-content input:focus,
.entry-content select:focus,
.entry-content textarea:focus {
  outline: 2px solid var(--h-accent);
  outline-offset: 1px;
  border-color: var(--h-accent);
}
.entry-content label {
  display: block;
  color: var(--h-text);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

/* Blog index / archive */
.post-list {
  display: grid;
  gap: 1.25rem;
  padding: 2.5rem 0 3.5rem;
}

.post-card {
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius);
  padding: 1.5rem;
  transition: border-color 0.15s;
}
.post-card:hover { border-color: var(--h-accent); }

.post-card h2 {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  border: 0;
  padding: 0;
}
.post-card h2 a { color: var(--h-text); }
.post-card h2 a:hover { color: var(--h-accent); }

.post-meta {
  font-size: 0.85rem;
  color: var(--h-muted);
  margin-bottom: 0.75rem;
}

.post-card .excerpt { margin: 0; color: var(--h-muted); }

/* Single post */
.single-entry header {
  padding: 3rem 0 1rem;
}
.single-entry .entry-meta {
  font-size: 0.9rem;
  color: var(--h-muted);
  margin-bottom: 0.75rem;
}

/* Pagination / comments */
.navigation.pagination,
.comments-area {
  padding-bottom: 3rem;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.nav-links a,
.nav-links span {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius-sm);
  background: var(--h-surface);
  color: var(--h-text);
  font-size: 0.9rem;
}
.nav-links a:hover { border-color: var(--h-accent); color: var(--h-accent); }
.nav-links .current { background: var(--h-accent); color: #0a0a0c; border-color: var(--h-accent); }

.comment-list { list-style: none; padding: 0; }
.comment-body {
  background: var(--h-surface);
  border: 1px solid var(--h-border);
  border-radius: var(--h-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--h-border);
  background: var(--h-surface);
  padding: 2.5rem 0 2rem;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 700px) {
  .footer-grid { grid-template-columns: 1fr; }
}

.footer-brand p {
  color: var(--h-muted);
  font-size: 0.95rem;
  max-width: 28rem;
}

.site-footer h3,
.footer-col h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--h-muted);
  margin-bottom: 0.85rem;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-col li + li { margin-top: 0.45rem; }
.footer-col a {
  color: var(--h-text);
  font-size: 0.95rem;
}
.footer-col a:hover { color: var(--h-accent); }

.footer-bottom {
  border-top: 1px solid var(--h-border);
  padding-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--h-muted);
}
.footer-bottom a { color: var(--h-muted); }
.footer-bottom a:hover { color: var(--h-accent); }

/* Utilities */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.alignwide { max-width: min(100%, 1280px); margin-inline: auto; }
.alignfull { width: 100vw; margin-left: calc(50% - 50vw); }

/* 404 */
.error-404 {
  padding: 5rem 0;
  text-align: center;
}
.error-404 .code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--h-accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}
