/* ============================================================
   הבית - עיצוב: כפתור בסרגל הפעולות, חלון הבית, מצב עריכה ומגש רהיטים
   ============================================================ */

/* כפתור הבית בסרגל הפעולות - אותו מבנה ואותם אנימציות של שאר הכפתורים */
.action-rail .house-btn { --c1: #ffc49a; --c2: #ff8f5e; --edge: #d86a3c; }

/* ---------- חלון הבית ---------- */
.hs-overlay {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    direction: rtl;
    font-family: 'Rubik', sans-serif;
    color: #1f2a44;
    background:
        radial-gradient(1200px 700px at 15% -10%, rgba(255, 255, 255, 0.85), transparent 60%),
        radial-gradient(900px 600px at 110% 110%, rgba(255, 214, 170, 0.55), transparent 60%),
        linear-gradient(160deg, #cfe8ff 0%, #e9f3ff 55%, #fff4e8 100%);
    opacity: 0;
    transform: scale(0.985);
    transition: opacity 0.28s ease, transform 0.36s cubic-bezier(0.2, 0.9, 0.2, 1);
    overflow: hidden;
}
.hs-overlay[hidden] { display: none; }
.hs-overlay.is-open { opacity: 1; transform: none; }

.hs-overlay button { font: inherit; color: inherit; }
.hs-overlay button:focus-visible { outline: 3px solid #6d8cff; outline-offset: 2px; }

/* ---------- סרגל עליון (זכוכית) ---------- */
.hs-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 24px rgba(31, 42, 68, 0.08);
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}
.hs-title { display: flex; flex-direction: column; min-width: 0; }
.hs-title-main { font-size: 18px; font-weight: 800; line-height: 1.1; }
.hs-title-sub { font-size: 12px; color: #6b7a99; }
.hs-bar { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; flex-wrap: wrap; }
.hs-bar[hidden] { display: none; }

.hs-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 0 #d7e0f0, 0 4px 10px rgba(31, 42, 68, 0.08);
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hs-icon:hover:not(:disabled) { transform: translateY(-1px); }
.hs-icon:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 #d7e0f0; }
.hs-icon:disabled { opacity: 0.4; cursor: default; }
.hs-close { margin-inline-start: 0; }

.hs-chip {
    height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 0 #d7e0f0, 0 4px 10px rgba(31, 42, 68, 0.08);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: transform 0.15s ease, filter 0.15s ease;
}
.hs-chip:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.03); }
.hs-chip:active:not(:disabled) { transform: translateY(2px); }
.hs-chip:disabled { opacity: 0.45; cursor: default; }
.hs-chip--ghost { background: transparent; box-shadow: none; color: #5a6a8c; }
.hs-chip--save {
    background: linear-gradient(180deg, #7c93ff, #5b6cf2);
    color: #ffffff;
    box-shadow: 0 3px 0 #3f4fc4, 0 8px 18px rgba(91, 108, 242, 0.35);
}
.hs-chip--save:hover:not(:disabled) { filter: brightness(1.06); }
.hs-chip--save:disabled { background: #c9d1e6; box-shadow: none; }
.hs-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff8a5b;
    box-shadow: 0 0 0 3px rgba(255, 138, 91, 0.25);
    display: inline-block;
}
.hs-dot[hidden] { display: none; }

/* מתגי סוג בית */
.hs-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-pills[hidden] { display: none; }
.hs-pill {
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    font-weight: 700;
    color: #5a6a8c;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}
.hs-pill.is-on { background: #1f2a44; color: #fff; }

/* ---------- אזור החדר ---------- */
.hs-main {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 90px 18px;
    transition: padding-bottom 0.42s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.hs-overlay.is-drawer-open .hs-main { padding-bottom: 230px; }

.hs-room-wrap {
    position: relative;
    width: min(100%, calc((100vh - 150px) * 16 / 9));
    transition: width 0.42s cubic-bezier(0.2, 0.9, 0.2, 1);
}
/* במצב עריכה החדר מתכווץ כדי שהמגש למטה לא יכסה אותו */
.hs-overlay.is-drawer-open .hs-room-wrap {
    width: min(100%, calc((100vh - 370px) * 16 / 9));
}

.hs-room {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 26px;
    border: 10px solid #ffffff;
    background: linear-gradient(170deg, #f7efe3, #efe2cf) center / cover no-repeat;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.9) inset,
        0 30px 60px -20px rgba(31, 42, 68, 0.35),
        0 12px 24px -12px rgba(31, 42, 68, 0.2);
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}
.hs-overlay.is-edit .hs-room { box-shadow: 0 0 0 4px rgba(124, 147, 255, 0.45), 0 30px 60px -20px rgba(31, 42, 68, 0.35); }

.hs-stage { position: absolute; inset: 0; }

.hs-item {
    position: absolute;
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
}
.hs-item-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 8px 10px rgba(31, 42, 68, 0.18));
    transition: transform 0.2s ease;
}
.hs-item-img.is-flip { transform: scaleX(-1); }
.hs-item.is-new { animation: hs-land 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
.hs-item.is-drag { z-index: 999 !important; }
.hs-item.is-drag .hs-item-img { transform: scale(1.03); }
@keyframes hs-land {
    0% { transform: translateY(-18px) scale(0.85); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

.hs-overlay.is-edit .hs-item { cursor: grab; }
.hs-overlay.is-edit .hs-item::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px dashed rgba(91, 108, 242, 0.35);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.hs-overlay.is-edit .hs-item:hover::after { opacity: 1; }
.hs-overlay.is-edit .hs-item.is-sel::after {
    opacity: 1;
    border: 2px solid #5b6cf2;
    box-shadow: 0 0 0 4px rgba(91, 108, 242, 0.18);
    animation: hs-pulse 1.6s ease-in-out infinite;
}
@keyframes hs-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(91, 108, 242, 0.18); }
    50% { box-shadow: 0 0 0 7px rgba(91, 108, 242, 0.06); }
}

/* ---------- עיפרון רועד (לבעלים בלבד) ---------- */
.hs-pencil {
    position: absolute;
    inset-inline-end: -66px;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #eef2ff);
    box-shadow: 0 3px 0 #c9d1ee, 0 10px 22px rgba(31, 42, 68, 0.18);
    font-size: 24px;
    cursor: pointer;
    animation: hs-wiggle 1.4s ease-in-out infinite;
}
.hs-pencil:hover { animation-play-state: paused; transform: translateY(-50%) scale(1.08); }
@keyframes hs-wiggle {
    0%, 100% { transform: translateY(-50%) rotate(-9deg); }
    50% { transform: translateY(-50%) rotate(9deg); }
}
.hs-overlay:not(.is-owner) .hs-pencil,
.hs-overlay.is-edit .hs-pencil { display: none; }

/* ---------- כלי עריכה (עמודה בצד החדר) ---------- */
.hs-tools {
    position: absolute;
    inset-inline-start: -78px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 16px 36px -10px rgba(31, 42, 68, 0.3);
}
.hs-tools button {
    width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    color: #3a4868;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.hs-tools button span { font-size: 19px; line-height: 1; }
.hs-tools button:hover:not(:disabled) { background: #eef2ff; transform: translateX(-2px); }
.hs-tools button:disabled { opacity: 0.35; cursor: default; }
.hs-tools .is-danger { color: #c2410c; }
.hs-tools .is-danger:hover:not(:disabled) { background: #fff1ec; }

.hs-status {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -30px;
    margin: 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1f8a4c;
}
.hs-status:empty { display: none; }
.hs-status.is-err { color: #d93025; }

/* ---------- מגש הרהיטים (נפתח מלמטה) ---------- */
.hs-drawer {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 3;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -18px 40px -12px rgba(31, 42, 68, 0.25);
    transform: translateY(105%);
    transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.2, 1);
}
.hs-overlay.is-edit .hs-drawer { transform: translateY(0); }
.hs-overlay.is-edit:not(.is-drawer-open) .hs-drawer { transform: translateY(calc(100% - 58px)); }
.hs-overlay.is-edit .hs-drawer { min-height: 0; }
.hs-overlay.is-edit:not(.is-drawer-open) .hs-main { padding-bottom: 60px; }

.hs-handle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 58px;
    border: 0;
    background: transparent;
    font-size: 15px;
    font-weight: 800;
    color: #1f2a44;
    cursor: pointer;
}
.hs-handle-bar {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: #c3cde0;
}

.hs-cards {
    display: flex;
    gap: 12px;
    padding: 0 18px 18px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}
.hs-empty { margin: 8px 0 14px; color: #6b7a99; font-size: 14px; }

.hs-card {
    flex: 0 0 auto;
    width: 112px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 8px 8px;
    border: 0;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 2px 0 #e3e9f6, 0 8px 16px -8px rgba(31, 42, 68, 0.25);
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1), box-shadow 0.2s ease;
}
.hs-card:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 2px 0 #d5dff2, 0 14px 22px -10px rgba(91, 108, 242, 0.45); }
.hs-card:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.hs-card img { width: 84px; height: 84px; object-fit: contain; }
.hs-card-name { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.2; }
.hs-card-count {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4150c9;
}
.hs-card.is-empty { opacity: 0.55; }
.hs-card.is-empty .hs-card-count { background: #eef4ec; color: #3c7a4c; }
.hs-card:disabled { cursor: default; }

/* ---------- בקר בבית ---------- */
.hs-visit {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    background: rgba(31, 42, 68, 0.25);
    backdrop-filter: blur(4px);
}
.hs-visit[hidden] { display: none; }
.hs-visit-box {
    width: min(92vw, 360px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px;
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 30px 60px -20px rgba(31, 42, 68, 0.4);
    animation: hs-pop 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes hs-pop { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.hs-visit-box h3 { margin: 0; font-size: 17px; }
.hs-visit-box input {
    height: 42px;
    padding: 0 14px;
    border: 1px solid #d5dff2;
    border-radius: 12px;
    font: inherit;
    font-size: 15px;
}
.hs-visit-box input:focus { outline: none; border-color: #6d8cff; box-shadow: 0 0 0 3px rgba(109, 140, 255, 0.2); }
.hs-visit-msg { margin: 0; min-height: 1em; font-size: 13px; color: #d93025; }
.hs-visit-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- הודעה קלה ---------- */
.hs-toast {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 20px);
    z-index: 6;
    padding: 12px 20px;
    border-radius: 999px;
    background: #1f2a44;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
    box-shadow: 0 14px 30px -10px rgba(31, 42, 68, 0.5);
}
.hs-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.hs-toast.is-err { background: #b42318; }

/* ---------- מצבי תצוגה ---------- */
/* לא display:none - כדי שהמגש והכלים יוכלו להיפתח/להיסגר באנימציה */
.hs-overlay:not(.is-edit) .hs-edit-only { visibility: hidden; pointer-events: none; }
.hs-overlay.is-edit .hs-edit-only { visibility: visible; }
.hs-overlay:not(.is-edit) .hs-tools { opacity: 0; transform: translateY(-50%) translateX(-12px); }
.hs-tools { transition: opacity 0.3s ease, transform 0.36s cubic-bezier(0.2, 0.9, 0.2, 1); }
.hs-overlay.is-edit .hs-view-only { display: none; }
.hs-overlay.is-owner .hs-home { display: none; }

/* ---------- מסכים צרים ---------- */
@media (max-width: 760px) {
    .hs-main { padding: 14px 14px 10px; }
    .hs-overlay.is-drawer-open .hs-main { padding-bottom: 210px; }
    .hs-room-wrap { width: 100%; }
    .hs-room { border-width: 6px; border-radius: 18px; }
    .hs-pencil { inset-inline-end: 6px; top: auto; bottom: -62px; transform: none; animation: none; }
    .hs-pencil:hover { transform: scale(1.06); }
    .hs-tools {
        inset-inline-start: 50%;
        top: auto;
        bottom: -110px;
        transform: translateX(50%);
        flex-direction: row;
        gap: 4px;
        padding: 6px;
    }
    .hs-tools button { width: 48px; }
    .hs-status { bottom: -140px; }
    .hs-cards { padding: 0 12px 14px; }
    .hs-card { width: 96px; }
    .hs-card img { width: 68px; height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
    .hs-pencil, .hs-item.is-new, .hs-overlay.is-edit .hs-item.is-sel::after { animation: none; }
    .hs-overlay, .hs-drawer, .hs-main { transition: none; }
}
