/* Autism-friendly design system (per neurodivergent design spec):
   - Muted pastel blue palette: #F5F5F5 bg, #333333 text, #4876AE accent
   - Lexend font (specifically designed for readability and reading difficulties)
   - No animations or transitions; prefers-reduced-motion honored
   - Generous whitespace, single column, left-aligned text
   - WCAG AA contrast (accent on white: 4.8:1; text on bg: 10.6:1)
   - Predictable, consistent layout across all pages
   - 8px grid spacing system
*/

/* Lexend — latin-ext (variable font: weights 300–600) */
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 300 600;
  font-display: block;
  src: url('/fonts/Lexend-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Lexend — latin */
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 300 600;
  font-display: block;
  src: url('/fonts/Lexend-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Noto Sans normal — variable font: weights 400–700 */
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-normal-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-normal-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Noto Sans italic 400 */
@font-face {
  font-family: 'Noto Sans';
  font-style: italic;
  font-weight: 400;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-italic-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: italic;
  font-weight: 400;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-italic-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: italic;
  font-weight: 400;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: italic;
  font-weight: 400;
  font-stretch: 100%;
  font-display: block;
  src: url('/fonts/NotoSans-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('/fonts/OpenDyslexic-Regular.woff2') format('woff2'),
       url('/fonts/OpenDyslexic-Regular.woff')  format('woff'),
       url('/fonts/OpenDyslexic-Regular.otf')   format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'OpenDyslexic';
  src: url('/fonts/OpenDyslexic-Bold.woff2') format('woff2'),
       url('/fonts/OpenDyslexic-Bold.woff')  format('woff'),
       url('/fonts/OpenDyslexic-Bold.otf')   format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Respect user's reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

:root {
  /* Muted pastel blue palette (calming, WCAG AA compliant) */
  /* --color-bg:        #F5F5F5; */
  --color-bg:         #F7F6F2;
  /* --color-surface:   #EAEAEA; */
  --color-surface:   #edece7;
  --color-text:      #333333;
  --color-text-sub:  #666666;
  --color-accent:    #4876AE;   /* muted steel blue — 4.8:1 with white */
  --color-accent-dk: #365E92;
  --color-border:     #CCCCCC;
  --color-btn-border: #CCCCCC;

  --color-alert:     #E15D44;   /* muted orange for errors/warnings */

  /* 8px grid spacing tokens */
  --spacing-xs: 4px;
  --spacing-s:  8px;
  --spacing-m:  16px;
  --spacing-l:  24px;

  /* Layout spacing (rem-based, scales with user font preferences) */
  --spacing-sm: 0.75rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 3rem;
  --spacing-xl: 5rem;

  --max-width:     90vw;
  --border-radius: 4px;
}

/* ── Dark theme ── */
html[data-theme="dark"] {
  --color-bg:        #1C1C1E;
  --color-surface:   #2A2A2E;
  --color-text:      #E5E5E5;
  --color-text-sub:  #9A9A9A;
  --color-accent:    #4876AE;
  --color-accent-dk: #6B9ED2;   /* lighter blue — readable on dark bg */
  --color-border:     #3A3A3C;
  --color-btn-border: #6B6B6B;
  --color-alert:      #E15D44;
}

html {
  font-size: 18px;
  background-color: var(--color-bg);
  color: var(--color-text);
}

body {
  font-family: 'Lexend', Arial, sans-serif;
  font-weight: 400;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

:lang(ru) body,
:lang(uk) body {
  font-family: 'Noto Sans', Arial, sans-serif;
}

html[data-font="dyslexic"] body {
  font-family: 'OpenDyslexic', Arial, sans-serif;
  -webkit-text-stroke: 0.4px currentColor;
}

/* ── Skip link for keyboard users ── */
.skip-link {
  position: absolute;
  top: -999px;
  left: 0;
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
}
.skip-link:focus { top: 0; }

/* ── Header & Navigation ── */
header {
  background-color: var(--color-surface);
  border-bottom: 0px solid var(--color-border);
  padding: var(--spacing-md) var(--spacing-lg);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 1.1rem;
  font-weight: 600;
  color: #35434e;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-name img {
  height: 1.5em;
  width: auto;
  display: block;
}

/* ── Header controls — shared base ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  background: none;
  border: 2px solid var(--color-btn-border);
  border-radius: var(--border-radius);
  padding: 0.2rem 0.55rem;
  min-height: 44px;
  min-width: 44px;
  color: var(--color-text-sub);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.5;
}

.btn:hover {
  background-color: var(--color-border);
  color: var(--color-text);
}

.btn:active {
  background-color: #9fb4ce;
  color: var(--color-text);
  border-color: var(--color-accent);
}

.btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.btn.cta,
.btn[aria-pressed="true"],
.btn[aria-current] {
  background-color: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent-dk);
}

.btn.cta:hover,
.btn[aria-pressed="true"]:hover,
.btn[aria-current]:hover {
  background-color: var(--color-accent-dk);
  border-color: var(--color-accent-dk);
  color: #fff;
}

.btn.cta:focus-visible,
.btn[aria-pressed="true"]:focus-visible,
.btn[aria-current]:focus-visible {
  outline-color: var(--color-accent-dk);
  box-shadow: 0 0 0 3px #fff;
}

html[data-theme="dark"] .btn[aria-pressed="true"]:focus-visible,
html[data-theme="dark"] .btn[aria-current]:focus-visible {
  outline-color: #fff;
  box-shadow: none;
}

/* ── Per-button specifics ── */
.font-btn      { font-size: 0.8rem; font-weight: 600; }
.theme-btn     { font-size: 1rem; line-height: 1; }
.text-size-btn { font-size: 1.1rem; font-weight: 700; line-height: 1; }
#text-reset    { font-size: 0.85rem; }
.lang-btn      { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; }
.nav-btn       { color: var(--color-text); font-weight: 500; font-size: 0.95rem; padding: 0.4rem 0.9rem; }

/* ── Accessibility menu ── */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-s);
}

.a11y-menu {
  position: relative;
}

.a11y-btn::after {
  content: '▾';
  font-size: 0.7em;
  margin-left: 0.5em;
}
.a11y-btn[aria-expanded="true"]::after {
  content: '▴';
}

.a11y-panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--spacing-s));
  background-color: var(--color-bg);
  border: 2px solid var(--color-btn-border);
  border-radius: var(--border-radius);
  padding: var(--spacing-s);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-s);
  z-index: 200;
  min-width: 220px;
  user-select: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  opacity: 1;
  transition: opacity 0.35s ease;
}

