/*
 * Bible Study colours, built on the site's brand variables.
 *
 * The study templates used Tailwind's grey, indigo, red, amber and green
 * classes. Those are not the brand palette, and several were not in the
 * pre-purged Tailwind build at all, so they silently did nothing. Everything
 * here reads from the brand variables in base.css and the status variables in
 * flash-messages.css. The value after each comma is only a fallback.
 *
 * Use the components (labels, fields, notices) where one fits; the short
 * colour classes at the end are for the remaining one-off cases.
 */

:root {
    --study-text-strong: var(--brand-dark, #11192c);
    --study-text-body: var(--text-primary, #1f2937);
    /* No brand variable is dark enough for small text on the page background
       (--text-secondary is 4.06:1 there). This navy-grey is 5.3:1 on the page
       background and 6.3:1 on white. */
    --study-text-muted: #56607a;
    /* Decoration only (large numerals, empty-state icons, disabled controls). */
    --study-text-faint: var(--brand-gray, #a6abbd);

    --study-surface-soft: var(--brand-light-bg, #f8fafc);
    --study-surface-sunken: var(--brand-background, #e6eef4);
    --study-line: var(--border-subtle, #e2e8f0);
    --study-line-soft: var(--border-subtle, #e2e8f0);

    --study-navy-soft: var(--brand-navy-subtle-bg, #eef2ff);
    --study-navy-line: rgba(43, 58, 127, 0.16);
    --study-gold-soft: var(--brand-accent-light, #fef5d8);
    --study-gold-ink: var(--brand-accent-ink, #806000);
    --study-ember-soft: var(--brand-orange-subtle-bg, rgba(250, 131, 52, 0.08));
    --study-ember-ink: var(--status-success-ink, #9a4a1c);
    --study-danger-soft: var(--status-error-bg, rgba(168, 50, 31, 0.09));
    --study-danger-line: var(--status-error-border, rgba(168, 50, 31, 0.28));
    --study-danger-ink: var(--status-error-ink, #a8321f);
}

/* ---------- Create forms (custom study, youth lesson, research brief) ----------
   Sized like the rest of the app (profile and dashboard forms): a title around
   30px, 46px fields in regular weight, sentence-case labels. These pages used
   to run a size up from everything around them: 48px titles, 54px bold fields,
   64px card padding. */

.study-form-page {
    max-width: 52rem;
    margin: 1.5rem auto 3.5rem;
}

.study-form-card {
    position: relative;
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--study-line);
    border-radius: 1.25rem;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
}

.study-form-header {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--study-line);
}

.study-form-header__text {
    flex: 1 1 auto;
    min-width: 0;
}

.study-form-kicker {
    margin-bottom: 0.5rem;
    color: var(--brand-navy);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.study-shell h1.study-form-title {
    margin: 0 0 0.5rem;
    color: var(--brand-navy);
    font-family: var(--study-font-display);
    font-size: 1.625rem;
    line-height: 1.15;
}

.study-shell p.study-form-intro {
    max-width: 34rem;
    margin: 0;
    color: var(--study-text-muted);
    font-family: var(--study-font-body, inherit);
    font-size: 0.9375rem;
    line-height: 1.55;
}

.study-form {
    display: grid;
    gap: 1.5rem;
}

.study-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem 1.5rem;
}

.study-option-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .study-form-card {
        padding: 2.25rem 2.5rem;
    }

    .study-form-header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        gap: 2rem;
    }

    .study-shell h1.study-form-title {
        font-size: 2rem;
    }

    .study-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .study-option-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.study-shell .study-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.4rem;
    color: var(--study-text-body);
    font-family: var(--study-font-body, inherit);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.4;
    text-transform: none;
}

.study-shell .study-label .material-icons {
    font-size: 1rem;
    color: var(--study-text-muted);
}

/* base.min.css styles input[type="text"] at a higher rank than one class, which
   left text inputs smaller and whiter than the selects beside them. Scoping to
   the study shell puts every field on the same rule. */
.study-shell .form-control {
    width: 100%;
    min-height: 2.875rem;
    border-radius: 0.75rem;
    border: 1px solid var(--study-line);
    padding: 0.625rem 0.875rem;
    background-color: #ffffff;
    font-family: var(--study-font-body, inherit);
    /* 16px keeps iOS from zooming the page when a field takes focus. */
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.4;
    color: var(--study-text-strong);
    box-shadow: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.study-shell .form-control::placeholder {
    color: var(--study-text-muted);
    opacity: 0.8;
}

.study-shell .form-control:hover {
    border-color: var(--study-text-faint);
}

.study-shell .form-control:focus {
    outline: none;
    border-color: var(--brand-navy);
    box-shadow: 0 0 0 3px rgba(43, 58, 127, 0.12);
}

.study-shell textarea.form-control {
    min-height: 7rem;
    line-height: 1.55;
}

.study-shell .form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    margin-top: 0.15rem;
    border-radius: 0.3rem;
    cursor: pointer;
    accent-color: var(--brand-navy);
}

.study-form-help {
    margin: 0.4rem 0 0;
    color: var(--study-text-muted);
    font-family: var(--study-font-body, inherit);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.study-form-error {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0.4rem 0 0;
    color: var(--study-danger-ink);
    font-family: var(--study-font-body, inherit);
    font-size: 0.8125rem;
    font-weight: 600;
}

.study-form-error .material-icons {
    font-size: 1rem;
}

.study-option-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    border: 1px solid var(--study-line);
    border-radius: 0.75rem;
    background: var(--study-surface-soft);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.study-option-row:hover {
    border-color: var(--study-text-faint);
}

.study-option-row strong {
    display: block;
    color: var(--study-text-strong);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
}

.study-option-row small {
    display: block;
    margin-top: 0.15rem;
    color: var(--study-text-muted);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.45;
}

/* The price of the run, shown beside each form's title. */
.study-cost-panel {
    flex: none;
    min-width: 11rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--study-navy-line);
    border-radius: 0.75rem;
    background: var(--study-navy-soft);
    color: var(--study-text-body);
}

.study-cost-panel__label {
    margin-bottom: 0.4rem;
    color: var(--brand-navy);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.study-cost-panel__value {
    color: var(--study-text-strong);
    font-size: 1.125rem;
    font-weight: 700;
}

.study-shell p.study-cost-panel__note {
    margin: 0.5rem 0 0;
    color: var(--study-text-muted);
    font-family: var(--study-font-body, inherit);
    font-size: 0.75rem;
}

.study-cost-row {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    color: var(--study-text-body);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.7;
}

.study-cost-row strong {
    color: var(--study-text-strong);
    font-weight: 700;
}

/* base.min.css styles every button[type="submit"] at a higher rank than one
   utility class, so Tailwind sizing on these buttons never applied. This rule
   outranks it and matches the site's own button size. */
.study-shell button.wizard-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    background-color: var(--brand-navy);
    color: #ffffff;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.08);
    transition: background-color 0.2s ease;
}

.study-shell button.wizard-submit .material-icons {
    font-size: 1.125rem;
}

.study-shell button.wizard-submit:hover {
    background-color: var(--brand-navy-light, #3b4c9b);
}

.study-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--study-line);
}

/* On a phone the two actions stack, so a long label (Portuguese, Spanish)
   cannot push the button past the edge of the card. */
@media (max-width: 479px) {
    .study-form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .study-shell .study-form-actions button.wizard-submit {
        justify-content: center;
        width: 100%;
        white-space: normal;
    }

    .study-form-actions .study-form-cancel {
        justify-content: center;
    }

    .study-form-actions .tooltip-container {
        display: block;
        width: 100%;
    }
}

.study-tradition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.5rem;
}

.study-tradition-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--study-line);
    border-radius: 0.75rem;
    background: var(--study-surface-soft);
    color: var(--study-text-body);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: border-color 0.12s ease, background-color 0.12s ease;
    user-select: none;
}

.study-tradition-option:has(input:checked) {
    border-color: var(--brand-navy);
    background: #ffffff;
    color: var(--brand-navy);
}

.study-tradition-option input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    border-radius: 0.3rem;
    cursor: pointer;
    accent-color: var(--brand-navy);
}

.study-form-cancel {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--study-text-muted);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.study-form-cancel .material-icons {
    font-size: 1.125rem;
}

.study-form-cancel:hover,
.study-form-cancel:focus-visible {
    color: var(--brand-navy);
}

/* ---------- Type scale for the other study pages ----------
   The templates size their headings with Tailwind classes two or three steps
   above the rest of the app (the study home title was 96px; the profile page's
   is 30px, the pricing page's 52px). These rules bring them back in line. */

.study-shell .study-hero {
    padding: 1.75rem 1.25rem;
}

/* The extra class match keeps this ahead of the page-title rule below. */
.study-shell .study-hero h1,
.study-shell .study-hero h1.font-display {
    margin-bottom: 0.75rem;
    font-size: clamp(1.75rem, 1.25rem + 2.4vw, 2.75rem);
    line-height: 1.1;
}

.study-shell .study-hero .study-kicker {
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.study-shell .study-hero p {
    font-size: 1rem;
    line-height: 1.5;
}

.study-shell .study-hero a.study-cta,
.study-shell .study-hero a.bg-white {
    min-height: 2.75rem;
    padding: 0.5rem 1.125rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    gap: 0.5rem;
}

.study-shell .study-hero a .material-icons {
    font-size: 1.25rem;
}

.study-shell a.study-resume-session-btn {
    min-height: 2.75rem;
    padding: 0.5rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

/* Page titles outside a hero: loading, review and detail pages. */
.study-shell h1.font-display {
    font-size: clamp(1.625rem, 1.3rem + 1.4vw, 2.125rem);
    line-height: 1.15;
}

.study-shell h2.font-display {
    font-size: 1.375rem;
    line-height: 1.25;
}

.study-shell p.font-serif.italic.text-lg,
.study-shell p.font-serif.italic.text-xl {
    font-size: 1rem;
    line-height: 1.55;
}

@media (min-width: 768px) {
    .study-shell .study-hero {
        padding: 2.5rem 2.5rem;
    }
}

/* ---------- Notices and errors ---------- */

.study-alert-error {
    background: var(--study-danger-soft);
    border: 1px solid var(--study-danger-line);
    color: var(--study-danger-ink);
}

.study-alert-error a {
    color: inherit;
}

.study-alert-error__body {
    color: var(--study-text-body);
}

.study-alert-error__action {
    display: inline-block;
    background: #ffffff;
    border: 1px solid var(--study-danger-line);
    color: var(--study-danger-ink);
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.study-alert-error__action:hover,
.study-alert-error__action:focus-visible {
    background: var(--study-surface-soft);
    color: var(--study-danger-ink);
}

/* "Your journey helps others" on the study home. */
.study-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--study-navy-line);
    border-radius: 1rem;
    background: var(--study-navy-soft);
    color: var(--study-text-body);
}

.study-notice > .material-icons {
    flex: none;
    margin-top: 0.125rem;
    color: var(--brand-navy);
    font-size: 1.375rem;
}

.study-notice__body {
    flex: 1 1 auto;
    min-width: 0;
}

.study-notice__title {
    margin: 0 0 0.25rem;
    color: var(--brand-navy);
    font-family: var(--study-font-body, inherit);
    font-size: 0.9375rem;
    font-weight: 700;
}

.study-notice__text {
    margin: 0;
    color: var(--study-text-body);
    font-family: var(--study-font-body, inherit);
    font-size: 0.875rem;
    line-height: 1.55;
}

.study-notice__text a {
    color: var(--brand-navy);
    font-weight: 700;
}

.study-shell button.study-notice__dismiss {
    flex: none;
    align-self: center;
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--study-navy-line);
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: none;
    color: var(--brand-navy);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: capitalize;
    cursor: pointer;
}

.study-shell button.study-notice__dismiss:hover,
.study-shell button.study-notice__dismiss:focus-visible {
    background: var(--brand-navy);
    color: #ffffff;
}

@media (max-width: 639px) {
    .study-notice {
        flex-wrap: wrap;
    }

    .study-shell button.study-notice__dismiss {
        margin-left: 2.25rem;
    }
}

/* ---------- Loading pages ---------- */

.study-spinner-halo {
    background: rgba(43, 58, 127, 0.1);
}

/* The ring turns; the icon inside it stays still. */
.study-shell .study-spinner {
    width: 5rem;
    height: 5rem;
    background: #ffffff;
}

.study-shell .study-spinner .material-icons {
    font-size: 1.75rem;
}

.study-spinner::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid var(--study-line-soft);
    border-top-color: var(--brand-orange);
    animation: studySpin 1s linear infinite;
}

@keyframes studySpin {
    to { transform: rotate(360deg); }
}

.study-status-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.9375rem;
    background: #ffffff;
    border: 1px solid var(--study-line-soft);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    color: var(--study-text-strong);
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.study-status-row .step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
}

.study-status-row .step-dot {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: 2px solid var(--study-line);
}

.study-status-row.is-active .step-dot {
    border-top-color: var(--brand-navy);
    animation: studySpin 0.8s linear infinite;
}

.study-step-done {
    color: var(--brand-navy);
}

@media (prefers-reduced-motion: reduce) {
    .study-status-row.is-active .step-dot,
    .study-spinner::before,
    .study-spinner-halo {
        animation: none;
    }
}

/* The orange call to action on the review pages. Dark navy text, like every
   other orange button in Bible Study: white on brand orange is only 2.5:1. */
.study-shell button.review-save {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    background-color: var(--brand-orange);
    color: var(--brand-navy-dark, #1e2b69);
    font-size: 0.9375rem;
    font-weight: 700;
    padding: 0.75rem 1.1rem;
    border-radius: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
    transition: filter 0.16s ease, transform 0.16s ease;
}

.study-shell button.review-save .material-icons {
    font-size: 1.15em;
    color: inherit;
}

.study-shell button.review-save:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.study-mini-spinner {
    border: 2px solid rgba(250, 131, 52, 0.22);
    border-top-color: var(--brand-orange);
    animation: studySpin 0.8s linear infinite;
}

/* ---------- Review pages ---------- */

.study-icon-tile {
    transition: background-color 0.2s ease, color 0.2s ease;
}

.study-icon-tile--navy {
    background: var(--study-navy-soft);
    color: var(--brand-navy);
}

.study-icon-tile--gold {
    background: var(--study-gold-soft);
    color: var(--study-gold-ink);
}

.study-icon-tile--ember {
    background: var(--study-ember-soft);
    color: var(--study-ember-ink);
}

.group:hover .study-icon-tile--navy {
    background: var(--brand-navy);
    color: #ffffff;
}

.group:hover .study-icon-tile--gold {
    background: var(--study-gold-ink);
    color: #ffffff;
}

.group:hover .study-icon-tile--ember {
    background: var(--study-ember-ink);
    color: #ffffff;
}

.study-session-index {
    background: var(--study-surface-soft);
    border-right: 1px solid var(--study-line-soft);
    color: var(--study-text-muted);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.group:hover .study-session-index {
    background: var(--brand-navy);
    color: #ffffff;
}

.study-chip {
    background: var(--study-surface-soft);
    border: 1px solid var(--study-line-soft);
    color: var(--study-text-muted);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.group:hover .study-chip {
    background: var(--study-navy-soft);
    border-color: var(--study-navy-line);
    color: var(--brand-navy);
}

.study-shell .study-inline-title {
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    color: var(--study-text-strong);
    transition: border-color 0.2s ease;
}

.study-shell .study-inline-title:hover {
    border-bottom-color: var(--study-line);
}

.study-shell .study-inline-title:focus {
    outline: none;
    border-bottom-color: var(--brand-orange);
}

.study-panel-navy {
    background: var(--brand-navy);
    color: #ffffff;
}

.study-shell .study-panel-navy__label {
    color: rgba(255, 255, 255, 0.82) !important;
}

.study-shell .study-panel-navy__text {
    color: rgba(255, 255, 255, 0.94) !important;
}

.study-panel-dark {
    background: var(--brand-dark, #11192c);
    color: #ffffff;
}

.study-shell .study-panel-dark__muted {
    color: rgba(255, 255, 255, 0.78) !important;
}

.study-scrim {
    background: rgba(17, 25, 44, 0.4);
}

/* ---------- Short colour classes for one-off cases ----------
   These carry !important like the Tailwind stand-ins they replace: heading and
   paragraph rules in the study stylesheet outrank a single class. */

.study-text-strong { color: var(--study-text-strong) !important; }
.study-text-body { color: var(--study-text-body) !important; }
.study-text-muted { color: var(--study-text-muted) !important; }
.study-text-faint { color: var(--study-text-faint) !important; }
.study-text-accent { color: var(--brand-navy) !important; }
.study-text-gold { color: var(--study-gold-ink) !important; }
.study-text-ember { color: var(--study-ember-ink) !important; }
.study-text-danger { color: var(--study-danger-ink) !important; }

.study-bg-soft { background-color: var(--study-surface-soft) !important; }
.study-bg-sunken { background-color: var(--study-surface-sunken) !important; }
.study-bg-line { background-color: var(--study-line) !important; }
.study-bg-accent-soft { background-color: var(--study-navy-soft) !important; }
.study-bg-gold-soft { background-color: var(--study-gold-soft) !important; }
.study-bg-ember-soft { background-color: var(--study-ember-soft) !important; }
.study-bg-danger-soft { background-color: var(--study-danger-soft) !important; }
.study-bg-orange-tint { background-color: var(--brand-orange-subtle-bg, rgba(250, 131, 52, 0.08)) !important; }
.study-bg-navy-tint { background-color: rgba(43, 58, 127, 0.06) !important; }

.study-border-soft { border-color: var(--study-line-soft) !important; }
.study-border-line { border-color: var(--study-line) !important; }
.study-border-accent { border-color: var(--study-navy-line) !important; }
.study-border-danger { border-color: var(--study-danger-line) !important; }
.study-border-orange-tint { border-color: rgba(250, 131, 52, 0.2) !important; }

.study-hover-soft:hover { background-color: var(--study-surface-sunken) !important; }
.study-hover-navy:hover { background-color: var(--brand-navy) !important; color: #ffffff !important; }
.study-hover-white-tint:hover { background-color: rgba(255, 255, 255, 0.2) !important; }
.study-hover-text-body:hover { color: var(--study-text-body) !important; }
.study-hover-text-navy:hover { color: var(--brand-navy) !important; }
.group:hover .study-group-hover-navy { background-color: var(--brand-navy) !important; color: #ffffff !important; }
.group:hover .study-group-hover-text-navy { color: var(--brand-navy) !important; }

/* Muted text needs the darker body tone on the sunken surface to stay readable. */
.study-bg-sunken.study-text-muted,
.study-bg-sunken .study-text-muted { color: var(--study-text-body) !important; }
