/* ================================================================
   AccessFlow — Theme compatibility: ensure fixed elements escape
   any parent transform/overflow stacking contexts
================================================================ */
#accessflow-launcher,
#accessflow-panel,
#af-ruler,
.af-mask {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* ================================================================
   AccessFlow — Public Styles v1.0.0
   ================================================================ */

/* ----------------------------------------------------------------
   CSS custom properties (panel theming)
---------------------------------------------------------------- */
:root {
  --af-brand:         #1c7a82;
  --af-brand-dark:    #145c63;
  --af-panel-bg:      #ffffff;
  --af-panel-border:  #e0e0e0;
  --af-panel-text:    #1a1a1a;
  --af-panel-subtle:  #f5f5f5;
  --af-section-head:  #444;
  --af-btn-bg:        #f0f0f0;
  --af-btn-hover:     #e0e0e0;
  --af-btn-text:      #1a1a1a;
  --af-active-bg:     #1c7a82;
  --af-active-text:   #ffffff;
  --af-panel-width:   340px;
  --af-radius:        12px;
  --af-shadow:        0 8px 32px rgba(0,0,0,0.16);
  --af-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ================================================================
   LAUNCHER BUTTON
================================================================ */
#accessflow-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483647;
  transform: translateZ(0);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--af-brand);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 18px;
  cursor: pointer;
  font-family: var(--af-font);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  user-select: none;
  outline: none;
}

body.af-position-left #accessflow-launcher {
  right: auto;
  left: 24px;
}

#accessflow-launcher:hover,
#accessflow-launcher:focus {
  background: var(--af-brand-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}

#accessflow-launcher:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.af-launcher-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.af-launcher-label {
  white-space: nowrap;
}

/* ================================================================
   PANEL
================================================================ */
#accessflow-panel {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 2147483646;
  transform: translateZ(0);
  width: var(--af-panel-width);
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 110px);
  background: var(--af-panel-bg);
  border: 1px solid var(--af-panel-border);
  border-radius: var(--af-radius);
  box-shadow: var(--af-shadow);
  font-family: var(--af-font);
  font-size: 14px;
  color: var(--af-panel-text);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: af-slide-up 0.2s ease;
}

body.af-position-left #accessflow-panel {
  right: auto;
  left: 24px;
}

#accessflow-panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@keyframes af-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------------------
   Panel header
---------------------------------------------------------------- */
.af-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--af-brand);
  color: #fff;
  flex-shrink: 0;
}

.af-panel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.af-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.af-close:hover,
.af-close:focus-visible {
  background: rgba(255,255,255,0.18);
  color: #fff;
  outline: 2px solid #fff;
}

/* ----------------------------------------------------------------
   Panel body
---------------------------------------------------------------- */
.af-panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 0 0 8px;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

/* ----------------------------------------------------------------
   Sections
---------------------------------------------------------------- */
.af-section {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--af-panel-border);
}

.af-section:last-child {
  border-bottom: none;
}

.af-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--af-section-head);
  margin: 0 0 10px;
}

/* ----------------------------------------------------------------
   Rows
---------------------------------------------------------------- */
.af-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.af-row:last-child {
  margin-bottom: 0;
}

.af-row-label {
  font-size: 13px;
  color: var(--af-panel-text);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 90px;
}

/* ----------------------------------------------------------------
   Button groups
---------------------------------------------------------------- */
.af-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ----------------------------------------------------------------
   Buttons
---------------------------------------------------------------- */
.af-btn {
  background: var(--af-btn-bg);
  color: var(--af-btn-text);
  border: 1px solid var(--af-panel-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--af-font);
  transition: background 0.15s;
  white-space: nowrap;
}

.af-btn:hover,
.af-btn:focus-visible {
  background: var(--af-btn-hover);
  outline: 2px solid var(--af-brand);
}

.af-btn-sm  { font-size: 11px; padding: 4px 8px; }
.af-btn-large { font-size: 15px; }

.af-btn-accent {
  background: var(--af-brand);
  color: #fff;
  border-color: var(--af-brand);
}

.af-btn-accent:hover,
.af-btn-accent:focus-visible {
  background: var(--af-brand-dark);
}

