/* css/onboarding.css — Mobile-first responsive */

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

body {
    margin: 0;
    background: #F7F9F8;
    font-family: 'Inter', sans-serif;
    color: #111827;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Shell ---- */
.ob-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 clamp(16px, 5vw, 32px) max(40px, env(safe-area-inset-bottom));
    position: relative;
}

/* ---- Progress bar (fixed top) ---- */
.ob-progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: #E5E7EB;
    z-index: 100;
}

.ob-progress-fill {
    height: 100%;
    background: #0E7C66;
    border-radius: 0 3px 3px 0;
    transition: width 450ms cubic-bezier(0.16,1,0.3,1);
    width: 5%;
}

/* ---- Top header row (back btn + logo) ---- */
.ob-top-bar {
    width: 100%;
    max-width: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* 3px progress bar + safe area + breathing room */
    padding-top: calc(3px + max(20px, env(safe-area-inset-top)));
    margin-bottom: clamp(20px, 5vw, 36px);
    flex-shrink: 0;
    min-height: 60px;
}

/* ---- Brand logo ---- */
.ob-brand {
    /* kept for compatibility — inside ob-top-bar now */
    flex-shrink: 0;
}

.ob-logo {
    height: 26px;
    object-fit: contain;
    display: block;
}

/* ---- Steps container ---- */
.ob-steps {
    width: 100%;
    max-width: 560px;
    flex: 1;
}

.ob-step { width: 100%; }

.ob-step--enter {
    animation: obSlideIn 0.32s cubic-bezier(0.16,1,0.3,1) forwards;
}

@keyframes obSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Step inner ---- */
.ob-step-inner {
    display: flex;
    flex-direction: column;
    gap: clamp(18px, 4vw, 26px);
}

/* ---- Question tag ---- */
.ob-question-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #4B5563;
    background: #F3F4F6;
    padding: 5px 11px;
    border-radius: 4px;
    width: fit-content;
}

