/**
 * Main theme stylesheet.
 *
 * Layout primitives, typography, forms, WordPress compat,
 * accessibility, print styles.
 */

/* ── Smooth Scroll ── */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--zb-header-height-sticky);
}

/* ── Selection Color ── */
::selection {
  background: var(--zb-primary);
  color: #fff;
}

/* ── Focus Styles ── */
*:focus-visible {
  outline: 2px solid var(--zb-primary);
  outline-offset: 2px;
}

/* ── Container ── */
.zt-container {
  max-width: var(--zb-container-width);
  margin-inline: auto;
  padding-inline: 20px;
}

/* ── Main Content Area ── */
.zt-main {
  min-height: 60vh;
  padding-block: var(--zb-space-xl);
}

.zt-builder-page .zt-main,
.zt-main.zt-builder-page {
  padding-block: 0;
}

/* ── Builder Full-Width Content ── */
.zt-content--full-width {
  max-width: none;
  padding: 0;
}

/* ── Page-Level Header/Footer Hide ── */
.zt-no-header .zt-header { display: none; }
.zt-no-footer .zt-footer { display: none; }

/* ── Sidebar Layout ── */
.zt-layout-sidebar {
  display: grid;
  gap: var(--zb-space-xl);
  align-items: start;
}

.zt-layout-sidebar.zt-sidebar-right {
  grid-template-columns: 1fr var(--zb-sidebar-width);
}

.zt-layout-sidebar.zt-sidebar-left {
  grid-template-columns: var(--zb-sidebar-width) 1fr;
}

.zt-layout-sidebar.zt-sidebar-left .zt-sidebar {
  order: -1;
}

@media (max-width: 991px) {
  .zt-layout-sidebar {
    grid-template-columns: 1fr;
  }

  .zt-layout-sidebar.zt-sidebar-left .zt-sidebar {
    order: 0;
  }
}

/* ── Typography Scale ── */
h1 { font-size: 2.5rem; margin-bottom: var(--zb-space-lg); }
h2 { font-size: 2rem; margin-bottom: var(--zb-space-md); }
h3 { font-size: 1.5rem; margin-bottom: var(--zb-space-md); }
h4 { font-size: 1.25rem; margin-bottom: var(--zb-space-sm); }
h5 { font-size: 1.125rem; margin-bottom: var(--zb-space-sm); }
h6 { font-size: 1rem; margin-bottom: var(--zb-space-sm); }

p {
  margin-bottom: var(--zb-space-md);
}

blockquote {
  border-left: 4px solid var(--zb-primary);
  padding: var(--zb-space-md) var(--zb-space-lg);
  margin: var(--zb-space-lg) 0;
  background: var(--zb-bg-alt);
  font-style: italic;
  color: var(--zb-text-light);
}

pre {
  background: var(--zb-bg-alt);
  border: 1px solid var(--zb-border);
  border-radius: 4px;
  padding: var(--zb-space-md);
  overflow-x: auto;
  font-size: 0.875rem;
  margin-bottom: var(--zb-space-lg);
}

code {
  background: var(--zb-bg-alt);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.875em;
}

pre code {
  background: none;
  padding: 0;
}

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

ul, ol {
  margin: 0 0 var(--zb-space-md) var(--zb-space-lg);
}

li {
  margin-bottom: var(--zb-space-xs);
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--zb-space-lg);
}

th, td {
  padding: var(--zb-space-sm) var(--zb-space-md);
  border: 1px solid var(--zb-border);
  text-align: left;
}

th {
  background: var(--zb-bg-alt);
  font-weight: 600;
}

.zt-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Form Defaults ── */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: var(--zb-space-sm) var(--zb-space-md);
  border: 2px solid var(--zb-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--zb-text);
  background: var(--zb-bg);
  transition: border-color var(--zb-transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--zb-primary);
  outline: none;
}

button,
input[type="submit"],
input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--zb-space-sm) var(--zb-space-lg);
  background: var(--zb-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--zb-transition-fast);
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
  background: var(--zb-secondary);
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: var(--zb-space-xs);
  font-size: 0.9375rem;
}

/* ── Page Header ── */
.zt-page-header {
  margin-bottom: var(--zb-space-xl);
}

.zt-page-title {
  font-size: 2rem;
}

.zt-archive-description {
  margin-top: var(--zb-space-sm);
  color: var(--zb-text-light);
  font-size: 1.0625rem;
}

/* ── Search Form ── */
.zt-search-form {
  display: flex;
  max-width: 480px;
}

.zt-search-field {
  flex: 1;
  border-right: none;
  border-radius: 4px 0 0 4px;
}

.zt-search-submit {
  padding: var(--zb-space-sm) var(--zb-space-md);
  border-radius: 0 4px 4px 0;
}

/* ── 404 ── */
.zt-error-404 {
  text-align: center;
  padding: var(--zb-space-2xl) 0;
}

.zt-404-content {
  max-width: 600px;
  margin: 0 auto;
}

.zt-404-content p {
  font-size: 1.125rem;
  color: var(--zb-text-light);
  margin-bottom: var(--zb-space-lg);
}

.zt-404-content .zt-search-form {
  margin: 0 auto var(--zb-space-xl);
}

.zt-404-suggestions {
  text-align: left;
}

