/**
 * P-DTR public styles — ProfiRehab brand.
 *
 * These forms are embedded by shortcode into pages that already carry the
 * site's header, logo and branding, so nothing here tries to be a page. It
 * styles one component that has to sit calmly inside someone else's layout.
 *
 * The brief is a 35-field medical history, filled in by people who are in pain,
 * frequently on a phone, sometimes in one sitting and sometimes over days. Every
 * decision below serves legibility and a sense of progress over expression.
 *
 * Colour comes from the brand manual, with one correction it does not make:
 * #19ae70 against white is 2.9:1, which fails WCAG AA. So the primary green
 * fills shapes and never carries text on a light ground; #0d4c2f (10:1) is the
 * green that text is allowed to use.
 */

/* ---------------------------------------------------------------- fonts --- */

/* Montserrat, self-hosted. Loading this from Google's CDN would send every
   visitor's IP to a third party on a site that processes health data, and would
   sit behind the cookie banner. Variable font: one file covers 100-900. */

/* latin-ext — carries č ď ľ ĺ ň ŕ š ť ž, without which Slovak breaks */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/montserrat-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin — carries á é í ó ú ý ô ä */
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/montserrat-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------- tokens --- */

.pdtr-form-container,
.pdtr-gate,
.pdtr-message-box,
.pdtr-therapy-embed {
    /* Brand */
    --pdtr-green:   #19ae70;  /* primary — fills and focus, never text on white */
    --pdtr-forest:  #0d4c2f;  /* tertiary — the green that text may use */
    --pdtr-mist:    #a9d9be;  /* accent — tints */
    --pdtr-ink:     #181818;  /* secondary — body text */
    --pdtr-surface: #ffffff;

    /* Neutrals derived from the brand ink rather than picked, so greys stay in
       the same family as the palette instead of drifting blue or warm. */
    --pdtr-canvas:  #f7f8f7;
    --pdtr-line:    rgba(24, 24, 24, 0.14);
    --pdtr-line-strong: rgba(24, 24, 24, 0.28);
    --pdtr-muted:   rgba(24, 24, 24, 0.62);

    --pdtr-danger:  #b3261e;

    /* One radius and one shadow, used everywhere. */
    --pdtr-radius:  10px;
    --pdtr-radius-lg: 16px;
    --pdtr-shadow:  0 1px 2px rgba(24, 24, 24, 0.06), 0 8px 24px rgba(24, 24, 24, 0.06);

    --pdtr-font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ------------------------------------------------------------ container --- */

.pdtr-form-container,
.pdtr-gate,
.pdtr-message-box {
    box-sizing: border-box;
    font-family: var(--pdtr-font);
    color: var(--pdtr-ink);
    -webkit-font-smoothing: antialiased;
}

.pdtr-form-container *,
.pdtr-form-container *::before,
.pdtr-form-container *::after,
.pdtr-gate *,
.pdtr-message-box * {
    box-sizing: inherit;
}

.pdtr-questionnaire-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px 64px;
}

.pdtr-form {
    background: var(--pdtr-surface);
    border: 1px solid var(--pdtr-line);
    border-radius: var(--pdtr-radius-lg);
    box-shadow: var(--pdtr-shadow);
    padding: 32px 28px 28px;
}

/* ----------------------------------------------------------- typography --- */

.pdtr-form h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 8px;
    color: var(--pdtr-ink);
}

.pdtr-form .form-description {
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--pdtr-muted);
    margin: 0 0 28px;
}

.pdtr-form-section h3 {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pdtr-forest);
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pdtr-line);
}

/* ------------------------------------------------------------- progress --- */

/* The signature of this form, and the one place worth being deliberate.
   Someone on question 20 of 35 is asking "how much more of this is there".
   On a phone the answer scrolls out of sight immediately, so the rail sticks
   to the top of the viewport and keeps answering. */

.pdtr-progress-container {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--pdtr-surface);
    padding: 14px 0 12px;
    margin: 0 0 24px;
    border-bottom: 1px solid var(--pdtr-line);
}

.pdtr-progress-bar {
    height: 6px;
    background: var(--pdtr-canvas);
    border: 1px solid var(--pdtr-line);
    border-radius: 999px;
    overflow: hidden;
}

.pdtr-progress-indicator {
    height: 100%;
    background: var(--pdtr-green);
    border-radius: 999px;
    transition: width 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pdtr-progress-text {
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--pdtr-muted);
}

