/* "Pregúntale a Chip" — product Q&A card on the product page (dark default, html.light-theme). */

.ask-chip {
    --ac-bg: #141416;
    --ac-surface: #1c1c1f;
    --ac-border: #2c2c31;
    --ac-border-strong: #3a3a40;
    --ac-text: #f4f4f6;
    --ac-muted: #a7a7b0;
    --ac-accent: var(--accent, #E52056);
    --ac-accent-text: var(--accent-on-dark, #FF7A9C);
    --ac-accent-soft: rgba(229, 32, 86, 0.12);
    --ac-chip-bg: #202024;
    --ac-chip-hover: #2a2a2f;
    --ac-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.7);
    --ac-ease: cubic-bezier(0.16, 1, 0.3, 1);

    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: clamp(20px, 3vw, 40px);
    margin: 8px 0 28px;
    padding: clamp(20px, 3vw, 32px);
    background:
        radial-gradient(120% 90% at 0% 0%, rgba(229, 32, 86, 0.09), transparent 55%),
        var(--ac-bg);
    border: 1px solid var(--ac-border);
    border-radius: 20px;
    box-shadow: var(--ac-shadow);
    color: var(--ac-text);
    isolation: isolate;
    overflow: hidden;
    --ac-trace: rgba(229, 32, 86, 0.16);
    --ac-mark-opacity: 0.24;
}

.light-theme .ask-chip {
    --ac-bg: #ffffff;
    --ac-surface: #f6f7fb;
    --ac-border: #e5e7eb;
    --ac-border-strong: #d5dae2;
    --ac-text: #0f172a;
    --ac-muted: #5b6474;
    --ac-accent-text: #B01342;
    --ac-accent-soft: rgba(196, 21, 74, 0.08);
    --ac-chip-bg: #f6f7fb;
    --ac-chip-hover: #eef0f5;
    --ac-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.28);

    background:
        radial-gradient(120% 90% at 0% 0%, rgba(196, 21, 74, 0.06), transparent 55%),
        var(--ac-bg);
}

.light-theme .ask-chip {
    --ac-trace: rgba(196, 21, 74, 0.13);
    --ac-mark-opacity: 0.16;
}

/* Board: copper traces from Chip's corner; the Loltec mark sits in the intro's free corner (.ask-chip__intro). */
.ask-chip__board {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.ask-chip__traces {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ask-chip__traces path {
    fill: none;
    stroke-width: 1.25;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ask-chip__trace-base path {
    stroke: var(--ac-trace);
}

/* The signal: a short bright pulse that rides the traces (pathLength=1 makes the dash length a fraction). */
.ask-chip__trace-signal path {
    stroke: var(--ac-accent);
    stroke-width: 2;
    stroke-dasharray: 0.04 1;
    stroke-dashoffset: 0.04;
    opacity: 0;
}

.ask-chip__pads circle {
    fill: var(--ac-bg);
    stroke: var(--ac-trace);
    stroke-width: 1.25;
}

.ask-chip__mark {
    position: absolute;
    top: 0;
    right: 0;
    z-index: -1;
    width: clamp(104px, 11vw, 150px);
    aspect-ratio: 112 / 88;
    opacity: var(--ac-mark-opacity);
    pointer-events: none;
    animation: ask-chip-mark-float 8s ease-in-out infinite;
    /* Only the angular mark of logo.png (its left 112 of 300 px), as a mask: one tint, any theme. */
    -webkit-mask: url('../images/logo.png') 0 50% / 268% auto no-repeat;
    mask: url('../images/logo.png') 0 50% / 268% auto no-repeat;
    background:
        linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.9) 50%, transparent 62%) -160% 0 / 250% 100% no-repeat,
        var(--ac-accent);
}

.light-theme .ask-chip__mark {
    background:
        linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, 0.95) 50%, transparent 62%) -160% 0 / 250% 100% no-repeat,
        var(--ac-accent);
}

/* One authored moment: when the card first comes into view and while Chip answers,
   a pulse travels the traces and a light sweeps across the mark. */
