/* PTP_FL_H13_CONTRAST_AUDIT_V1
 * Dark-mode text/background pairing, based on the existing 17-page theme.
 * Light mode, coastal image, sidebar branding, media, badges and functionality
 * are intentionally unaffected.
 */

/* Share card: the prior --pine-dark headline was nearly invisible against dark green. */
html[data-ptp-theme="dark"] .pwa-share-card .pwa-share-card-copy strong {
  color: #f3fff6 !important;
}
html[data-ptp-theme="dark"] .pwa-share-card .pwa-share-card-copy span,
html[data-ptp-theme="dark"] .pwa-share-card p {
  color: #c7dfd0 !important;
}
html[data-ptp-theme="dark"] .pwa-share-card .pwa-share-card-note {
  color: #effff3 !important;
  background: #224833 !important;
  border-color: #52775f !important;
}

/* Legacy page templates have bright fixed backgrounds while the new theme
 * gives their text a pale foreground. Pair dark surfaces with pale text.
 * All rules are limited to the dark theme. */
html[data-ptp-theme="dark"] :is(
  .manual, .toc, .manual-body, .quick-step,
  .course-rail, .lesson-card, .quiz-card, .completion-card,
  .sources-card, .field-guide-card, .teacher-card, .source-link,
  .answer-option, .question-item, .reflection-card, .auth-card,
  .mini-card, .teacher-point, .bill-sample, .confidence-card,
  .lesson-gate-note, .progress-card, .device-note, .concept,
  .overview-item, .implementation-item, .preference, .paper-meta,
  .stat, .mini-stat, .fact, .definition, .sheet-card, .rep-card,
  .method-step, .rule-link, .source-box, .map-message,
  .course, .privacy, .note, .notification-summary-card,
  .notification-toggle-row, .data-table, .data-table th,
  .data-table td, .table-wrap, .section-card,
  .card.form-card, .card.success-card,
  .district-switcher-card, .system-state,
  .pwa-share-card
) {
  background: #192f25 !important;
  color: #edf9f0 !important;
  border-color: #456c55 !important;
}

/* Layering for nested cards and table rows so boundaries remain legible. */
html[data-ptp-theme="dark"] :is(
  .answer-option, .question-item, .source-link, .mini-stat,
  .fact, .definition, .method-step, .rule-link, .quick-step,
  .teacher-point, .overview-item, .implementation-item, .preference,
  .notification-toggle-row, .data-table th
) {
  background: #254234 !important;
}
html[data-ptp-theme="dark"] :is(
  .notice, .callout, .official-notice-banner
) {
  background: #40351c !important;
  color: #fff0c6 !important;
  border-color: #ab8a45 !important;
}

/* Restore dark-mode headlines on panels with fixed pine-dark heading rules.
 * Exclude branded pills, whose light backgrounds need dark lettering. */
html[data-ptp-theme="dark"] :is(
  .card, .manual, .toc, .course-rail, .section-card, .stat, .mini-stat,
  .fact, .definition, .sheet-card, .rep-card, .lesson-card,
  .quiz-card, .teacher-card, .field-guide-card, .sources-card,
  .rule-link, .source-box, .method-step, .course, .privacy,
  .notification-summary-card
) :is(h1,h2,h3,h4,th) {
  color: #f4fff7 !important;
}
html[data-ptp-theme="dark"] :is(
  .stat, .mini-stat, .fact, .definition, .sheet-card, .rep-card,
  .course, .privacy, .source-box, .rule-link,
  .notification-summary-card
) strong {
  color: #f4fff7 !important;
}
html[data-ptp-theme="dark"] :is(
  .notice, .callout, .official-notice-banner
) :is(h1,h2,h3,h4,strong,p,li) {
  color: #fff0c6 !important;
}

/* Standalone pages with white gradient hero cards: not the green branded
 * district hero or the coastal masthead. */
