/* Nova, the visible AI tutor window (public/nova.js), as in
   docs/master/APPROVED_NOVA_LESSON_REFERENCE.png: Nova's approved portrait in a rounded window,
   her name and "AI tutor" on a bar across its foot, a sound-wave mark while she speaks, and the
   mute, microphone and full-screen buttons. Lightweight CSS only: no video, no generated imagery.
   Every state is also said in words in .nova-status. The earlier drawing (#tutor-nova) shows only
   if the portrait does not load. */

.nova {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0;
  color: #1d1b3a;
}

.nova-window {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #3b2f7a 0%, #1d1b3a 100%);
  box-shadow: 0 10px 28px rgba(20, 30, 80, 0.22);
}
.nova-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

/* The portrait holder (also used beside the question and in the conversation). */
.nova-portrait { position: relative; display: block; overflow: hidden; }
.nova-portrait .nova-avatar {
  position: absolute;
  inset: 12%;
  width: 76%;
  height: 76%;
  transform-origin: 50% 60%;
}
.nova-photo { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }
.nova-photo[hidden] { display: none; }
.nova-portrait[data-art="ready"] > .nova-avatar { display: none; }
.nova-frame-portrait { position: absolute; inset: 0; }

/* Her speaking face (public/nova-face.js): a canvas holding her mouth and jaw region of the same
   approved picture, warped while she speaks and placed by script exactly over that region (physical
   left/top: the picture is never mirrored, also right to left). Nothing is drawn on top of her:
   no shape, no mask, no other image. Hidden at rest, and never shown over the fallback drawing. */
.nova-face { position: absolute; left: 0; top: 0; pointer-events: none; }
/* Her head: the portrait and both face canvases move together (a slight tilt, nod or breath set
   by script as a transform; none with reduced motion). */
.nova-head { position: absolute; inset: 0; transform-origin: 50% 80%; }
/* With the optional foreground and background pictures (public/art/README-face-assets.md): the
   room stays still and only she moves. Both are the same 900x745 frame as the portrait, placed
   exactly like it; the portrait itself is then hidden under her foreground. */
.nova-layer { position: absolute; inset: 0; display: none; inline-size: 100%; block-size: 100%; object-fit: cover; object-position: 50% 28%; pointer-events: none; }
.nova-frame[data-layers="ready"] .nova-layer { display: block; }
.nova-frame[data-layers="ready"] .nova-head .nova-photo { visibility: hidden; }
.nova-face[hidden], .nova-frame-portrait:not([data-art="ready"]) ~ .nova-face { display: none; }

.nova-fx { position: absolute; inset: 0; pointer-events: none; }

