/**
 * WP Acessível JINC — Frontend Accessibility Bar
 *
 * Sticky top bar with high-contrast native styling.
 * CSS Custom Properties enable the high-contrast toggle mode.
 *
 * @spec-ref Phase 3 — Frontend Accessibility Bar
 */

/* ── Design Tokens ── */

:root {
  --jinc-bar-bg: #1a1a2e;
  --jinc-bar-text: #e0e0e0;
  --jinc-bar-accent: #00d4aa;
  --jinc-bar-hover: #00f0c0;
  --jinc-bar-focus-ring: #00d4aa;
  --jinc-bar-height: 48px;
  --jinc-bar-font-size: 0.875rem;
  --jinc-bar-radius: 6px;
  --jinc-bar-gap: 0.5rem;
  --jinc-base-font-size: 100%;
}

/* ══════════════════════════════════════════════════════════
   HIGH CONTRAST MODE — Aggressive Theme Override
   Toggled via JS: html.jinc-high-contrast
   ══════════════════════════════════════════════════════════ */

html.jinc-high-contrast {
  --jinc-bar-bg: #000000;
  --jinc-bar-text: #ffffff;
  --jinc-bar-accent: #ffff00;
  --jinc-bar-hover: #ffff00;
  --jinc-bar-focus-ring: #ffff00;
}

/*
 * Aggressive CSS Reset for theme elements.
 * Uses html.jinc-high-contrast as root selector for maximum specificity.
 * EXCLUDES #jinc-a11y-bar and its children to preserve bar layout.
 */

/* ── Base Elements ── */

html.jinc-high-contrast body {
  background-color: #000000 !important;
  color: #ffffff !important;
}

html.jinc-high-contrast *:not(.jinc-a11y-wrapper):not(.jinc-a11y-wrapper *) {
  color: #ffffff !important;
  border-color: #ffffff !important;
}

/* ── Typography & Links ── */

html.jinc-high-contrast a:not(.jinc-a11y-wrapper a),
html.jinc-high-contrast a:visited:not(.jinc-a11y-wrapper a) {
  color: #ffff00 !important;
  text-decoration: underline !important;
}

html.jinc-high-contrast a:hover:not(.jinc-a11y-wrapper a),
html.jinc-high-contrast a:focus:not(.jinc-a11y-wrapper a) {
  color: #00ffff !important;
  outline: 2px solid #ffff00 !important;
}

/* ── Backgrounds: Headers, Sections, Divs, Cards ── */

html.jinc-high-contrast header:not(.jinc-a11y-wrapper),
html.jinc-high-contrast footer:not(.jinc-a11y-wrapper),
html.jinc-high-contrast main,
html.jinc-high-contrast article,
html.jinc-high-contrast section,
html.jinc-high-contrast aside,
html.jinc-high-contrast nav:not(.jinc-a11y-wrapper nav),
html.jinc-high-contrast div:not(.jinc-a11y-wrapper):not(.jinc-a11y-wrapper div),
html.jinc-high-contrast figure,
html.jinc-high-contrast blockquote,
html.jinc-high-contrast pre,
html.jinc-high-contrast code,
html.jinc-high-contrast table,
html.jinc-high-contrast th,
html.jinc-high-contrast td,
html.jinc-high-contrast li,
html.jinc-high-contrast details,
html.jinc-high-contrast summary {
  background-color: #000000 !important;
  color: #ffffff !important;
}

/* ── Headings ── */

html.jinc-high-contrast h1:not(.jinc-a11y-wrapper h1),
html.jinc-high-contrast h2:not(.jinc-a11y-wrapper h2),
html.jinc-high-contrast h3:not(.jinc-a11y-wrapper h3),
html.jinc-high-contrast h4,
html.jinc-high-contrast h5,
html.jinc-high-contrast h6 {
  color: #ffffff !important;
}

/* ── Form Elements ── */

