/* Shared final theme layer for teacher, login and student screens. */
:root {
  --control-hover-bg: #e4d7fa;
  --control-hover-text: #302044;
  --control-hover-border: #b49ae8;
}

html[data-theme="dark"] {
  --brand-ink: #edf1f7;
  --brand-lilac-soft: #30263f;
  --brand-lilac-pale: #1c1923;
  --surface-tint: #25202e;
  --brand-gradient-page: linear-gradient(180deg, #17131e, #101318);
  --brand-gradient-surface: linear-gradient(135deg, #282132, #191d24);
  --brand-gradient-surface-soft: linear-gradient(135deg, #30263f, #20252d);
  --brand-gradient-action: linear-gradient(135deg, #73539e, #604080);
  --control-hover-bg: #cbb2f0;
}

html[data-theme="dark"] body {
  background: var(--brand-gradient-page);
}

/* Existing workspace styles contain !important headers; theme tokens also
   keep those headers and their pseudo-elements on the same dark surface. */
html[data-theme="dark"] :is(
  .student-portal-card, .login-card, .student-account-dropdown,
  .student-account-button, .student-avatar-option, .student-pet-accessory-option,
  .student-pet-environment-option,
  .student-piece-card, .student-piece-empty, .student-award-card,
  .student-completed-quests, .practice-check, .student-pet-speech,
  .student-companion-bubble, .student-practice-session-pet,
  .student-practice-piece-choice,
  .student-portal-card input, .student-portal-card select,
  .student-pet-settings-form select, .piece-rich-text-tool
) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

html[data-theme="dark"] :is(
  .student-level-card, .student-pet-stage, .student-avatar-selector,
  .student-practice-session, .schedule-student-card, .schedule-empty
) {
  background: var(--brand-gradient-surface);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .student-pet-stage[data-environment="garden"] {
  background: linear-gradient(145deg, #1f3329, #394536 58%, #4f4935);
}
html[data-theme="dark"] .student-pet-stage[data-environment="stage"] {
  background: radial-gradient(circle at 75% 14%, rgba(243,211,125,.22) 0 8%, transparent 9%), linear-gradient(145deg, #332440, #4a293a 55%, #4d412a);
}
html[data-theme="dark"] .student-pet-stage[data-environment="beach"] {
  background: linear-gradient(180deg, #1f3443 0 44%, #27505c 44% 58%, #5a4b35 58% 100%);
}
html[data-theme="dark"] .student-pet-stage[data-environment="night"] {
  background: radial-gradient(circle at 78% 18%, rgba(255,245,186,.7) 0 6%, transparent 7%), linear-gradient(145deg, #25233f, #443b63 60%, #554b66);
}
html[data-theme="dark"] .student-pet-stage[data-environment="space"] {
  background: radial-gradient(circle at 78% 18%, rgba(224,190,255,.4) 0 5%, transparent 6%), linear-gradient(145deg, #141224, #292044 55%, #44385f);
}
html[data-theme="dark"] .student-pet-stage[data-environment="castle"] {
  background: linear-gradient(180deg, #302b3c 0 62%, #443a34 62% 100%);
}
html[data-theme="dark"] .student-pet-stage[data-environment="aurora"] {
  background: radial-gradient(ellipse at 28% 25%, rgba(96,226,160,.22) 0 18%, transparent 40%), radial-gradient(ellipse at 72% 18%, rgba(173,107,235,.26) 0 16%, transparent 38%), linear-gradient(145deg, #101928, #1d2a43 55%, #2e394f);
}

html[data-theme="dark"] :is(
  .student-pet-stats span, .student-pet-viewport, .pet-journey-step,
  .student-level-track, .student-quest-progress, .student-quest-chooser-hint,
  .student-companion-control, .student-pet-home,
  .schedule-focus-count, .schedule-focus-refresh,
  .item-actions button, .portal-switch-link
) {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

html[data-theme="dark"] :is(
  .student-avatar-option.selected, .student-pet-accessory-option.selected,
  .student-pet-environment-option.selected,
  .practice-check.complete, .student-piece-card.quest-complete,
  .student-practice-piece-choice.is-recorded,
  .pet-journey-step.complete, .pet-journey-step.current,
  .student-sidebar-v2-link.active, .student-edit-tab.active,
  .schedule-focus li, .is-current .schedule-focus li
) {
  background: var(--brand-lilac-soft);
  color: var(--accent-dark);
  border-color: var(--brand-lilac);
}

html[data-theme="dark"] :is(
  .student-level-card strong, .student-pet-accessory-fieldset legend,
  .student-completed-quests summary, .student-quest-progress-row strong
) { color: var(--text); }

html[data-theme="dark"] :is(
  .student-award-date, .student-completed-quests summary span:last-child,
  .student-detail-label, .student-detail-value, .schedule-focus-count,
  .student-login-help, .student-practice-piece-choice small
) { color: var(--muted); }

html[data-theme="dark"] .schedule-focus-skeleton {
  background: linear-gradient(90deg, var(--surface-soft), #352e40, var(--surface-soft));
}

/* Match teacher disclosures to the portal's completed-quests treatment. */
.statistics-disclosure {
  overflow: hidden;
  border: 1px solid #e0d7ea;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.statistics-disclosure > summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 0;
  padding: 0.9rem 1rem;
  color: #463a52;
  background: transparent !important;
  border-bottom: 0 !important;
  font-weight: 750;
}

.statistics-disclosure > summary::after {
  content: "+";
  order: 3;
  font-size: 1.2rem;
}

.statistics-disclosure[open] > summary::after {
  content: "−";
}

.statistics-disclosure .statistics-summary-hint {
  margin-left: auto;
  color: #746b7d;
  font-size: 0.78rem;
  font-weight: 600;
}

.statistics-disclosure > .statistics-content {
  padding: 1rem;
  background: transparent;
}

html[data-theme="dark"] .statistics-disclosure {
  background: var(--surface);
  border-color: var(--border-strong);
}

html[data-theme="dark"] .statistics-disclosure > summary {
  color: var(--text);
}

html[data-theme="dark"] .statistics-disclosure .statistics-summary-hint {
  color: var(--muted);
}

html[data-theme="dark"] #studentPiecesList .piece-admin-actions .piece-delete-button {
  background: #2b2022;
  color: #f2a3aa;
  border-color: #563538;
}

html[data-theme="dark"] :is(input, textarea)::placeholder { color: #a5adba; opacity: 1; }
html[data-theme="dark"] :is(.rich-piece-copy, .piece-rich-text-editor) p { color: inherit; }
html[data-theme="dark"] .sonare-lockup-mark { content: url("sonare-mark-dark.svg"); }
html[data-theme="dark"] .sonare-brand-mark.sonare-logo-svg { content: normal; }
html[data-theme="dark"] .sonare-logo-bar--ink { fill: #edf1f7; }

/* One hover/focus treatment beats legacy green gradients and late-injected
   component rules. Disabled controls keep their existing state. */
html body :is(button, .button, [role="button"], .portal-switch-link, summary):not(:disabled):not([aria-disabled="true"]):is(:hover, :focus-visible) {
  background: var(--control-hover-bg) !important;
  color: var(--control-hover-text) !important;
  border-color: var(--control-hover-border) !important;
}

html body :is(button, .button, [role="button"], .portal-switch-link, summary):not(:disabled):not([aria-disabled="true"]):is(:hover, :focus-visible) :is(span, strong, small) {
  color: inherit;
}

html body :is(button, a, input, select, textarea, summary, [contenteditable="true"]):focus-visible {
  outline: 2px solid var(--brand-lilac);
  outline-offset: 3px;
}

html body :is(input, select, textarea, [contenteditable="true"]):focus {
  border-color: var(--brand-lilac);
  box-shadow: 0 0 0 3px rgba(180, 154, 232, 0.2);
}

.lesson-sync-notice { margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.lesson-sync-notice p { margin: 0 0 0.75rem; }
.lesson-sync-error { color: var(--danger) !important; }
#lessonRecovery { margin-top: 1rem; }
#lessonRecovery summary { cursor: pointer; padding: 0.75rem; border-radius: 8px; }
#lessonRecovery .list-item { margin-top: 0.5rem; }

html body button:is(:hover, :focus-visible) :is(.student-sidebar-v2-icon, .student-menu-icon) { background: transparent; }
