/* ============================================================
   MILLER THE FARMER — Read-Along upgrades (css/readalong.css)
   Owner: readalong builder. Built on site.css custom properties;
   tints reuse the site's chip fills (var(--tint-grass), var(--tint-sky), var(--tint-barn)).
   ============================================================ */

.reader { --ra-size: 22px; }
#read [hidden], .ra-cards [hidden] { display: none !important; }

/* ---------- reading modes ---------- */
.ra-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.ra-mode {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 8px 6px; border: 3px solid var(--outline); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text-primary); cursor: pointer;
  font-family: var(--font-display); box-shadow: 0 4px 0 var(--outline);
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.ra-mode:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--outline); }
.ra-mode:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.ra-mode .ra-mode-ico { font-size: 24px; line-height: 1; }
.ra-mode b { font-weight: 600; font-size: 17px; line-height: 1.15; text-align: center; }
.ra-mode small { font-family: var(--font-body); font-size: 12px; font-weight: 700; color: var(--text-secondary); text-align: center; line-height: 1.2; }
.ra-mode[aria-checked="true"] { background: var(--tractor-yellow); transform: translateY(3px); box-shadow: 0 1px 0 var(--outline), inset 0 3px 0 rgba(0, 0, 0, .1); }

/* ---------- tool row ---------- */
.ra-tools { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: center; margin-bottom: var(--space-3); }
.ra-chip {
  min-height: 48px; padding: 8px 14px; border: 2.5px solid var(--outline); border-radius: var(--radius-pill);
  background: var(--surface-primary); color: var(--text-primary); cursor: pointer; box-shadow: 0 3px 0 var(--outline);
  font-family: var(--font-display); font-weight: 500; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.ra-chip[aria-pressed="true"] { background: var(--hill-lime); }
.ra-size {
  min-height: 48px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px;
  border: 2.5px solid var(--outline); border-radius: var(--radius-pill); background: var(--surface-primary);
  font-family: var(--font-display); font-weight: 600; box-shadow: 0 3px 0 var(--outline);
}
.ra-size .a-sm { font-size: 13px; } .ra-size .a-lg { font-size: 22px; }
.ra-size input { width: 110px; accent-color: var(--barn); height: 28px; }

.ra-sightbar {
  display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: center;
  background: var(--tint-grass); border: 2.5px solid var(--outline); border-radius: var(--radius-lg); padding: 8px 10px; margin-bottom: var(--space-3);
}
.ra-sightbar .lvl { min-height: 44px; min-width: 52px; font-size: 16px; }
.ra-sightbar .ra-sight-note { font-weight: 700; font-size: 14px; color: var(--text-secondary); }

/* ---------- stage: big kid arrows ---------- */
.reader .reader-stage { position: relative; touch-action: pan-y; }
.reader .page-arrow { width: 72px; height: 72px; }
.reader .page-arrow svg { width: 38px; height: 38px; }
.reader .page-arrow:disabled { opacity: .35; cursor: default; transform: none; }
.ra-stage-num { display: none; }
.ra-sticker {
  position: absolute; top: 10px; right: 92px; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 34px; background: var(--tractor-yellow);
  border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--outline); transform: rotate(-12deg); pointer-events: none;
}
.ra-sticker.pop { animation: raPop .5s ease-out; }
@keyframes raPop { 0% { transform: scale(.2) rotate(-40deg); } 70% { transform: scale(1.2) rotate(-6deg); } 100% { transform: scale(1) rotate(-12deg); } }

/* ---------- text ---------- */
.reader .reader-text { font-size: var(--ra-size); }
.reader-text button.w, .sb-text button.w {
  font: inherit; color: inherit; background: none; border: 0; margin: 0; cursor: pointer;
  padding: 1px 4px; border-radius: 6px; display: inline; line-height: inherit; letter-spacing: inherit; text-transform: inherit;
  -webkit-tap-highlight-color: transparent;
}
.reader-text button.w:hover { background: rgba(142, 231, 238, .4); }
.sb-text button.w:hover { background: rgba(255,249,236,.16); }
.reader-text button.w:focus-visible, .sb-text button.w:focus-visible { outline: 3px solid var(--sky-dark); outline-offset: 1px; }
.reader-text .ra-p, .sb-text .ra-p { margin-left: -4px; letter-spacing: 0; }
.reader-text .w.sight, .sb-text .w.sight { box-shadow: inset 0 -0.32em 0 var(--hill-lime); }
.sb-text .w.sight { box-shadow: inset 0 -0.22em 0 var(--grass); }
.reader-text .w.on, .sb-text .w.on { background: var(--sun); color: var(--bark); box-shadow: none; }
.reader-text .w.echo { background: var(--tint-sky); color: var(--bark); }
.reader-text .w.tap, .sb-text .w.tap { background: var(--sky); color: var(--bark); }

