/* Readable text on dark/colored Bulma surfaces.
   theme_generated.css sets color: var(--text-primary) on p, .title, .column,
   .container, and similar. In light mode that is near-black, so copy on
   primary/info/success/danger/link/dark backgrounds becomes unreadable. */

:is(
    .notification.is-primary,
    .notification.is-info,
    .notification.is-success,
    .notification.is-danger,
    .notification.is-link,
    .notification.is-dark,
    .hero.is-primary,
    .hero.is-link,
    .hero.is-info,
    .hero.is-success,
    .hero.is-danger,
    .hero.is-dark,
    .has-background-dark,
    .box.has-background-dark
) {
    color: #fff;
}

:is(
    .notification.is-primary,
    .notification.is-info,
    .notification.is-success,
    .notification.is-danger,
    .notification.is-link,
    .notification.is-dark,
    .has-background-dark,
    .box.has-background-dark
) :is(
    .title,
    .subtitle,
    .content,
    p,
    strong,
    em,
    li,
    h1, h2, h3, h4, h5, h6,
    .column,
    .container,
    .text,
    .media-content,
    .level-item,
    .level-left,
    .level-right,
    .control,
    .field-body,
    .field-label,
    .icon-text,
    label,
    .label,
    .checkbox,
    .is-size-7,
    .is-size-6,
    .help,
    .text-muted
) {
    color: #fff;
}

:is(
    .notification.is-primary,
    .notification.is-info,
    .notification.is-success,
    .notification.is-danger,
    .notification.is-link,
    .notification.is-dark,
    .has-background-dark,
    .box.has-background-dark
) a:not(.button):not(.navbar-item) {
    color: #fff;
    text-decoration: underline;
}

:is(
    .notification.is-primary,
    .notification.is-info,
    .notification.is-success,
    .notification.is-danger,
    .notification.is-link,
    .notification.is-dark,
    .has-background-dark,
    .box.has-background-dark
) :is(.has-text-info, .has-text-success, .has-text-danger, .has-text-primary, .has-text-primary-dark, .has-text-link, .has-text-grey) {
    color: #fff !important;
    filter: none;
}

.hero.is-primary .title,
.hero.is-primary .subtitle,
.hero.is-link .title,
.hero.is-link .subtitle,
.hero.is-info .title,
.hero.is-info .subtitle,
.hero.is-success .title,
.hero.is-success .subtitle,
.hero.is-danger .title,
.hero.is-danger .subtitle,
.hero.is-dark .title,
.hero.is-dark .subtitle,
.hero.is-primary .hero-body,
.hero.is-link .hero-body,
.hero.is-info .hero-body,
.hero.is-success .hero-body,
.hero.is-danger .hero-body,
.hero.is-dark .hero-body,
.hero.is-primary .container,
.hero.is-link .container,
.hero.is-info .container,
.hero.is-success .container,
.hero.is-danger .container,
.hero.is-dark .container,
.hero.is-primary .column,
.hero.is-link .column,
.hero.is-info .column,
.hero.is-success .column,
.hero.is-danger .column,
.hero.is-dark .column {
    color: #fff;
}

/* Light cards nested in a colored hero must keep theme body text. */
:is(.hero.is-primary, .hero.is-link, .hero.is-info, .hero.is-success, .hero.is-danger, .hero.is-dark) .box {
    color: var(--text-primary);
}

:is(.hero.is-primary, .hero.is-link, .hero.is-info, .hero.is-success, .hero.is-danger, .hero.is-dark) .box :is(.title, .subtitle, p, .content) {
    color: var(--text-primary);
}

/* Amber surfaces need dark text; white on warning fails contrast. */
.notification.is-warning:not(.is-light),
.hero.is-warning .title,
.hero.is-warning .subtitle,
.hero.is-warning .hero-body,
.button.is-warning,
.button.is-warning:hover,
.tag.is-warning {
    color: #1f2937;
}

.notification.is-warning:not(.is-light) :is(
    .title,
    .subtitle,
    .content,
    p,
    li,
    ul,
    ol,
    em,
    span,
    label,
    small,
    h1, h2, h3, h4, h5, h6,
    strong,
    .column,
    .container,
    .is-size-7,
    .is-size-6
) {
    color: #1f2937;
}

/* Generic .button:hover { color: var(--text-primary) } would darken labels
   on colored buttons in light mode. */
