/* Accessibility widget (site-wide) */
:root {
  --a11y-accent: #b85a3a;
  --a11y-panel-bg: #ffffff;
  --a11y-panel-border: #f0eae5;
  --a11y-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
  --a11y-font-scale: 1;
  --a11y-zoom-scale: 1;
}

html {
  font-size: calc(16px * var(--a11y-font-scale));
  zoom: var(--a11y-zoom-scale);
}

.a11y-skip-link {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 2147483647;
  padding: 10px 14px;
  border-radius: 10px;
  background: #111;
  color: #fff;
  text-decoration: none;
  transform: translateY(-140%);
  transition: transform 0.2s ease;
}

.a11y-skip-link:focus,
.a11y-skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid #ffd84d;
  outline-offset: 2px;
}

.a11y-fab {
  position: fixed;
  right: 18px;
  left: auto;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
  top: auto;
  z-index: 2147483647;
  opacity: 1 !important;
  visibility: visible !important;
  border: 1px solid rgba(255,255,255,0.35);
  background: linear-gradient(135deg, #b85a3a 0%, #d46b4a 55%, #b85a3a 100%);
  color: #fff;
  border-radius: 999px;
  padding: 12px 16px;
  font: 800 15px/1 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
  transform: translateZ(0);
  min-height: 48px;
}
.a11y-fab:hover { transform: translateY(-1px); box-shadow: 0 18px 48px rgba(0,0,0,0.22); }
.a11y-fab:active { transform: translateY(0); box-shadow: 0 14px 38px rgba(0,0,0,0.18); }
.a11y-fab:focus-visible { outline: 4px solid rgba(255,255,255,0.8); outline-offset: 3px; }

.a11y-fab-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.28);
  font-size: 18px;
}
.a11y-fab-text { white-space: nowrap; }

@media (max-width: 520px) {
  .a11y-fab { padding: 12px; }
  .a11y-fab-text { display: none; }
}

.a11y-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 9998;
  display: none;
}
.a11y-backdrop[data-open="true"] { display: block; }

.a11y-panel {
  position: fixed;
  right: 18px;
  left: auto;
  bottom: 72px;
  top: auto;
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 100px);
  z-index: 2147483647;
  display: none;
  background: var(--a11y-panel-bg);
  border: 1px solid var(--a11y-panel-border);
  border-radius: 18px;
  box-shadow: var(--a11y-shadow);
  overflow: hidden;
}
.a11y-panel[data-open="true"] { display: block; }

