/* Hide elements until Alpine.js initializes */
[x-cloak] {
    display: none !important;
}

/* --- Sticky footer layout --- */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main#main-content {
    flex: 1;
}

/* Custom styles not processed by Tailwind */

/* High contrast: keep errors red (not yellow) */
[data-theme="high-contrast"] {
    --color-error: #ff6b6b;
}

label.required::after,
.required-mark::after {
    content: " *";
    color: var(--color-error);
    font-weight: 700;
}

/* Hide asterisk on radio/checkbox labels (asterisk goes on fieldset legend instead) */
input[type="radio"] + label.required::after,
input[type="checkbox"] + label.required::after {
    content: none;
}

/* --- Accent heading (replaces inline style="color: var(--color-bg-accent)") --- */
.accent-heading {
    color: var(--color-bg-accent);
}

[data-theme="high-contrast"] .accent-heading {
    color: #ffff00 !important;
}

/* --- Flash messages --- */
.flash-success {
    background-color: var(--color-success-bg);
    border: 2px solid var(--color-success);
    color: var(--color-success);
}

.flash-error {
    background-color: var(--color-error-bg);
    border: 2px solid var(--color-error);
    color: var(--color-error);
}

[data-theme="high-contrast"] .flash-success {
    background-color: #000000;
    border-color: #4ade80;
    color: #4ade80;
}

[data-theme="high-contrast"] .flash-error {
    background-color: #000000;
    border-color: #ff6b6b;
    color: #ff6b6b;
}

[data-theme="high-contrast"] .error-summary {
    background-color: #000000;
    border-color: #ff6b6b;
}

[data-theme="high-contrast"] .error-summary h2,
[data-theme="high-contrast"] .error-summary a,
[data-theme="high-contrast"] .error-summary p,
[data-theme="high-contrast"] .error-summary li {
    color: #ff6b6b;
}

/* --- Hero secondary button --- */
.btn-hero-secondary {
    background: transparent;
    color: white;
    border-color: white;
}

.btn-hero-secondary:visited {
    color: white;
}

.btn-hero-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

[data-theme="high-contrast"] .btn-hero-secondary {
    color: #ffff00 !important;
    border-color: #ffff00 !important;
    background: transparent !important;
}

[data-theme="high-contrast"] .btn-hero-secondary:hover {
    background: rgba(255, 255, 0, 0.15) !important;
}

/* --- Hero CTA button --- */
.btn-hero-cta {
    font-size: 1.25rem;
    padding: 1rem 2.5rem;
}

@media (max-width: 640px) {
    .btn-hero-cta {
        font-size: 1.125rem;
        padding: 0.875rem 2rem;
        width: 100%;
        text-align: center;
    }

    .btn-hero-secondary {
        width: 100%;
        text-align: center;
    }
}

/* --- Step circles (homepage "Jak wziąć udział?") --- */
.step-circle {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--color-bg-accent);
    color: var(--color-text-inverse);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    margin: 0 auto 1rem;
}

@media (max-width: 640px) {
    .step-circle {
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }
}

[data-theme="high-contrast"] .step-circle {
    background: #ffff00 !important;
    color: #000000 !important;
}

/* --- Mobile menu button --- */
.mobile-menu-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.25rem;
    color: white;
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    min-height: 2.75rem;
    min-width: 2.75rem;
    margin-left: auto;
}

[data-theme="high-contrast"] .mobile-menu-btn {
    color: #ffff00 !important;
    border-color: #ffff00 !important;
}

/* --- Mobile navigation --- */
@media (max-width: 1099px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .main-nav {
        display: none;
        width: 100%;
        flex-basis: 100%;
        order: 10;
    }

    .main-nav.nav-open {
        display: block;
    }

    .main-nav ul {
        flex-direction: column;
        gap: 0;
        width: 100%;
    }

    .main-nav li {
        width: 100%;
    }

    .main-nav a {
        display: block;
        width: 100%;
        padding: 0.875rem 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        white-space: normal;
        text-align: left;
        font-size: 1.1rem;
    }
}

@media (min-width: 1100px) {
    .main-nav {
        display: flex !important;
    }

    .mobile-menu-btn {
        display: none !important;
    }
}

/* --- Accessibility toolbar mobile --- */
@media (max-width: 640px) {
    .a11y-toolbar .max-w-6xl {
        justify-content: center;
        gap: 0.5rem;
    }

    .a11y-toolbar span.mr-2 {
        display: none;
    }

    .a11y-toolbar button {
        flex: 1;
        text-align: center;
        font-size: 0.85rem;
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }
}