.button.is-primary,
.button.is-primary:hover,
.button.is-info,
.button.is-info:hover,
.button.is-success,
.button.is-success:hover,
.button.is-danger,
.button.is-danger:hover,
.button.is-link,
.button.is-link:hover,
.button.is-dark,
.button.is-dark:hover,
.tag.is-primary,
.tag.is-info,
.tag.is-success,
.tag.is-danger,
.tag.is-link,
.tag.is-dark {
    color: #fff;
}

.message.is-primary .message-header,
.message.is-info .message-header,
.message.is-success .message-header,
.message.is-danger .message-header,
.message.is-link .message-header,
.message.is-dark .message-header {
    color: #fff;
}

.message.is-warning .message-header {
    color: #1f2937;
}

/* Dark-mode accent is a pale violet/blue; keep inverted surfaces dark enough
   for white text instead of white-on-lavender. */
[data-theme="dark"] :is(.notification.is-primary, .notification.is-info) {
    background-color: #6d28d9;
    color: #fff;
}

[data-theme="dark"] .button.is-primary,
[data-theme="dark"] .button.is-primary:hover,
[data-theme="dark"] .tag.is-primary {
    background-color: #6d28d9;
    color: #fff;
}

[data-theme="dark"] .button.is-info,
[data-theme="dark"] .button.is-info:hover,
[data-theme="dark"] .tag.is-info {
    background-color: #1d4ed8;
    color: #fff;
}


/* ==========================================================================
   Readable colours on every surface, in light and dark mode
   --------------------------------------------------------------------------
   Found by measuring the rendered pages: Bulma's own text colours (.content h2,
   .has-text-*, links, table headers) and its bright surface colours (.is-success,
   .has-background-*) did not meet WCAG AA (4.5:1 normal text, 3:1 large) against
   this theme in one mode or the other. These rules come last on purpose.
   ========================================================================== */

:root {
    --surface-primary: #6d28d9;
    --surface-info: #1d4ed8;
    --surface-success: #15803d;
    --surface-danger: #b91c1c;
    --surface-link: #1d4ed8;
    --surface-warning: #fb923c;
    --on-light: #111827;
    --text-success: #15803d;
    --text-warning: #b45309;
    --text-danger: #b91c1c;
    --text-info: #1d4ed8;
    --text-link: #1d4ed8;
    --text-accent: #6d28d9;
    --text-grey: #4b5563;
    --text-grey-light: #6b7280;
}

[data-theme="dark"] {
    --text-success: #4ade80;
    --text-warning: #fdba74;
    --text-danger: #fca5a5;
    --text-info: #93c5fd;
    --text-link: #93c5fd;
    --text-accent: #c4b5fd;
    --text-grey: #cbd5e1;
    --text-grey-light: #94a3b8;
}

/* 1. Bulma's .content headings, strong and table text use fixed dark greys */
.content :is(h1, h2, h3, h4, h5, h6, strong, th) {
    color: var(--text-primary);
}
.content blockquote {
    color: var(--text-secondary);
}
.table :is(th, td) {
    color: var(--text-primary);
}
.table thead th {
    color: var(--text-primary);
}

/* 2. Text-colour helpers: pick shades that read on the page background of each mode */
.has-text-success { color: var(--text-success) !important; }
.has-text-warning { color: var(--text-warning) !important; }
.has-text-danger { color: var(--text-danger) !important; }
.has-text-info { color: var(--text-info) !important; }
.has-text-link { color: var(--text-link) !important; }
.has-text-primary { color: var(--text-accent) !important; }
.has-text-grey { color: var(--text-grey) !important; }
.has-text-grey-light, .has-text-grey-lighter { color: var(--text-grey-light) !important; }
.help, .is-size-7.has-text-grey { color: var(--text-grey); }
.help.is-danger { color: var(--text-danger); }
a:not([class]),
a:is(.has-text-weight-bold, .is-size-7, .is-size-6, .is-underlined) {
    color: var(--text-link);
}
[data-theme="dark"] :is(a:not([class]), a:is(.has-text-weight-bold, .is-size-7, .is-size-6, .is-underlined)) {
    color: var(--text-accent);
}

