/* Focus layout for Years 3-4 lessons.
 *
 * The stock lesson is a 50/50 split: a wall of transcript on the left, the
 * diagram squeezed on the right. For a Year 3 reader that is backwards — the
 * picture is the lesson and the words are support. This layout gives the
 * visual the middle 60%, puts Explanation and Watch Out in narrow side
 * columns, and hides their text until the student asks for it, so what is on
 * screen is the diagram and the voice.
 *
 * Applied only to pages carrying data-tnas-focus. Paired with focus-lesson.js,
 * which does the DOM rearranging; this file is only presentation.
 */

/* Explanation and Watch Out share one narrow column; the diagram takes the
   rest. 1fr 4fr is a true 20/80 of the space left after the gap. */
body[data-tnas-focus] .app-container {
  grid-template-columns: 1fr 4fr;
  gap: 20px;
  align-items: start;
}

body[data-tnas-focus] .visual-pane {
  /* The centre column is the lesson: let it use the height it needs. */
  min-height: 70vh;
}

/* ── Side columns ─────────────────────────────────────────────────────────── */
.focus-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

/* Only the active step's block is shown; the rest stay in the DOM so the
   narration buttons built at load time keep working. */
.focus-side [data-focus-step]:not(.is-active),
.focus-turn [data-focus-step]:not(.is-active) {
  display: none;
}

.focus-side .script-block,
.focus-side .tips-block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg, 16px);
  padding: 16px;
  margin: 0;
}

/* The label row carries the heading, the listen button and the reveal toggle. */
.focus-side .script-label,
.focus-side .tips-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

/* ── Words hidden until asked for ─────────────────────────────────────────── */
.focus-side .script-text,
.focus-side .tips-text {
  display: none;
}

body.tnas-show-words .focus-side .script-text,
body.tnas-show-words .focus-side .tips-text {
  display: block;
}

.focus-reveal {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.focus-reveal:hover {
  color: var(--text);
  border-color: var(--brand);
}

/* ── Transport: ⏮ ▶ ⏸ ⏹ ⏭, at the top of the lesson column ───────────────── */
.focus-transport {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px 6px;
  flex-wrap: wrap;
}

/* The lesson's own "Prev Step / Next Step" pair is replaced by the arrows in
   the transport. It is hidden rather than removed: those arrows click these
   buttons, which is what keeps one implementation of stepping. */
body[data-tnas-focus] .navigation-controls {
  display: none;
}

.focus-ctl {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  /* Big enough for a Year 3 finger on a tablet. */
  min-width: 74px;
  min-height: 58px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text, #f3f4f6);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.focus-ctl:hover:not(:disabled) {
  border-color: var(--brand, #6366f1);
  background: rgba(99, 102, 241, 0.12);
}

.focus-ctl:active:not(:disabled) {
  transform: translateY(1px);
}

.focus-ctl:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.focus-ctl-glyph {
  font-size: 20px;
  line-height: 1;
}

.focus-ctl-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Play is the primary action, so it carries the brand colour. */
.focus-ctl-play:not(:disabled) {
  background: var(--brand, #6366f1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.28);
}

.focus-ctl-play:not(:disabled):hover {
  background: var(--brand, #6366f1);
  filter: brightness(1.08);
}

/* While a clip runs, Pause is what the student wants next. */
.focus-ctl-pause:not(:disabled) {
  border-color: var(--brand, #6366f1);
  color: var(--brand, #a5b4fc);
}

/* A lesson with no narration keeps the arrows and drops the audio buttons
   rather than showing three controls that can do nothing. */
.focus-transport-silent .focus-ctl-play,
.focus-transport-silent .focus-ctl-pause,
.focus-transport-silent .focus-ctl-stop {
  display: none;
}

/* ── Your Turn, under the diagram ─────────────────────────────────────────── */
.focus-turn {
  padding: 0 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.focus-turn .action-block {
  margin: 0;
}

/* The quiz takes over the centre column; the side notes are about the lesson,
   so they step out of the way rather than sitting there unrelated. */
body[data-tnas-focus].tnas-quiz-open .focus-side {
  display: none;
}

body[data-tnas-focus].tnas-quiz-open .app-container {
  grid-template-columns: 1fr;
  max-width: 1100px;
}

body[data-tnas-focus].tnas-quiz-open .focus-turn,
body[data-tnas-focus].tnas-quiz-open .focus-transport {
  display: none;
}

/* ── Narrow screens ───────────────────────────────────────────────────────── */
/* A tablet is the common Year 3 device: one column, diagram first, the words
   after it — the same order of importance as the wide layout. */
@media (max-width: 1080px) {
  body[data-tnas-focus] .app-container {
    grid-template-columns: 1fr;
  }

  .focus-side {
    position: static;
    max-height: none;
    overflow: visible;
  }

  body[data-tnas-focus] .visual-pane {
    order: -1;
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .focus-ctl,
  .focus-ctl:hover:not(:disabled),
  .focus-ctl:active:not(:disabled) {
    transition: none;
    transform: none;
  }
}
