/* =========================================================================
   Brief — formularz klienta
   Minimalistyczny, papierowy interfejs. Bez frameworków, bez zależności.
   ========================================================================= */

:root {
    --bg:            #faf9f7;
    --surface:       #ffffff;
    --ink:           #1b1b1a;
    --ink-soft:      #47453f;
    --muted:         #6e6b66;
    --line:          #e5e2dc;
    --line-strong:   #cfcbc2;
    --accent:        #2f6f4e;
    --accent-soft:   #eef4f0;
    --accent-ink:    #235739;
    --error:         #a32c1f;
    --error-soft:    #fcefed;
    --success:       #235739;
    --radius:        12px;
    --radius-lg:     18px;
    --shadow:        0 1px 2px rgba(27,27,26,.04), 0 8px 24px -12px rgba(27,27,26,.14);
    --serif:         Georgia, 'Iowan Old Style', 'Times New Roman', serif;
    --sans:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --step:          clamp(1.6rem, 1.1rem + 2vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

/* Atrybut hidden musi wygrywać z regułami display (flex/grid) poniżej. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: var(--step); margin: 0 0 .5em; }
h2 { font-size: clamp(1.3rem, 1rem + 1.2vw, 1.8rem); margin: 0 0 .4em; }
p  { margin: 0 0 1em; }
a  { color: var(--accent-ink); }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .88em;
    background: #f1efeb;
    padding: .15em .4em;
    border-radius: 5px;
    word-break: break-all;
}

/* --- Pomijanie do treści / a11y ---------------------------------------- */
.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--ink); color: #fff; padding: .75rem 1.25rem; z-index: 100;
}
.skip-link:focus { left: 0; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Układ ------------------------------------------------------------- */
.page-narrow { display: flex; justify-content: center; padding: 2rem 1rem 4rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 1rem + 3vw, 3rem);
    width: 100%;
    max-width: 520px;
}

.form-shell { max-width: 780px; margin: 0 auto; padding: 0 1.25rem 6rem; }

/* --- Nagłówek formularza ----------------------------------------------- */
.form-header {
    padding: clamp(2rem, 1rem + 4vw, 4rem) 0 1.5rem;
}
.form-header .eyebrow {
    font-size: .8rem; letter-spacing: .14em; text-transform: uppercase;
    color: var(--muted); margin: 0 0 1rem; font-family: var(--sans);
}

/* --- Progress ----------------------------------------------------------- */
.progress {
    position: sticky; top: 0; z-index: 20;
    background: rgba(250,249,247,.92);
    backdrop-filter: saturate(180%) blur(8px);
    padding: .9rem 0 .75rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2.5rem;
}
.progress-meta {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: .85rem; color: var(--muted); margin-bottom: .5rem;
    letter-spacing: .02em;
}
.progress-meta strong { color: var(--ink); font-weight: 600; }
.progress-track {
    height: 4px; background: var(--line); border-radius: 99px; overflow: hidden;
}
.progress-bar {
    height: 100%; width: 0; background: var(--accent);
    border-radius: 99px; transition: width .35s cubic-bezier(.4,0,.2,1);
}

