/* ==========================================================================
   UI/UX REFRESH - 2026-10-02
   Loaded last (see functions.php). Each section fixes an issue found in the
   live-site review; the older stylesheets use !important heavily, so some
   overrides here have to as well.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. No sideways scrolling on phones
   AdSense full-width units are wider than the viewport. `clip` cuts them off
   without making <html> a scroll container, so the sticky header still works.
   -------------------------------------------------------------------------- */
html {
  overflow-x: clip;
}

@supports not (overflow: clip) {
  body {
    overflow-x: hidden;
  }
}

/* --------------------------------------------------------------------------
   2. Header
   -------------------------------------------------------------------------- */

/* Dropdown arrow: the "active underline" rule positioned it under the item,
   where it showed up as a stray dot under "Courses" and "Authors". */
#site-primary-menu > li.menu-item-has-children > a::after,
.sf-menu > li.menu-item-has-children > a::after {
  content: '\25BE' !important;
  position: static !important;
  display: inline-block;
  width: auto !important;
  height: auto !important;
  background: none !important;
  transform: none !important;
  margin-left: 5px;
  font-size: 0.85em !important;
  line-height: 1;
  opacity: 0.7;
}

/* Mobile: logo and menu button on one row (was stacked, 145px tall). */
@media (max-width: 900px) {
  .wrapper-header {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.5rem 1rem !important;
    min-height: 60px;
  }

  #site-header-main {
    width: auto !important;
    flex: 1 1 auto;
    justify-content: flex-start !important;
  }

  #site-mobile-menu-toggle {
    margin: 0 0 0 auto !important;
    padding: 0 !important;
    background: transparent !important;
    flex: 0 0 auto;
    width: auto !important;
  }
}

/* --------------------------------------------------------------------------
   3. Post cards
   -------------------------------------------------------------------------- */

/* The type badge sits on the cover image, never on the title. */
.ilovewp-post::before {
  pointer-events: none;
}

/* Fallback cover for posts without a featured image (template-parts/content.php).
   Keeps every card the same shape so the grid lines up. */
.post-cover--fallback a {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  text-decoration: none !important;
  color: var(--hamnus-white) !important;
  background:
    radial-gradient(circle at 20% 15%, rgba(20, 184, 166, 0.28), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(245, 158, 11, 0.18), transparent 40%);
}

.fallback-cover-icon {
  width: 44px;
  height: 44px;
  opacity: 0.9;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 4h7a3 3 0 0 1 3 3v13a2 2 0 0 0-2-2H2z'/%3E%3Cpath d='M22 4h-7a3 3 0 0 0-3 3v13a2 2 0 0 1 2-2h8z'/%3E%3C/svg%3E");
}

.fallback-cover-label {
  font-family: var(--hamnus-font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.4;
  max-width: 90%;
  color: rgba(255, 255, 255, 0.92);
}

/* Meta line: no separators (they end up at the start of a wrapped line);
   spacing alone separates author and date, categories get their own line. */
.ilovewp-post .post-meta {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 1rem;
}

.ilovewp-post .post-meta > span::before,
.ilovewp-post .post-meta > span:not(:first-child)::before {
  content: none !important;
  display: none !important;
}

.ilovewp-post .post-meta > .post-meta-category {
  flex-basis: 100%;
}

/* Bigger tap targets for the small meta links. */
.ilovewp-post .post-meta a {
  display: inline-block;
  padding: 0.2rem 0;
}

@media (prefers-reduced-motion: reduce) {
  .ilovewp-post:hover .post-cover img,
  .ilovewp-post:hover .post-cover-wrapper img {
    transform: none !important;
  }
}

/* --------------------------------------------------------------------------
   4. Pagination - wraps instead of overflowing on phones
   -------------------------------------------------------------------------- */
.navigation.pagination .nav-links,
.nav-links {
  display: flex !important;
  flex-wrap: wrap !important;
  justify-content: center;
  gap: 0.4rem;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   5. Homepage intro (index.php)
   -------------------------------------------------------------------------- */
.hamnus-intro {
  background: linear-gradient(135deg, var(--hamnus-primary) 0%, var(--hamnus-primary-light) 100%);
  color: var(--hamnus-white);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  margin: 0 0 2.25rem;
  position: relative;
  overflow: hidden;
}

.hamnus-intro::after {
  content: '';
  position: absolute;
  inset: auto -60px -80px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.35), transparent 70%);
  pointer-events: none;
}

.hamnus-intro-title {
  color: var(--hamnus-white) !important;
  font-family: var(--hamnus-font-heading);
  font-size: clamp(1.6rem, 1.1rem + 2vw, 2.35rem) !important;
  line-height: 1.2 !important;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem !important;
}

.hamnus-intro-text {
  color: rgba(255, 255, 255, 0.88) !important;
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 640px;
  margin: 0 0 1.4rem !important;
}