.zt-404-suggestions ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.zt-404-suggestions li {
  padding: var(--zb-space-sm) 0;
  border-bottom: 1px solid var(--zb-border);
}

/* ── Sidebar ── */
.zt-sidebar {
  font-size: 0.9375rem;
}

.zt-sidebar .widget {
  margin-bottom: var(--zb-space-lg);
  padding-bottom: var(--zb-space-lg);
  border-bottom: 1px solid var(--zb-border);
}

.zt-sidebar .widget:last-child {
  border-bottom: none;
}

.zt-sidebar .widget-title {
  font-size: 1.125rem;
  margin-bottom: var(--zb-space-md);
}

.zt-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.zt-sidebar li {
  padding: var(--zb-space-xs) 0;
}

/* ── Accessibility ── */
.screen-reader-text,
.zt-sr-only {
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  white-space: nowrap;
}

.screen-reader-text:focus,
.zt-sr-only:focus {
  background-color: #f1f1f1;
  border-radius: 3px;
  box-shadow: 0 0 2px 2px rgba(0,0,0,0.6);
  clip: auto !important;
  clip-path: none;
  color: #21759b;
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  height: auto;
  left: 5px;
  line-height: normal;
  padding: 15px 23px 14px;
  text-decoration: none;
  top: 5px;
  width: auto;
  z-index: 100000;
}

.skip-link {
  z-index: 999999;
}

/* ── WordPress Alignment Classes ── */
.alignleft {
  float: left;
  margin-right: var(--zb-space-lg);
  margin-bottom: var(--zb-space-md);
}

.alignright {
  float: right;
  margin-left: var(--zb-space-lg);
  margin-bottom: var(--zb-space-md);
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: var(--zb-space-md);
}

.alignwide {
  max-width: calc(var(--zb-container-width) + var(--zb-space-xl));
  margin-inline: calc(50% - 50vw + var(--zb-space-md));
  width: calc(100vw - var(--zb-space-lg));
}

.alignfull {
  max-width: none;
  margin-inline: calc(50% - 50vw);
  width: 100vw;
}

/* ── WordPress Caption ── */
.wp-caption {
  max-width: 100%;
  margin-bottom: var(--zb-space-md);
}

.wp-caption-text {
  font-size: 0.875rem;
  color: var(--zb-text-light);
  padding-top: var(--zb-space-xs);
}

/* ── WordPress Gallery ── */
.gallery {
  display: grid;
  gap: var(--zb-space-sm);
  margin-bottom: var(--zb-space-lg);
}

.gallery-columns-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-columns-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-columns-4 { grid-template-columns: repeat(4, 1fr); }

.gallery-item { margin: 0; }
.gallery-item img { border-radius: 4px; }

/* ── WordPress Block Compat ── */
.wp-block-image { margin-bottom: var(--zb-space-lg); }
.wp-block-quote { border-left-color: var(--zb-primary); }
.wp-block-separator { border-color: var(--zb-border); }

/* ── Scroll to Top Button ── */
.zt-scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--zb-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--zb-shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--zb-transition-base), visibility var(--zb-transition-base), background var(--zb-transition-fast);
}

.zt-scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.zt-scroll-top:hover {
  background: var(--zb-secondary);
}

/* ── Hero Featured Image ── */
.zt-hero-featured {
  position: relative;
  min-height: 400px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
}

.zt-hero-overlay {
  width: 100%;
  padding: var(--zb-space-2xl) 0 var(--zb-space-xl);
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
}

.zt-hero-title {
  color: #fff;
  font-size: 3rem;
  margin-bottom: var(--zb-space-sm);
}

.zt-hero-overlay .zt-post-meta,
.zt-hero-overlay .zt-post-meta a {
  color: rgba(255,255,255,0.85);
}

@media (max-width: 767px) {
  .zt-hero-featured { min-height: 280px; }
  .zt-hero-title { font-size: 2rem; }
}

/* ── Lightbox ── */
.zt-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--zb-transition-base), visibility var(--zb-transition-base);
}

.zt-lightbox-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.zt-lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

/* ── Breadcrumbs ── */
.zt-breadcrumbs {
  margin-bottom: var(--zb-space-lg);
  font-size: 0.875rem;
}

.zt-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--zb-space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.zt-breadcrumb__item {
  display: inline-flex;
  align-items: center;
  gap: var(--zb-space-xs);
}

.zt-breadcrumb__link {
  color: var(--zb-text-light);
}

.zt-breadcrumb__link:hover {
  color: var(--zb-primary);
}

.zt-breadcrumb__current {
  color: var(--zb-text);
  font-weight: 500;
}

.zt-breadcrumb__sep {
  color: var(--zb-border);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Print Stylesheet ── */
@media print {
  .zt-header,
  .zt-footer,
  .zt-sidebar,
  .zt-scroll-top,
  .zt-share,
  .zt-related-posts,
  .zt-pagination,
  .zt-breadcrumbs,
  .zt-mobile-menu,
  .zt-top-bar,
  .skip-link,
  #zt-scroll-top {
    display: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  .zt-main {
    padding: 0;
  }

  .zt-container {
    max-width: none;
    padding: 0;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  a[href^="#"]::after,
  a[href^="javascript"]::after {
    content: "";
  }

  img {
    max-width: 100% !important;
  }
}