/* ---------------------------------------------------------------- forms --- */

.pdtr-form-section {
    display: none;
}

.pdtr-form-section.active {
    display: block;
    animation: pdtr-section-in 260ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pdtr-section-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.pdtr-form-group {
    margin-bottom: 22px;
}

.pdtr-form-group > label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 8px;
    color: var(--pdtr-ink);
}

.pdtr-form-container input[type="text"],
.pdtr-form-container input[type="email"],
.pdtr-form-container input[type="tel"],
.pdtr-form-container input[type="number"],
.pdtr-form-container textarea,
.pdtr-form-container select,
.pdtr-gate input[type="email"] {
    width: 100%;
    font-family: var(--pdtr-font);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--pdtr-ink);
    background: var(--pdtr-surface);
    border: 1px solid var(--pdtr-line-strong);
    border-radius: var(--pdtr-radius);
    padding: 12px 14px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
    -webkit-appearance: none;
    appearance: none;
}

.pdtr-form-container textarea {
    min-height: 96px;
    resize: vertical;
}

.pdtr-form-container select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23181818' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 11px;
    padding-right: 40px;
}

.pdtr-form-container input:focus,
.pdtr-form-container textarea:focus,
.pdtr-form-container select:focus,
.pdtr-gate input:focus {
    outline: none;
    border-color: var(--pdtr-green);
    box-shadow: 0 0 0 3px rgba(25, 174, 112, 0.22);
}

.pdtr-form-container ::placeholder {
    color: rgba(24, 24, 24, 0.38);
}

/* Required marker. The asterisk is already in the label text. */
.pdtr-form-group.required > label::after {
    content: '';
}

/* Validation marks fields with .pdtr-field-error -- both the section
   navigation in questionnaire-form.php and the submit handler in
   pdtr-questionnaire.js use that class, not .error. */
.pdtr-form-container input.pdtr-field-error,
.pdtr-form-container textarea.pdtr-field-error,
.pdtr-form-container select.pdtr-field-error {
    border-color: var(--pdtr-danger);
    box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.14);
}

.pdtr-form-container .pdtr-checkbox-item input.pdtr-field-error + label {
    border-color: var(--pdtr-danger);
}

/* ------------------------------------------------------------ checkbox --- */

/* Fifteen symptom checkboxes. Rendered as tappable tiles rather than bare
   controls: on a phone a 16px checkbox next to text is a hard target, and this
   is the one question where people tick several things quickly. */

.pdtr-checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.pdtr-checkbox-item {
    position: relative;
}

.pdtr-checkbox-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pdtr-checkbox-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 14px;
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--pdtr-ink);
    background: var(--pdtr-surface);
    border: 1px solid var(--pdtr-line-strong);
    border-radius: var(--pdtr-radius);
    cursor: pointer;
    transition: border-color 140ms ease, background-color 140ms ease;
}

.pdtr-checkbox-item label::before {
    content: '';
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border: 1px solid var(--pdtr-line-strong);
    border-radius: 5px;
    background: var(--pdtr-surface) no-repeat center center;
    background-size: 12px;
    transition: background-color 140ms ease, border-color 140ms ease;
}

.pdtr-checkbox-item label:hover {
    border-color: var(--pdtr-green);
}

.pdtr-checkbox-item input:checked + label {
    background: rgba(169, 217, 190, 0.28);
    border-color: var(--pdtr-green);
}

.pdtr-checkbox-item input:checked + label::before {
    background-color: var(--pdtr-green);
    border-color: var(--pdtr-green);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23181818' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E");
}

.pdtr-checkbox-item input:focus-visible + label {
    border-color: var(--pdtr-green);
    box-shadow: 0 0 0 3px rgba(25, 174, 112, 0.22);
}

/* -------------------------------------------------------------- sliders --- */

/* Six 1-10 scales. Browser defaults are the ugliest thing on the old form and
   the hardest to read at a glance, so the track carries the brand green and the
   thumb is deliberately large enough to drag with a thumb. */

.pdtr-range-slider {
    padding: 4px 0 0;
}

.pdtr-range-slider input[type="range"] {
    width: 100%;
    height: 28px;
    margin: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.pdtr-range-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: var(--pdtr-canvas);
    border: 1px solid var(--pdtr-line);
}

.pdtr-range-slider input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: var(--pdtr-canvas);
    border: 1px solid var(--pdtr-line);
}

.pdtr-range-slider input[type="range"]::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--pdtr-green);
}