/* 3. Bright Bulma surfaces get darker shades so white text reaches 4.5:1 (the .is-light variants are left to the theme) */
:is(.notification.is-success, .has-background-success, .button.is-success, .tag.is-success, .hero.is-success, .message.is-success .message-header):not(.is-light) {
    background-color: var(--surface-success) !important;
    border-color: var(--surface-success);
    color: #fff;
}
:is(.notification.is-danger, .has-background-danger, .button.is-danger, .tag.is-danger, .hero.is-danger, .message.is-danger .message-header):not(.is-light) {
    background-color: var(--surface-danger) !important;
    border-color: var(--surface-danger);
    color: #fff;
}
:is(.notification.is-info, .has-background-info, .button.is-info, .tag.is-info, .hero.is-info, .notification.is-link, .has-background-link, .button.is-link, .tag.is-link):not(.is-light) {
    background-color: var(--surface-info) !important;
    border-color: var(--surface-info);
    color: #fff;
}
:is(.notification.is-primary, .has-background-primary, .button.is-primary, .tag.is-primary, .hero.is-primary):not(.is-light) {
    background-color: var(--surface-primary) !important;
    border-color: var(--surface-primary);
    color: #fff;
}
/* Bulma's bold heroes paint a bright gradient over the background colour */
:is(.hero.is-primary, .hero.is-info, .hero.is-success, .hero.is-danger, .hero.is-link).is-bold {
    background-image: none !important;
}
/* Text on those surfaces is white, except inside a nested light card, box, message or warning notification */
:is(.has-background-success, .has-background-danger, .has-background-info, .has-background-link, .has-background-primary, .notification.is-success, .notification.is-danger, .notification.is-info, .notification.is-link, .notification.is-primary):not(.is-light) :is(p, li, strong, em, span, small, label, .label, h1, h2, h3, h4, h5, h6, .title, .subtitle, .heading, .help, .is-size-7, .is-size-6, .is-size-5, .has-text-grey, .has-text-grey-light, .has-text-success, .has-text-info, .has-text-primary, .has-text-link, .has-text-danger, .has-text-warning):not(.button):not(.tag):not(:is(.notification.is-warning, .notification.is-light, .message-body, .gift-messages-box, .button, .tag) *) {
    color: #fff !important;
}
:is(.button, .tag) :is(span, i, strong, .icon) {
    color: inherit;
}

/* 4. Surfaces that stay pale in both modes keep dark text (the theme itself repaints the *-light variants) */
:is(.has-background-light, .has-background-white, .has-background-white-ter, .has-background-white-bis, .has-background-warning) {
    color: var(--on-light);
}
:is(.has-background-light, .has-background-white, .has-background-white-ter, .has-background-white-bis, .has-background-warning) :is(p, li, strong, em, span, small, label, .label, h1, h2, h3, h4, h5, h6, .title, .subtitle, .heading, .help, .is-size-7, .is-size-6, .is-size-5, .has-text-grey, .has-text-grey-light):not(.button):not(.tag) {
    color: var(--on-light) !important;
}

/* 4b. Dark text helpers and plain notifications in dark mode */
[data-theme="dark"] :is(.has-text-dark, .has-text-black, .has-text-black-bis, .has-text-grey-dark) {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .notification:not(.is-primary):not(.is-link):not(.is-info):not(.is-success):not(.is-warning):not(.is-danger):not(.is-dark):not(.is-light) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 4c. Bulma's .content tables use fixed dark greys */
.content table :is(th, td),
.content table thead :is(th, td),
.content table tfoot :is(th, td) {
    color: var(--text-primary);
}

/* 4d. Calendar and dashboard widgets with their own colours */
.fc {
    color: var(--text-primary);
}
.fc :is(a, .fc-daygrid-day-number, .fc-col-header-cell-cushion, .fc-toolbar-title) {
    color: var(--text-primary);
}
.info-box-text, .info-box-number {
    color: var(--text-primary);
}

/* 5. Gift and invite boxes on the dashboard: explicit colours instead of Bulma classes that do not exist */
.gift-messages-box {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
}
.gift-messages-box :is(h4, p, div, span, strong, small) {
    color: inherit;
}
.gift-messages-box .gift-message-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}
.gift-messages-box .gift-message-item .gift-message-meta {
    color: var(--text-secondary);
}

/* 6. .is-light notifications are pale in light mode and repainted dark by the theme in dark mode,
   so their text must follow the theme text colour, not the white used on solid notifications */