/* easy-read (dyslexia-friendly): no external font — wider spacing, steady left edge, plain sans */
.reader-text.ra-easy, .sb-text.ra-easy {
  font-family: Verdana, Tahoma, "Trebuchet MS", var(--font-body); text-transform: none; font-size: .9em;
  letter-spacing: .08em; word-spacing: .32em; line-height: 2.1; font-weight: 600; text-align: left;
}
.reader-text.ra-easy { background: var(--paper); border-radius: var(--radius-md); padding: 10px 14px; }

/* word bubble */
.ra-bubble {
  position: fixed; z-index: 310; transform: translate(-50%, -100%);
  background: var(--cream); color: var(--bark); border: 3px solid var(--outline);
  border-radius: var(--radius-lg); padding: 6px 18px; box-shadow: var(--shadow-pop);
  font-family: var(--font-display); font-weight: 600; font-size: 34px; line-height: 1.2; pointer-events: none;
  white-space: nowrap;
}
.ra-bubble small { display: block; font-family: var(--font-body); font-size: 12px; font-weight: 800; color: var(--text-secondary); text-align: center; }

/* echo prompt */
.ra-echo {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3); flex-wrap: wrap;
  margin-top: var(--space-3); padding: 10px 14px; border-radius: var(--radius-lg); border: 2.5px solid var(--outline);
  background: var(--tint-sky); font-family: var(--font-display); font-weight: 600; font-size: 20px;
}
.ra-echo .ra-ring { width: 44px; height: 44px; flex: 0 0 auto; }
.ra-echo .ra-ring circle { fill: none; stroke-width: 6; }
.ra-echo .ra-ring .bg { stroke: rgba(43, 26, 16, .12); }
.ra-echo .ra-ring .fg { stroke: var(--sky-dark); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }

/* controls */
.reader .reader-controls .btn { min-height: 56px; }
.ra-secondary { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }

/* progress */
.ra-progress { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); font-weight: 700; color: var(--text-secondary); }
.ra-bar { flex: 1 1 160px; max-width: 320px; height: 16px; border-radius: var(--radius-pill); background: var(--cream); border: 2.5px solid var(--outline); overflow: hidden; }
.ra-bar i { display: block; height: 100%; width: 0; background: linear-gradient(180deg, var(--hill-lime), var(--hill-grass)); border-radius: inherit; transition: width var(--transition-normal); }
.ra-link { background: none; border: 0; color: var(--barn-red-text); font-weight: 800; cursor: pointer; text-decoration: underline; min-height: 44px; font-family: var(--font-body); font-size: 14px; }

/* filmstrip thumbs as buttons with read marks */
.reader .filmstrip button {
  position: relative; flex: 0 0 auto; padding: 0; border: 3px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; opacity: .6; transition: opacity var(--transition-fast), border-color var(--transition-fast);
}
.reader .filmstrip button img { width: 64px; border-radius: 7px; opacity: 1; border: 0; }
.reader .filmstrip button:hover, .reader .filmstrip button.done { opacity: 1; }
.reader .filmstrip button.cur { opacity: 1; border-color: var(--barn); }
.reader .filmstrip button.done::after {
  content: "✓"; position: absolute; right: -4px; top: -4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--grass); color: #fff; font-size: 13px; font-weight: 900; display: grid; place-items: center;
}
.reader .filmstrip button.stk::after { content: "⭐"; background: var(--sun); }

