/**
 * iPin Modern — Base Styles
 * Reset, typography, global elements, WCAG utilities.
 *
 * WCAG 2.2 compliance:
 *   1.4.3  Contrast (AA)       — all text pairs verified in tokens.css
 *   1.4.11 Non-text Contrast   — focus rings, borders meet 3:1
 *   2.4.7  Focus Visible       — :focus-visible on all interactive elements
 *   2.4.11 Focus Appearance    — min 2px outline, offset, area ≥ perimeter²×0.0625
 *   2.4.3  Focus Order         — logical DOM order maintained
 *   2.5.8  Target Size (AA)    — min 24×24 px enforced via min-height/min-width
 *   1.4.12 Text Spacing        — no style blocks text spacing overrides
 *   1.4.4  Resize Text         — em/rem units throughout, no px font sizes
 *   2.3.3  Animation           — prefers-reduced-motion respected
 *   1.4.6  Enhanced Contrast   — prefers-contrast: more handled
 */

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  font-size: var(--font-size-base);
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--line-height);
  background: var(--bg-body);
  color: var(--txt-primary);
  padding-top: var(--nav-height);
  padding-bottom: 3rem;
  transition:
    background var(--dur),
    color      var(--dur);
}

/* ── Skip to content (WCAG 2.4.1) ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  background: var(--bg-card);
  color: var(--clr-accent-1);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border: 2px solid var(--clr-accent-1);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0s;
}

.skip-link:focus {
  top: calc(var(--nav-height) + 8px);
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Global focus style (WCAG 2.4.7 / 2.4.11) ──
   Visible on all interactive elements. Uses box-shadow
   so it composites correctly on any background colour.   */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}

/* Remove focus ring on mouse/touch – only keyboard users see it */
:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* ── Minimum touch/click target size (WCAG 2.5.8) ──
   24×24 px minimum. Nav items, buttons, links in nav
   already meet this via padding; enforce globally here. */
a, button, [role="button"], input, select, textarea, label[for] {
  min-height: 24px;
}

/* ── Links ── */
a {
  color: var(--clr-accent-2);
  text-decoration: underline;
  text-decoration-color: rgba(120,75,160,.35);
  text-underline-offset: 3px;
  transition: color var(--dur), text-decoration-color var(--dur);
}

a:hover {
  color: var(--clr-accent-1);
  text-decoration-color: currentColor;
}

/* ── Headings ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--txt-primary);
}

/* ── Images ── */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Embeds ── */
embed, iframe, object, video {
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* ── WP Alignment ── */
img.aligncenter, div.aligncenter { display: block; margin: 0 auto; border-radius: var(--radius-sm); }
img.alignright { float: right; margin: 0.25rem 0 1rem 1.5rem; border-radius: var(--radius-sm); }
img.alignleft  { float: left;  margin: 0.25rem 1.5rem 1rem 0; border-radius: var(--radius-sm); }
.alignright { float: right; }
.alignleft  { float: left; }

/* ── WP Captions (WCAG 1.1.1 — caption text always visible) ── */
.wp-caption {
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.625rem;
  max-width: 100%;
  margin: 0.75rem auto;
  text-align: center;
}

.wp-caption img { border-radius: var(--radius-sm); margin-bottom: 0.375rem; }

.wp-caption-text {
  font-size: 0.8rem;
  color: var(--txt-muted);
  margin: 0;
}

.gallery-caption { color: var(--txt-muted); font-size: 0.8rem; }

/* ── Utilities ── */
.clearfix::after { content: ''; display: block; clear: both; }
.text-center     { text-align: center; }

/* Visually hidden — accessible to screen readers (WCAG 1.3.1) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Prefers-reduced-motion (WCAG 2.3.3) ── */
@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;
  }
}

/* ── High-contrast mode (WCAG 1.4.6 / Windows Forced Colours) ── */
@media (forced-colors: active) {
  a                    { color: LinkText; }
  a:hover              { color: LinkText; }
  button, [role="button"] { border: 1px solid ButtonText; }
  :focus-visible       { outline: 3px solid Highlight; box-shadow: none; }
  .skip-link           { border: 2px solid Highlight; }
}

/* ── prefers-contrast: more ── */
@media (prefers-contrast: more) {
  :root {
    --txt-secondary: #4A4654;
    --txt-muted:     #4A4654;
    --border:        rgba(0,0,0,.45);
  }

  [data-theme="dark"] {
    --txt-secondary: #C8C3D8;
    --txt-muted:     #C8C3D8;
    --border:        rgba(255,255,255,.45);
  }
}

/* ── Ad slot wrapper — reserves layout space before creative loads (CLS) ──
   min-height is set inline by ipin_ad() based on slot type (header vs grid).
   The wrapper itself never contributes extra space when the slot is empty
   because ipin_ad() returns early and outputs nothing when no code is set. */
.ipin-ad-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden; /* prevent ad creatives expanding beyond reserved space */
}

/* =========================================================
   STANDALONE SEARCH FORM
   Used on: empty state (index.php), 404.php, and search
   results. Loaded in base.css so it's available on every
   page — single.css is only loaded on singular views.
   ========================================================= */
.search-form-wrap {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto;
}

.search-form-wrap input[type="search"] {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 11px 20px;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--txt-primary);
  transition: border-color var(--dur), box-shadow var(--dur);
  /* Remove UA default search cancel button on WebKit */
  -webkit-appearance: none;
  appearance: none;
}

.search-form-wrap input[type="search"]:focus-visible {
  outline: none;
  border-color: var(--clr-accent-1);
  box-shadow: var(--focus-ring);
}

.search-form-wrap button {
  flex-shrink: 0;
  background: var(--grad-brand-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 11px 24px;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--dur), transform var(--dur) var(--ease);
}

.search-form-wrap button:hover  { opacity: .86; transform: scale(1.03); }
.search-form-wrap button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* =========================================================
   SITE FOOTER — #footer
   Defined in base.css so it renders correctly on all pages
   including the homepage, 404, and tag archives where
   single.css is not loaded.
   ========================================================= */
#footer {
  background: var(--grad-brand-btn);
  color: rgba(255,255,255,.90);
  text-align: center;
  padding: 28px 24px;
  margin-top: 52px;
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1.6;
}

#footer a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  opacity: .95;
  transition: opacity var(--dur);
}

#footer a:hover      { opacity: 1; text-decoration: underline; text-underline-offset: 3px; }
#footer a:focus-visible {
  outline: 2px solid rgba(255,255,255,.8);
  outline-offset: 2px;
  border-radius: 2px;
}

/* =========================================================
   SCROLL-TO-TOP BUTTON
   Fixed, uses brand gradient, slides up on hover.
   Min 44×44 px tap target (WCAG 2.5.8).
   Moved to base.css so it works on all page types.
   ========================================================= */
#scrolltotop {
  position: fixed;
  bottom: 26px;
  right: 22px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--grad-brand-btn);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: var(--shadow-md);
  font-size: 1rem;
  font-family: var(--font-body);
}

#scrolltotop.visible {
  opacity: 1;
  pointer-events: auto;
}

#scrolltotop:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: var(--shadow-lg);
}

#scrolltotop:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#scrolltotop .sr-only {
  position: absolute;
  width: 1px; height: 1px;
  clip: rect(0,0,0,0);
  overflow: hidden;
  white-space: nowrap;
}

@media (max-width: 600px) {
  #scrolltotop { right: 12px; bottom: 14px; }
}
