/**
 * Alternative Homepage - Full-Screen Launcher
 *
 * App-like hero launcher with centered tool icons.
 * Route: /z/webpages?command=home&step=publicalt
 *
 * Bootstrap 5.3 dark mode compatible
 * @see /php/ide/data/webpages/homepublic.php  homepublicalt()
 */

/* ============================================
   Full-screen hero background
   ============================================ */
.alt-homepage {
    position: fixed;
    inset: 0;
    top: 56px;
    background: #1a5f2a url('/objects/hero.jpg') center/cover no-repeat;
    overflow: hidden;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.alt-homepage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 0;
}
/* Everything inside sits above the overlay */
.alt-homepage > * {
    position: relative;
    z-index: 1;
}

@media (min-width: 992px) {
    .alt-homepage { top: 62px; }
}

/* Hide PageWrap footer and reset container on alt homepage */
body:has(.alt-homepage) > .container > footer.page-footer { display: none; }
body:has(.alt-homepage) > .container {
    padding: 0;
    margin: 0;
    max-width: none;
}

/* ============================================
   Company branding
   ============================================ */
.alt-branding {
    text-align: center;
    margin-bottom: 2.5rem;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.alt-branding h1 {
    font-size: clamp(1.8rem, 5vw, 3.2rem);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,0.5);
    margin: 0 0 0.25rem;
    letter-spacing: 0.02em;
}
.alt-branding p {
    font-size: clamp(0.95rem, 2vw, 1.3rem);
    color: rgba(255,255,255,0.88);
    text-shadow: 0 1px 6px rgba(0,0,0,0.4);
    margin: 0;
    font-weight: 300;
    letter-spacing: 0.04em;
}
.alt-branding.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Broker credit */
.alt-broker {
    position: absolute;
    bottom: 0.75rem;
    right: 1rem;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.03em;
    transition: opacity 0.4s ease;
}
.alt-broker-owner {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
}
.alt-broker:hover { color: rgba(255,255,255,0.75); }
.alt-broker:hover .alt-broker-owner { color: rgba(255,255,255,0.9); }

/* ============================================
   Icon dock (centered)
   ============================================ */
.alt-dock {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: center;
    transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.alt-dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.alt-dock-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.22), rgba(255,255,255,0.06));
    backdrop-filter: blur(18px) saturate(1.4) brightness(1.1);
    -webkit-backdrop-filter: blur(18px) saturate(1.4) brightness(1.1);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow:
        0 8px 24px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.35),
        inset 0 -1px 0 rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
/* Specular highlight overlay */
.alt-dock-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(ellipse 70% 50% at 50% 15%, rgba(255,255,255,0.3), transparent 70%);
    pointer-events: none;
}
.alt-dock-item:hover .alt-dock-icon {
    transform: scale(1.14);
    background: linear-gradient(135deg, rgba(255,255,255,0.32), rgba(255,255,255,0.1));
    border-color: rgba(255,255,255,0.45);
    box-shadow:
        0 12px 32px rgba(0,0,0,0.22),
        0 0 20px rgba(255,255,255,0.08),
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(255,255,255,0.08);
}
.alt-dock-item:active .alt-dock-icon {
    transform: scale(0.95);
}
.alt-dock-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

/* Secondary dock (smaller) */
.alt-dock-secondary {
    margin-top: 1rem;
    gap: 1.25rem;
}
.alt-dock-secondary .alt-dock-icon {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
}
.alt-dock-secondary .alt-dock-label {
    font-size: 0.72rem;
}

/* Active highlight ring */
.alt-dock-item.active .alt-dock-icon {
    background: linear-gradient(135deg, rgba(255,255,255,0.35), rgba(255,255,255,0.12));
    border-color: rgba(255,255,255,0.55);
    box-shadow:
        0 0 0 2px rgba(255,255,255,0.6),
        0 8px 24px rgba(0,0,0,0.2),
        0 0 20px rgba(255,255,255,0.12),
        inset 0 1px 0 rgba(255,255,255,0.45);
}

/* ============================================
   Popover on hover
   ============================================ */
.alt-dock-item .alt-popover {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.78rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.alt-dock-item .alt-popover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.8);
}
.alt-dock-item:hover .alt-popover {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   Mini-dock state (tool is open)
   ============================================ */
.alt-dock.mini {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0.5rem 1rem;
    gap: 1rem;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    justify-content: center;
}
@media (min-width: 992px) {
    .alt-dock.mini { top: 62px; }
}
.alt-dock.mini .alt-dock-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.25);
}
.alt-dock-secondary.mini {
    margin-top: 0;
    position: fixed;
    top: calc(56px + 50px); /* below primary mini dock */
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0.3rem 1rem;
    gap: 0.75rem;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    justify-content: center;
}
@media (min-width: 992px) {
    .alt-dock-secondary.mini { top: calc(62px + 50px); }
}
.alt-dock-secondary.mini .alt-dock-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
}
.alt-dock-secondary.mini .alt-dock-label {
    display: none;
}
.alt-dock-secondary.mini .alt-popover {
    display: none;
}
.alt-dock-secondary.mini .alt-dock-item:hover .alt-dock-icon {
    transform: scale(1.08);
}
.alt-dock.mini .alt-dock-label {
    display: none;
}
.alt-dock.mini .alt-popover {
    display: none;
}
.alt-dock.mini .alt-dock-item:hover .alt-dock-icon {
    transform: scale(1.08);
}

/* ============================================
   Tool panel
   ============================================ */