html.jinc-high-contrast input:not(.jinc-a11y-wrapper input),
html.jinc-high-contrast textarea:not(.jinc-a11y-wrapper textarea),
html.jinc-high-contrast select:not(.jinc-a11y-wrapper select),
html.jinc-high-contrast button:not(.jinc-a11y-wrapper button) {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

html.jinc-high-contrast input:focus:not(.jinc-a11y-wrapper input),
html.jinc-high-contrast textarea:focus:not(.jinc-a11y-wrapper textarea),
html.jinc-high-contrast select:focus:not(.jinc-a11y-wrapper select),
html.jinc-high-contrast button:focus:not(.jinc-a11y-wrapper button) {
  outline: 3px solid #ffff00 !important;
  outline-offset: 2px;
}

/* ── Images ── */

html.jinc-high-contrast img {
  filter: contrast(1.2) brightness(1.1);
}

/* ── Shadows & Gradients Removal ── */

html.jinc-high-contrast *:not(.jinc-a11y-wrapper):not(.jinc-a11y-wrapper *) {
  text-shadow: none !important;
  box-shadow: none !important;
  background-image: none !important;
}

/* ── Table Borders ── */

html.jinc-high-contrast table:not(.jinc-a11y-wrapper table),
html.jinc-high-contrast th:not(.jinc-a11y-wrapper th),
html.jinc-high-contrast td:not(.jinc-a11y-wrapper td) {
  border: 1px solid #ffffff !important;
}

/* ══════════════════════════════════════════════════════════
   LARGE FONT MODE
   ══════════════════════════════════════════════════════════ */

html.jinc-large-font {
  --jinc-base-font-size: 125%;
}

html.jinc-large-font body {
  font-size: var(--jinc-base-font-size) !important;
}

/* ══════════════════════════════════════════════════════════
   BAR LAYOUT — Normal (default) styles
   ══════════════════════════════════════════════════════════ */

/* ── Bar Container ── */

.jinc-a11y-wrapper {
  position: sticky;
  top: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--jinc-bar-height);
  padding: 0.375rem 1rem;
  background-color: var(--jinc-bar-bg);
  color: var(--jinc-bar-text);
  font-family: var(--jinc-bar-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  font-size: var(--jinc-bar-font-size);
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.jinc-a11y-wrapper[data-bar-size="small"] {
  --jinc-bar-height: 40px;
  --jinc-bar-font-size: 0.75rem;
}
.jinc-a11y-wrapper[data-bar-size="large"] {
  --jinc-bar-height: 56px;
  --jinc-bar-font-size: 1rem;
}

/* ── Nav Container ── */

.jinc-a11y-wrapper nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center; /* keep items centered vertically */
  gap: 10px;
  max-width: 1200px;
  width: 100%;
  justify-content: var(--jinc-bar-align, center);
}

.jinc-bar-title {
  font-weight: 700;
  margin-right: auto;
  font-size: 1.1em;
}

/* ── Buttons & Links (including skip link — ALWAYS VISIBLE) ── */

.jinc-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 2px solid var(--jinc-bar-accent);
  border-radius: var(--jinc-btn-radius, 4px); /* Consome a nova variável */
  min-height: 44px; /* Tamanho de toque mínimo WCAG */
  background: transparent;
  color: var(--jinc-bar-text);
  font-size: inherit;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.jinc-bar-btn:hover,
.jinc-bar-btn:focus,
.jinc-bar-btn:focus-visible {
  background-color: var(--jinc-bar-accent);
  color: var(--jinc-bar-text-hover);
}

.jinc-bar-btn:focus-visible {
  outline: 3px solid var(--jinc-bar-focus-ring);
  outline-offset: 2px;
}

/* ── Active state (aria-pressed="true") ── */

.jinc-bar-btn[aria-pressed="true"] {
  background-color: var(--jinc-bar-accent);
  color: var(--jinc-bar-text-hover);
  font-weight: 600;
}

html.jinc-high-contrast .jinc-a11y-wrapper .jinc-bar-btn[aria-pressed="true"] {
    background-color: #ffff00 !important;
    color: #000000 !important; 
    border-color: #000000 !important;
}

html.jinc-high-contrast .jinc-a11y-wrapper .jinc-bar-btn:hover,
html.jinc-high-contrast .jinc-a11y-wrapper .jinc-bar-btn:focus {
    background-color: #ffff00 !important;
    color: #000000 !important; 
    border-color: #000000 !important;
}

/* ── Icon decorative spans ── */

.jinc-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25em; /* Dashicons default works well around 20px */
  line-height: 1;
}

/* Hide icons when show_icons is false */
.jinc-no-icons svg, 
.jinc-no-icons i, 
.jinc-no-icons .jinc-bar-icon {
  display: none !important;
}

/*
 * Skip Link: ALWAYS VISIBLE in the bar.
 * No longer hidden off-screen — it's a first-class button in the toolbar.
 * Uses the same .jinc-bar-btn styling as the other controls.
 */

/* ── Responsive: stack vertically on small screens ── */

@media (max-width: 600px) {
  .jinc-a11y-wrapper {
    padding: 0.375rem 0.5rem;
  }

  .jinc-a11y-wrapper nav {
    gap: 0.375rem;
  }

  .jinc-bar-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
  }
}

/* ── Respect reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  .jinc-bar-btn {
    transition: none;
  }
}

/* ── WordPress admin bar offset ── */

body.admin-bar .jinc-a11y-wrapper:not([data-layout="floating_pill"]) {
  top: 32px;
}

@media (max-width: 782px) {
  body.admin-bar .jinc-a11y-wrapper:not([data-layout="floating_pill"]) {
    top: 46px;
  }
}

/* ══════════════════════════════════════════════════════════
   BAR LAYOUT — Floating Pill styles
   ══════════════════════════════════════════════════════════ */

.jinc-a11y-wrapper[data-layout="floating_pill"] {
  position: fixed;
  top: auto;
  bottom: 20px;
  border-radius: 50px;
  padding: 10px 20px;
  width: auto;
}

.jinc-a11y-wrapper[data-layout="floating_pill"][data-position="bottom_right"] {
  right: 20px;
  left: auto;
}

.jinc-a11y-wrapper[data-layout="floating_pill"][data-position="bottom_left"] {
  left: 20px;
  right: auto;
}

/* Adjust nav for floating pill */
.jinc-a11y-wrapper[data-layout="floating_pill"] nav {
  flex-wrap: nowrap;
}

@media (max-width: 600px) {
  .jinc-a11y-wrapper[data-layout="floating_pill"] {
    bottom: 10px;
    border-radius: 20px;
    padding: 8px 12px;
  }
  
  .jinc-a11y-wrapper[data-layout="floating_pill"][data-position="bottom_right"] {
    right: 10px;
  }
  
  .jinc-a11y-wrapper[data-layout="floating_pill"][data-position="bottom_left"] {
    left: 10px;
  }
}