.a11y-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--a11y-panel-border);
}
.a11y-title { font-size: 15px; font-weight: 700; }
.a11y-close {
  border: 1px solid var(--a11y-panel-border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.a11y-close:focus-visible { outline: 3px solid rgba(184,90,58,0.35); outline-offset: 3px; }

.a11y-body {
  padding: 12px 14px 14px;
  overflow: auto;
  max-height: calc(100vh - 170px);
}
.a11y-grid {
  display: grid;
  gap: 2px;
}
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.a11y-row + .a11y-row { border-top: 1px dashed #eee; }
.a11y-row label { font-size: 14px; color: #2c2c2c; }
.a11y-row small { display: block; color: #6b6b6b; font-size: 12px; margin-top: 2px; }
.a11y-row input[type="checkbox"] { width: 18px; height: 18px; }

.a11y-range {
  margin-top: 12px;
  border: 1px solid #f0eae5;
  border-radius: 12px;
  padding: 10px;
}
.a11y-range label {
  display: block;
  font-size: 13px;
  color: #3e3e3e;
  margin-bottom: 8px;
}
.a11y-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.a11y-mini-btn {
  min-width: 44px;
  border: 1px solid #eadfd8;
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}
.a11y-mini-btn:hover { background: #faf1eb; }
.a11y-value {
  min-width: 60px;
  text-align: center;
  font-weight: 700;
  color: #5a3428;
}

.a11y-actions {
  display: flex;
  gap: 10px;
  padding-top: 12px;
}
.a11y-btn {
  flex: 1;
  border: 1px solid var(--a11y-panel-border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
}
.a11y-btn.primary {
  border-color: rgba(184,90,58,0.35);
  background: rgba(184,90,58,0.08);
  color: #4b2418;
}
.a11y-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--a11y-accent);
  text-decoration: underline;
  font-size: 13px;
}

.a11y-links-group {
  display: grid;
  gap: 6px;
}

.a11y-alt-note {
  margin-top: 4px;
  margin-bottom: 8px;
  background: #fff7e8;
  border: 1px solid #f1debe;
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #5e4317;
}

/* --- global modes --- */
body.a11y-keyboard :focus-visible {
  outline: 3px solid #ff9800 !important;
  outline-offset: 3px !important;
}

body.a11y-monochrome {
  filter: grayscale(1) !important;
}

body.a11y-sepia {
  filter: sepia(0.65) !important;
}

body.a11y-contrast {
  background: #fff !important;
  color: #111 !important;
}
body.a11y-contrast a { color: #0b4aa2 !important; }
body.a11y-contrast .sidebar,
body.a11y-contrast .sidebar-section,
body.a11y-contrast .item-card,
body.a11y-contrast .hot-card,
body.a11y-contrast .content,
body.a11y-contrast .container {
  border-color: #222 !important;
}

body.a11y-black-yellow {
  background: #000 !important;
  color: #ffeb3b !important;
}
body.a11y-black-yellow a,
body.a11y-black-yellow p,
body.a11y-black-yellow span,
body.a11y-black-yellow h1,
body.a11y-black-yellow h2,
body.a11y-black-yellow h3,
body.a11y-black-yellow h4,
body.a11y-black-yellow li {
  color: #ffeb3b !important;
}

body.a11y-invert {
  filter: invert(1) hue-rotate(180deg) !important;
}

body.a11y-headings h1,
body.a11y-headings h2,
body.a11y-headings h3,
body.a11y-headings h4,
body.a11y-headings h5,
body.a11y-headings h6 {
  background: #fff2c9 !important;
  color: #3b2300 !important;
  box-shadow: 0 0 0 2px #f0c96a inset;
  border-radius: 6px;
  padding: 2px 6px;
}

body.a11y-links a { text-decoration: underline !important; text-underline-offset: 3px; }

body.a11y-readable,
body.a11y-readable * {
  font-family: "Arial", "Verdana", sans-serif !important;
  letter-spacing: 0.02em;
}

body.a11y-big-cursor,
body.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 34 34'%3E%3Cpath d='M4 2l10 24 4-9 9-4z' fill='black' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E") 2 2, auto !important;
}

body.a11y-black-cursor,
body.a11y-black-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Cpath d='M5 2l11 26 4-9 9-4z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 2 2, auto !important;
}

body.a11y-reading-mode .container,
body.a11y-reading-mode main,
body.a11y-reading-mode .content,
body.a11y-reading-mode .main-content {
  max-width: 920px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
body.a11y-reading-mode p,
body.a11y-reading-mode li {
  line-height: 1.95 !important;
  font-size: 1.08em !important;
}

body.a11y-stop-motion *,
body.a11y-stop-motion *::before,
body.a11y-stop-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* --- global responsive baseline (site-wide) --- */
*, *::before, *::after {
  box-sizing: border-box;
}

img,
video,
iframe,
svg {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
}

@media (max-width: 992px) {
  .container,
  .content,
  .main-content,
  .page,
  .wrapper {
    width: 100%;
    max-width: 100%;
  }

  .content-wrapper,
  .layout,
  .two-col,
  .split,
  .header-inner,
  .footer-brand {
    flex-wrap: wrap;
    gap: 14px;
  }

  .sidebar {
    width: 100%;
    max-width: 100%;
  }

  .grid,
  .cards,
  .items-grid,
  .hot-grid,
  .premium-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .container,
  .content,
  .main-content,
  .page,
  .wrapper {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .grid,
  .cards,
  .items-grid,
  .hot-grid,
  .premium-grid,
  .stats-grid,
  .analytics-grid {
    grid-template-columns: 1fr !important;
  }

  .content-wrapper,
  .layout,
  .two-col,
  .split,
  .header-inner,
  .footer-brand,
  .a11y-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* Mobile-first sidebar placement: show it first, pinned near top for quick access */
  .content-wrapper .sidebar,
  .layout .sidebar,
  .sidebar {
    order: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    position: sticky;
    top: 8px;
    z-index: 20;
    margin-bottom: 12px;
  }

  .content-wrapper .main-content,
  .layout > section,
  .layout > .main-content,
  .main-content {
    order: 2 !important;
  }

  .sidebar-content,
  .sidebar-section {
    border-radius: 14px;
    padding: 14px !important;
  }

  /* Force expanded sidebar on mobile (index uses collapsed desktop behavior) */
  .sidebar.collapsed {
    width: 100% !important;
  }

  .sidebar.collapsed .sidebar-content {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .sidebar.collapsed::after,
  .sidebar:not(.collapsed)::after {
    display: none !important;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .a11y-fab {
    width: auto !important;
    max-width: max-content;
    min-width: 48px;
    right: 12px;
    bottom: 12px;
    padding: 10px 12px;
    border-radius: 999px;
  }

  .a11y-fab-text {
    display: inline;
  }

  h1, .h1 { font-size: clamp(1.4rem, 6vw, 1.9rem); }
  h2, .h2 { font-size: clamp(1.2rem, 5vw, 1.55rem); }
  h3, .h3 { font-size: clamp(1.05rem, 4.5vw, 1.25rem); }

  input,
  select,
  textarea,
  button {
    max-width: 100%;
    font-size: 16px;
  }

  table,
  .table,
  .table-wrap {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .box,
  .card,
  .item-card,
  .hot-card,
  .panel,
  .sidebar-section {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .container,
  .content,
  .main-content,
  .page,
  .wrapper {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .hot-link,
  .item-link,
  .form-actions button,
  .form-actions .btn {
    width: 100%;
    text-align: center;
  }

  .a11y-fab {
    width: 48px !important;
    min-width: 48px;
    height: 48px;
    padding: 7px;
    right: 10px;
    bottom: 10px;
  }

  .a11y-fab .a11y-fab-text {
    display: none;
  }

  .a11y-fab .a11y-fab-icon {
    width: 32px;
    height: 32px;
    margin: 0;
  }

  .a11y-panel {
    right: 10px;
    width: calc(100vw - 20px);
  }
}