.pdtr-range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 26px;
    height: 26px;
    margin-top: -11px;
    border-radius: 50%;
    background: var(--pdtr-green);
    border: 3px solid var(--pdtr-surface);
    box-shadow: 0 1px 4px rgba(24, 24, 24, 0.28);
    transition: transform 120ms ease;
}

.pdtr-range-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--pdtr-green);
    border: 3px solid var(--pdtr-surface);
    box-shadow: 0 1px 4px rgba(24, 24, 24, 0.28);
}

.pdtr-range-slider input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.08);
}

.pdtr-range-slider input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(25, 174, 112, 0.28);
}

.pdtr-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pdtr-muted);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- buttons --- */

.pdtr-button,
.pdtr-gate-submit,
.pdtr-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 13px 24px;
    font-family: var(--pdtr-font);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1;
    /* Ink on green, not white on green: white would be 2.9:1 and unreadable. */
    color: var(--pdtr-ink);
    background: var(--pdtr-green);
    border: 1px solid transparent;
    border-radius: var(--pdtr-radius);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms ease, color 140ms ease, transform 80ms ease;
}

.pdtr-button:hover,
.pdtr-gate-submit:hover,
.pdtr-submit-button:hover {
    background: var(--pdtr-forest);
    color: var(--pdtr-surface);
}

.pdtr-button:active,
.pdtr-gate-submit:active,
.pdtr-submit-button:active {
    transform: translateY(1px);
}

.pdtr-button:focus-visible,
.pdtr-gate-submit:focus-visible,
.pdtr-submit-button:focus-visible {
    outline: 2px solid var(--pdtr-forest);
    outline-offset: 2px;
}

.pdtr-button:disabled,
.pdtr-gate-submit:disabled,
.pdtr-submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdtr-button-secondary,
.pdtr-prev-button {
    color: var(--pdtr-forest);
    background: transparent;
    border-color: var(--pdtr-line-strong);
}

.pdtr-button-secondary:hover,
.pdtr-prev-button:hover {
    background: var(--pdtr-canvas);
    color: var(--pdtr-forest);
    border-color: var(--pdtr-forest);
}

.pdtr-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--pdtr-line);
}

.pdtr-form-actions .pdtr-next-button,
.pdtr-form-actions .pdtr-submit-button {
    margin-left: auto;
}

/* --------------------------------------------------------- save / status --- */

.pdtr-save-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

#pdtr-save-status {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--pdtr-muted);
}

#pdtr-save-status.success {
    color: var(--pdtr-forest);
}

#pdtr-save-status.error {
    color: var(--pdtr-danger);
}

/* --------------------------------------------------------- message boxes --- */

.pdtr-message-box {
    max-width: 720px;
    margin: 0 auto;
    padding: 28px;
    background: var(--pdtr-surface);
    border: 1px solid var(--pdtr-line);
    border-left: 4px solid var(--pdtr-green);
    border-radius: var(--pdtr-radius-lg);
    box-shadow: var(--pdtr-shadow);
}

.pdtr-message-box h3 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 10px;
    color: var(--pdtr-ink);
}

.pdtr-message-box p {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--pdtr-muted);
    margin: 0 0 12px;
}

.pdtr-message-box p:last-child {
    margin-bottom: 0;
}

/* A notice sitting directly above the e-mail form, rather than alone on the
   page. It introduces the form, so it loses the card chrome and the gap. */
.pdtr-message-box.pdtr-notice-inline {
    max-width: 440px;
    margin: 0 auto -1px;
    padding: 22px 28px 20px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: 0;
    box-shadow: none;
}

.pdtr-notice-inline + .pdtr-gate {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-left: 4px solid var(--pdtr-green);
}

.pdtr-message-box a:not(.pdtr-button) {
    color: var(--pdtr-forest);
    font-weight: 600;
    text-underline-offset: 3px;
}

.pdtr-success-message,
.pdtr-error-message,
.pdtr-info-message {
    padding: 12px 16px;
    border-radius: var(--pdtr-radius);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 16px;
}

.pdtr-success-message {
    background: rgba(169, 217, 190, 0.32);
    color: var(--pdtr-forest);
}

.pdtr-error-message {
    background: rgba(179, 38, 30, 0.08);
    color: var(--pdtr-danger);
}

.pdtr-info-message {
    background: var(--pdtr-canvas);
    color: var(--pdtr-muted);
}

/* ------------------------------------------------------ gate / request --- */

