/*-
 * ***LICENSE_START***
 * Elicit Survey
 * %%
 * Copyright (C) 2025 - 2026 Elicit Software LLC
 * %%
 * PolyForm Noncommercial License 1.0.0
 * <https://polyformproject.org/licenses/noncommercial/1.0.0>
 * ***LICENSE_END***
 */

/*
   Elicit Survey Application Theme - Vaadin 25 with Lumo Theme

   This is the master application stylesheet loaded via @StyleSheet, after the
   Lumo theme (which AppConfig loads via @StyleSheet(Lumo.STYLESHEET)).

   This theme provides:
   - Application-specific component styling
   - Brand integration architecture via CSS custom properties
   - Base Vaadin Lumo theme integration (Vaadin 24 compatible styling)

   Brand colors and typography are provided by:
   - Default: ./brand/ directory (copied into Docker image)
   - External: Mounted brand directories (e.g., um-brand, test-brand)

   Visit https://vaadin.com/docs/latest/styling/application-theme for more information.
*/

/* The Lumo theme and its utility classes are loaded via @StyleSheet(Lumo.STYLESHEET)
   and @StyleSheet(Lumo.UTILITY_STYLESHEET) in AppConfig, ahead of this file, so the
   application overrides below win the cascade. Do not @import the theme here. */

/* Brand theme integration */
/* Note: Brand CSS is loaded dynamically via AppConfig during runtime */
/* This avoids build-time dependency issues while maintaining runtime flexibility */

/* Import component styles */
@import 'components/branded-header.css';

/* Per-language font scale (UC-009 BR-011) */
/* LocaleLayout writes --elicit-font-scale onto the document element from the mounted
   i18n-config.json when a locale declares one; it is absent, and so 1, for every other
   locale and for a mount that declares none. Scaling the ROOT font size is what makes one
   property enough: Lumo's font sizes, spacing and control sizes, the brand typography
   tokens and this application's own rules are all expressed in rem, so the whole page grows
   in proportion and nothing clips. 100% is the reader's own browser default -- a scale
   multiplies that rather than replacing it, so a respondent who has enlarged text keeps the
   enlargement. Arabic is the case this exists for: its apparent x-height is smaller than
   Latin's in the system font stack, so it reads small at a size that is comfortable in
   English. */
html {
    font-size: calc(100% * var(--elicit-font-scale, 1));
}

/* Brand Integration Architecture */
/* These CSS custom properties provide the contract between brands and the application.
   The mapping lives on :root — the same selector the brand color/typography files use —
   so a mounted brand overrides these by CSS source order (it is injected after this
   file by AppConfig), rather than depending on html-vs-:root specificity. */