.hamnus-intro-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.hamnus-topic-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none !important;
  color: var(--hamnus-white) !important;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.hamnus-topic-chip:hover,
.hamnus-topic-chip:focus-visible {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 600px) {
  .hamnus-intro {
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.75rem;
  }

  .hamnus-intro-text {
    font-size: 0.98rem;
  }

  .hamnus-topic-chip {
    min-height: 36px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
  }
}

/* "Browse Topics" on course hub pages (archive.php): compact two-column
   list on phones so the lessons aren't pushed far down the page. */
@media (max-width: 600px) {
  .subcategory-grid {
    padding: 1rem !important;
    margin: 0.5rem 0 1.5rem !important;
  }

  .subcategory-title {
    margin-bottom: 0.6rem !important;
  }

  .subcategory-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }

  .subcategory-card {
    padding: 0.6rem 0.7rem !important;
  }

  .subcat-name {
    font-size: 0.84rem;
    line-height: 1.3;
  }

  .subcat-count {
    font-size: 0.74rem !important;
  }
}

/* --------------------------------------------------------------------------
   6. Article pages - readable line length and tidy meta
   -------------------------------------------------------------------------- */
.single-post .site-content-wrapper > article,
.single-post .site-content-wrapper > .thumbnail-post-intro,
.single-post .site-content-wrapper > .navigation,
.single-post .site-content-wrapper > .post-navigation,
.single-post .site-content-wrapper > #comments,
.single-post .site-content-wrapper > .comments-area {
  max-width: 760px;
  margin-left: auto !important;
  margin-right: auto !important;
}

.single-post .post-single p,
.single-post .post-single li {
  font-size: 1.0625rem;
  line-height: 1.75;
}

.single-post .ilovewp-meta-flex {
  display: flex !important;
  align-items: center;
  gap: 0.85rem;
}

.single-post .ilovewp-page-intro .post-meta {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 1rem;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.single-post .ilovewp-page-intro .post-meta > span::before,
.single-post .ilovewp-page-intro .post-meta > span:not(:first-child)::before {
  content: none !important;
  display: none !important;
}

.single-post .ilovewp-page-intro .post-meta > .post-meta-category {
  flex-basis: 100%;
}

@media (max-width: 600px) {
  .single-post .post-meta-gravatar img {
    width: 44px !important;
    height: 44px !important;
  }

  .single-post .ilovewp-page-intro .post-meta {
    font-size: 0.85rem;
  }
}

/* --------------------------------------------------------------------------
   7. Footer - readable size and contrast
   -------------------------------------------------------------------------- */
.site-footer,
.site-footer p,
.site-footer .site-credits,
.site-footer .copyright {
  font-size: 0.875rem !important;
  color: #cbd5e1 !important;
}

.site-footer a,
.footer-legal-links a {
  color: #e2e8f0 !important;
}

.footer-legal-links a {
  display: inline-block;
  padding: 0.4rem 0.3rem;
  font-size: 0.875rem !important;
}

/* --------------------------------------------------------------------------
   8. 404 page (404.php)
   -------------------------------------------------------------------------- */
.hamnus-404 {
  width: 100%;
  max-width: 760px;
  margin: 0 auto !important;
  float: none !important;
  padding: 2.5rem 0 3rem;
}

.hamnus-404-code {
  font-family: var(--hamnus-font-heading);
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 0.75rem;
  color: var(--hamnus-accent);
}

.hamnus-404 .title-page {
  margin: 0 0 0.5rem;
}

.hamnus-404-text {
  color: var(--hamnus-gray-600);
  margin: 0 0 1.5rem;
}

.hamnus-404 .search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.hamnus-404 .search-form label {
  flex: 1 1 auto;
}

.hamnus-404 .search-form .search-field {
  width: 100%;
}

.hamnus-404 .hamnus-topic-chip {
  color: var(--hamnus-primary) !important;
  background: var(--hamnus-gray-50);
  border-color: var(--hamnus-gray-200);
}

.hamnus-404 .hamnus-topic-chip:hover,
.hamnus-404 .hamnus-topic-chip:focus-visible {
  color: var(--hamnus-accent) !important;
  border-color: var(--hamnus-accent);
  background: var(--hamnus-white);
}

.hamnus-404-subtitle {
  font-size: 1.15rem;
  margin: 2.25rem 0 0.75rem;
}

.hamnus-404-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hamnus-gray-200);
}

.hamnus-404-recent li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--hamnus-gray-200);
}

.hamnus-404-recent a {
  font-weight: 600;
  color: var(--hamnus-gray-800);
  text-decoration: none;
}

.hamnus-404-recent a:hover {
  color: var(--hamnus-accent);
}

.hamnus-404-recent time {
  font-size: 0.85rem;
  color: var(--hamnus-gray-500);
}

/* --------------------------------------------------------------------------
   9. Keyboard focus that is actually visible
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--hamnus-accent);
  outline-offset: 2px;
}
