/*
 * "Ask your AI" chooser (Brand Bible 1.3 §7.10): layout and contents of the panel.
 * Loaded before amtecco-ask-ai.css, which holds the tile, toast, phone sheet and motion.
 */

/* ---------- The chooser ---------- */

.ask-ai__panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    display: flex;
    flex-direction: column;
    width: min(23.5rem, calc(100vw - 2rem));
    /* The script measures the room between the navigation bar and the tile (or the
       screen edge on phones) as --ask-panel-max; the fallback is a safe estimate. */
    max-height: var(--ask-panel-max, calc(100dvh - 11rem));
    gap: 0.75rem;
    overflow: hidden;
    padding: 1.25rem;
    border: 1px solid var(--ask-line);
    border-radius: var(--amtecco-radius);
    background: var(--ask-surface);
    box-shadow: 0 1.5rem 3.5rem rgba(0, 0, 0, 0.5);
}

/* Header and actions stay in view; only the body scrolls. */
.ask-ai__head,
.ask-ai__foot {
    flex: none;
}

.ask-ai__body {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    /* Rows always take their full content height; the body scrolls instead of squeezing them. */
    grid-auto-rows: max-content;
    align-content: start;
    gap: 0.75rem;
    /* Room for focus outlines, which the scroll box would otherwise clip. */
    margin: -0.25rem;
    padding: 0.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.ask-ai__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.ask-ai__head h2 {
    margin: 0;
    color: var(--amtecco-paper) !important;
    font-family: var(--amtecco-display);
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.3 !important;
}

.ask-ai__close {
    display: grid;
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    margin: -0.5rem -0.5rem 0 0;
    place-items: center;
    border: 0;
    border-radius: var(--amtecco-radius);
    background: transparent;
    color: var(--amtecco-paper-soft) !important;
    cursor: pointer;
}

.ask-ai__intro {
    margin: 0;
    color: var(--amtecco-paper-soft);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.ask-ai__question {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--amtecco-line);
    border-radius: var(--amtecco-radius);
    background: var(--amtecco-carbon-deep);
    color: var(--amtecco-paper-soft);
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ask-ai__options {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ask-ai__option {
    display: grid;
    color: inherit;
    text-decoration: none;
    width: 100%;
    min-height: 3.25rem;
    grid-template-columns: minmax(0, 1fr) 1rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--amtecco-line);
    border-radius: var(--amtecco-radius);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--amtecco-motion-fast) var(--amtecco-ease-standard), background-color var(--amtecco-motion-fast) var(--amtecco-ease-standard);
}

.ask-ai__option:hover,
.ask-ai__option:focus-visible {
    border-color: var(--ask-accent);
    background: var(--amtecco-graphite-2);
}

.ask-ai__option:focus-visible,
.ask-ai__more:focus-visible,
.ask-ai__copy:focus-visible,
.ask-ai__close:focus-visible,
.ask-ai__toast-action:focus-visible,
.ask-ai__question-toggle:focus-visible {
    outline: 2px solid var(--amtecco-paper);
    outline-offset: 2px;
}

/* Four whole lines ending in an ellipsis; "Show the full question" opens it in place. */
.ask-ai__question:not(.is-expanded) .ask-ai__question-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.ask-ai__option-text {
    display: grid;
    min-width: 0;
}

.ask-ai__option-text strong {
    color: var(--amtecco-paper);
    font-size: 1rem;
    font-weight: 600;
}

.ask-ai__option-text small {
    color: var(--amtecco-steel);
    font-size: 0.875rem;
    line-height: 1.35;
}

.ask-ai__go {
    color: var(--amtecco-steel);
}

.ask-ai__question-toggle {
    margin-top: -0.625rem;
}

.ask-ai__more,
.ask-ai__question-toggle {
    justify-self: start;
    min-height: 2.75rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--amtecco-paper-soft) !important;
    font-size: 0.9375rem;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

.ask-ai__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--amtecco-line);
}

.ask-ai__remember {
    display: inline-flex;
    min-height: 2.75rem;
    align-items: center;
    gap: 0.5rem;
    color: var(--amtecco-paper-soft);
    font-size: 0.9375rem;
    cursor: pointer;
}

.ask-ai__remember input {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--ask-accent);
}

.ask-ai__copy {
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--amtecco-line-strong);
    border-radius: var(--amtecco-radius);
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.ask-ai__copy:hover {
    border-color: var(--ask-accent);
}
