/*
Theme Name: Accessible Affiliate
Theme URI: https://example.com/accessible-affiliate
Author: JB
Author URI: https://example.com
Description: A fully accessible (WCAG 2.1 AA) WordPress theme inspired by the layout of nonprofit affiliate sites: hero banner, card-based content sections, mega navigation, and a contact-rich footer. Logos are user-replaceable via the Customizer (Site Identity for the header logo, Theme Options for the footer logo).
Version: 1.10.0
Requires at least: 5.9
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: accessible-affiliate
Tags: accessibility-ready, custom-logo, custom-menu, featured-images, full-width-template, one-column, two-columns, translation-ready, blog, news
*/

/* ==========================================================================
   1. Custom properties & base
   ========================================================================== */
:root {
  --aa-primary: #00467f;        /* 8.4:1 on white */
  --aa-primary-dark: #002a4d;
  --aa-accent: #ffb81c;         /* used as bg with dark text only */
  --aa-text: #1a1a1a;
  --aa-text-light: #ffffff;
  --aa-muted: #595959;          /* 7:1 on white */
  --aa-bg: #ffffff;
  --aa-bg-alt: #f2f5f8;
  --aa-border: #c9d3dc;
  --aa-focus: #b35900;          /* high-visibility focus ring */
  --aa-max-width: 72rem;
  --aa-font: "Helvetica Neue", Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  font-family: var(--aa-font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--aa-text);
  background: var(--aa-bg);
  -webkit-text-size-adjust: 100%;
}

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

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