.ask-chip--live .ask-chip__trace-signal path,
.ask-chip--busy .ask-chip__trace-signal path {
    animation: ask-chip-signal 1.6s var(--ac-ease) both;
}

.ask-chip--busy .ask-chip__trace-signal path {
    animation-iteration-count: infinite;
}

.ask-chip__trace-signal path:nth-child(2) { animation-delay: 0.18s; }

.ask-chip--live .ask-chip__mark {
    animation: ask-chip-sweep 2.2s var(--ac-ease) 0.3s both, ask-chip-mark-float 8s ease-in-out infinite;
}

.ask-chip--busy .ask-chip__mark {
    animation: ask-chip-sweep 2.2s var(--ac-ease) 0.3s infinite both, ask-chip-mark-float 8s ease-in-out infinite;
}

.ask-chip ::selection {
    background: var(--ac-accent);
    color: #fff;
}

/* Intro column */
.ask-chip__intro {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.ask-chip__avatar {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
    color: var(--ac-accent);
}

.ask-chip__avatar svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ask-chip__die {
    fill: var(--ac-accent);
}

.ask-chip__eye {
    fill: #fff;
    transform-box: fill-box;
    transform-origin: center;
}

.ask-chip__smile {
    stroke: #fff;
}

.ask-chip__pins path {
    opacity: 0.55;
}

.ask-chip__title {
    margin: 0 0 10px;
    font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.625rem);
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.015em;
    text-wrap: balance;
    color: var(--ac-text);
}

.ask-chip__title-accent {
    display: block;
    font-weight: 800;
    color: var(--ac-accent-text);
}

.ask-chip__subtitle {
    max-width: 46ch;
    margin: 0 0 20px;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--ac-muted);
}

/* Suggestion chips */
.ask-chip__suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ask-chip__suggestion,
.ask-chip__followup {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: left;
    color: var(--ac-text);
    background: var(--ac-chip-bg);
    border: 1px solid var(--ac-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s var(--ac-ease), border-color 0.2s var(--ac-ease), transform 0.2s var(--ac-ease);
}

.ask-chip__suggestion:hover,
.ask-chip__followup:hover {
    background: var(--ac-chip-hover);
    border-color: var(--ac-accent);
}

.ask-chip__suggestion:active,
.ask-chip__followup:active {
    transform: translateY(1px);
}

.ask-chip__suggestion:disabled,
.ask-chip__followup:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ask-chip__skeleton {
    width: 168px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--ac-chip-bg) 0%, var(--ac-chip-hover) 50%, var(--ac-chip-bg) 100%);
    background-size: 200% 100%;
    animation: ask-chip-shimmer 1.4s linear infinite;
}

.ask-chip__skeleton--short {
    width: 120px;
}

/* Workspace column */
.ask-chip__workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    align-self: center;
}

.ask-chip__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 8px 8px 18px;
    background: var(--ac-surface);
    border: 1px solid var(--ac-border-strong);
    border-radius: 16px;
    transition: border-color 0.2s var(--ac-ease), box-shadow 0.2s var(--ac-ease);
}

.ask-chip__form:focus-within {
    border-color: var(--ac-accent);
    box-shadow: 0 0 0 3px var(--ac-accent-soft);
}

.ask-chip__input {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    max-height: 140px;
    padding: 9px 0;
    font: inherit;
    font-size: 1rem;
    line-height: 1.4;
    color: var(--ac-text);
    background: transparent;
    border: 0;
    outline: none;
    resize: none;
    caret-color: var(--ac-accent);
}

.ask-chip__input::placeholder {
    color: var(--ac-muted);
    opacity: 1;
}

.ask-chip__send {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background: var(--btn-primary-bg, var(--ac-accent));
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s var(--ac-ease), opacity 0.2s var(--ac-ease);
}

.ask-chip__send svg {
    width: 20px;
    height: 20px;
}

.ask-chip__send:hover:not(:disabled) {
    transform: translateY(-1px);
}

.ask-chip__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ask-chip :focus-visible {
    outline: 2px solid var(--ac-accent);
    outline-offset: 2px;
}

.ask-chip__input:focus-visible {
    outline: none;
}

/* Answer */
.ask-chip__answer {
    padding: 4px 0 0;
}