.notification:is(.is-primary, .is-link, .is-info, .is-success, .is-warning, .is-danger).is-light,
.notification:is(.is-primary, .is-link, .is-info, .is-success, .is-warning, .is-danger).is-light :is(p, li, strong, em, span, small, label, .label, h1, h2, h3, h4, h5, h6, .title, .subtitle, .content, .heading, .help, .is-size-7, .is-size-6, .column, .has-text-grey) {
    color: var(--text-primary) !important;
}
.notification:is(.is-primary, .is-link, .is-info, .is-success, .is-warning, .is-danger).is-light a:not(.button) {
    color: var(--text-link) !important;
}
[data-theme="dark"] .notification:is(.is-primary, .is-link, .is-info, .is-success, .is-warning, .is-danger).is-light a:not(.button) {
    color: var(--text-accent) !important;
}
/* a plain .is-light notification keeps Bulma's pale grey in dark mode, so repaint it */
[data-theme="dark"] .notification.is-light:not(.is-primary):not(.is-link):not(.is-info):not(.is-success):not(.is-warning):not(.is-danger) {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}
[data-theme="dark"] .notification.is-light:not(.is-primary):not(.is-link):not(.is-info):not(.is-success):not(.is-warning):not(.is-danger) :is(p, li, strong, span, label, .label, .radio, .checkbox, .help, .is-size-7, .is-size-6, h1, h2, h3, h4, h5, h6) {
    color: var(--text-primary) !important;
}

/* 7. Muted text needs 4.5:1 on the palest grey surfaces too */
:root:not([data-theme="dark"]) {
    --text-muted: #5b6472;
}

/* 8. FullCalendar (history page) takes its colours from variables; point them at the theme */
.fc {
    --fc-page-bg-color: var(--bg-primary);
    --fc-neutral-bg-color: var(--bg-secondary);
    --fc-neutral-text-color: var(--text-secondary);
    --fc-border-color: var(--border-color);
    --fc-today-bg-color: rgba(124, 58, 237, 0.12);
    --fc-list-event-hover-bg-color: var(--bg-secondary);
}
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
    color: var(--text-primary);
}
.fc .fc-day-other .fc-daygrid-day-top {
    opacity: 0.65;
}

/* 9. Spread page buttons: the dark-mode accent is pale violet, so give them a solid dark surface */
.nav-button-primary,
.nav-button-primary:hover {
    background: var(--surface-primary);
    color: #fff;
}
.fc .fc-day-other .fc-daygrid-day-top {
    opacity: 0.85 !important;
}

/* 10. Smaller fixes found by the same measurements */
.question-box {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
    color: #fff;
}
.question-box :is(p, strong, em, span, div, h1, h2, h3, h4, h5, h6) {
    color: inherit;
}
.title strong, .subtitle strong {
    color: inherit;
}
/* text that asks for white on a coloured block keeps that colour in its children */
:is(.has-text-white, .has-text-white-ter, .has-text-white-bis, .has-text-light) :is(p, li, strong, em, span, small, .is-size-7, .is-size-6, .subtitle, .title, h1, h2, h3, h4, h5, h6):not(.button):not(.tag) {
    color: inherit;
}
/* boxes inside a warning hero follow the theme, not the hero's dark amber text */
.hero.is-warning .box,
.hero.is-warning .box :is(.title, .subtitle, p, .content, li, strong, em, span, h1, h2, h3, h4, h5, h6) {
    color: var(--text-primary);
}
/* the dark theme only repaints some .is-light notifications */
[data-theme="dark"] .notification.is-link.is-light {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

/* 11. More fixes from the measurements */
.notification.is-warning:not(.is-light) :is(p, li, strong, em, span, small, label, .title, .subtitle, .heading, .help, .is-size-7, .is-size-6, h1, h2, h3, h4, h5, h6) {
    color: #1f2937 !important;
}
:is(.has-background-success, .has-background-danger, .has-background-info, .has-background-link, .has-background-primary):not(.is-light) a:not(.button):not(.tag) {
    color: #fff !important;
    text-decoration: underline;
}
.tabs a {
    color: var(--text-secondary);
}
.tabs li.is-active a {
    color: var(--text-accent);
    border-bottom-color: var(--text-accent);
}
.card-title, .card-header-title, .progress-description, .info-box-text, .info-box-number {
    color: var(--text-primary);
}

/* 12. Last round of measured fixes */
.button:is(.is-primary, .is-info, .is-success, .is-danger, .is-link, .is-dark):not(.is-light) :is(span, i, strong, .icon) {
    color: #fff !important;
}
.button.is-warning :is(span, i, strong, .icon),
.tag.is-warning,
.tag.is-warning :is(span, strong) {
    color: #1f2937 !important;
}
:is(.notification.is-success, .notification.is-danger, .notification.is-info, .notification.is-primary, .notification.is-link) .subtitle {
    opacity: 1;
}
.tabs li a {
    color: var(--text-secondary) !important;
}
.tabs li.is-active a {
    color: var(--text-accent) !important;
}
