/* ===== FORM INTAKE — 初診問卷 ===== */

body {
    font-family: 'Noto Sans TC', 'Inter', sans-serif;
    background: var(--bg-1); color: var(--text-b);
    line-height: 1.8; font-weight: 400; font-size: 16px;
    transition: background var(--transition-theme), color var(--transition-theme);
    overflow: hidden; height: 100vh; height: 100dvh;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}
input, textarea, select { font-family: inherit; }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200; height: 3px;
    background: var(--line);
}
.progress-bar-fill {
    height: 100%; width: 0%; background: var(--c1);
    transition: width 0.6s var(--ease-out-expo);
}

/* ===== BACK BUTTON ===== */
.back-btn {
    position: fixed; top: 24px; left: 28px; z-index: 150;
    display: flex; align-items: center; gap: 8px;
    font-size: 0.82rem; color: var(--text-m); letter-spacing: 0.5px;
    transition: color 0.3s, opacity 0.4s var(--ease-out-expo), transform 0.4s var(--ease-out-expo);
    opacity: 0; pointer-events: none; transform: translateX(-8px);
    min-height: 44px; min-width: 44px; padding: 8px 12px;
}
.back-btn.visible { opacity: 1; pointer-events: auto; transform: translateX(0); }
.back-btn:hover { color: var(--text-h); }
.back-btn:active { opacity: 0.7; }
.back-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ===== STEP COUNTER ===== */
.step-counter {
    position: fixed; top: 26px; right: 28px; z-index: 150;
    font-size: 0.75rem; color: var(--text-m); letter-spacing: 1px;
    font-family: 'Inter', sans-serif; font-weight: 400;
    transition: color var(--transition-theme);
}

/* ===== FORM CONTAINER ===== */
.form-container {
    position: relative; width: 100%; height: 100vh; height: 100dvh;
    overflow: hidden;
}
.form-container::before {
    content: ''; position: fixed; top: 0; left: 0; right: 0;
    height: 68px; z-index: 140; pointer-events: none;
    background: linear-gradient(to bottom, var(--bg-1) 55%, transparent);
    transition: background var(--transition-theme);
}