.ask-chip__answer:focus {
    outline: none;
}

.ask-chip__answer[hidden] {
    display: none;
}

/* Empty field: the example stays on one line (it was wrapping and getting cut on phones). */
.ask-chip__input:placeholder-shown {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The shopper's question: their own bubble, on the right, like any chat. */
.ask-chip__question {
    width: fit-content;
    max-width: min(85%, 34rem);
    margin: 0 0 12px auto;
    padding: 9px 14px;
    border-radius: 16px 16px 4px 16px;
    background: var(--ac-accent-soft);
    color: var(--ac-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

/* Chip's answer: his face beside a tinted reply, so it reads as his voice and not as page copy. */
.ask-chip__reply {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.ask-chip__reply-avatar {
    display: grid;
    width: 32px;
    height: 32px;
    margin-top: 2px;
}

.ask-chip__reply-avatar svg {
    width: 100%;
    height: 100%;
}

.ask-chip__reply-body {
    min-width: 0;
    padding: 12px 16px 14px;
    border-radius: 4px 16px 16px 16px;
    background: var(--ac-surface);
}

.ask-chip__reply-name {
    margin: 0 0 4px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--ac-accent-text);
}

/* Suggestions and buttons hang from the reply, not from the card edge. */
.ask-chip__answer > .ask-chip__followups,
.ask-chip__answer > .ask-chip__actions {
    padding-left: 44px;
}

@media (max-width: 480px) {
    .ask-chip__answer > .ask-chip__followups,
    .ask-chip__answer > .ask-chip__actions {
        padding-left: 0;
    }

    .ask-chip__reply {
        gap: 10px;
    }

    .ask-chip__reply-avatar {
        width: 28px;
        height: 28px;
    }
}

.ask-chip__text {
    font-size: 0.975rem;
    line-height: 1.65;
    color: var(--ac-text);
    overflow-wrap: anywhere;
}

.ask-chip__text p {
    margin: 0 0 0.6em;
}

.ask-chip__text p:last-child {
    margin-bottom: 0;
}

.ask-chip__text a {
    color: var(--ac-accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ask-chip__text strong {
    font-weight: 700;
}

.ask-chip__text code {
    padding: 1px 5px;
    font-size: 0.9em;
    background: var(--ac-chip-bg);
    border-radius: 6px;
}

.ask-chip__text--error,
.ask-chip__text--limited {
    color: var(--ac-text);
}

.ask-chip__word {
    animation: ask-chip-word 0.45s var(--ac-ease) both;
}

.ask-chip__thinking {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ac-muted);
    font-size: 0.9rem;
}

.ask-chip__dots {
    display: inline-flex;
    gap: 4px;
}

.ask-chip__dots span {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--ac-accent);
    animation: ask-chip-pin 1s var(--ac-ease) infinite;
}

.ask-chip__dots span:nth-child(2) { animation-delay: 0.15s; }
.ask-chip__dots span:nth-child(3) { animation-delay: 0.3s; }

/* Chip "thinks": its pins light up while waiting. */
.ask-chip--busy .ask-chip__pins path {
    animation: ask-chip-pins 1.2s var(--ac-ease) infinite;
}

.ask-chip--busy .ask-chip__eye {
    animation: ask-chip-blink 2.4s ease-in-out infinite;
}

.ask-chip__label {
    display: block;
    margin: 16px 0 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ac-muted);
}

.ask-chip__sources,
.ask-chip__followups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ask-chip__sources[hidden],
.ask-chip__followups[hidden],
.ask-chip__actions[hidden],
.ask-chip__cta[hidden] {
    display: none;
}

.ask-chip__sources .ask-chip__label,
.ask-chip__followups .ask-chip__label {
    flex-basis: 100%;
    margin: 14px 0 0;
}

.ask-chip__source {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 5px 10px;
    font-size: 0.8125rem;
    color: var(--ac-accent-text);
    background: var(--ac-accent-soft);
    border-radius: 999px;
    text-decoration: none;
}

.ask-chip__source span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ask-chip__source svg {
    flex: none;
    width: 13px;
    height: 13px;
}

.ask-chip__source:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ask-chip__followup {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.8125rem;
    background: transparent;
}

.ask-chip__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.ask-chip__cta,
.ask-chip__ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 16px;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s var(--ac-ease), border-color 0.2s var(--ac-ease);
}

.ask-chip__cta {
    color: #fff;
    background: var(--btn-primary-bg, var(--ac-accent));
    border: 0;
}

.ask-chip__cta svg {
    width: 18px;
    height: 18px;
}

.ask-chip__cta:hover {
    background: var(--btn-primary-bg-hover, var(--accent-hover, #c41847));
}

.ask-chip__ghost {
    color: var(--ac-text);
    background: transparent;
    border: 1px solid var(--ac-border-strong);
}

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

/* Card footer across both columns: Chip guides, an advisor answers for sure. */
.ask-chip__notice {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px 14px;
    padding-top: clamp(16px, 2vw, 20px);
    border-top: 1px solid var(--ac-border);
}

.ask-chip__notice-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 9999px;
    background: var(--ac-accent-soft);
    color: var(--ac-accent-text);
}

.ask-chip__notice-icon svg {
    width: 17px;
    height: 17px;
}

.ask-chip__notice-text {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--ac-muted);
    text-wrap: pretty;
}

.ask-chip__notice-title {
    font-weight: 700;
    color: var(--ac-text);
}

.ask-chip__notice-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--ac-border-strong);
    border-radius: 9999px;
    color: var(--ac-text);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.18s var(--ac-ease), border-color 0.18s var(--ac-ease);
}

