/* ==========================================================================
   ACCESSIBILITY WIDGET STYLING - Alessandro Canali 2026
   ========================================================================== */

/* Global Variable Hooks for scaling */
:root {
  --access-font-scale: 1;
  --access-line-height-scale: 1;
}

/* Apply scaling variables globally */
html {
  font-size: calc(16px * var(--access-font-scale, 1)) !important;
  transition: font-size 0.2s ease;
}

body,
p,
a,
span,
h1,
h2,
h3,
h4,
h5,
h6,
li,
button,
input {
  line-height: calc(1.5 * var(--access-line-height-scale, 1)) !important;
}

/* ==========================================================================
   ACCESSIBILITY TRIGGER BUTTON
   ========================================================================== */
#accessibility-trigger {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 72px;
  height: 44px;
  border-radius: 6px;
  background: #ffffff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.22) !important;
  outline: none !important;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999999;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

#accessibility-trigger:hover {
  transform: scale(1.08);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.38) !important;
  outline: none !important;
  box-shadow: none;
}

#accessibility-trigger:focus,
#accessibility-trigger:active,
#accessibility-trigger:focus-visible {
  border: 1px solid rgba(0, 0, 0, 0.22) !important;
  outline: none !important;
  box-shadow: none !important;
}

#accessibility-trigger svg {
  width: 44px;
  height: 24px;
}

/* ==========================================================================
   ACCESSIBILITY MODAL PANEL
   ========================================================================== */
#accessibility-panel {
  position: fixed;
  bottom: 80px;
  left: 20px;
  width: 24rem;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 110px);
  background: var(--bg-card, rgba(255, 255, 255, 0.85));
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: none;
  border-radius: 20px;
  box-shadow: 0 10px 45px rgba(0, 0, 0, 0.12);
  z-index: 1000000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#accessibility-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header styling */
.access-header {
  padding: 1.25rem 1.5rem;
  background: var(--text-primary, #1d1d1f);
  color: var(--bg-primary, #ffffff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.access-title-wrapper {
  display: flex;
  flex-direction: column;
}

.access-header h3 {
  color: #ffffff;
  font-family: var(--font-main, sans-serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.access-lang-select {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 4px;
}

.access-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.access-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.access-close-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Quick Actions Toolbar */
.access-quick-actions {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
  gap: 8px;
}

.access-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-primary, #1d1d1f);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.access-quick-btn:hover {
  background: #f5f5f7;
}

.access-quick-btn:active {
  transform: scale(0.98);
}

.access-quick-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Content Area */
.access-content {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.access-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.access-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #86868b);
  margin-bottom: 2px;
}

/* Adjustments Grid & Controls */
.access-setting-card {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-light, rgba(0, 0, 0, 0.05));
  border-radius: 12px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.access-setting-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary, #1d1d1f);
}

.access-setting-header svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.access-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 3px;
}

.access-stepper-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f5f5f7;
  color: var(--text-primary, #1d1d1f);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.access-stepper-btn:hover {
  background: #e8e8ed;
}

.access-stepper-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary, #1d1d1f);
}

/* 3-Column Feature Grid */
.access-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.access-feature-btn {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary, #1d1d1f);
}

.access-feature-btn:hover {
  background: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.access-feature-btn:active {
  transform: translateY(0);
}

.access-feature-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0px;
}