.alt-tool-panel {
    position: fixed;
    top: calc(56px + 1rem); /* navbar + spacing */
    left: 7.5%;
    right: 7.5%;
    bottom: 1rem;
    background: var(--bs-body-bg);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.alt-tool-panel.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (min-width: 992px) {
    .alt-tool-panel { top: calc(62px + 1rem); }
}

/* Tool panel header */
.alt-tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    flex-shrink: 0;
}
.alt-tool-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--bs-body-color);
}
.alt-tool-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--bs-body-color);
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.alt-tool-close:hover { opacity: 1; }

/* Tool panel content area */
.alt-tool-content {
    flex: 1;
    overflow: auto;
    position: relative;
    min-height: 0; /* allow flex item to shrink below content size */
}
/* Iframes fill the content area exactly — no scrollbar */
.alt-tool-content iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================
   Inline chat (inside tool panel)
   ============================================ */
.alt-chat-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.alt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.alt-chat-typing {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    font-style: italic;
    display: none;
}
.alt-chat-typing.show { display: block; }
.alt-chat-typing span {
    display: inline-block;
    animation: altChatDots 1.4s infinite;
}
.alt-chat-typing span:nth-child(2) { animation-delay: .2s; }
.alt-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes altChatDots {
    0%, 80%, 100% { opacity: .3; }
    40% { opacity: 1; }
}
.alt-chat-input-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--bs-border-color);
    flex-shrink: 0;
}
.alt-chat-input-bar input {
    flex: 1;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    outline: none;
}
.alt-chat-input-bar input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), .2);
}
.alt-chat-input-bar button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bs-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.alt-chat-input-bar button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ============================================
   Featured slider container
   ============================================ */
.alt-tool-content .featured-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--bs-secondary-color);
    font-size: 0.95rem;
}

/* ============================================
   Dark mode
   ============================================ */
[data-bs-theme="dark"] .alt-dock-icon {
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.04));
    border-color: rgba(255,255,255,0.2);
}
[data-bs-theme="dark"] .alt-dock-item:hover .alt-dock-icon {
    background: linear-gradient(135deg, rgba(255,255,255,0.25), rgba(255,255,255,0.08));
}
[data-bs-theme="dark"] .alt-dock.mini,
[data-bs-theme="dark"] .alt-dock-secondary.mini {
    background: rgba(0,0,0,0.65);
}
[data-bs-theme="dark"] .alt-tool-panel {
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
[data-bs-theme="dark"] .alt-chat-input-bar input {
    background-color: var(--bs-tertiary-bg);
    border-color: rgba(255,255,255,0.15);
    color: var(--bs-emphasis-color);
}
[data-bs-theme="dark"] .alt-chat-input-bar input:focus {
    border-color: #4da3ff;
    box-shadow: 0 0 0 2px rgba(77,163,255,0.3);
}
[data-bs-theme="dark"] .alt-chat-input-bar button {
    background: #4da3ff;
    color: #000;
}
[data-bs-theme="dark"] .chat-msg-user {
    background-color: #2563b8;
}
[data-bs-theme="dark"] .chat-msg-assistant {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-emphasis-color);
    border: 1px solid rgba(255,255,255,0.08);
}

/* ============================================
   Responsive (mobile)
   ============================================ */
@media (max-width: 767px) {
    .alt-dock { gap: 1rem; }
    .alt-dock-icon {
        width: 64px;
        height: 64px;
        font-size: 1.6rem;
    }
    .alt-dock-label { font-size: 0.72rem; }
    .alt-dock-item .alt-popover { display: none; }

    .alt-dock-secondary { margin-top: 0.75rem; gap: 1rem; }
    .alt-dock-secondary .alt-dock-icon {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
    .alt-dock-secondary .alt-dock-label { font-size: 0.68rem; }

    .alt-dock.mini .alt-dock-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    .alt-dock-secondary.mini .alt-dock-icon {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    .alt-dock.mini { gap: 0.75rem; padding: 0.4rem 0.5rem; }
    .alt-dock-secondary.mini { gap: 0.6rem; padding: 0.25rem 0.5rem; top: calc(56px + 44px); }

    .alt-tool-panel {
        left: 2%;
        right: 2%;
        top: calc(56px + 0.5rem);
        bottom: 0.5rem;
        border-radius: 8px;
    }
    .alt-branding h1 { font-size: 1.6rem; }
    .alt-branding p { font-size: 0.9rem; }
    .alt-branding { margin-bottom: 1.5rem; }
}

/* ============================================
   Entry animation
   ============================================ */
@keyframes altFadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.alt-branding { animation: altFadeInUp 0.6s ease both; }
.alt-dock { animation: altFadeInUp 0.6s ease 0.15s both; }
.alt-dock-item:nth-child(1) { animation: altFadeInUp 0.5s ease 0.2s both; }
.alt-dock-item:nth-child(2) { animation: altFadeInUp 0.5s ease 0.3s both; }
.alt-dock-item:nth-child(3) { animation: altFadeInUp 0.5s ease 0.4s both; }
.alt-dock-item:nth-child(4) { animation: altFadeInUp 0.5s ease 0.5s both; }
.alt-dock-secondary { animation: altFadeInUp 0.5s ease 0.55s both; }
.alt-dock-secondary .alt-dock-item:nth-child(1) { animation: altFadeInUp 0.5s ease 0.6s both; }
.alt-dock-secondary .alt-dock-item:nth-child(2) { animation: altFadeInUp 0.5s ease 0.7s both; }