:root {
    /* Brand variables are populated by brand CSS files */
    /* Mapping brand variables to Lumo theme properties */
    --lumo-font-family: var(--brand-font-primary, -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif);

    /* Primary color mapping.
       --lumo-primary-text-color is used for text/links on light surfaces, so it maps to
       a dedicated --brand-primary-text token rather than the raw --brand-primary: a light
       brand primary (e.g. a yellow) fails WCAG contrast as text even though it is fine as
       a button/background fill. Brands with a light primary should set --brand-primary-text
       to a darkened variant; it defaults to the primary for brands whose primary is dark. */
    --lumo-primary-color: var(--brand-primary, hsl(214, 90%, 52%));
    --lumo-primary-text-color: var(--brand-primary-text, var(--brand-primary, hsl(214, 90%, 52%)));
    --lumo-primary-contrast-color: var(--brand-primary-contrast, hsl(0, 0%, 100%));
    --lumo-base-color: var(--brand-base, hsl(0, 0%, 100%));

    /* Question/field-label text. Overrides Lumo's default derivation of
       --lumo-secondary-text-color from --lumo-contrast-70pct, which tracks
       whatever brands set --lumo-shade to and can drop below WCAG AA (4.5:1)
       on light brand backgrounds. See brand-colors.css for the contrast math. */
    --lumo-secondary-text-color: var(--brand-text-secondary, var(--lumo-contrast-70pct));

    /* Primary color variants */
    --lumo-primary-color-50pct: var(--brand-primary-50pct, hsla(214, 90%, 52%, 0.5));
    --lumo-primary-color-10pct: var(--brand-primary-10pct, hsla(214, 90%, 52%, 0.1));

    /* Status color mapping */
    --lumo-error-color: var(--brand-error, hsl(3, 85%, 48%));
    --lumo-error-text-color: var(--brand-error, hsl(3, 85%, 48%));
    --lumo-error-color-50pct: var(--brand-error-50pct, hsla(3, 85%, 48%, 0.5));
    --lumo-error-color-10pct: var(--brand-error-10pct, hsla(3, 85%, 48%, 0.1));

    --lumo-success-color: var(--brand-success, hsl(145, 72%, 30%));
    --lumo-success-text-color: var(--brand-success, hsl(145, 72%, 30%));
    --lumo-success-color-50pct: var(--brand-success-50pct, hsla(145, 72%, 30%, 0.5));
    --lumo-success-color-10pct: var(--brand-success-10pct, hsla(145, 72%, 30%, 0.1));

    --lumo-warning-color: var(--brand-warning, hsl(43, 100%, 48%));
    /* Kept distinct from --lumo-warning-color: a bright fill color is fine as
       a background/badge fill, but frequently fails AA contrast used as its
       own text color -- see brand-colors.css's --brand-warning-text. */
    --lumo-warning-text-color: var(--brand-warning-text, var(--brand-warning, hsl(43, 100%, 48%)));
    --lumo-warning-color-50pct: var(--brand-warning-50pct, hsla(43, 100%, 48%, 0.5));
    --lumo-warning-color-10pct: var(--brand-warning-10pct, hsla(43, 100%, 48%, 0.1));
}

/* ============================================================================ */
/* APPLICATION-SPECIFIC STYLING                                                */
/* ============================================================================ */
/* The following styles are specific to the Elicit Survey application          */
/* and are not related to branding. These remain constant across all brands.   */

/* Elicit Input Field Customization */
.elicit-input-field::part(label) {
    word-wrap: unset;
    white-space: unset;
    overflow: unset;
}

/* Survey Review Components */
.review-section {
    white-space: pre-line;
}

.review-item-question {
    font-weight: bold;
    padding-inline-start: 10px;
}

/* Application Animations */
@keyframes flash {
    0% { background-color: var(--lumo-base-color, white); }
    10% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 10%, transparent)); }
    20% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 15%, transparent)); }
    30% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 20%, transparent)); }
    40% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 25%, transparent)); }
    50% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 30%, transparent)); }
    60% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 25%, transparent)); }
    70% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 20%, transparent)); }
    80% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 15%, transparent)); }
    90% { background-color: var(--brand-interactive-light, color-mix(in srgb, var(--brand-primary, #0A3D62) 10%, transparent)); }
    100% { background-color: var(--lumo-base-color, white); }
}

.flash {
    animation: flash 1.5s ease-in-out;
}

/* Layout Utilities */
.scroller {
    overflow: auto;
    display: flex;
    flex-direction: column;
    /* dvh tracks the dynamic viewport so mobile browser chrome does not clip content;
       100vh would overflow on iOS Safari. */
    height: 100dvh;
    box-sizing: border-box;
}

.reviewCard {
    box-shadow: var(--lumo-box-shadow-s, 0 4px 8px rgba(0, 0, 0, 0.1));
    border: 1px solid var(--lumo-contrast-20pct, #e0e0e0);
    border-radius: var(--lumo-border-radius-m, 4px);
    padding: var(--lumo-space-m, 16px);
    background-color: var(--lumo-base-color, #fff);
}