.screen-reader-text:focus {
  background-color: var(--aa-bg);
  clip: auto !important;
  clip-path: none;
  color: var(--aa-primary);
  display: block;
  font-size: 1rem;
  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 {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100001;
  background: var(--aa-primary-dark);
  color: var(--aa-text-light);
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Visible focus indicator everywhere — never remove outlines */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
  outline: 3px solid var(--aa-focus);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) { outline-color: transparent; }
a:focus-visible { outline: 3px solid var(--aa-focus); outline-offset: 2px; }

/* ==========================================================================
   3. Typography & links
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.25;
  color: var(--aa-primary-dark);
  margin: 1.5em 0 0.5em;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); }

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

a:hover { color: var(--aa-primary-dark); }

/* ==========================================================================
   4. Layout
   ========================================================================== */
.aa-container {
  max-width: var(--aa-max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-main { padding: 1rem 0 3rem; }

/* ==========================================================================
   5. Header
   ========================================================================== */
.site-header {
  border-bottom: 4px solid var(--aa-primary);
}

/* Right column of the band: Donate / Contact + search on top, menu below */
.site-header__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex: 1 1 0;
  min-width: 0;
}

.site-header__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

/*
 * Gradient band behind logo + menu (hawaii.nfb.org-style
 * .header-gradient-layer). When a Header Media graphic is set it becomes
 * the band background, stretched 105% x 100% exactly like the NFB site;
 * otherwise a CSS gradient fades white (logo side) into the brand color
 * (menu side).
 */
.site-header__band {
  background: linear-gradient(
    90deg,
    var(--aa-bg) 0%,
    var(--aa-bg) 34%,
    var(--aa-primary) 58%,
    var(--aa-primary-dark) 100%
  );
}

.site-header__band.has-banner-image {
  background-color: var(--aa-primary-dark);
  background-repeat: no-repeat;
  background-size: 105% 100%;
  background-position: left center;
}

.site-header__band-inner {
  display: flex;
  flex-wrap: nowrap; /* logo and right column always share one row on desktop */
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  max-width: var(--aa-max-width);
  margin: 0 auto;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 1 auto;
  min-width: 0;    /* allow wide logos to shrink instead of pushing */
  max-width: 40%;
}

.site-branding .custom-logo-link { display: block; max-width: 100%; }

.custom-logo {
  max-height: 90px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.site-title {
  margin: 0;
  font-size: 1.5rem;
}

.site-title a {
  color: var(--aa-primary-dark);
  text-decoration: none;
}

.site-title a:hover { text-decoration: underline; }

.site-description { margin: 0; color: var(--aa-muted); font-size: 1rem; }

/* Utility nav (Donate / Contact) */
.utility-nav ul {
  display: flex;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.utility-nav a {
  display: inline-block;
  background: var(--aa-primary);
  color: var(--aa-text-light);
  text-decoration: none;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
}

.utility-nav a:hover,
.utility-nav a:focus {
  background: var(--aa-primary-dark);
  text-decoration: underline;
}

/* Separate the buttons from the dark side of the band graphic */
.site-header__band .utility-nav a {
  border: 1px solid rgba(255, 255, 255, 0.65);
}

/* Header search */
.header-search form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.header-search input[type="search"] {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--aa-border);
  border-radius: 4px;
  font-size: 1rem;
  min-width: 10rem;
}

/* ==========================================================================
   6. Primary navigation (accessible dropdowns, right-justified in the band)
   ========================================================================== */
.main-navigation {
  align-self: stretch;
}

.menu-toggle {
  display: none;
  width: 100%;
  background: var(--aa-primary);
  color: var(--aa-text-light);
  border: 0;
  border-radius: 4px;
  font-size: 1.125rem;
  font-weight: 700;
  padding: 0.85rem 1.25rem;
  text-align: left;
  cursor: pointer;
}

.menu-toggle:hover { background: var(--aa-primary-dark); }

.main-navigation ul.nav-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end; /* right-justified main menu */
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-navigation li { position: relative; }

.main-navigation a,
.main-navigation .submenu-toggle {
  display: block;
  color: var(--aa-text-light);
  text-decoration: none;
  font-weight: 600;
  padding: 0.85rem 1.1rem;
  background: transparent;
  border: 0;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); /* legibility over banner graphics */
}

.main-navigation a:hover,
.main-navigation a:focus,
.main-navigation .submenu-toggle:hover,
.main-navigation .submenu-toggle:focus {
  background: var(--aa-primary-dark);
  color: var(--aa-text-light);
  text-decoration: underline;
}

.main-navigation li.menu-item-has-children > a {
  display: inline-block;
  padding-right: 0.25rem;
}

.submenu-toggle {
  padding: 0.85rem 0.6rem;
}

.submenu-toggle .toggle-icon::after {
  content: "▾";
  display: inline-block;
  transition: transform 0.15s ease;
}

.submenu-toggle[aria-expanded="true"] .toggle-icon::after {
  transform: rotate(180deg);
}

.main-navigation ul.sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 16rem;
  background: var(--aa-primary-dark);
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.main-navigation ul.sub-menu.is-open { display: block; }

.main-navigation ul.sub-menu a {
  padding: 0.65rem 1.1rem;
  font-weight: 400;
}

.main-navigation ul.sub-menu ul.sub-menu {
  position: static;
  box-shadow: none;
  padding-left: 1rem;
}

@media (max-width: 60rem) {
  /* On small screens the band collapses to a solid background so the logo
     and stacked menu never sit on an unpredictable slice of the graphic. */
  .site-header__band,
  .site-header__band.has-banner-image {
    background: var(--aa-bg);
    background-image: none;
  }

  .site-header__band-inner { flex-direction: column; align-items: stretch; }

  .site-branding { justify-content: center; max-width: 100%; }

  .site-header__right { align-items: stretch; }

  .site-header__tools { justify-content: center; }

  .menu-toggle { display: block; }

  .main-navigation ul.nav-menu {
    display: none;
    flex-direction: column;
    background: var(--aa-primary);
    border-radius: 4px;
  }

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

  .main-navigation ul.sub-menu {
    position: static;
    box-shadow: none;
    padding-left: 1rem;
  }
}

/* ==========================================================================
   6b. Logo bar under the main navigation (Customize > Logo Bar)
   White strip with user-set height (--aa-logo-bar-height) and spacing
   (--aa-logo-gap). Logos scale to the bar height minus 5px padding top
   and bottom, keeping their aspect ratio, vertically centered.
   ========================================================================== */
.aa-logo-bar {
  display: flex;
  align-items: center;            /* vertical centering */
  justify-content: center;
  column-gap: var(--aa-logo-gap, 48px); /* adjustable spacing */
  row-gap: 0;
  height: var(--aa-logo-bar-height, 80px); /* user-set bar height */
  background: var(--aa-bg);       /* white */
  padding: 5px 1.25rem;           /* 5px top/bottom padding */
}

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

.aa-logo-bar__img,
.aa-logo-bar img {
  /* Logos scale with the bar: height minus the 5px top + bottom padding */
  height: calc(var(--aa-logo-bar-height, 80px) - 10px);
  width: auto;       /* keep aspect ratio */
  max-width: 100%;
  object-fit: contain;
}

@media (max-width: 60rem) {
  /* Mobile: keep logos side by side at full size; they only wrap when
     they no longer fit, and wrapped rows have 0 vertical spacing. */
  .aa-logo-bar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--aa-logo-bar-height, 80px);
  }
}

/* ==========================================================================
   7. Hero
   ========================================================================== */
.aa-hero {
  position: relative;
  background: var(--aa-primary-dark);
  color: var(--aa-text-light);
  margin-top: -1rem; /* sit flush against the header / logo bar */
}

/* Page featured-image banner reuses the hero fit classes; no dark panel */
.aa-page-banner {
  background: transparent;
  line-height: 0;
}

/* Default ("Fill area"): fixed banner height, image cropped to fill */
.aa-hero__image {
  width: 100%;
  height: clamp(16rem, 45vw, 28rem);
  object-fit: cover;
  display: block;
}

/* "Full width (natural height)": whole image edge to edge, no cropping —
   a short, wide image fills the width and the banner shrinks to match. */