html[data-ptp-theme="dark"] main.shell > .hero,
html[data-ptp-theme="dark"] main.shell > .stats .stat,
html[data-ptp-theme="dark"] .page-shell > main > .hero {
  background: #1a3427 !important;
  color: #f4fff6 !important;
  border-color: #466d55 !important;
}
html[data-ptp-theme="dark"] main.shell > .hero :is(h1,h2,h3,strong) {
  color: #f4fff6 !important;
}
html[data-ptp-theme="dark"] :is(
  .course-rail, .manual, .toc, .lesson-card, .quiz-card,
  .field-guide-card, .sources-card, .teacher-card,
  .stat, .source-box, .rep-card, .fact, .definition
) :is(p,li,dd,dt,small,.meta,.rail-copy,.intro,.hint,.subtitle) {
  color: #c8ddcf !important;
}

/* Card data tables and secondary panels must not remain white behind pale text. */
html[data-ptp-theme="dark"] :is(.data-table, .data-table th, .data-table td,
  .sheet-card table, .card table, .manual table, .lesson-card table,
  .manual .manual-contents, .manual .manual-section,
  .manual .chapter, .toc a, .notice-table td, .notice-table th) {
  background-color: #192f25 !important;
  color: #eaf8ee !important;
  border-color: #456c55 !important;
}
html[data-ptp-theme="dark"] :is(.data-table th, .card table th,
 .manual table th, .lesson-card table th) {
 background-color: #254234 !important;
 color: #f4fff7 !important;
}

/* Branded active navigation and call-to-action green buttons keep original
 * backgrounds. Header artwork, photo/video and Pinech expressions unchanged. */
@media print {
  html[data-ptp-theme="dark"] :is(.manual,.card,.panel,.toc,.lesson-card,.data-table) {
    background: white !important;
    color: black !important;
  }
}

/* Remaining inherited pine-dark typography on dark panels. These panels
 * are ordinary content surfaces, not brand/verification badges. */
html[data-ptp-theme="dark"] :is(
  .card, .panel, .toc, .manual, .course-rail, .teacher-card,
  .lesson-card, .quiz-card, .method-step, .reflection-card,
  .mini-card, .bill-sample, .concept, .auth-card, .quick-step,
  .source-box, .section-card, .district-switcher-card, .system-state
) :is(strong,label) {
  color: #f1fff5 !important;
}
html[data-ptp-theme="dark"] :is(.card,.panel,.course-rail,.lesson-card,
 .quiz-card,.teacher-card,.manual,.toc) :is(td,th) {
  color: #f1fff5 !important;
}

/* Small sub-cards on both classroom courses had fixed ivory backgrounds. */
html[data-ptp-theme="dark"] :is(
 .confidence-check, .learning-objective, .can-now,
 .hero-stat, .objective, .question-item, .device-note,
 .reflection-card, .auth-card, .method-box, .screenshot-card,
 .grade-notice, .lesson-summary, .field-guide-card label,
 .field-guide-card .label, .answer-list .answer-option,
 .summary-card
) {
  background: #254234 !important;
  color: #eefbf3 !important;
  border-color: #547b62 !important;
}
html[data-ptp-theme="dark"] :is(.confidence-check,.learning-objective,
 .can-now,.hero-stat,.objective,.method-box,.grade-notice,
 .summary-card) :is(h1,h2,h3,h4,strong,label,span,p,small) {
  color: #eefbf3 !important;
}