/* --- FAQ Accordion --- */
.faq-item {
    border: 2px solid var(--color-border-light);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.faq-question {
    width: 100%;
    text-align: left;
    padding: 1.25rem 1.5rem;
    font-family: var(--font-family);
    font-size: 1.125rem;
    font-weight: 700;
    background: var(--color-bg-base);
    color: var(--color-text-primary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

@media (max-width: 640px) {
    .faq-question {
        padding: 1rem;
        font-size: 1rem;
    }

    .faq-answer {
        padding: 0 1rem 1rem;
    }
}

.faq-question:hover {
    background: var(--color-bg-subtle);
}

.faq-answer {
    padding: 0 1.5rem 1.25rem;
}

[data-theme="high-contrast"] .faq-item {
    border-color: #ffff00;
}

[data-theme="high-contrast"] .faq-question {
    color: #ffffff;
}

/* --- Table --- */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--color-border-light);
}

th {
    background: var(--color-bg-subtle);
    font-weight: 700;
    border-bottom-color: var(--color-border);
}

@media (max-width: 640px) {
    th, td {
        padding: 0.5rem 0.5rem;
        font-size: 0.95rem;
    }
}

[data-theme="high-contrast"] th {
    background: #111;
    color: #ffff00;
    border-bottom-color: #ffff00;
}

[data-theme="high-contrast"] td {
    border-bottom-color: #ffff00;
    color: #ffffff;
}

/* --- Button small variant --- */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    min-height: 2.5rem;
}

@media (max-width: 640px) {
    .btn-sm {
        width: 100%;
        text-align: center;
    }
}

/* --- Summary definition list (registration step 4) --- */
.summary-dl {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.75rem 1.5rem;
}

@media (max-width: 640px) {
    .summary-dl {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .summary-dl dt {
        margin-top: 0.75rem;
    }

    .summary-dl dt:first-child {
        margin-top: 0;
    }
}

/* --- Progress tracker mobile --- */
@media (max-width: 640px) {
    .progress-tracker {
        gap: 0.25rem;
    }

    .progress-step {
        font-size: 0.8rem;
        padding-top: 2.25rem;
    }

    .progress-step::before {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
    }
}

/* --- Header: logos and nav centering --- */

.header-logo-right {
    display: block;
}

@media (max-width: 1099px) {
    .header-logo-right {
        margin-left: 0;
    }
}

/* --- Footer logos --- */
.footer-logos {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* --- Discipline row (select + remove button) --- */
.discipline-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.discipline-row select {
    flex: 1;
    min-width: 0;
}

.discipline-row .btn {
    width: auto !important;
    flex-shrink: 0;
}

/* --- Select dropdown — larger options on desktop --- */
select option {
    padding: 0.5rem 0.75rem;
    font-size: 1.125rem;
}

/* --- Registration step buttons mobile --- */
@media (max-width: 640px) {
    .step-buttons {
        flex-direction: column-reverse;
    }

    .step-buttons .btn {
        width: 100%;
        text-align: center;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .faq-question,
    input, select, textarea {
        transition: none !important;
    }

    .btn:hover {
        transform: none !important;
    }
}

/* --- Form row (two fields side by side) --- */
.form-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.form-row-field {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

@media (max-width: 820px) {
    .form-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    .form-row-field,
    .form-row fieldset {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }

    .form-row-field input[type="text"],
    .form-row-field input[type="email"],
    .form-row-field input[type="tel"],
    .form-row-field select,
    .form-row-field textarea {
        width: 100% !important;
    }
}

/* --- Date inputs (GDS pattern: day/month/year) --- */
.date-inputs {
    display: flex !important;
    flex-direction: row !important;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: nowrap;
}

.date-input-field label {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.375rem;
    color: var(--color-text-primary);
}

.date-input-field input {
    width: 100% !important;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.date-input-day,
.date-input-month {
    width: 3.5rem !important;
    max-width: 3.5rem !important;
    flex: 0 0 3.5rem !important;
}

.date-input-year {
    width: 5rem !important;
    max-width: 5rem !important;
    flex: 0 0 5rem !important;
}

/* --- Link styles --- */
.link {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link:hover {
    color: var(--color-link-hover);
}

.link:focus-visible {
    outline: 4px solid var(--color-focus);
    outline-offset: 4px;
}

[data-theme="high-contrast"] .link {
    color: #ffff00 !important;
}

/* --- Text muted --- */
.text-muted {
    color: var(--color-text-secondary);
}