/* ---------- comprehension ---------- */
.ra-qzone:empty { display: none; }
.ra-qzone { margin-top: var(--space-4); }
.ra-q {
  background: var(--cream); border: 3px solid var(--outline); border-radius: var(--radius-lg); box-shadow: 0 4px 0 var(--outline);
  padding: var(--space-4); margin-bottom: var(--space-3);
}
.ra-q-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-family: var(--font-display); font-weight: 600; color: var(--barn-dark); }
.ra-q-head small { font-family: var(--font-body); font-weight: 800; color: var(--text-secondary); font-size: 12px; }
.ra-q-text { font-size: 19px; font-weight: 700; margin: 6px 0 10px; }
.ra-q-choices { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ra-q-choices button {
  flex: 1 1 180px; min-height: 52px; padding: 10px 14px; border-radius: var(--radius-md);
  border: 2.5px solid var(--outline); background: var(--surface-primary); color: var(--text-primary); box-shadow: 0 3px 0 var(--outline);
  font-family: var(--font-body); font-weight: 700; font-size: 16px; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.ra-q-choices.pics button { flex: 1 1 100px; flex-direction: column; text-align: center; font-family: var(--font-display); font-size: 18px; }
.ra-q-choices.pics img { width: 84px; height: 84px; object-fit: contain; }
.ra-q-choices button.right { background: var(--tint-grass); }
.ra-q-choices button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.ra-q-choices button.nope { opacity: .45; }
.ra-q-why { margin-top: 10px; font-weight: 700; color: var(--green-text); }
.ra-q-why.soft { color: var(--text-secondary); }
.ra-q-ideas { margin: 10px 0 0 1.2em; }
.ra-q-ideas li { margin-bottom: 4px; }
.ra-countdown { display: flex; justify-content: center; align-items: center; gap: var(--space-3); flex-wrap: wrap; font-weight: 700; color: var(--text-secondary); margin-bottom: var(--space-3); }

.ra-panel { margin-top: var(--space-4); border-top: 2px dashed rgba(43, 26, 16, .15); padding-top: var(--space-4); }
.ra-panel h3 { font-size: 22px; margin-bottom: var(--space-2); }
.ra-bands { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.ra-bands .ka-band { min-height: 52px; }
.ra-when { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); font-weight: 700; }
.ra-when .lvl { min-height: 44px; }
.ra-end { text-align: center; background: var(--tint-hay); border: 3px solid var(--outline); border-radius: var(--radius-lg); padding: var(--space-4); margin-top: var(--space-4); }
.ra-end h3 { font-size: 26px; }

/* ---------- flash cards ---------- */
.ra-cards {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px;
  background: rgba(43, 26, 16, .55);
}
.ra-cards-box {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--paper); border: 3px solid var(--outline); border-radius: var(--radius-xl); padding: var(--space-5);
  box-shadow: var(--shadow-pop); text-align: center; position: relative;
}
.ra-cards-box h3 { font-size: clamp(19px, 5vw, 24px); padding: 0 48px; }
.ra-cards-close { position: absolute; top: 10px; right: 10px; width: 48px; height: 48px; border-radius: 50%; border: 2.5px solid var(--outline); background: var(--cream); font-size: 22px; cursor: pointer; color: var(--text); }
.ra-cards-hear { margin: var(--space-4) auto; }
.ra-cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.ra-card {
  min-height: 92px; border-radius: var(--radius-lg); border: 3px solid var(--outline);
  background: var(--surface-primary); font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 7vw, 34px);
  color: var(--bark); cursor: pointer; box-shadow: var(--shadow-lifted); overflow-wrap: anywhere;
}
.ra-card.right { background: var(--tint-grass); border-color: var(--grass-dark); }
.ra-card.nope { opacity: .35; }
.ra-cards-dots { display: flex; justify-content: center; gap: 6px; margin-top: var(--space-4); }
.ra-cards-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(43, 26, 16, .15); }
.ra-cards-dots i.ok { background: var(--grass); } .ra-cards-dots i.try { background: var(--hay); }
.ra-cards-stars { font-size: 40px; letter-spacing: 6px; margin: var(--space-3) 0; }
.ra-cards-msg { min-height: 1.6em; font-weight: 800; margin-top: var(--space-2); }

/* ---------- phone ---------- */
@media (max-width: 640px) {
  .reader { --ra-size: 19px; padding: var(--space-3); }
  .ra-mode { min-height: 72px; padding: 6px 4px; }
  .ra-mode b { font-size: 14px; }
  .ra-mode small { display: none; }
  .reader .reader-stage { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "img img img" "prev num next"; gap: var(--space-2); align-items: center; }
  .reader .reader-stage .reader-img { grid-area: img; max-height: 46vh; }
  .reader #raPrev { grid-area: prev; } .reader #raNext { grid-area: next; }
  .ra-stage-num { display: block; grid-area: num; text-align: center; font-weight: 800; color: var(--text-secondary); }
  .reader .page-arrow { width: 68px; height: 68px; }
  .ra-sticker { right: 8px; top: 8px; width: 52px; height: 52px; font-size: 28px; }
  .ra-size input { width: 90px; }
  .ra-cards-box { padding: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  .ra-sticker.pop { animation: none; }
  .ra-mode:hover { transform: none; }
}