.access-feature-btn.active {
  background: var(--text-primary, #1d1d1f);
  border-color: var(--text-primary, #1d1d1f);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.access-feature-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

/* Footer tag */
.access-footer {
  padding: 0.6rem;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--text-primary, #1d1d1f);
  border-top: 1px solid var(--border-light, rgba(255, 255, 255, 0.05));
}

.access-footer a {
  color: #ffffff;
  text-decoration: underline;
}

/* ==========================================================================
   ACCESSIBILITY OVERRIDES & FEATURES
   ========================================================================== */

/* 1. Readable Font */
.access-readable-font-active,
.access-readable-font-active * {
  font-family: 'OpenDyslexic', 'Verdana', 'Arial', sans-serif !important;
}

/* 2. Text Alignments */
.access-align-left-active,
.access-align-left-active * {
  text-align: left !important;
}

.access-align-center-active,
.access-align-center-active * {
  text-align: center !important;
}

.access-align-right-active,
.access-align-right-active * {
  text-align: right !important;
}

/* 3. Text Letter Spacing */
.access-spacing-tight,
.access-spacing-tight * {
  letter-spacing: -0.05em !important;
}

.access-spacing-wide,
.access-spacing-wide * {
  letter-spacing: 0.08em !important;
}

.access-spacing-wider,
.access-spacing-wider * {
  letter-spacing: 0.16em !important;
}

.access-spacing-widest,
.access-spacing-widest * {
  letter-spacing: 0.24em !important;
}

/* 4. Grayscale & Saturation & Contrast Overrides */
.access-monochrome-active {
  filter: grayscale(100%) !important;
}

.access-sat-low-active {
  filter: saturate(40%) !important;
}

.access-sat-high-active {
  filter: saturate(180%) !important;
}

.access-contrast-high-active {
  filter: contrast(135%) !important;
}

/* 5. Custom High Contrast Themes */
.access-contrast-light-active {
  --bg-primary: #ffffff !important;
  --bg-secondary: #ffffff !important;
  --bg-card: #ffffff !important;
  --text-primary: #000000 !important;
  --text-secondary: #111111 !important;
  --border-light: #000000 !important;
}

.access-contrast-light-active body {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-light-active header,
.access-contrast-light-active header.scrolled,
.access-contrast-light-active section,
.access-contrast-light-active footer {
  background-color: #ffffff !important;
  background: #ffffff !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

.access-contrast-light-active .glass-panel,
.access-contrast-light-active .portfolio-card,
.access-contrast-light-active .skills-card,
.access-contrast-light-active .gear-item,
.access-contrast-light-active .gear-intro-block,
.access-contrast-light-active .skills-illustration {
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #000000 !important;
  box-shadow: none !important;
}

.access-contrast-light-active .skills-icon-wrapper {
  background: #ffffff !important;
  border: 1px solid #000000 !important;
  color: #000000 !important;
}

.access-contrast-light-active .skills-badge,
.access-contrast-light-active .portfolio-tag {
  background: #ffffff !important;
  border: 1px solid #000000 !important;
  color: #000000 !important;
}

.access-contrast-light-active .btn-primary,
.access-contrast-light-active .btn-contact {
  background: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #000000 !important;
}

.access-contrast-light-active .btn-primary:hover,
.access-contrast-light-active .btn-contact:hover {
  background: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-light-active .btn-secondary {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #000000 !important;
}

.access-contrast-light-active .btn-secondary:hover {
  background: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-light-active .nav-link {
  color: #000000 !important;
}

.access-contrast-light-active .social-icon {
  background: #ffffff !important;
  border: 1px solid #000000 !important;
}

.access-contrast-light-active #accessibility-panel {
  background: #ffffff !important;
  border: none !important;
  color: #000000 !important;
}

.access-contrast-light-active .access-header {
  background: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-light-active .access-feature-btn {
  border: 1px solid #000000 !important;
  color: #000000 !important;
  background: #ffffff !important;
}

.access-contrast-light-active .access-feature-btn.active {
  background: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-light-active .access-quick-btn {
  border: 1px solid #000000 !important;
  color: #000000 !important;
  background: #ffffff !important;
}

.access-contrast-light-active .access-quick-btn:hover {
  background: #f0f0f2 !important;
}

.access-contrast-light-active .access-stepper {
  border: 1px solid #000000 !important;
}

.access-contrast-light-active .access-stepper-btn {
  background: #f0f0f2 !important;
  color: #000000 !important;
}

.access-contrast-light-active .access-footer {
  background: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-dark-active {
  --bg-primary: #000000 !important;
  --bg-secondary: #000000 !important;
  --bg-card: #000000 !important;
  --text-primary: #ffffff !important;
  --text-secondary: #eeeeee !important;
  --border-light: #ffffff !important;
}

.access-contrast-dark-active body {
  background-color: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-dark-active header,
.access-contrast-dark-active header.scrolled,
.access-contrast-dark-active section,
.access-contrast-dark-active footer {
  background-color: #000000 !important;
  background: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

.access-contrast-dark-active .glass-panel,
.access-contrast-dark-active .portfolio-card,
.access-contrast-dark-active .skills-card,
.access-contrast-dark-active .gear-item,
.access-contrast-dark-active .gear-intro-block,
.access-contrast-dark-active .skills-illustration {
  background: #000000 !important;
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
  box-shadow: none !important;
}

.access-contrast-dark-active .skills-icon-wrapper {
  background: #000000 !important;
  border: 1px solid #ffffff !important;
  color: #ffffff !important;
}

.access-contrast-dark-active .skills-badge,
.access-contrast-dark-active .portfolio-tag {
  background: #000000 !important;
  border: 1px solid #ffffff !important;
  color: #ffffff !important;
}

.access-contrast-dark-active .btn-primary,
.access-contrast-dark-active .btn-contact {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #ffffff !important;
}

.access-contrast-dark-active .btn-primary:hover,
.access-contrast-dark-active .btn-contact:hover {
  background: #000000 !important;
  color: #ffffff !important;
}

.access-contrast-dark-active .btn-secondary {
  background: #000000 !important;
  color: #ffffff !important;
  border: 1px solid #ffffff !important;
}

.access-contrast-dark-active .btn-secondary:hover {
  background: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-dark-active .nav-link {
  color: #ffffff !important;
}

.access-contrast-dark-active .social-icon {
  background: #000000 !important;
  border: 1px solid #ffffff !important;
}

.access-contrast-dark-active #accessibility-panel {
  background: #000000 !important;
  border: none !important;
  color: #ffffff !important;
}

.access-contrast-dark-active .access-header {
  background: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-dark-active .access-header h3 {
  color: #000000 !important;
}

.access-contrast-dark-active .access-close-btn {
  color: #000000 !important;
}

.access-contrast-dark-active .access-feature-btn {
  border: 1px solid #ffffff !important;
  color: #ffffff !important;
  background: #000000 !important;
}

.access-contrast-dark-active .access-feature-btn.active {
  background: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-dark-active .access-quick-btn {
  border: 1px solid #ffffff !important;
  color: #ffffff !important;
  background: #000000 !important;
}

.access-contrast-dark-active .access-quick-btn:hover {
  background: #121212 !important;
}

.access-contrast-dark-active .access-stepper {
  border: 1px solid #ffffff !important;
  background: #000000 !important;
}

.access-contrast-dark-active .access-stepper-btn {
  background: #121212 !important;
  color: #ffffff !important;
}

.access-contrast-dark-active .access-stepper-value {
  color: #ffffff !important;
}

.access-contrast-dark-active .access-footer {
  background: #ffffff !important;
  color: #000000 !important;
}

.access-contrast-dark-active .access-footer a {
  color: #000000 !important;
}

/* 6. Reading Guide Line */
.access-reading-guide-line {
  position: fixed;
  left: 0;
  width: 100vw;
  height: 5px;
  background-color: #0066cc;
  box-shadow: 0 0 10px rgba(0, 102, 204, 0.8);
  pointer-events: none;
  z-index: 10000000;
  display: none;
  transform: translateY(-50%);
}

/* 7. Reading Mask */
.access-reading-mask-top,
.access-reading-mask-bottom {
  position: fixed;
  left: 0;
  width: 100vw;
  background-color: rgba(0, 0, 0, 0.72);
  pointer-events: none;
  z-index: 10000000;
  display: none;
}

.access-reading-mask-top {
  top: 0;
}

.access-reading-mask-bottom {
  bottom: 0;
}

/* 8. Stop Animations */
.access-stop-animations-active *,
.access-stop-animations-active *::before,
.access-stop-animations-active *::after {
  animation: none !important;
  transition: none !important;
  transform: none !important;
  scroll-behavior: auto !important;
}

/* 9. Hide Images */
.access-hide-images-active img,
.access-hide-images-active svg:not(.access-widget-svg),
.access-hide-images-active video {
  visibility: hidden !important;
  opacity: 0 !important;
}

.access-hide-images-active .portfolio-thumb-container,
.access-hide-images-active .gear-logo-container,
.access-hide-images-active .skills-illustration {
  background: rgba(0, 0, 0, 0.15) !important;
  border: 1px dashed rgba(0, 0, 0, 0.3) !important;
  position: relative;
}

.access-hide-images-active .portfolio-thumb-container::after {
  content: "Immagine Nascosta";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* 10. Highlight Hover */
.access-hovered-target {
  outline: 3px dashed var(--accent-blue, #0066cc) !important;
  outline-offset: 3px !important;
}

/* 11. Highlight Focus */
.access-highlight-focus-active *:focus {
  outline: 4px solid var(--accent-blue, #0066cc) !important;
  outline-offset: 4px !important;
}

/* 12. Large Cursors */
.access-cursor-black-active,
.access-cursor-black-active * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M0 0l22.4 54.4 6.4-19.2 19.2-6.4z' fill='black' stroke='white' stroke-width='4'/%3E%3C/svg%3E"), auto !important;
}

.access-cursor-white-active,
.access-cursor-white-active * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cpath d='M0 0l22.4 54.4 6.4-19.2 19.2-6.4z' fill='white' stroke='black' stroke-width='4'/%3E%3C/svg%3E"), auto !important;
}

/* 13. Large Scale & Wide Spacing Desktop Grid Adjustments */
@media (min-width: 992px) {

  .access-large-scale .hero-grid,
  .access-spacing-wide .hero-grid,
  .access-spacing-wider .hero-grid,
  .access-spacing-widest .hero-grid {
    grid-template-columns: 1fr !important;
    gap: 3rem !important;
    text-align: center !important;
  }

  .access-large-scale .hero-image-wrapper,
  .access-spacing-wide .hero-image-wrapper,
  .access-spacing-wider .hero-image-wrapper,
  .access-spacing-widest .hero-image-wrapper {
    order: -1 !important;
  }

  .access-large-scale .hero-content,
  .access-spacing-wide .hero-content,
  .access-spacing-wider .hero-content,
  .access-spacing-widest .hero-content {
    align-items: center !important;
  }

  /* Keep titles on a single line if scaling is large but letter spacing is normal/tight */
  .access-large-scale:not(.access-spacing-wide):not(.access-spacing-wider):not(.access-spacing-widest) .hero-title,
  .access-large-scale:not(.access-spacing-wide):not(.access-spacing-wider):not(.access-spacing-widest) .hero-tagline {
    white-space: nowrap !important;
  }

  /* Force wrapping when letter spacing is wide, wider, or widest to prevent off-screen clipping */
  .access-spacing-wide .hero-title,
  .access-spacing-wide .hero-tagline,
  .access-spacing-wider .hero-title,
  .access-spacing-wider .hero-tagline,
  .access-spacing-widest .hero-title,
  .access-spacing-widest .hero-tagline {
    white-space: normal !important;
    word-break: break-word !important;
  }
}

/* 14. Enable horizontal scroll under large scale or wide letter spacing to prevent text clipping */
.access-large-scale,
.access-spacing-wide,
.access-spacing-wider,
.access-spacing-widest,
.access-large-scale body,
.access-spacing-wide body,
.access-spacing-wider body,
.access-spacing-widest body {
  overflow-x: auto !important;
}