/* The bar across the foot of the window. */
.nova-bar {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(180deg, rgba(12, 16, 40, 0) 0%, rgba(12, 16, 40, 0.78) 45%);
  color: #ffffff;
}
.nova-name { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 1.15rem; min-width: 0; }
.nova-name strong { padding: 0.1rem 0.6rem; border-radius: 0.6rem; background: rgba(12, 16, 40, 0.55); }
.nova-ai {
  display: inline-block;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: #ecebff;
  color: #2c1f5e;
  font-size: 0.78rem;
  font-weight: 700;
}
.nova-wave { display: none; width: 2.6rem; height: 1rem; background: repeating-linear-gradient(90deg, #ffffff 0 2px, transparent 2px 5px); opacity: 0.9; }
.nova-controls { display: flex; gap: 0.35rem; }
.nova-control {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(12, 16, 40, 0.55);
  color: #ffffff;
  cursor: pointer;
}
.nova-control[hidden] { display: none; }
.nova-control[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.nova-control[aria-pressed="true"] { background: #2a4fd8; }
.nova-control-icon { width: 22px; height: 22px; fill: currentColor; }
.nova-control:focus-visible { outline: 3px solid #ffb020; outline-offset: 2px; }

.nova-status { margin: 0; font-weight: 700; color: #2c1f5e; }
.nova-caption { margin: 0; font-size: 0.95rem; line-height: 1.4; }
.nova-note { margin: 0; font-size: 0.75rem; color: #4a4766; }
.nova-ai-status {
  margin: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 0.5rem;
  background: #fff4d6;
  color: #5c3b00;
  font-size: 0.8rem;
  font-weight: 600;
}
.nova-ai-status[hidden] { display: none; }
/* The AI tutor is not available for this account: said in words, on a warmer ground. */
.nova-ai-status[data-ai="unavailable"] { background: #ffe6d9; color: #6e2400; border-inline-start: 4px solid #d55e00; }
/* Where offered chapters come from (uploaded pages, not checked against the syllabus). */
.nova-provenance { margin: 0; font-size: 0.8rem; color: #3d3a5c; font-style: italic; }
.nova-provenance[hidden] { display: none; }
.nova-caption, .nova-actions, .nova-provenance, .nova-note, .nova-ai-status { grid-column: 1 / -1; }
.nova-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.nova-actions[hidden] { display: none; }
.nova-action {
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  border-radius: 0.75rem;
  border: 2px solid #2a4fd8;
  background: #ffffff;
  color: #1a2f8a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nova-action:focus-visible { outline: 3px solid #ffb020; outline-offset: 2px; }

/* Full screen: the window fills the screen, the portrait keeps its proportions. */
.nova-window:fullscreen { display: grid; place-items: center; background: #0c1028; border-radius: 0; }
.nova-window:fullscreen .nova-frame { width: min(100vw, 133vh); }

/* States */
.nova[data-state="idle"] .nova-avatar { animation: nova-float 4s ease-in-out infinite; }
.nova[data-state="speaking"] .nova-avatar { animation: nova-talk 0.45s ease-in-out infinite alternate; }
.nova[data-state="speaking"] .nova-wave { display: inline-block; animation: nova-blink 0.6s ease-in-out infinite alternate; }
.nova[data-state="speaking"] .nova-fx {
  background: radial-gradient(circle at 50% 55%, transparent 52%, rgba(255, 204, 61, 0.3) 54%, transparent 58%);
  animation: nova-wave 1s linear infinite;
}
.nova[data-state="listening"] .nova-window { box-shadow: 0 0 0 4px #2bb3a3, 0 10px 28px rgba(20, 30, 80, 0.22); }
.nova[data-state="listening"] .nova-fx {
  box-shadow: inset 0 0 0 0 rgba(43, 179, 163, 0.6);
  animation: nova-pulse 1.4s ease-out infinite;
}
.nova[data-state="thinking"] .nova-avatar { animation: nova-tilt 1.6s ease-in-out infinite; opacity: 0.9; }
.nova[data-state="thinking"] .nova-fx {
  background:
    radial-gradient(circle at 44% 12%, #ffffff 2%, transparent 3%),
    radial-gradient(circle at 50% 12%, #ffffff 2%, transparent 3%),
    radial-gradient(circle at 56% 12%, #ffffff 2%, transparent 3%);
  animation: nova-blink 1.2s steps(3) infinite;
}
.nova[data-state="waiting"] .nova-window { box-shadow: 0 0 0 4px #ffb020, 0 10px 28px rgba(20, 30, 80, 0.22); }
.nova[data-state="waiting"] .nova-status { color: #7a4a00; }

@keyframes nova-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
@keyframes nova-talk { from { transform: scale(1); } to { transform: scale(1.06, 0.97); } }
@keyframes nova-wave { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@keyframes nova-pulse { 0% { box-shadow: inset 0 0 0 0 rgba(43, 179, 163, 0.6); } 100% { box-shadow: inset 0 0 0 1.2rem rgba(43, 179, 163, 0); } }
@keyframes nova-tilt { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes nova-blink { 0% { opacity: 0.3; } 100% { opacity: 1; } }

/* Reduced motion: no movement; states stay distinguishable by the window edge and the words. */
@media (prefers-reduced-motion: reduce) {
  .nova .nova-avatar, .nova .nova-fx, .nova .nova-wave { animation: none !important; }
  /* Her mouth still moves with her words (it carries meaning), gently: public/nova-face.js halves
     the movement and slows it a little under this preference. */
  .nova[data-state="speaking"] .nova-window { box-shadow: 0 0 0 4px #ffcc3d; }
  .nova[data-state="thinking"] .nova-window { box-shadow: 0 0 0 4px #9a8cff; }
}

/* Below the workspace's three-column width (1024px, public/workspace.css) Nova sits at the top of
   the lesson column: a compact strip (a small square portrait, the bar beside it, then the words)
   that never covers the question or the answer controls. */
@media (max-width: 1023px) {
  .nova { grid-template-columns: 3.25rem 1fr; align-items: center; column-gap: 0.6rem; row-gap: 0.25rem; }
  .nova-window { display: contents; }
  /* A strip, not a panel: the AI label stays in her name bar and in the lesson's notice. */
  .nova-note { display: none; }
  .nova-status { font-size: 0.85rem; }
  .nova-caption { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; font-size: 0.88rem; }
  .nova-frame { grid-row: span 2; width: 3.25rem; aspect-ratio: 1 / 1; border-radius: 1rem; background: #2c1f5e; }
  .nova-bar { position: static; padding: 0; background: none; color: #1d1b3a; }
  .nova-name strong { padding: 0; background: none; }
  .nova-wave { background: repeating-linear-gradient(90deg, #2a4fd8 0 2px, transparent 2px 5px); }
  .nova-control { background: #e8ecff; color: #1a2f8a; }
  .nova-control[data-nova-control="fullscreen"] { display: none; } /* the strip is not a window */
  .nova-caption, .nova-actions, .nova-provenance, .nova-note, .nova-ai-status { grid-column: 1 / -1; }
}