/* ===== STEP ===== */
.step {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 80px 40px 120px;
    opacity: 0; pointer-events: none;
    transform: translateY(60px);
    transition: opacity 0.6s var(--ease-out-expo), transform 0.6s var(--ease-out-expo);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.step.active {
    opacity: 1; pointer-events: auto;
    transform: none;  /* none, not translateY(0) — avoids iOS containing-block bug */
    z-index: 5;
}
.step.exit-up {
    opacity: 0; transform: translateY(-60px);
}

.step-inner {
    width: 100%; max-width: 600px; margin: 0 auto;
}

/* ===== QUESTION NUMBER ===== */
.q-num {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: 'Inter', sans-serif; font-size: 0.75rem;
    color: var(--c1); letter-spacing: 2px; font-weight: 500;
    margin-bottom: 16px; text-transform: uppercase;
}
.q-num .arrow { font-size: 0.65rem; }

/* ===== QUESTION TITLE ===== */
.q-title {
    font-family: 'Noto Serif TC', 'Cormorant Garamond', serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 400;
    color: var(--text-h); line-height: 1.5; margin-bottom: 40px;
    letter-spacing: 0.5px;
    transition: color var(--transition-theme);
}

/* ===== TEXT INPUT ===== */
.input-group {
    position: relative; margin-bottom: 8px;
}
.input-group input {
    width: 100%; padding: 16px 0 12px; border: none; border-bottom: 1.5px solid var(--line-h);
    background: transparent; font-size: 1.15rem; color: var(--text-h);
    outline: none; transition: border-color 0.4s;
    font-weight: 300; letter-spacing: 0.3px;
}
.input-group input::placeholder { color: transparent; }
.input-group label {
    position: absolute; left: 0; top: 16px;
    font-size: 1.05rem; color: var(--text-m); font-weight: 300;
    pointer-events: none;
    transition: top 0.3s var(--ease-out-expo), font-size 0.3s var(--ease-out-expo), color 0.3s var(--ease-out-expo), letter-spacing 0.3s var(--ease-out-expo);
}
.input-group input:focus ~ label,
.input-group input:not(:placeholder-shown) ~ label {
    top: -8px; font-size: 0.75rem; color: var(--c1); letter-spacing: 0.5px;
}
.input-group .line {
    position: absolute; bottom: 0; left: 50%; width: 100%; height: 2px;
    background: var(--c1); transform: scaleX(0) translateX(-50%);
    transform-origin: center; transition: transform 0.5s var(--ease-out-expo);
}
.input-group input:focus ~ .line { transform: scaleX(1) translateX(-50%); }

/* ===== RADIO / CHECKBOX CARDS ===== */
.card-grid {
    display: grid; gap: 12px;
}
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.option-card {
    position: relative; display: flex; align-items: center; gap: 14px;
    padding: 20px 24px; border-radius: 8px;
    border: 1.5px solid var(--line-h); background: var(--bg-card);
    cursor: pointer; user-select: none;
    transition: border-color 0.35s var(--ease-out-expo), background 0.35s var(--ease-out-expo), transform 0.35s var(--ease-out-expo), box-shadow 0.35s var(--ease-out-expo);
    min-height: 44px;
}
.option-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(var(--c1-rgb), 0.08);
    border-color: rgba(var(--c1-rgb), 0.3);
}
.option-card.selected {
    border-color: var(--c1);
    background: rgba(var(--c1-rgb), 0.04);
    box-shadow: 0 4px 20px rgba(var(--c1-rgb), 0.1);
}
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card .card-icon {
    font-size: 1.4rem; flex-shrink: 0;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; background: rgba(var(--c1-rgb), 0.06);
}
.option-card .card-label {
    font-size: 0.95rem; color: var(--text-h); font-weight: 400;
    transition: color var(--transition-theme);
}
.option-card .check-indicator {
    position: absolute; top: 10px; right: 10px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 1.5px solid var(--line-h);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.35s var(--ease-out-expo), border-color 0.35s var(--ease-out-expo);
}
.option-card.selected .check-indicator {
    background: var(--c1); border-color: var(--c1);
}
.option-card .check-indicator svg {
    width: 12px; height: 12px; stroke: #fff; stroke-width: 2.5;
    fill: none; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 16; stroke-dashoffset: 16;
    transition: stroke-dashoffset 0.35s var(--ease-out-expo);
}
.option-card.selected .check-indicator svg {
    stroke-dashoffset: 0;
}
.option-card .check-indicator.checkbox { border-radius: 5px; }
.option-card.compact { padding: 14px 20px; }
.option-card.compact .card-label { font-size: 0.9rem; }