.pdtr-gate {
    max-width: 440px;
    margin: 0 auto;
    padding: 28px;
    background: var(--pdtr-surface);
    border: 1px solid var(--pdtr-line);
    border-radius: var(--pdtr-radius-lg);
    box-shadow: var(--pdtr-shadow);
}

.pdtr-gate label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.pdtr-gate .pdtr-gate-submit {
    width: 100%;
    margin-top: 16px;
}

.pdtr-gate-message {
    margin: 16px 0 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--pdtr-muted);
}

.pdtr-gate-action {
    margin: 12px 0 0;
}

.pdtr-gate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 13px 24px;
    font-weight: 600;
    color: var(--pdtr-ink);
    background: var(--pdtr-green);
    border-radius: var(--pdtr-radius);
    text-decoration: none;
}

.pdtr-gate-button:hover {
    background: var(--pdtr-forest);
    color: var(--pdtr-surface);
}

/* The site theme styles bare `form` and `a` elements, and wins against a
   single class on source order. Measured on the live site, that left the
   gate shrink-wrapped to 313px beside a 440px notice -- so the joined card
   above reads as two offset ones -- and painted both action links theme
   blue (#3b82f6) on the dark green button, which is unreadable.
   Every selector below carries an element or an extra class purely to
   out-specify the theme. Dropping those qualifiers silently hands the
   rules back to it, and nothing errors. */

form.pdtr-gate {
    display: block;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.pdtr-gate .pdtr-gate-action {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    margin: 16px 0 0;
}

.pdtr-gate .pdtr-gate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 13px 24px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    /* White on forest is ~10:1. The ink-on-green pairing used by the submit
       button does not survive here: the theme repaints the background. */
    color: var(--pdtr-surface);
    background: var(--pdtr-forest);
    border-radius: var(--pdtr-radius);
}

.pdtr-gate .pdtr-gate-button:hover,
.pdtr-gate .pdtr-gate-button:focus {
    color: var(--pdtr-ink);
    background: var(--pdtr-green);
}

/* Never had a rule of its own, so it rendered as a default theme link. */
.pdtr-gate .pdtr-gate-secondary {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--pdtr-forest);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.pdtr-gate .pdtr-gate-secondary:hover {
    color: var(--pdtr-ink);
}

/* ---------------------------------------------------------------- embed --- */

.pdtr-therapy-embed {
    max-width: 900px;
    margin: 0 auto;
}

.pdtr-therapy-embed iframe {
    width: 100%;
    border: 0;
    border-radius: var(--pdtr-radius-lg);
}

/* --------------------------------------------------------------- mobile --- */

@media (max-width: 600px) {
    .pdtr-questionnaire-container {
        padding: 0 12px 48px;
    }

    .pdtr-form {
        padding: 22px 18px 20px;
        border-radius: var(--pdtr-radius);
    }

    .pdtr-form h2 {
        font-size: 1.375rem;
    }

    .pdtr-checkbox-group {
        grid-template-columns: 1fr;
    }

    .pdtr-form-actions {
        flex-direction: column-reverse;
    }

    .pdtr-form-actions .pdtr-button,
    .pdtr-form-actions .pdtr-submit-button {
        width: 100%;
        margin-left: 0;
    }

    .pdtr-gate,
    .pdtr-message-box {
        padding: 20px;
        border-radius: var(--pdtr-radius);
    }
}

/* ------------------------------------------------------------- a11y --- */

@media (prefers-reduced-motion: reduce) {
    .pdtr-form-section.active {
        animation: none;
    }

    .pdtr-progress-indicator,
    .pdtr-button,
    .pdtr-checkbox-item label,
    .pdtr-range-slider input[type="range"]::-webkit-slider-thumb {
        transition: none;
    }
}

@media (prefers-contrast: more) {
    .pdtr-form-container,
    .pdtr-gate,
    .pdtr-message-box {
        --pdtr-line: rgba(24, 24, 24, 0.4);
        --pdtr-line-strong: rgba(24, 24, 24, 0.7);
        --pdtr-muted: rgba(24, 24, 24, 0.85);
    }
}

@media print {
    .pdtr-progress-container,
    .pdtr-form-actions,
    .pdtr-save-progress-container {
        display: none;
    }

    .pdtr-form-section {
        display: block !important;
        page-break-inside: avoid;
    }

    .pdtr-form {
        border: 0;
        box-shadow: none;
    }
}
