/* UI Enhancements: skeletons, skip-link, loading overlay, ripple, progress bar, focus-visible */

/* Skip link */
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 10000;
  transition: top var(--motion-fast) var(--easing-smooth), opacity var(--motion-fast) var(--easing-smooth);
}
.skip-link:focus {
  top: 8px;
  outline: none;
  box-shadow: 0 10px 30px rgba(26,115,232,0.24);
}

/* Loading overlay + spinner */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.65);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
}
.loading .loading-overlay {
  display: flex;
  pointer-events: none;
}
.loading-overlay .spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.08);
  border-top-color: var(--primary);
  animation: spin 1600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Top progress bar */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  width: 0%;
  z-index: 10001;
  transition: width 1600ms linear, opacity 900ms ease;
}
.top-progress.active { width: 40%; }
.top-progress.simulate { width: 80%; }
.top-progress.done { width: 100%; opacity: 0; }

/* Skeleton shimmer for preview and card elements */
.preview-card, .panel, .card-panel, .feature-card {
  position: relative;
  overflow: hidden;
}
.loading .preview-card *,
.loading .panel *,
.loading .card-panel *,
.loading .feature-card * {
  visibility: hidden;
}
.loading .preview-card::before,
.loading .panel::before,
.loading .card-panel::before,
.loading .feature-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0) 100%);
  transform: translateX(-100%);
  animation: shimmer 2600ms linear infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Focus visible accessible outlines */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

/* Ripple effect for clickable controls */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  transform: scale(0);
  opacity: 0.9;
  pointer-events: none;
  animation: ripple 1200ms cubic-bezier(0.2,0.9,0.3,0.95);
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* Micro interactions for buttons */
.btn-animate { transition: transform var(--motion-fast) var(--easing-smooth), box-shadow var(--motion-fast) var(--easing-smooth); }
.button, button { transition: transform var(--motion-medium) var(--easing-smooth), box-shadow var(--motion-medium) var(--easing-smooth); }
.button:hover, button:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 18px 42px rgba(26,115,232,0.18); }
.btn-animate:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 18px 42px rgba(26,115,232,0.18); }

/* Small accessibility helpers */
[role="navigation"] a { outline: none; }

/* Typewriter / typing animation support */
.type-animate {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  vertical-align: bottom;
}
.type-animate.typing::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 1em;
  background: var(--text);
  margin-left: 6px;
  animation: blinkCaret 700ms steps(1) infinite;
}
@keyframes blinkCaret { 0% { opacity: 1 } 50% { opacity: 0 } 100% { opacity: 1 } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .loading .preview-card::before,
  .loading .panel::before { animation: none; }
  .btn-animate { transition: none; }
  .type-animate.typing::after { animation: none; }
}

/* ── Settings panel in sidebar ──────────────────────────── */
.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 2px;
}
.setting-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}
.toggle-switch {
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    padding: 0;
    transition:
        background var(--motion-fast) ease,
        border-color var(--motion-fast) ease;
    flex-shrink: 0;
}
.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text);
    transition: transform var(--motion-fast) ease;
}
.toggle-switch[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
}
.toggle-switch[aria-pressed="true"]::after {
    transform: translateX(16px);
    background: #fff;
}
.settings-panel input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-muted);
    outline: none;
    cursor: pointer;
}
.settings-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform var(--motion-fast) ease;
}
.settings-panel input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
.settings-panel input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}
