/* ============================================================
   RESET + BASE
   Restrained baseline. Warm, calm palette — not clinical,
   not childish. Teachers will show this to parents.
   ============================================================ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
               Ubuntu, Cantarell, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f0eb;
  min-height: 100vh;
}

/* Screen-reader-only helper. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* ============================================================
   LAYOUT
   App-level containers. Two-column grid for desktop.
   ============================================================ */

.app-header {
  background: #3b5998;
  color: #ffffff;
  padding: 1.25rem 2rem;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header .subtitle {
  color: #b8ccec;
  margin-top: 0.2rem;
  font-size: 0.92rem;
}

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

.app-footer {
  text-align: center;
  color: #9a9aa0;
  font-size: 0.8rem;
  padding: 2rem;
}

/* ============================================================
   INPUT PANEL
   Left column: sample buttons, text textarea, convert button.
   ============================================================ */

.input-panel h2,
.output-panel h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #334155;
}

/* Sample passage quick-load buttons. */
.sample-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sample-button {
  background: #ffffff;
  border: 1px solid #d6cfc6;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: #5a5247;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sample-button:hover {
  border-color: #3b5998;
  color: #3b5998;
  background: #edf2fa;
}

.sample-button.active {
  border-color: #3b5998;
  background: #edf2fa;
  color: #3b5998;
  font-weight: 600;
}

/* Text input area. */
.text-input {
  width: 100%;
  min-height: 300px;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid #d6cfc6;
  border-radius: 8px;
  resize: vertical;
}

.text-input::placeholder {
  color: #9a9490;
}

/* Main convert button. */
.convert-button {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: #3b5998;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.convert-button:hover {
  background: #2d4a7a;
}

/* ============================================================
   OUTPUT PANEL
   Right column: adjustment toggles, converted display, changes
   panel, readability stats.
   ============================================================ */

/* Adjustment toggle bar — compact row of checkboxes. */
.adjustments-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  background: #ffffff;
  border: 1px solid #d6cfc6;
  border-radius: 8px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: #5a5247;
  cursor: pointer;
  user-select: none;
}

.toggle-input {
  width: 16px;
  height: 16px;
  accent-color: #3b5998;
  cursor: pointer;
}

.toggle-text {
  white-space: nowrap;
}

/* The converted text display area. This is the main output
   that the teacher will print or screenshot. */
.converted-display {
  background: #fffef8;
  border: 1px solid #d6cfc6;
  border-radius: 8px;
  padding: 1.5rem;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

.converted-display .empty-state {
  color: #9a9490;
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

/* ---- Dyslexia-friendly text styles ---- */

/* Base converted text — always applied. Left-aligned, never
   justified. Sans-serif. Cream background reduces glare. */
.converted-text {
  text-align: left;
  color: #2c2c2c;
  font-size: 1.1rem;
  line-height: 1.8;
}

/* Extra spacing mode — increased letter and word spacing.
   Research: Zorzi et al. (2012) found extra-large spacing
   improved reading speed and accuracy by 20% in dyslexic
   readers without any training. */
.converted-text.spacing-on {
  letter-spacing: 0.08em;
  word-spacing: 0.2em;
  line-height: 2.2;
}

/* Line guides mode — alternating soft background bands on
   each line to help the reader track across the page.
   Uses a repeating gradient keyed to line-height. */
.converted-text.guides-on {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent calc(1em * 1.1),
    rgba(59, 89, 152, 0.06) calc(1em * 1.1),
    rgba(59, 89, 152, 0.06) calc(1em * 2.2)
  );
  background-size: 100% calc(1em * 2.2);
}

.converted-text.spacing-on.guides-on {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent calc(1em * 1.1),
    rgba(59, 89, 152, 0.06) calc(1em * 1.1),
    rgba(59, 89, 152, 0.06) calc(1em * 2.2)
  );
  background-size: 100% calc(1em * 2.2);
}

/* Paragraph chunks — extra spacing between short paragraphs. */
.converted-text .chunk {
  margin-bottom: 1.25em;
}

.converted-text .chunk:last-child {
  margin-bottom: 0;
}

/* Syllable marks — dots between syllables, styled subtly so
   they help without cluttering. */
.syllable-dot {
  color: #3b5998;
  font-weight: 700;
  margin: 0 0.05em;
  user-select: none;
  font-size: 0.6em;
  vertical-align: middle;
}

/* Reading ruler — a highlight band that follows the mouse
   vertically. Helps the reader focus on one line at a time. */
.reading-ruler {
  position: absolute;
  left: 0;
  right: 0;
  height: 2.4em;
  background: rgba(255, 235, 59, 0.18);
  border-top: 2px solid rgba(255, 193, 7, 0.35);
  border-bottom: 2px solid rgba(255, 193, 7, 0.35);
  pointer-events: none;
  transition: top 0.08s ease;
  border-radius: 4px;
  display: none;
}

.reading-ruler.visible {
  display: block;
}

/* Print button. */
.print-button {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: #ffffff;
  color: #3b5998;
  border: 1px solid #3b5998;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.print-button:hover {
  background: #edf2fa;
}

/* ============================================================
   WHAT CHANGED PANEL
   Explains each adjustment with the research rationale.
   ============================================================ */

.changes-panel {
  margin-top: 1rem;
  background: #ffffff;
  border: 1px solid #d6cfc6;
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.changes-panel h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.75rem;
}

.change-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0ece6;
}

.change-item:last-child {
  border-bottom: none;
}

.change-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #3b5998;
  margin-bottom: 0.2rem;
}

.change-desc {
  font-size: 0.82rem;
  color: #5a5247;
  line-height: 1.5;
}

.change-tag {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.1rem 0.4rem;
  background: #edf2fa;
  color: #3b5998;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ============================================================
   READABILITY STATS BAR
   Shows word count, avg sentence length, estimated reading
   level. Helps teachers gauge appropriateness.
   ============================================================ */

.stats-bar {
  margin-top: 0.75rem;
  display: flex;
  gap: 1.25rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #d6cfc6;
  border-radius: 8px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #3b5998;
}

.stat-label {
  font-size: 0.72rem;
  color: #7a756e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   STATES
   Focus visibility, hover, active.
   ============================================================ */

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid #3b5998;
  outline-offset: 2px;
}

.convert-button:active {
  transform: translateY(1px);
}

/* ============================================================
   PRINT STYLES
   When the teacher prints, show only the converted text —
   no controls, no header, no explanations. Clean handout.
   ============================================================ */

@media print {
  body {
    background: #ffffff;
    font-size: 14pt;
  }

  .app-header,
  .input-panel,
  .adjustments-bar,
  .print-button,
  .changes-panel,
  .stats-bar,
  .app-footer,
  .sample-buttons,
  .output-panel h2 {
    display: none !important;
  }

  .app-main {
    display: block;
    padding: 0;
    max-width: 100%;
  }

  .converted-display {
    border: none;
    padding: 0;
    background: #ffffff;
  }

  .converted-text {
    font-size: 14pt;
    color: #000000;
  }
}