.ask-chip__notice-cta svg {
    width: 18px;
    height: 18px;
    color: #25d366;
    flex-shrink: 0;
}

.ask-chip__notice-cta:hover {
    border-color: #25d366;
    background: rgba(37, 211, 102, 0.1);
}

.ask-chip__notice-cta:focus-visible {
    outline: 2px solid var(--ac-accent);
    outline-offset: 2px;
}

/* Tablets and phones: the button drops under the text, full width and easy to tap. */
@media (max-width: 720px) {
    .ask-chip__notice {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
    }

    .ask-chip__notice-cta {
        grid-column: 1 / -1;
        min-height: 44px;
    }
}

@keyframes ask-chip-signal {
    0% { stroke-dashoffset: 0.04; opacity: 0; }
    12% { opacity: 1; }
    85% { opacity: 1; }
    100% { stroke-dashoffset: -1; opacity: 0; }
}

/* A slow drift: transform only, so it costs nothing to paint. */
@keyframes ask-chip-mark-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(-2deg); }
}

@keyframes ask-chip-sweep {
    from { background-position: -160% 0, 0 0; }
    to { background-position: 260% 0, 0 0; }
}

@keyframes ask-chip-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@keyframes ask-chip-word {
    from { opacity: 0; filter: blur(4px); }
    to { opacity: 1; filter: blur(0); }
}

@keyframes ask-chip-pin {
    0%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

@keyframes ask-chip-pins {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

@keyframes ask-chip-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    96% { transform: scaleY(0.15); }
}

@media (max-width: 992px) {
    .ask-chip {
        grid-template-columns: 1fr;
    }

    .ask-chip__mark {
        width: clamp(84px, 16vw, 120px);
    }

    .ask-chip__workspace {
        align-self: stretch;
    }
}

@media (max-width: 480px) {
    .ask-chip {
        margin: 4px 0 20px;
        border-radius: 16px;
    }

    /* Smaller on phones so it ends above the title, which wraps across the whole width. */
    .ask-chip__mark {
        width: 76px;
    }

    .ask-chip__avatar {
        width: 44px;
        height: 44px;
        margin-bottom: 12px;
    }

    /* Smaller padding and avatar: keep the traces leaving from Chip's centre. */
    .ask-chip__traces {
        transform: translate(-20px, -18px);
    }

    .ask-chip__suggestion {
        min-height: 44px;
    }

    .ask-chip {
        padding: 18px 16px;
    }

    .ask-chip__actions > * {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ask-chip *,
    .ask-chip *::before,
    .ask-chip *::after {
        animation: none !important;
        transition: none !important;
    }
}