/* Toggle buttons (on/off) */
.af-toggle-btn {
  background: var(--af-btn-bg);
  color: var(--af-btn-text);
  border: 1px solid var(--af-panel-border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--af-font);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.af-toggle-btn:hover,
.af-toggle-btn:focus-visible {
  background: var(--af-btn-hover);
  outline: 2px solid var(--af-brand);
}

.af-toggle-btn.af-active,
.af-toggle-btn[aria-pressed="true"] {
  background: var(--af-active-bg);
  color: var(--af-active-text);
  border-color: var(--af-active-bg);
}

/* Cycle buttons */
.af-cycle-btn {
  background: var(--af-btn-bg);
  color: var(--af-btn-text);
  border: 1px solid var(--af-panel-border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--af-font);
  min-width: 70px;
  text-align: center;
  transition: background 0.15s;
}

.af-cycle-btn:hover,
.af-cycle-btn:focus-visible {
  background: var(--af-btn-hover);
  outline: 2px solid var(--af-brand);
}

/* Select */
.af-select {
  border: 1px solid var(--af-panel-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--af-font);
  background: var(--af-btn-bg);
  color: var(--af-btn-text);
  cursor: pointer;
  flex: 1;
  max-width: 170px;
}

.af-select:focus-visible {
  outline: 2px solid var(--af-brand);
}

/* ----------------------------------------------------------------
   Preset grid
---------------------------------------------------------------- */
.af-presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.af-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 1px solid var(--af-panel-border);
  border-radius: 8px;
  background: var(--af-panel-subtle);
  color: var(--af-btn-text);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--af-font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.2;
}

.af-preset-btn svg {
  width: 22px;
  height: 22px;
  color: var(--af-brand);
}

.af-preset-btn:hover,
.af-preset-btn:focus-visible {
  background: var(--af-btn-hover);
  border-color: var(--af-brand);
  outline: 2px solid var(--af-brand);
}

.af-preset-btn.af-active {
  background: var(--af-active-bg);
  color: var(--af-active-text);
  border-color: var(--af-active-bg);
}

.af-preset-btn.af-active svg {
  color: #fff;
}

/* ----------------------------------------------------------------
   Reset section
---------------------------------------------------------------- */
.af-section-reset {
  padding: 10px 14px;
}

.af-reset-btn {
  width: 100%;
  background: transparent;
  color: #b00020;
  border: 1px solid #e0b0b5;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--af-font);
  cursor: pointer;
  transition: background 0.15s;
}

.af-reset-btn:hover,
.af-reset-btn:focus-visible {
  background: #fff0f2;
  outline: 2px solid #b00020;
}

/* ================================================================
   READING RULER
================================================================ */
#af-ruler {
  position: fixed;
  left: 0;
  width: 100%;
  height: 32px;
  background: rgba(255, 230, 100, 0.35);
  border-top: 2px solid rgba(200, 160, 0, 0.4);
  border-bottom: 2px solid rgba(200, 160, 0, 0.4);
  pointer-events: none;
  z-index: 2147483644;
  transform: translateZ(0);
}

body.af-ruler-active::before,
body.af-ruler-active::after {
  content: '';
  display: block;
  position: fixed;
  left: 0;
  width: 100%;
  background: rgba(0,0,0,0.08);
  pointer-events: none;
  z-index: 9997;
}

/* ================================================================
   SCREEN MASK
================================================================ */
.af-mask {
  position: fixed;
  left: 0;
  width: 100%;
  background: rgba(0,0,0,0.72);
  pointer-events: none;
  z-index: 2147483643;
  transform: translateZ(0);
}

.af-mask-top {
  top: 0;
  height: 40%;
}

.af-mask-bottom {
  top: 52%;
  bottom: 0;
  height: auto;
}

/* ================================================================
   BODY-LEVEL EFFECTS
================================================================ */

/* ---- Text size ---- */
.af-text-plus1  body, body.af-text-plus1  { font-size: 106% !important; }
.af-text-plus2  body, body.af-text-plus2  { font-size: 112% !important; }
.af-text-plus3  body, body.af-text-plus3  { font-size: 120% !important; }
.af-text-plus4  body, body.af-text-plus4  { font-size: 130% !important; }
.af-text-plus5  body, body.af-text-plus5  { font-size: 140% !important; }
.af-text-minus1 body, body.af-text-minus1 { font-size: 94% !important; }
.af-text-minus2 body, body.af-text-minus2 { font-size: 88% !important; }
.af-text-minus3 body, body.af-text-minus3 { font-size: 82% !important; }
.af-text-minus4 body, body.af-text-minus4 { font-size: 76% !important; }
.af-text-minus5 body, body.af-text-minus5 { font-size: 70% !important; }