/* Heading text must not inherit pine-dark from the old light-mode classes. */
html[data-ptp-theme="dark"] :is(
  .page-shell main .hero, main.shell > .hero,
  .hero .hero-grid, .card.summary-card, .card.kpi
) :is(h1,h2,h3,strong,label,span) {
  color: #f1fff5 !important;
}
html[data-ptp-theme="dark"] :is(.page-shell main .hero, main.shell > .hero)
 :is(.lead,.hero-lead,p) { color: #c9e1d2 !important; }

/* Civic learning navigation: dark text on a dark active item was invisible. */
html[data-ptp-theme="dark"] :is(.course-rail,.toc) :is(a,button,span,strong) {
  color: #e8f8ed;
}
html[data-ptp-theme="dark"] :is(.course-rail,.toc) :is(.active,.selected) {
  background: #2b6043 !important;
  color: #f5fff8 !important;
}
html[data-ptp-theme="dark"] :is(.course-rail,.toc) :is(.active,.selected) :is(span,strong) {
  color: #f5fff8 !important;
}
html[data-ptp-theme="dark"] :is(.course-rail,.toc) .lesson-number {
  background: #315a43 !important;
  color: #f2fff6 !important;
}

/* Soft labels keep the original pale-green brand treatment in dark mode. */
html[data-ptp-theme="dark"] :is(.community-hero,.hero,.page-shell) :is(
  .eyebrow,.status-badge.soft,.kicker
) {
  background: #dbefdf !important;
  color: #113f2b !important;
}

/* Main feed and static page utility controls keep deep-green fills with
 * readable bright labels, rather than switching button colors. */
html[data-ptp-theme="dark"] :is(.nav-button.secondary,.quiet-button,
 .topbar .button.secondary,.topbar .back,.topbar .return-button) {
  color: #f4fff6 !important;
  border-color: #527b61 !important;
}
html[data-ptp-theme="dark"] :is(.topbar .brand,.topbar .brand-title,
 .topbar .brand-copy,.topbar .brand strong,.topbar .brand span) {
  color: #f4fff6 !important;
}
html[data-ptp-theme="dark"] .district-switcher-card label,
html[data-ptp-theme="dark"] .system-state strong,
html[data-ptp-theme="dark"] .card.form-card label,
html[data-ptp-theme="dark"] .card.kpi strong {
  color: #f4fff6 !important;
}

/* Links inside darkened explanatory content need to be visibly distinct. */
html[data-ptp-theme="dark"] :is(.paper-meta,.card.conclusion,.manual,.lesson-card,
 .sources-card,.privacy,.toc) a:not(.button) {
  color: #a9edbf !important;
}

/* Final template-specific pairing identified in browser contrast checks. */
html[data-ptp-theme="dark"] :is(.grade-notice,.privacy-note,.ican) {
  background: #443820 !important;
  color: #fff0cf !important;
  border-color: #b29051 !important;
}
html[data-ptp-theme="dark"] :is(.grade-notice,.privacy-note,.ican) :is(h1,h2,h3,h4,p,span,strong) {
  color: #fff0cf !important;
}
html[data-ptp-theme="dark"] .card.method small {
  background: #254234 !important;
  color: #d6ecdd !important;
}
html[data-ptp-theme="dark"] .card.form-card label span,
html[data-ptp-theme="dark"] .card.form-card .label {
  color: #effbf3 !important;
}
html[data-ptp-theme="dark"] :is(.page-shell main .hero,main.shell > .hero) .eyebrow {
  background: #dbeedf !important;
  color: #123c2b !important;
}
html[data-ptp-theme="dark"] .bill-sample .center.small { color: #e3eee4 !important; }
html[data-ptp-theme="dark"] .secondary-button {
  color: #f1fff5 !important;
  background: #25543c !important;
  border-color: #527e61 !important;
}
html[data-ptp-theme="dark"] :is(.method,.method-box) {
  background: #192f25 !important;
  border-color: #456c55 !important;
}
html[data-ptp-theme="dark"] main > .section-head h2 {
  color: #f1fff5 !important;
}
html[data-ptp-theme="dark"] .profile-page .eyebrow,
html[data-ptp-theme="dark"] main.shell > .eyebrow {
  color: #a9e6b9 !important;
}
html[data-ptp-theme="dark"] .top a.back { color: #f4fff6 !important; }
html[data-ptp-theme="dark"] .portrait-wrap .placeholder {
  color: #173f2b !important;
}
html[data-ptp-theme="dark"] :is(.caution,.problem-callout) {
  background: #473a20 !important;
  color: #fff0ca !important;
  border-color: #b08e48 !important;
}
html[data-ptp-theme="dark"] :is(.caution,.problem-callout) :is(strong,p,span) {
  color: #fff0ca !important;
}
html[data-ptp-theme="dark"] .method .eyebrow {
  color: #eed48d !important;
}
