/* ฟอร์มประกอบกระทง 3 ขั้นตอน (templates/_builder-form.php) · ใช้ทั้งหน้าลอยกระทงและหน้าแรก · ทุกอย่างอยู่ใต้ .lkb */

.lkb {
    --lkb-green: #00ae4d;
    --lkb-text: #1f2937;
    --lkb-muted: #6b7280;
    --lkb-line: #e5e7eb;
    --lkb-opt-bg: #f9fafb;
    --lkb-sel-bg: rgba(0, 174, 77, 0.1);
    --lkb-night: linear-gradient(180deg, #0f1e36 0%, #1a3354 62%, #1f4a6e 100%);
    color: var(--lkb-text);
    font-family: inherit;
    text-align: left;
}

html[data-site-theme="dark"] #lkHome .lkb {
    --lkb-text: #f3f4f6;
    --lkb-muted: #9ca3af;
    --lkb-line: #374151;
    --lkb-opt-bg: #1f2937;
    --lkb-sel-bg: rgba(0, 174, 77, 0.18);
}

.lkb [hidden] { display: none !important; }

.lkb .lkb-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ───────── ขั้นตอน ───────── */
.lkb .lkb-steps {
    display: flex;
    gap: 6px;
    margin: 0 36px 12px 0;
    padding: 0;
    list-style: none;
}

.lkb .lkb-steps li {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 3px solid var(--lkb-line);
    color: var(--lkb-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.lkb .lkb-steps li span {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: 50%;
    background: var(--lkb-line);
    color: var(--lkb-muted);
    font-size: 12px;
}

.lkb .lkb-steps li.is-active,
.lkb .lkb-steps li.is-done {
    border-color: var(--lkb-green);
    color: var(--lkb-text);
}

.lkb .lkb-steps li.is-active span,
.lkb .lkb-steps li.is-done span {
    background: var(--lkb-green);
    color: #fff;
}

/* ───────── ภาพตัวอย่าง ───────── */
.lkb .lkb-preview {
    height: 150px;
    border-radius: 14px;
    background: var(--lkb-night);
    padding: 8px 0 4px;
    box-shadow: inset 0 -18px 24px -14px rgba(90, 170, 230, 0.45);
}

.lkb .lkb-preview .lka {
    filter: drop-shadow(0 0 14px rgba(255, 200, 90, 0.35));
}

.lkb .lkb-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 8px 0 2px;
}

.lkb .lkb-preview-name {
    font-size: 13px;
    color: var(--lkb-muted);
    line-height: 1.4;
}

/* ปุ่มสุ่มกระทง */
.lkb .lkb-random {
    flex: none;
    margin: 0;
    padding: 7px 14px;
    border: 1.5px solid #f5c04a;
    border-radius: 999px;
    background: #fff8e1;
    color: #8a5a00;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.lkb .lkb-random:hover { background: #ffefc2; transform: translateY(-1px); }
.lkb .lkb-random:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

html[data-site-theme="dark"] #lkHome .lkb .lkb-random {
    background: rgba(245, 190, 60, 0.14);
    border-color: rgba(245, 190, 60, 0.5);
    color: #fcd877;
}

.lkb .lkb-preview.is-rolling .lka {
    animation: lkb-roll 0.45s ease-out;
}

@keyframes lkb-roll {
    0%   { transform: scale(0.7) rotate(-8deg); opacity: 0.3; }
    60%  { transform: scale(1.08) rotate(3deg); opacity: 1; }
    100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .lkb .lkb-preview.is-rolling .lka { animation: none; }
}

/* ───────── ตัวเลือก ───────── */
.lkb .lkb-label {
    display: block;
    margin: 12px 0 6px;
    color: var(--lkb-text);
    font-size: 14px;
    font-weight: 700;
}

.lkb .lkb-grid {
    display: grid;
    gap: 8px;
}

.lkb .lkb-grid-4 { grid-template-columns: repeat(4, 1fr); }
.lkb .lkb-grid-3 { grid-template-columns: repeat(3, 1fr); }

.lkb .lkb-opt {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    padding: 5px 5px 6px;
    border: 2px solid var(--lkb-line);
    border-radius: 12px;
    background: var(--lkb-opt-bg);
    color: var(--lkb-text);
    font: inherit;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.lkb .lkb-opt:hover { transform: translateY(-2px); }

.lkb .lkb-opt[aria-checked="true"] {
    border-color: var(--lkb-green);
    background: var(--lkb-sel-bg);
    font-weight: 700;
}

.lkb .lkb-thumb {
    height: 64px;
    border-radius: 8px;
    background: var(--lkb-night);
    padding: 3px 0;
    pointer-events: none;
}

.lkb .lkb-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.lkb .lkb-swatch {
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--lkb-line), 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s;
}

.lkb .lkb-swatch[aria-checked="true"] {
    box-shadow: 0 0 0 3px var(--lkb-green), 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.lkb .lkb-opt:focus-visible,
.lkb .lkb-swatch:focus-visible,
.lkb .lkb-btn:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

/* ───────── ขั้นที่ 3 ───────── */
.lkb .lkb-input {
    display: block;
    width: 100%;
    margin: 0;
    padding: 11px 13px;
    border: 1.5px solid var(--lkb-line);
    border-radius: 10px;
    background: transparent;
    color: var(--lkb-text);
    font: inherit;
    font-size: 16px;
    resize: vertical;
}

.lkb textarea.lkb-input { min-height: 70px; }

.lkb .lkb-input:focus {
    outline: none;
    border-color: var(--lkb-green);
}

.lkb .lkb-count {
    margin-top: 4px;
    text-align: right;
    font-size: 12px;
    color: var(--lkb-muted);
}

.lkb .lkb-rule {
    margin: 8px 0 0;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff7e0;
    border: 1px solid #f5d27a;
    color: #7a5200;
    font-size: 13px;
    line-height: 1.5;
}

html[data-site-theme="dark"] #lkHome .lkb .lkb-rule {
    background: rgba(245, 190, 60, 0.12);
    border-color: rgba(245, 190, 60, 0.4);
    color: #fcd877;
}

.lkb .lkb-terms {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--lkb-opt-bg);
    border: 1px solid var(--lkb-line);
    color: var(--lkb-muted);
    font-size: 12.5px;
    line-height: 1.6;
}