/* --- Krok --------------------------------------------------------------- */
.step { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.step-in { animation: fade-up .28s cubic-bezier(.4,0,.2,1) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.step-legend { display: block; width: 100%; padding: 0; margin: 0 0 2rem; }
.step-number {
    display: block; font-size: .8rem; letter-spacing: .14em;
    text-transform: uppercase; color: var(--accent); margin-bottom: .5rem;
}
.step-title { font-family: var(--serif); font-size: var(--step); line-height: 1.15; }
.step-note {
    margin-top: 1rem; font-size: .95rem; color: var(--ink-soft);
    background: var(--accent-soft); border-left: 3px solid var(--accent);
    padding: .85rem 1rem; border-radius: 0 var(--radius) var(--radius) 0;
}

/* --- Pola --------------------------------------------------------------- */
.field { margin: 0 0 2.25rem; }
.field > label, .group-label {
    display: block; font-size: 1.06rem; font-weight: 600;
    color: var(--ink); margin-bottom: .6rem; line-height: 1.4;
}
.hint, .help {
    display: block; font-weight: 400; font-size: .92rem; color: var(--muted);
    margin-bottom: .7rem;
}
.field > label .req { color: var(--accent); margin-left: .15em; }

input[type=text], input[type=email], input[type=tel], input[type=url],
input[type=date], input[type=password], textarea, select {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: .95rem 1rem;
    min-height: 56px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.6; }

input::placeholder, textarea::placeholder { color: #a5a199; }

input:hover, textarea:hover { border-color: #b6b1a7; }

input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,111,78,.18);
}

/* --- Radio / checkbox jako karty --------------------------------------- */
.options { display: grid; gap: .6rem; border: 0; padding: 0; margin: 0; min-inline-size: 0; }

.option {
    display: flex; align-items: flex-start; gap: .85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
    min-height: 56px;
}
.option:hover { border-color: var(--accent); background: #fcfdfc; }
.option input { position: absolute; opacity: 0; width: 0; height: 0; }
.option .box {
    flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px;
    border: 2px solid var(--line-strong); background: var(--surface);
    display: grid; place-items: center;
    transition: border-color .15s, background .15s;
}
.option .box::after {
    content: ''; opacity: 0; transition: opacity .12s, transform .12s;
    transform: scale(.7);
}
.option--radio .box { border-radius: 50%; }
.option--radio .box::after { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.option--check .box { border-radius: 6px; }
.option--check .box::after {
    width: 11px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
    transform: rotate(-45deg) scale(.7); margin-top: -3px;
}
.option input:checked ~ .box { background: var(--accent); border-color: var(--accent); }
.option input:checked ~ .box::after { opacity: 1; transform: scale(1); }
.option--check input:checked ~ .box::after { transform: rotate(-45deg) scale(1); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option:focus-within { box-shadow: 0 0 0 3px rgba(47,111,78,.2); border-color: var(--accent); }
.option .option-text { flex: 1; line-height: 1.45; }

/* Zgoda na ostatnim kroku */
.consent { padding: 1.25rem; background: var(--accent-soft); border-color: var(--accent); }
.consent .option-text { font-size: 1rem; }

/* --- Pola warunkowe ----------------------------------------------------- */
.conditional {
    border-left: 2px solid var(--line-strong);
    padding-left: 1.25rem;
    margin-left: .25rem;
}

/* --- Błędy -------------------------------------------------------------- */
.field.has-error input, .field.has-error textarea { border-color: var(--error); background: var(--error-soft); }
.field-error {
    display: flex; align-items: center; gap: .4rem;
    color: var(--error); font-size: .92rem; margin-top: .5rem; font-weight: 500;
}
.field-error::before { content: '!'; font-weight: 700; display: inline-grid; place-items: center;
    width: 18px; height: 18px; border-radius: 50%; background: var(--error); color: #fff; font-size: .75rem; }

.alert {
    padding: 1rem 1.15rem; border-radius: var(--radius);
    margin: 0 0 1.75rem; font-size: .95rem; border: 1px solid;
}
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.alert-error   { background: var(--error-soft); border-color: #eec9c3; color: var(--error); }
.alert-success { background: var(--accent-soft); border-color: #c7dcd0; color: var(--success); }
.alert-info    { background: #f3f1ec; border-color: var(--line); color: var(--ink-soft); }
.alert-restore { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }

/* --- Przyciski ---------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font: inherit; font-weight: 600; font-size: 1rem;
    padding: .9rem 1.75rem; min-height: 54px;
    border-radius: 99px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink);
    cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(47,111,78,.4); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.btn-small { min-height: 42px; padding: .5rem 1.1rem; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.nav {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line);
}
.nav .spacer { flex: 1; }

/* --- Autosave ----------------------------------------------------------- */
.autosave {
    position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 30;
    background: var(--ink); color: #fff; font-size: .82rem;
    padding: .55rem 1rem; border-radius: 99px;
    opacity: 0; transform: translateY(6px); pointer-events: none;
    transition: opacity .25s, transform .25s;
}
.autosave.is-visible { opacity: .92; transform: none; }

/* --- Ekran podziękowania ------------------------------------------------ */
.thanks { max-width: 560px; margin: 0 auto; padding: clamp(3rem, 10vh, 7rem) 1.25rem; text-align: center; }
.thanks .mark {
    width: 64px; height: 64px; margin: 0 auto 2rem; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
    font-size: 1.8rem;
}
.thanks p { color: var(--ink-soft); }

/* --- Instalator / logowanie -------------------------------------------- */
.checklist { list-style: none; padding: 0; margin: 0 0 1.75rem; }
.checklist li { padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.checklist li span { display: inline-block; width: 1.4em; font-weight: 700; }
.checklist .ok span   { color: var(--accent); }
.checklist .fail span { color: var(--error); }

/* --- Responsywność ------------------------------------------------------ */
@media (max-width: 640px) {
    body { font-size: 16px; }
    .form-shell { padding: 0 1rem 7rem; }
    .field { margin-bottom: 1.85rem; }
    .nav {
        position: fixed; left: 0; right: 0; bottom: 0; margin: 0;
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--line);
        padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
        z-index: 25;
    }
    .nav .btn { flex: 1; padding: .9rem 1rem; }
    .btn { min-height: 52px; }
    .autosave { bottom: auto; top: 4.6rem; right: 1rem; }
    .conditional { padding-left: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

@media print {
    .progress, .nav, .autosave { display: none !important; }
    .step[hidden] { display: block !important; }
}