/* ===== CUSTOM SELECT ===== */
.custom-select-wrap {
    position: relative; display: inline-block;
}
.custom-select-btn {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px; border-radius: 8px;
    border: 1.5px solid var(--line-h); background: var(--bg-card);
    font-size: 0.95rem; color: var(--text-h); min-width: 140px;
    min-height: 44px;
    transition: border-color 0.3s var(--ease-out-expo), background 0.3s var(--ease-out-expo);
    cursor: pointer;
}
.custom-select-btn:hover, .custom-select-btn.open {
    border-color: var(--c1);
}
.custom-select-btn .chevron {
    width: 16px; height: 16px; stroke: var(--text-m); fill: none; stroke-width: 1.5;
    transition: transform 0.3s var(--ease-out-expo);
}
.custom-select-btn.open .chevron { transform: rotate(180deg); }
.custom-select-list {
    position: fixed;
    background: var(--bg-card); border: 1.5px solid var(--line-h);
    border-radius: 8px; z-index: 200;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
    overflow-x: hidden; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
.custom-select-list.open {
    opacity: 1; pointer-events: auto;
}
.custom-select-list .option {
    padding: 12px 20px; font-size: 0.9rem; color: var(--text-b);
    cursor: pointer; transition: background 0.2s, color 0.2s;
    min-height: 44px; display: flex; align-items: center;
}
.custom-select-list .option:hover {
    background: rgba(var(--c1-rgb), 0.06); color: var(--text-h);
}
.custom-select-list .option.selected {
    color: var(--c1); font-weight: 500;
}

/* scrollbar */
.custom-select-list::-webkit-scrollbar { width: 4px; }
.custom-select-list::-webkit-scrollbar-track { background: transparent; }
.custom-select-list::-webkit-scrollbar-thumb { background: var(--line-h); border-radius: 4px; }

/* ===== DATE PICKER ROW ===== */
.date-row {
    display: flex; gap: 12px; align-items: flex-start;
}
.date-row .custom-select-wrap { flex: 1; }
.date-row .custom-select-wrap:first-child { flex: 1.3; }
.date-label {
    font-size: 0.7rem; color: var(--text-m); letter-spacing: 1px;
    margin-bottom: 6px; display: block;
}

/* ===== TEXTAREA ===== */
.textarea-group { position: relative; }
.textarea-group textarea {
    width: 100%; min-height: 120px; padding: 20px;
    border: 1.5px solid var(--line-h); border-radius: 8px;
    background: var(--bg-card); font-size: 1rem; color: var(--text-h);
    outline: none; resize: vertical; line-height: 1.8;
    font-weight: 300; letter-spacing: 0.3px;
    transition: border-color 0.4s, box-shadow 0.4s;
}
.textarea-group textarea::placeholder { color: var(--text-m); font-weight: 300; }
.textarea-group textarea:focus {
    border-color: var(--c1);
    box-shadow: 0 0 0 3px rgba(var(--c1-rgb), 0.08);
}
.textarea-group .char-count {
    position: absolute; bottom: 12px; right: 16px;
    font-size: 0.72rem; color: var(--text-m); font-family: 'Inter', sans-serif;
}

/* Conditional textarea */
.conditional-area {
    overflow: hidden; opacity: 0; height: 0;
    transition: opacity 0.4s var(--ease-out-expo), height 0s 0.4s;
    margin-top: 0;
}
.conditional-area.show {
    opacity: 1; height: auto;
    transition: opacity 0.4s var(--ease-out-expo), height 0s;
    margin-top: 24px;
}

/* ===== TIME SLOT CARDS ===== */
.time-card { text-align: center; padding: 28px 20px; }
.time-card .time-icon {
    width: 48px; height: 48px; margin: 0 auto 12px;
    display: flex; align-items: center; justify-content: center;
}
.time-card .time-icon svg { width: 36px; height: 36px; stroke: var(--c1); fill: none; stroke-width: 1.2; }
.time-card .time-period { font-size: 1rem; font-weight: 500; color: var(--text-h); margin-bottom: 4px; }
.time-card .time-range { font-size: 0.78rem; color: var(--text-m); font-family: 'Inter', sans-serif; }

/* ===== NAVIGATION BOTTOM ===== */
.nav-bottom {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 20px 40px 28px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    opacity: 0; pointer-events: none; transform: translateY(20px);
    transition: opacity 0.5s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
}
.nav-bottom.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

.next-btn {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 15px 40px; border-radius: 100px;
    background: var(--text-h); color: var(--bg-1);
    font-size: 0.85rem; font-weight: 500; letter-spacing: 1px;
    min-height: 44px;
    transition: transform 0.3s var(--ease-out-expo), box-shadow 0.3s, background var(--transition-theme), color var(--transition-theme);
}
.next-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(var(--c1-rgb), 0.2);
}
.next-btn:active { transform: scale(0.97); }
.next-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.next-btn:disabled { opacity: 0.35; pointer-events: none; }

