/*
 * WB Starter — theme.css
 *
 * Base styles. Elementor handles page design; this file covers tokens,
 * reset, typography, header/nav/footer, archive cards and a11y.
 *
 *  1. Custom properties (tokens)
 *  2. Reset / base
 *  3. Typography
 *  4. Layout
 *  5. Header
 *  6. Header layout presets
 *  7. Navigation (desktop)
 *  8. Navigation (mobile)
 *  9. Footer
 * 10. Buttons & forms
 * 11. Posts, archives, comments
 * 12. Elementor
 * 13. Accessibility
 */

/* ── 1. Custom properties ─────────────────────────────────────────────────── */

:root {
  /* Colours: defaults only. Customizer values override these via wp_head. */
  --color-primary:    #000000;
  --color-secondary:  #555555;
  --color-accent:     #ffffff;
  --color-bg:         #ffffff;
  --color-text:       #1a1a1a;
  --color-text-muted: #666666;
  --color-border:     #e0e0e0;

  /* Typography */
  --font-body:         system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-heading:      var(--font-body);
  --font-size-base:    1rem;
  --font-size-sm:      0.875rem;
  --font-size-lg:      1.125rem;
  --line-height-body:  1.65;
  --line-height-tight: 1.2;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --max-width:     1140px;
  --content-width: 720px;
  --gutter:        1.25rem;
  --border-radius: 4px;

  /* Header / footer */
  --header-height: 70px;
  --header-bg:     #ffffff;
  --header-border: var(--color-border);
  --footer-bg:     #1a1a1a;
  --footer-text:   #ffffff;

  /* Admin bar offset for the sticky header (set below when logged in) */
  --admin-bar-offset: 0px;
}

/* ── 2. Reset / base ──────────────────────────────────────────────────────── */

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

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

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

img,
video {
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration: none;
}

/* Strip list styling only where the theme renders lists as UI (menus etc.) */
.nav-menu,
.nav-menu ul,
.footer-nav-menu,
.social-links,
.comment-list,
.comment-list .children {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ── 3. Typography ────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--line-height-tight);
  font-weight: 700;
  margin-bottom: var(--space-md);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

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

p:last-child {
  margin-bottom: 0;
}

.entry-content ul,
.entry-content ol {
  padding-left: var(--space-xl);
  margin: 0 0 var(--space-md);
}

.entry-content li {
  margin-bottom: var(--space-xs);
}

blockquote {
  border-left: 4px solid var(--color-primary);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  font-style: italic;
  color: var(--color-text-muted);
}

/* ── 4. Layout ────────────────────────────────────────────────────────────── */

.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.site-content {
  flex: 1;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-main {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding: var(--space-3xl) var(--gutter);
}

/* Single posts read better at a narrower measure */
.single-content .entry-content,
.single-content .entry-header {
  max-width: var(--content-width);
  margin-inline: auto;
}

/* Full Width page template: no container, keeps vertical spacing */
.site-main--full-width {
  max-width: none;
}

.site-main--blank {
  max-width: none;
  padding: 0;
}

/* ── 5. Header ────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: var(--admin-bar-offset);
  z-index: 1000;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

/* Keep the sticky header below the WP admin bar.
   The admin bar is only fixed above 600px wide. */
@media (min-width: 601px) {
  body.admin-bar { --admin-bar-offset: 46px; }
}

@media (min-width: 783px) {
  body.admin-bar { --admin-bar-offset: 32px; }
}

.site-header__inner {
  min-height: var(--header-height);  /* min-height, so stacked layouts can grow */
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Branding */
.site-branding {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  color: var(--color-text);
}

.custom-logo-link {
  display: inline-block;
}

.custom-logo {
  max-height: 50px;
  width: auto;
}

.site-tagline {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.3;
  color: var(--color-text-muted);
}

/* ── 6. Header layout presets ─────────────────────────────────────────────── */

/* Preset 1: Logo left / Nav right (default) */
.header-layout--logo-left-nav-right {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

/* Preset 2: Logo centre / Nav below */
.header-layout--logo-center-nav-below {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding-block: var(--space-md);
}

.header-layout--logo-center-nav-below .site-branding {
  align-items: center;
  text-align: center;
}

.header-layout--logo-center-nav-below .nav-menu {
  justify-content: center;
}

/* Preset 3: Logo left / Nav centre / CTA right.
   3-column grid keeps the nav truly centred whatever the logo/CTA widths. */
.header-layout--logo-left-nav-center {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-lg);
}

.header-layout--logo-left-nav-center .site-branding { justify-self: start; }
.header-layout--logo-left-nav-center .main-navigation { justify-self: center; }
.header-layout--logo-left-nav-center .header-cta { justify-self: end; }

/* No CTA set: still centre the nav, using an empty third column.
   (The has-cta class comes from PHP, so no :has() needed.) */
.header-layout--logo-left-nav-center:not(.header-layout--has-cta)::after {
  content: '';
}

/* ── 7. Navigation (desktop) ──────────────────────────────────────────────── */

.main-navigation {
  display: flex;
  align-items: center;
}

.nav-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-lg);
}