html[data-theme="dark"] .a11y-panel {
  background-color: var(--color-surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.a11y-panel[hidden] {
  display: none;
}

.a11y-panel.is-closing {
  opacity: 0;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-m);
}

.a11y-label {
  font-size: 0.85rem;
  color: var(--color-text-sub);
  white-space: nowrap;
}

.a11y-label--dyslexic {
  font-family: 'OpenDyslexic', Arial, sans-serif;
}

.a11y-controls {
  display: flex;
  gap: var(--spacing-xs);
}

/* ── Language switcher & main nav layout ── */
.lang-switcher {
  display: flex;
  gap: var(--spacing-s);
  align-items: center;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-s);
}

/* ── Main content ── */
main {
  flex: 1;
  padding: var(--spacing-xl) var(--spacing-lg);
}

/* ── About photo ── */
.page-header--with-photo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
}

.about-photo {
  width:  160px;
  height: 160px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  display: block;
}

.page-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Page header ── */
.page-header {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
}

.page-header .subtitle {
  margin-top: var(--spacing-sm);
  font-size: 1.05rem;
  color: var(--color-text-sub);
  font-weight: 300;
}

/* ── Body content sections ── */
.section {
  margin-top: var(--spacing-lg);
}

.section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-accent-dk);
  margin-bottom: var(--spacing-sm);
}

