/* Neurodivergent and accessibility-focused reading profile */

:root {
  --nd-reading-max-width: 72ch;
  --nd-reading-line-height: 1.72;
  --nd-reading-letter-spacing: 0.01em;
  --nd-reading-word-spacing: 0.08em;
  --nd-paragraph-gap: 0.9em;
  --nd-focus-ring: #005fcc;
}

main :where(p, li, blockquote, dd) {
  max-width: var(--nd-reading-max-width);
  line-height: var(--nd-reading-line-height);
  letter-spacing: var(--nd-reading-letter-spacing);
  word-spacing: var(--nd-reading-word-spacing);
}

main p + p {
  margin-top: var(--nd-paragraph-gap);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--nd-focus-ring) !important;
  outline-offset: 3px !important;
}

:root[data-nd-spacing="relaxed"] {
  --nd-reading-max-width: 68ch;
  --nd-reading-line-height: 1.95;
  --nd-reading-letter-spacing: 0.02em;
  --nd-reading-word-spacing: 0.16em;
  --nd-paragraph-gap: 1.2em;
}

:root[data-nd-font="dyslexic"] :where(body, button, input, select, textarea) {
  font-family: "Atkinson Hyperlegible", "OpenDyslexic", "Lexend", "Segoe UI", "Verdana", sans-serif !important;
}

:root[data-nd-links="underlined"] a {
  text-decoration: underline !important;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
}

:root[data-nd-contrast="high"] {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --text: #111111;
  --muted: #222222;
  --border: #2a2a2a;
  --accent: #003ea8;
  --focus-ring: #000000;
  --nd-focus-ring: #000000;
}

:root[data-nd-distractions="reduced"] body {
  background: var(--bg) !important;
}

:root[data-nd-distractions="reduced"] :where(.command-launcher, .command-overlay, .reading-guide) {
  display: none !important;
}

:root[data-nd-motion="reduced"] *,
:root[data-nd-motion="reduced"] *::before,
:root[data-nd-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

.nd-open-button {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9998;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  min-height: 44px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

.nd-open-button:hover {
  border-color: var(--accent);
}

.nd-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 1rem;
}

.nd-overlay[hidden] {
  display: none !important;
}

.nd-panel {
  width: min(620px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
}

.nd-panel h2 {
  margin-top: 0;
}

.nd-panel p {
  margin-top: 0.4rem;
}

.nd-grid {
  display: grid;
  gap: 0.8rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-block: 0.8rem;
}

.nd-control {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  background: var(--bg-alt);
}

.nd-control label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  margin: 0;
}

.nd-control select {
  width: 100%;
  margin-top: 0.4rem;
  min-height: 42px;
}

.nd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.nd-actions button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

.nd-actions .nd-close {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nd-actions .nd-reset {
  background: var(--bg-alt);
  color: var(--text);
}

@media (max-width: 720px) {
  .nd-open-button {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    text-align: center;
  }
}

@media print {
  .nd-open-button,
  .nd-overlay {
    display: none !important;
  }
}