.nav-menu li {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.nav-menu a {
  display: block;
  padding: var(--space-sm) var(--space-xs);
  text-decoration: none;
  color: var(--color-text);
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-menu a:hover,
.nav-menu .current-menu-item > a,
.nav-menu .current-menu-ancestor > a {
  color: var(--color-primary);
}

/* Dropdown toggle (chevron drawn in CSS, no icon font) */
.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--border-radius);
  color: inherit;
  cursor: pointer;
}

.nav-dropdown-toggle__icon {
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-25%) rotate(45deg);
  transition: transform 0.2s ease;
}

.is-open > .nav-dropdown-toggle .nav-dropdown-toggle__icon {
  transform: translateY(25%) rotate(-135deg);
}

/* Submenus: hidden by default, shown by .is-open (click/keyboard) or hover on mouse devices */
.nav-menu .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 220px;
  padding: var(--space-sm) 0;
  background: var(--header-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.nav-menu .is-open > .sub-menu {
  display: block;
}

@media (hover: hover) and (min-width: 769px) {
  .nav-menu li:hover > .sub-menu {
    display: block;
  }
}

.nav-menu .sub-menu li {
  display: flex;
  width: 100%;
}

.nav-menu .sub-menu a {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  white-space: nowrap;
}

/* Third-level menus fly out to the right */
.nav-menu .sub-menu .sub-menu {
  top: calc(-1 * var(--space-sm) - 1px);
  left: 100%;
}

/* Mobile menu button: hidden on desktop */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 28px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.menu-toggle__bar {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Animate the bars into an X when open */
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* ── 8. Navigation (mobile) ───────────────────────────────────────────────── */

@media (max-width: 768px) {

  /* All presets collapse to: branding left, hamburger right */
  .header-layout--logo-left-nav-right,
  .header-layout--logo-center-nav-below,
  .header-layout--logo-left-nav-center {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-block: var(--space-sm);
  }

  .header-layout--logo-center-nav-below .site-branding {
    align-items: flex-start;
    text-align: left;
  }

  .header-layout--logo-left-nav-center::after {
    content: none;
  }

  /* CTA is hidden on mobile to keep the bar uncluttered.
     Add the CTA page as a menu item if it needs to be reachable on mobile. */
  .header-cta {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .main-navigation {
    position: static;
  }

  .site-header__inner {
    position: relative;
  }

  /* Menu panel drops down below the header bar, full width */
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: calc(100vh - var(--header-height) - var(--admin-bar-offset));
    overflow-y: auto;
    padding: var(--space-sm) 0;
    background: var(--header-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
  }

  .nav-menu.is-open {
    display: flex;
  }

  .nav-menu li {
    width: 100%;
  }

  .nav-menu a {
    flex: 1;
    padding: var(--space-sm) var(--gutter);
  }

  .nav-dropdown-toggle {
    width: 2.75rem;      /* comfortable touch target */
    height: 2.75rem;
    margin-right: var(--space-sm);
  }

  /* Submenus become an accordion */
  .nav-menu .sub-menu,
  .nav-menu .sub-menu .sub-menu {
    position: static;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }

  .nav-menu .sub-menu a {
    padding-left: calc(var(--gutter) + var(--space-lg));
    white-space: normal;
  }

  .nav-menu .sub-menu .sub-menu a {
    padding-left: calc(var(--gutter) + var(--space-2xl));
  }
}

/* ── 9. Footer ────────────────────────────────────────────────────────────── */

.site-footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  padding: var(--space-2xl) var(--gutter);
}

.site-footer__inner {
  max-width: var(--max-width);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.site-footer a {
  color: rgba(255, 255, 255, 0.85);
}

.site-footer a:hover {
  color: #fff;
}

.footer-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-xl);
}

.footer-nav-menu,
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
}