body.af-text-plus1  p, body.af-text-plus1  li, body.af-text-plus1  td,
body.af-text-plus2  p, body.af-text-plus2  li, body.af-text-plus2  td,
body.af-text-plus3  p, body.af-text-plus3  li, body.af-text-plus3  td,
body.af-text-plus4  p, body.af-text-plus4  li, body.af-text-plus4  td,
body.af-text-plus5  p, body.af-text-plus5  li, body.af-text-plus5  td,
body.af-text-minus1 p, body.af-text-minus1 li, body.af-text-minus1 td,
body.af-text-minus2 p, body.af-text-minus2 li, body.af-text-minus2 td,
body.af-text-minus3 p, body.af-text-minus3 li, body.af-text-minus3 td,
body.af-text-minus4 p, body.af-text-minus4 li, body.af-text-minus4 td,
body.af-text-minus5 p, body.af-text-minus5 li, body.af-text-minus5 td { font-size: inherit !important; }

/* ---- Line spacing ---- */
body.af-line-medium p, body.af-line-medium li, body.af-line-medium td,
body.af-line-medium div { line-height: 1.9 !important; }
body.af-line-wide   p, body.af-line-wide   li, body.af-line-wide   td,
body.af-line-wide   div { line-height: 2.4 !important; }

/* ---- Letter spacing ---- */
body.af-ls-medium p, body.af-ls-medium li, body.af-ls-medium td { letter-spacing: 0.06em !important; }
body.af-ls-wide   p, body.af-ls-wide   li, body.af-ls-wide   td { letter-spacing: 0.12em !important; }

/* ---- Dyslexia font ---- */
body.af-dyslexia-font,
body.af-dyslexia-font p,
body.af-dyslexia-font li,
body.af-dyslexia-font td,
body.af-dyslexia-font h1,
body.af-dyslexia-font h2,
body.af-dyslexia-font h3,
body.af-dyslexia-font h4 {
  font-family: 'Comic Sans MS', 'Comic Sans', 'Trebuchet MS', Arial, sans-serif !important;
  letter-spacing: 0.04em !important;
}

/* ---- Highlight links ---- */
body.af-highlight-links a {
  text-decoration: underline 2px !important;
  text-underline-offset: 3px !important;
  background-color: rgba(255, 255, 100, 0.3) !important;
  padding: 0 2px !important;
  border-radius: 2px !important;
  color: #00306e !important;
  font-weight: 600 !important;
}

/* ---- Highlight headings ---- */
body.af-highlight-headings h1,
body.af-highlight-headings h2,
body.af-highlight-headings h3,
body.af-highlight-headings h4,
body.af-highlight-headings h5,
body.af-highlight-headings h6 {
  border-bottom: 2px solid var(--af-brand) !important;
  padding-bottom: 4px !important;
  color: #14505a !important;
}

/* ---- Large cursor ---- */
body.af-cursor-large,
body.af-cursor-large * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M8 2l16 16-7-1-4 9-2-1 4-9-7-1z' fill='black' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 0 0, auto !important;
}

/* ---- Focus mode ---- */
body.af-focus-mode .widget,
body.af-focus-mode aside,
body.af-focus-mode .sidebar,
body.af-focus-mode #sidebar,
body.af-focus-mode .widget-area,
body.af-focus-mode .secondary,
body.af-focus-mode .wp-block-column:not(:first-child),
body.af-focus-mode nav:not([role="navigation"]):not(.main-navigation):not(#site-navigation),
body.af-focus-mode .site-footer-widget-area,
body.af-focus-mode .related-posts {
  display: none !important;
}

body.af-focus-mode .entry-content,
body.af-focus-mode article,
body.af-focus-mode main,
body.af-focus-mode #content,
body.af-focus-mode .site-content {
  max-width: 720px !important;
  margin: 0 auto !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
}

body.af-focus-mode {
  background-color: #fafaf8 !important;
}

/* ================================================================
   FOCUS MODE — AccessFlow elements must never be hidden
================================================================ */
body.af-focus-mode #accessflow-launcher,
body.af-focus-mode #accessflow-panel,
body.af-focus-mode #af-ruler,
body.af-focus-mode #af-mask-top,
body.af-focus-mode #af-mask-bottom {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.af-focus-mode #accessflow-panel[hidden],
body.af-focus-mode #accessflow-panel[style*="display: none"],
body.af-focus-mode #accessflow-panel[style*="display:none"] {
  display: none !important;
}