.enter-hint {
    font-size: 0.72rem; color: var(--text-m); letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
}
.enter-hint kbd {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    background: var(--bg-2); font-size: 0.68rem; font-family: inherit;
    margin: 0 2px;
}

/* ===== WELCOME SCREEN ===== */
.welcome-content { text-align: center; }
.welcome-logo {
    font-family: 'Cormorant Garamond', serif; font-size: 1.1rem;
    color: var(--text-m); letter-spacing: 3px; margin-bottom: 32px; font-weight: 400;
}
.welcome-title {
    font-family: 'Noto Serif TC', 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5.5vw, 3rem); font-weight: 400;
    color: var(--text-h); line-height: 1.4; margin-bottom: 16px; letter-spacing: 2px;
    transition: color var(--transition-theme);
}
.welcome-sub {
    font-size: 0.95rem; color: var(--text-m); font-weight: 300;
    line-height: 1.9; margin-bottom: 48px; letter-spacing: 0.3px;
}
.welcome-sub em { font-style: normal; color: var(--text-b); }
.start-btn {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 18px 52px; border-radius: 100px;
    border: 1.5px solid var(--text-h); color: var(--text-h);
    font-size: 0.88rem; font-weight: 500; letter-spacing: 2px;
    min-height: 44px;
    background: linear-gradient(to right, var(--text-h) 50%, transparent 50%);
    background-size: 200% 100%;
    background-position: right;
    transition: color 0.5s var(--ease-out-expo), background-position 0.5s var(--ease-out-expo), border-color var(--transition-theme);
}
.start-btn:hover { color: var(--bg-1); background-position: left; }
.start-btn svg {
    width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5;
    transition: transform 0.3s var(--ease-out-expo);
}
.start-btn:hover svg { transform: translateX(4px); }
.welcome-decor { width: 48px; height: 1px; background: var(--line-h); margin: 0 auto 32px; }

/* ===== COMPLETION SCREEN ===== */
.complete-content { text-align: center; }
.check-circle {
    width: 80px; height: 80px; border-radius: 50%;
    border: 2px solid var(--c1); margin: 0 auto 32px;
    display: flex; align-items: center; justify-content: center;
    animation: scaleIn 0.6s var(--ease-out-expo) both;
}
@keyframes scaleIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.check-circle svg {
    width: 32px; height: 32px; stroke: var(--c1); fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    stroke-dasharray: 50; stroke-dashoffset: 50;
    animation: drawCheck 0.6s 0.3s var(--ease-out-expo) both;
}
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
.complete-title {
    font-family: 'Noto Serif TC', serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 400;
    color: var(--text-h); margin-bottom: 16px; letter-spacing: 1px;
}
.complete-sub {
    font-size: 0.95rem; color: var(--text-m); font-weight: 300;
    line-height: 1.9; max-width: 400px; margin: 0 auto;
}

/* ===== VALIDATION ===== */
.input-error { color: #D4564E; font-size: 0.78rem; margin-top: 8px; opacity: 0; transition: opacity 0.3s; }
.input-error.show { opacity: 1; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .step { padding: 70px 24px 140px; }
    .card-grid.cols-3 { grid-template-columns: 1fr; }
    .card-grid.cols-2 { grid-template-columns: 1fr; }
    .date-row { gap: 8px; }
    .date-row .custom-select-btn { min-width: unset; padding: 12px 14px; font-size: 0.88rem; }
    .nav-bottom { padding: 16px 24px 24px; }
    .next-btn { width: 100%; justify-content: center; padding: 16px; }
    .back-btn { top: 16px; left: 16px; }
    .step-counter { top: 18px; right: 16px; }
    .option-card { padding: 16px 18px; }
    .time-card { padding: 20px 16px; }
    .welcome-title { letter-spacing: 1px; }
    .enter-hint { display: none; }
}