.aa-hero--natural .aa-hero__image {
  height: auto;
}

/* "Fit inside (no crop)": fixed height, whole image letterboxed within it */
.aa-hero--contain .aa-hero__image {
  object-fit: contain;
  background: var(--aa-primary-dark);
}

.aa-hero__content {
  background: var(--aa-primary-dark);
  padding: 2rem 1.25rem;
}

.aa-hero__content > div {
  max-width: var(--aa-max-width);
  margin: 0 auto;
}

.aa-hero__title {
  color: var(--aa-text-light);
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.aa-hero__text {
  font-size: 1.15rem;
  max-width: 50rem;
  margin: 0;
}

/* ==========================================================================
   8. Cards / sections (matches block patterns)
   ========================================================================== */
.aa-section { padding: 2.5rem 0 1rem; }

.aa-section--alt { background: var(--aa-bg-alt); }

.aa-section > h2,
.entry-content h2 {
  border-bottom: 3px solid var(--aa-accent);
  padding-bottom: 0.35rem;
}

.aa-card,
.wp-block-column.aa-card {
  background: var(--aa-bg);
  border: 1px solid var(--aa-border);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.aa-card img { display: block; width: 100%; object-fit: cover; }

.aa-card h3 { margin: 1rem 1rem 0.5rem; }

.aa-card p { margin: 0 1rem 1rem; }

.aa-card .wp-block-buttons,
.aa-card .aa-card__link { margin: auto 1rem 1.25rem; }

.wp-block-button__link,
.aa-button {
  background: var(--aa-primary);
  color: var(--aa-text-light);
  font-weight: 700;
  text-decoration: none;
  padding: 0.65rem 1.3rem;
  border-radius: 4px;
  display: inline-block;
}

.wp-block-button__link:hover,
.wp-block-button__link:focus,
.aa-button:hover,
.aa-button:focus {
  background: var(--aa-primary-dark);
  color: var(--aa-text-light);
  text-decoration: underline;
}

/* ==========================================================================
   9. Content
   ========================================================================== */
.entry-header .entry-title { margin-top: 0.5em; }

.entry-meta {
  color: var(--aa-muted);
  font-size: 0.95rem;
}

article.hentry { margin-bottom: 2.5rem; }

.post-thumbnail img { border-radius: 6px; }

.page-header .page-title { margin-top: 0.5em; }

/* Forms */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
textarea,
select {
  border: 2px solid var(--aa-muted);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--aa-text);
  max-width: 100%;
}

button,
input[type="submit"] {
  background: var(--aa-primary);
  color: var(--aa-text-light);
  border: 0;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
}

button:hover,
input[type="submit"]:hover {
  background: var(--aa-primary-dark);
}

label { font-weight: 600; }

/* Pagination */
.navigation.pagination .nav-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.navigation.pagination .page-numbers {
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--aa-primary);
  border-radius: 4px;
  text-decoration: none;
}

.navigation.pagination .page-numbers.current {
  background: var(--aa-primary);
  color: var(--aa-text-light);
}

/* ==========================================================================
   10. Contact band + Footer
   ========================================================================== */
.aa-contact-band {
  background: var(--aa-bg-alt);
  border-top: 4px solid var(--aa-accent);
  padding: 2.5rem 0;
}

.aa-contact-band h2 { margin-top: 0; }

.aa-contact-band address { font-style: normal; }

.site-footer {
  background: var(--aa-primary-dark);
  color: var(--aa-text-light);
  padding: 2.5rem 0 1.5rem;
}

.site-footer a { color: var(--aa-text-light); }

.site-footer a:hover,
.site-footer a:focus { color: var(--aa-accent); }

.site-footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 2rem;
  align-items: start;
}

.site-footer__logo img { max-height: 80px; width: auto; }

.footer-navigation ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-navigation li { margin-bottom: 0.5rem; }

.aa-social-links ul {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.aa-social-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.site-info {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 0.95rem;
}

/* ==========================================================================
   11. Widgets
   ========================================================================== */
.widget { margin-bottom: 2rem; }

.widget-title {
  font-size: 1.2rem;
  margin-top: 0;
}

/* ==========================================================================
   12. Alignment / WP core compatibility
   ========================================================================== */
.alignwide { max-width: calc(var(--aa-max-width) + 8rem); margin-left: auto; margin-right: auto; }
.alignfull { width: 100%; max-width: none; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }
.alignleft { float: left; margin: 0.5rem 1.5rem 1rem 0; }
.alignright { float: right; margin: 0.5rem 0 1rem 1.5rem; }

.wp-caption { max-width: 100%; }
.wp-caption-text { color: var(--aa-muted); font-size: 0.95rem; }

/* ==========================================================================
   13. Print
   ========================================================================== */
@media print {
  .site-header, .main-navigation, .site-footer, .aa-contact-band, .skip-link { display: none; }
  body { color: #000; }
  a { color: #000; text-decoration: underline; }
}