.footer-nav-menu a,
.social-links a {
  font-size: var(--font-size-sm);
  text-decoration: none;
}

.footer-nav-menu a:hover,
.social-links a:hover {
  text-decoration: underline;
}

.site-footer__credit {
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.7);
}

/* ── 10. Buttons & forms ──────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: 0.65em 1.4em;
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.btn--primary:hover {
  background-color: transparent;
  color: var(--color-primary);
}

.btn--outline {
  background-color: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

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

/* Search form (core markup) */
.search-form {
  display: flex;
  gap: var(--space-sm);
  max-width: 480px;
  margin-top: var(--space-md);
}

.search-form label {
  flex: 1;
}

.search-field,
.comment-form input:not([type="submit"]):not([type="checkbox"]),
.comment-form textarea {
  width: 100%;
  padding: 0.6em 0.8em;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
}

.search-submit,
.comment-form .submit {
  padding: 0.6em 1.2em;
  font: inherit;
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: var(--border-radius);
  cursor: pointer;
}

/* ── 11. Posts, archives, comments ────────────────────────────────────────── */

.archive-header {
  margin-bottom: var(--space-2xl);
}

.entry-header {
  margin-bottom: var(--space-xl);
}

.entry-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.entry-thumbnail {
  margin-bottom: var(--space-xl);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: var(--space-xl);
  margin-bottom: var(--space-3xl);
}

.post-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
}

.post-card__thumbnail img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.post-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

.post-card__title {
  font-size: 1.15rem;
  margin-bottom: 0;
}

.post-card__title a {
  color: var(--color-text);
  text-decoration: none;
}

.post-card__title a:hover {
  color: var(--color-primary);
}

.post-card__meta,
.post-card__excerpt {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.post-card__excerpt {
  flex: 1;
}

.post-card__read-more {
  align-self: flex-start;
  margin-top: var(--space-sm);
  font-size: var(--font-size-sm);
}

.no-results {
  max-width: var(--content-width);
}

/* Pagination / post navigation */
.pagination .nav-links,
.post-navigation .nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-sm);
}

.post-navigation {
  max-width: var(--content-width);
  margin: var(--space-2xl) auto 0;
}

/* Comments */
.comments-area {
  max-width: var(--content-width);
  margin: var(--space-3xl) auto 0;
}

.comment-list .comment {
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--color-border);
}

.comment-list .children {
  padding-left: var(--space-xl);
}

.comment-meta {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.comment-form p {
  margin-bottom: var(--space-md);
}

/* ── 12. Elementor ────────────────────────────────────────────────────────── */

/* Pages built with Elementor: drop the theme container so sections
   (including Stretch Section and full-width containers) go edge to edge.
   The wb-elementor-page body class is added in functions.php. */
.wb-elementor-page .site-main {
  max-width: none;
  padding: 0;
}

/* Page title: use Elementor's per-page "Hide Title" toggle.
   It targets h1.entry-title by default, which matches this theme's markup. */

/* Elementor Canvas template outputs no header/footer itself;
   this is a safety net in case either slips through. */
body.elementor-template-canvas .site-header,
body.elementor-template-canvas .site-footer {
  display: none;
}

/* ── 13. Accessibility ────────────────────────────────────────────────────── */

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

.site-footer :focus-visible {
  outline-color: #fff;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 100000;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.skip-link:focus {
  top: var(--admin-bar-offset);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