.lkb .lkb-terms a {
    color: var(--lkb-green);
    font-weight: 700;
    text-decoration: underline;
    white-space: nowrap;
}

.lkb .message {
    display: none;
    margin: 4px 0 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
}

.lkb .message.error {
    background: #fde8e8;
    border: 1px solid #f8b4b4;
    color: #9b1c1c;
}

/* ───────── ปุ่ม ───────── */
.lkb .lkb-nav {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.lkb .lkb-btn {
    flex: 1;
    margin: 0;
    padding: 12px;
    border-radius: 10px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.lkb .lkb-btn-main {
    flex: 2;
    border: 0;
    background: linear-gradient(135deg, #00ae4d, #00d65d);
    color: #fff;
}

.lkb .lkb-btn-main:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.lkb .lkb-btn-ghost {
    border: 1.5px solid var(--lkb-line);
    background: transparent;
    color: var(--lkb-text);
}

/* ───────── มือถือ ───────── */
@media (max-width: 480px) {
    .lkb .lkb-steps li { font-size: 11px; gap: 4px; }
    .lkb .lkb-preview { height: 118px; }
    .lkb .lkb-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .lkb .lkb-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .lkb .lkb-thumb { height: 56px; }
    .lkb .lkb-swatch { width: 32px; height: 32px; }
}

/* ───────── เลือก ลอยกระทง / ปล่อยโคมลอย ───────── */
.lkb .lkb-kind {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 0 40px 12px 0;
    padding: 4px;
    border-radius: 12px;
    background: var(--lkb-opt-bg);
    border: 1px solid var(--lkb-line);
}

.lkb .lkb-kind-btn {
    margin: 0;
    padding: 9px 8px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--lkb-muted);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.lkb .lkb-kind-btn[aria-checked="true"] {
    background: linear-gradient(135deg, #ffe39a, #f5a43a);
    color: #3b1d00;
    box-shadow: 0 2px 8px rgba(240, 138, 43, 0.35);
}

.lkb .lkb-kind-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

/* โคมลอย: ไม่มีขั้นเลือกฐาน / ดอกไม้ และไม่มีปุ่มสุ่ม */
.lkb.is-lantern .lkb-steps,
.lkb.is-lantern .lkb-random { display: none; }

.lkb.is-lantern .lkb-preview {
    background:
        radial-gradient(ellipse 50% 60% at 50% 55%, rgba(255, 190, 90, 0.25), transparent 70%),
        linear-gradient(180deg, #070b24 0%, #1b1f5c 60%, #3b2a6e 100%);
}

@media (max-width: 480px) {
    .lkb .lkb-kind-btn { font-size: 14px; padding: 8px 6px; }
}