.section p {
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

.section p:last-child { margin-bottom: 0; }

.section p a:not(.btn) {
  color: var(--color-accent-dk);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0 2px;
  border-radius: 2px;
}

.section p a:not(.btn):hover {
  color: var(--color-accent-dk);
  background-color: #D9E6F5;
  text-decoration-thickness: 2px;
}

.section p a:not(.btn):focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* ── Highlight box (blockquote) ── */
.highlight-box {
  margin-left: 0;
  margin-right: 0;
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-accent);
  padding: var(--spacing-md) var(--spacing-md);
  margin: var(--spacing-lg) 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.highlight-box p {
  margin: 0;
  color: var(--color-text);
  font-weight: 500;
}

/* ── Blockquotes inside markdown-rendered sections ── */
.block-section blockquote {
  margin-left: 0;
  margin-right: 0;
  background-color: var(--color-surface);
  border-left: 4px solid var(--color-accent);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.block-section blockquote p {
  margin: 0;
  font-weight: 500;
}

/* ── Ordered/unordered lists ── */
.section ul,
.section ol {
  padding-left: 1.5rem;
  margin-bottom: var(--spacing-md);
}

.section li {
  margin-bottom: 0.6rem;
  color: var(--color-text);
}

/* ── Step list (My Method page) ── */
/* ── Ordered lists inside markdown blocks render as step list ── */
.block-section ol {
  list-style: none;
  padding: 0 0 0 var(--spacing-sm);
  counter-reset: step-counter;
}

.block-section ol li {
  counter-increment: step-counter;
  position: relative;
  padding: var(--spacing-md) 0 var(--spacing-md) calc(2.25rem + var(--spacing-md));
  border-bottom: 1px solid var(--color-border);
}

.block-section ol li:last-child { border-bottom: none; }

.block-section ol li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  background-color: var(--color-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.block-section ol li p {
  margin: 0;
}

.block-section ol li p + p {
  margin-top: 0.35rem;
  font-size: 0.95rem;
  color: var(--color-text-sub);
}


/* ── Contact form ── */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-field label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}

.form-field .hint {
  font-size: 0.85rem;
  color: var(--color-text-sub);
  font-weight: 300;
}

.form-field input,
.form-field textarea,
.form-field select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 0.65rem 0.85rem;
  width: 100%;
}

.form-field input:focus-visible,
.form-field textarea:focus-visible,
.form-field select:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-color: var(--color-accent);
}

.form-field textarea {
  min-height: 140px;
  resize: vertical;
}


/* ── Contact info block ── */
.contact-info {
  margin-top: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.contact-item {
  display: flex;
  gap: var(--spacing-sm);
  align-items: flex-start;
}

.contact-label {
  font-weight: 600;
  min-width: 80px;
  color: var(--color-text-sub);
  font-size: 0.9rem;
}

.contact-value {
  color: var(--color-text);
}

.contact-value a {
  color: var(--color-accent-dk);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0 2px;
  border-radius: 2px;
}

.contact-value a:hover {
  color: var(--color-accent-dk);
  background-color: #D9E6F5;
  text-decoration-thickness: 2px;
}

.contact-value a:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* ── Footer ── */
footer {
  background-color: var(--color-surface);
  border-top: 2px solid var(--color-border);
  padding: var(--spacing-md) var(--spacing-lg);
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-sub);
}

footer .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-name-7 {
  color: #5d8b97;
  font-size: 1.2rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  html { font-size: 16px; }
  header, main, footer { padding-left: var(--spacing-md); padding-right: var(--spacing-md); }
  main { padding-top: var(--spacing-lg); padding-bottom: var(--spacing-lg); }
  .page-header h1 { font-size: 1.6rem; }

  .page-header--with-photo {
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
    gap: var(--spacing-md);
  }

  .about-photo {
    width:  110px;
    height: 110px;
  }

  .header-top {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .header-controls {
    order: 1;
    flex-direction: column;
    align-items: flex-end;
  }

  .site-name {
    order: 2;
    padding: var(--spacing-s) 0;
    font-size: 2rem;
    justify-content: center;
  }

 .site-name-7 {
   font-size: 2.1rem;
  }

  .lang-switcher {
    flex-wrap: nowrap;
  }

  nav:not(.lang-switcher) {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  nav:not(.lang-switcher) .btn:last-child {
    grid-column: 1 / -1;
  }
}

html[data-theme="dark"] .site-name {
  color: #fff;
}

/* ── Dark theme overrides for hardcoded light values ── */
html[data-theme="dark"] .section p a:not(.btn):hover,
html[data-theme="dark"] .contact-value a:hover {
  background-color: #243650;
}

/* ── 9/12 column layout: kicks in when 75vw >= 800px content width ── */
@media (min-width: 1067px) {
  :root {
    --max-width: min(75vw, 1000px);
  }
}
