/*
Theme Name: YouthPlug Tools
Theme URI: https://tools.youthplug.co.za
Description: Lightweight, SEO-optimized, mobile-first theme for the YouthPlug Tools Platform. Designed for high-traffic tool pages and AdSense monetization.
Author: YouthPlug
Version: 1.0.5
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
Text Domain: youthplug-tools
*/

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.ypt-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.ypt-site-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.ypt-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  gap: 1rem;
}

.ypt-logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.ypt-logo span { color: #2563eb; }

/* ---------- Primary navigation ---------- */
.ypt-site-header {
  position: relative;
  z-index: 1000;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.ypt-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  gap: 1rem;
  position: relative;
  z-index: 2;
}

.ypt-primary-nav {
  position: relative;
}

/* Reset lists */
.ypt-nav,
.ypt-nav ul,
ul.ypt-nav,
ul.ypt-nav ul {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Desktop: horizontal top menu */
ul.ypt-nav {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
}

ul.ypt-nav > li {
  position: relative;
  display: block;
  margin: 0;
  flex: 0 0 auto;
}

ul.ypt-nav > li > a {
  display: block;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 6px;
}

ul.ypt-nav > li > a:hover,
ul.ypt-nav > li:hover > a,
ul.ypt-nav > li.current-menu-item > a,
ul.ypt-nav > li.current-menu-ancestor > a {
  color: #2563eb;
  text-decoration: none;
  background: #f1f5f9;
}

ul.ypt-nav > li.menu-item-has-children > a::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0.4rem;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

/* Desktop submenus – hidden by default */
ul.ypt-nav ul.sub-menu,
ul.ypt-nav .sub-menu {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  min-width: 220px;
  max-width: 300px;
  background: #fff !important;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 12px 28px -6px rgb(0 0 0 / 0.15);
  padding: 0.35rem 0 !important;
  margin: 0 !important;
  z-index: 9999 !important;
}

ul.ypt-nav > li:hover > ul.sub-menu,
ul.ypt-nav > li:focus-within > ul.sub-menu,
ul.ypt-nav > li.is-open > ul.sub-menu {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

ul.ypt-nav .sub-menu li {
  display: block;
  margin: 0;
  position: relative;
  width: 100%;
}

ul.ypt-nav .sub-menu a {
  display: block;
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  white-space: nowrap;
}

ul.ypt-nav .sub-menu a:hover {
  background: #f1f5f9;
  color: #2563eb;
  text-decoration: none;
}

ul.ypt-nav .sub-menu ul.sub-menu {
  top: 0 !important;
  left: 100% !important;
}

ul.ypt-nav .sub-menu li:hover > ul.sub-menu,
ul.ypt-nav .sub-menu li:focus-within > ul.sub-menu,
ul.ypt-nav .sub-menu li.is-open > ul.sub-menu {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

ul.ypt-nav > li:last-child > ul.sub-menu,
ul.ypt-nav > li:nth-last-child(2) > ul.sub-menu {
  left: auto !important;
  right: 0 !important;
}

.ypt-sub-toggle {
  display: none;
}

.ypt-menu-toggle {
  display: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.45rem 0.7rem;
  color: #0f172a;
  z-index: 3;
}

/* ========== MOBILE ========== */
@media (max-width: 900px) {
  .ypt-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Hide desktop horizontal menu bar */
  .ypt-primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 10px 24px -4px rgb(0 0 0 / 0.12);
    max-height: min(80vh, 520px);
    overflow-y: auto;
    z-index: 1001;
  }

  /* When hamburger opens the menu */
  .ypt-primary-nav.is-open,
  body.ypt-mobile-menu-open .ypt-primary-nav {
    display: block !important;
  }

  ul.ypt-nav {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100%;
    padding: 0.25rem 0 0.75rem !important;
  }

  ul.ypt-nav > li {
    width: 100%;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
  }

  ul.ypt-nav > li > a {
    padding: 0.95rem 3.25rem 0.95rem 1.25rem;
    border-radius: 0;
    white-space: normal;
    font-size: 0.95rem;
  }

  ul.ypt-nav > li.menu-item-has-children > a::after,
  ul.ypt-nav .sub-menu li.menu-item-has-children > a::after {
    display: none !important;
  }

  .ypt-sub-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    width: 48px;
    height: 52px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    z-index: 2;
  }

  .ypt-sub-toggle .ypt-chevron {
    display: block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #64748b;
    transition: transform 0.2s;
  }

  li.is-open > .ypt-sub-toggle .ypt-chevron {
    transform: rotate(180deg);
  }

  ul.ypt-nav .sub-menu li.menu-item-has-children {
    position: relative;
  }

  ul.ypt-nav .sub-menu li.menu-item-has-children > a {
    padding-right: 3rem;
  }

  /* Submenus hidden until expanded */
  ul.ypt-nav ul.sub-menu,
  ul.ypt-nav .sub-menu {
    position: static !important;
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    min-width: 0 !important;
    max-width: none !important;
    width: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #f8fafc !important;
    padding: 0 !important;
  }

  ul.ypt-nav > li:hover > ul.sub-menu,
  ul.ypt-nav > li:focus-within > ul.sub-menu,
  ul.ypt-nav .sub-menu li:hover > ul.sub-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  ul.ypt-nav > li.is-open > ul.sub-menu,
  ul.ypt-nav .sub-menu li.is-open > ul.sub-menu {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  ul.ypt-nav .sub-menu a {
    padding: 0.8rem 1.25rem 0.8rem 1.75rem;
    white-space: normal;
    font-size: 0.9rem;
    border-bottom: 1px solid #eef2f7;
  }

  ul.ypt-nav .sub-menu .sub-menu a {
    padding-left: 2.5rem;
    background: #f1f5f9;
  }
}

/* Hero */
.ypt-hero {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  padding: 3rem 0 2.5rem;
  text-align: center;
}
.ypt-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
}
.ypt-hero p {
  font-size: 1.1rem;
  color: #64748b;
  max-width: 560px;
  margin: 0 auto 1.5rem;
}

/* Category cards on home */
.ypt-categories {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.ypt-cat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.15s;
}
.ypt-cat-card:hover {
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.08);
  transform: translateY(-2px);
  text-decoration: none;
}
.ypt-cat-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.ypt-cat-label { font-weight: 700; font-size: 0.95rem; }

/* Main content area */
.ypt-main {
  padding: 2rem 0 3rem;
}

.ypt-content-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
}
@media (max-width: 900px) {
  .ypt-content-with-sidebar {
    grid-template-columns: 1fr;
  }
}

.ypt-sidebar {
  position: sticky;
  top: 5rem;
  align-self: start;
}

/* Footer */
.ypt-site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 2.5rem 0 1.5rem;
  font-size: 0.9rem;
}
.ypt-footer-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}
.ypt-footer-inner h4 {
  color: #fff;
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}
.ypt-footer-inner a {
  color: #94a3b8;
  display: block;
  margin-bottom: 0.35rem;
}
.ypt-footer-inner a:hover { color: #fff; }
.ypt-footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
}

/* Blog / single post basics */
.ypt-entry-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
}
.ypt-entry-meta {
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 1.5rem;
}
.ypt-entry-content {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
}

/* Ad placeholders */
.ypt-ad-header,
.ypt-ad-footer {
  text-align: center;
  padding: 0.75rem 0;
  background: #f1f5f9;
}

/* Utility */
.ypt-section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
}