/* ================================================================
   COLOUR THEMES
================================================================ */

/* ---- High Contrast ---- */
body.af-theme-high-contrast {
  background-color: #000000 !important;
  color: #ffffff !important;
}

body.af-theme-high-contrast * {
  background-color: transparent !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

body.af-theme-high-contrast a {
  color: #ffff00 !important;
  text-decoration: underline !important;
}

body.af-theme-high-contrast input,
body.af-theme-high-contrast select,
body.af-theme-high-contrast textarea,
body.af-theme-high-contrast button {
  background-color: #111111 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
}

body.af-theme-high-contrast img {
  filter: contrast(1.2) !important;
}

/* Panel overrides for high contrast */
body.af-theme-high-contrast #accessflow-panel { background: #111 !important; color: #fff !important; }
body.af-theme-high-contrast #accessflow-launcher { background: #ffe600 !important; color: #000 !important; }

/* ---- Dark Mode ---- */
body.af-theme-dark {
  background-color: #1a1a2e !important;
  color: #e0e0e0 !important;
}

body.af-theme-dark article,
body.af-theme-dark main,
body.af-theme-dark .site-content,
body.af-theme-dark .entry-content,
body.af-theme-dark section,
body.af-theme-dark header,
body.af-theme-dark .site-header {
  background-color: #1a1a2e !important;
  color: #e0e0e0 !important;
}

body.af-theme-dark a { color: #7ec8e3 !important; }
body.af-theme-dark h1, body.af-theme-dark h2,
body.af-theme-dark h3, body.af-theme-dark h4 { color: #c0e0f0 !important; }

body.af-theme-dark img { filter: brightness(0.88) !important; }

body.af-theme-dark #accessflow-panel {
  background: #252540 !important;
  color: #e0e0e0 !important;
  border-color: #444 !important;
}

/* ---- Light Background ---- */
body.af-theme-light {
  background-color: #ffffff !important;
  color: #111111 !important;
}

body.af-theme-light * {
  background-color: transparent !important;
  color: #111111 !important;
}

body.af-theme-light a { color: #004b8d !important; }

/* ---- Soft Contrast ---- */
body.af-theme-soft {
  background-color: #f0ede8 !important;
  color: #2c2c2c !important;
  filter: contrast(0.92) !important;
}

body.af-theme-soft * { background-color: transparent !important; }
body.af-theme-soft article, body.af-theme-soft main { background: #f7f4ef !important; }
body.af-theme-soft a { color: #3a6080 !important; }

/* ---- Warm Reading ---- */
body.af-theme-warm {
  background-color: #fdf6e3 !important;
  color: #3b2b1a !important;
}

body.af-theme-warm article,
body.af-theme-warm main,
body.af-theme-warm .site-content { background-color: #fdf6e3 !important; }
body.af-theme-warm a { color: #8b4513 !important; }
body.af-theme-warm h1, body.af-theme-warm h2,
body.af-theme-warm h3 { color: #5a3210 !important; }

body.af-theme-warm img { filter: sepia(0.18) !important; }

/* Panel never gets distorted by theme */
#accessflow-panel,
#accessflow-launcher {
  filter: none !important;
}

/* ================================================================
   MOBILE
================================================================ */
@media (max-width: 600px) {
  #accessflow-launcher {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
  }

  body.af-position-left #accessflow-launcher { left: 16px; }

  #accessflow-panel {
    bottom: 70px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 90px);
  }

  body.af-position-left #accessflow-panel {
    left: 8px;
    right: 8px;
  }

  .af-presets-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ================================================================
   PRINT — hide toolbar
================================================================ */
@media print {
  #accessflow-launcher,
  #accessflow-panel,
  #af-ruler,
  .af-mask { display: none !important; }
}