/* ---- Question title ---- */
.ob-question {
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    font-weight: 800;
    color: #111827;
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.ob-question-sub {
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    color: #6B7280;
    margin: -8px 0 0;
    line-height: 1.5;
}

/* ---- Pills ---- */
.ob-pills {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 2-col layout on tablets+ */
@media (min-width: 600px) {
    .ob-pills {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

.ob-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    /* min 52px touch target */
    padding: clamp(13px, 3vw, 16px) clamp(14px, 3.5vw, 20px);
    background: #FFFFFF;
    border: 1.5px solid #D1D5DB;
    border-radius: 10px;
    font-size: clamp(0.88rem, 2.5vw, 0.95rem);
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    text-align: left;
    transition: border-color 130ms, background 130ms, box-shadow 130ms, transform 100ms;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.ob-pill:hover {
    border-color: #0E7C66;
    color: #0E7C66;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14,124,102,0.08);
}

.ob-pill:active { transform: scale(0.98); }

.ob-pill--selected {
    border-color: #0E7C66;
    background: #F0FDF4;
    color: #065F46;
    font-weight: 600;
}

.ob-pill-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(36px, 10vw, 44px);
    height: clamp(36px, 10vw, 44px);
    background: #F3F4F6;
    border-radius: 8px;
    color: #6B7280;
    transition: background 0.18s, color 0.18s;
    flex-shrink: 0;
}

.ob-pill-icon svg { width: 18px; height: 18px; }

.ob-pill:hover .ob-pill-icon    { background: #E8F4F2; color: #0E7C66; }
.ob-pill--selected .ob-pill-icon { background: #0E7C66; color: #FFFFFF; }

/* Checkmark on selected */
.ob-pill--selected::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: #0E7C66 url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") no-repeat center / 10px;
    border-radius: 50%;
}

/* ---- Insight/fact box ---- */
.ob-fact {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-left: 3px solid #3B82F6;
    border-radius: 8px;
}

.ob-fact--appear {
    animation: obFactIn 0.35s cubic-bezier(0.16,1,0.3,1) forwards;
}

@keyframes obFactIn {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ob-fact-icon { color: #3B82F6; flex-shrink: 0; margin-top: 2px; }

.ob-fact-text {
    font-size: 0.83rem;
    color: #334155;
    line-height: 1.55;
    font-weight: 500;
}

/* ---- Continue button ---- */
.ob-continue-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    /* 52px touch target */
    padding: 15px 24px;
    background: #0E7C66;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: background 130ms, transform 100ms;
    -webkit-tap-highlight-color: transparent;
}

.ob-continue-btn:hover  { background: #0a6355; }
.ob-continue-btn:active { transform: scale(0.99); }

/* ---- Theme grid ---- */
.ob-themes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(10px, 3vw, 16px);
    margin-top: 16px;
}

.ob-theme-card {
    background: #FFFFFF;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    padding: clamp(12px, 3vw, 16px);
    cursor: pointer;
    transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.ob-theme-card:hover {
    transform: translateY(-2px);
    border-color: #D1D5DB;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.ob-theme--selected {
    border-color: #0E7C66;
    background: #F0FDF4;
    box-shadow: 0 4px 14px rgba(14,124,102,0.12);
}

.ob-theme-preview {
    width: 100%;
    height: clamp(36px, 8vw, 48px);
    border-radius: 7px;
    margin-bottom: 10px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.ob-theme-name {
    font-size: clamp(0.78rem, 2vw, 0.88rem);
    font-weight: 600;
    color: #374151;
}

/* ---- Address step ---- */
.ob-address-wrap { position: relative; }

.ob-address-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid #D1D5DB;
    border-radius: 10px;
    padding: 13px 16px;
    background: #FFFFFF;
    transition: border-color 130ms, box-shadow 130ms;
}

.ob-address-input-wrap:focus-within {
    border-color: #0E7C66;
    box-shadow: 0 0 0 3px rgba(14,124,102,0.09);
}

.ob-address-icon { stroke: #9CA3AF; flex-shrink: 0; }

.ob-address-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem; /* 16px — no iOS zoom */
    color: #111827;
    font-family: inherit;
    background: transparent;
    min-width: 0;
}
.ob-address-input::placeholder { color: #9CA3AF; }

.ob-spinner {
    width: 16px; height: 16px;
    border: 2px solid #E5E7EB;
    border-top-color: #0E7C66;
    border-radius: 50%;
    animation: obSpin 0.65s linear infinite;
    flex-shrink: 0;
}

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

.ob-address-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.07);
    overflow: hidden;
    z-index: 50;
    /* Prevent overflow off-screen on mobile */
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: obDropIn 0.18s ease;
}

@keyframes obDropIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ob-address-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    font-size: 0.88rem;
    color: #374151;
    cursor: pointer;
    border-bottom: 1px solid #F9FAFB;
    transition: background 100ms;
    min-height: 48px;
}

.ob-address-item:last-child { border-bottom: none; }
.ob-address-item:hover      { background: #F3F4F6; }
.ob-address-item svg        { stroke: #6B7280; flex-shrink: 0; }

/* Voce "usa esattamente" — distinta visivamente dai suggerimenti normali */
.ob-address-item--manual        { color: #374151; }
.ob-address-item--manual:hover  { background: #EFF6F4; }
.ob-address-item--manual svg    { stroke: #0E7C66; }
.ob-address-item--manual strong { color: #0E7C66; font-weight: 600; }

.ob-address-empty {
    padding: 16px;
    font-size: 0.85rem;
    color: #9CA3AF;
    text-align: center;
}

.ob-address-confirmed {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #166534;
    min-height: 48px;
}
.ob-address-confirmed svg    { stroke: #166534; flex-shrink: 0; }
.ob-address-confirmed span   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-address-confirmed button {
    background: none; border: none;
    color: #059669; font-size: 0.78rem; font-weight: 600;
    cursor: pointer; text-decoration: underline;
    white-space: nowrap; flex-shrink: 0;
}

/* ---- Final step form ---- */
.ob-step-inner--final { gap: clamp(20px, 4vw, 28px); }

.ob-final-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #E5E7EB;
}

.ob-final-check {
    width: 44px; height: 44px;
    background: #0E7C66;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ob-final-check svg { stroke: #FFFFFF; }

.ob-final-title {
    font-size: clamp(1.15rem, 4vw, 1.4rem);
    font-weight: 800;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.ob-final-sub { font-size: 0.83rem; color: #6B7280; margin: 0; }

.ob-final-form {
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 20px);
}

.ob-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ob-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #374151;
}

.ob-input {
    padding: 13px 15px;
    border: 1.5px solid #D1D5DB;
    border-radius: 9px;
    font-size: 1rem; /* 16px — no iOS zoom */
    color: #111827;
    background: #FFFFFF;
    font-family: inherit;
    transition: border-color 130ms, box-shadow 130ms;
    width: 100%;
    -webkit-appearance: none;
}

.ob-input:focus {
    outline: none;
    border-color: #0E7C66;
    box-shadow: 0 0 0 3px rgba(14,124,102,0.09);
}

.ob-input--error   { border-color: #EF4444 !important; }
.ob-input--success { border-color: #0E7C66; }

.ob-field-feedback { font-size: 0.76rem; font-weight: 500; min-height: 14px; }
.ob-feedback--ok  { color: #059669; }
.ob-feedback--err { color: #DC2626; }

/* Password */
.ob-password-wrap { position: relative; }

.ob-password-toggle {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    cursor: pointer; color: #6B7280;
    display: flex; align-items: center;
    padding: 6px;
    /* bigger tap target */
    min-width: 36px; min-height: 36px;
    justify-content: center;
}

.ob-password-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.ob-strength-bar {
    flex: 1;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    overflow: hidden;
}

.ob-strength-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 280ms ease, background 280ms ease;
    width: 0%;
}

.ob-strength-label {
    font-size: 0.73rem;
    font-weight: 600;
    color: #6B7280;
    min-width: 52px;
    text-align: right;
}

.ob-form-error {
    padding: 11px 14px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: 8px;
    font-size: 0.83rem;
    color: #B91C1C;
    font-weight: 500;
}

.ob-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px 24px;
    background: #0E7C66;
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    font-size: clamp(0.95rem, 2.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    transition: background 130ms, transform 100ms;
    margin-top: 4px;
    -webkit-tap-highlight-color: transparent;
}
.ob-submit-btn:hover    { background: #0a6355; }
.ob-submit-btn:active   { transform: scale(0.99); }
.ob-submit-btn:disabled { background: #D1D5DB; cursor: not-allowed; }

/* ---- Back button — absolute inside ob-top-bar, never overlaps logo ---- */
.ob-back-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 5px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    font-size: 0.82rem;
    font-weight: 500;
    color: #4B5563;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 110ms;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    z-index: 90;
    min-height: 38px;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
/* Compensate for safe-area offset in top-bar */
.ob-top-bar .ob-back-btn {
    top: calc(50% + max(0px, env(safe-area-inset-top)) / 2);
}
.ob-back-btn:hover { color: #111827; background: #F9FAFB; border-color: #D1D5DB; }

/* ---- Login link ---- */
.ob-login-link {
    font-size: 0.84rem;
    color: #6B7280;
    text-align: center;
    margin-top: 28px;
    margin-bottom: 8px;
}
.ob-login-link a { color: #0E7C66; font-weight: 600; text-decoration: underline; }

/* ---- Utils ---- */
.hidden { display: none !important; }

/* ---- Tablet: pills 2-col for most fields ---- */
@media (min-width: 560px) {
    .ob-pills[data-field="pain_strumento"],
    .ob-pills[data-field="pain_sfida"],
    .ob-pills[data-field="scontrino_medio"] {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

/* ---- Small phones (< 360px) ---- */
@media (max-width: 359px) {
    .ob-themes-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .ob-pill-icon   { width: 32px; height: 32px; }
    .ob-pill-icon svg { width: 16px; height: 16px; }
}
