/*=============== PORTFOLIO AGENT (Ame) ===============*/
/* Themed to match the site: light developer-terminal chrome, monospace,
   macOS window dots, `➜` prompt, and the bright-blue accent.
   Structure/class names are shared by the floating and embedded panels. */

:root {
    --tp-accent: hsl(230, 100%, 50%);
    --tp-accent-soft: hsl(230, 100%, 96%);
    --tp-ink: #333333;
    --tp-muted: #6b7280;
    --tp-line: #e0e0e0;
    --tp-surface: #ffffff;
    --tp-canvas: #fafafa;
    --tp-header: #f5f5f5;
    --tp-mono: 'Menlo', 'Monaco', 'Courier New', monospace;
    --tp-shadow: 0 12px 34px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ---- Floating launcher (pixel cat button) ---- */
.tp-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9000;
    padding: 8px;
    border: 1px solid #ddcaa6;
    border-radius: 50%;
    background: #f4ead6;
    cursor: pointer;
    box-shadow: var(--tp-shadow);
    transition: transform 0.15s ease, background 0.15s ease;
}

.tp-launcher:hover {
    transform: translateY(-3px);
    background: #ede0c8;
}

.tp-launcher:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--tp-accent) 55%, transparent);
    outline-offset: 2px;
}

.tp-launcher:active {
    transform: scale(0.93);
}

.tp-cat {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    object-position: 50% 40%;
    animation: tp-bob 2.8s ease-in-out infinite;
    transform-origin: 50% 100%;
}

.tp-launcher:hover .tp-cat {
    animation-duration: 1.1s;
}

/* Monospace tooltip, terminal-style */
.tp-launcher::after {
    content: 'chat with ame';
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    padding: 4px 8px;
    border: 1px solid #ddcaa6;
    border-radius: 6px;
    background: #f4ead6;
    color: #6b5a3d;
    font-family: var(--tp-mono);
    font-size: 0.68rem;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.tp-launcher:hover::after,
.tp-launcher:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

@keyframes tp-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .tp-cat { animation: none; }
}

/* ---- Panel ---- */
.tp-panel {
    position: fixed;
    right: 24px;
    bottom: 82px;
    z-index: 9001;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: min(78vh, 640px);
    display: flex;
    flex-direction: column;
    background: var(--tp-surface);
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: var(--tp-shadow);
    overflow: hidden;
    font-family: var(--tp-mono);
    color: var(--tp-ink);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tp-panel.tp-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---- Header (terminal window chrome) ---- */
.tp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--tp-header);
    border-bottom: 1px solid var(--tp-line);
}

.tp-dots {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.tp-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.tp-dot--red { background-color: #ff5f56; }
.tp-dot--yellow { background-color: #ffbd2e; }
.tp-dot--green { background-color: #27c93f; }

.tp-avatar {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: #e8ddc4;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
}
.tp-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 42%; }

.tp-head-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.tp-name { font-weight: 700; font-size: 0.8rem; color: #111827; }
.tp-status { font-size: 0.68rem; color: var(--tp-muted); display: flex; align-items: center; gap: 6px; }
.tp-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #27c93f; }
.tp-status.is-busy .tp-status-dot { background: #ffbd2e; animation: tp-blink 0.9s infinite; }
.tp-status.is-busy .tp-status-text { color: #b45309; }

@keyframes tp-blink { 50% { opacity: 0.35; } }

.tp-close {
    margin-left: auto;
    border: 1px solid var(--tp-line);
    background: #fff;
    color: var(--tp-muted);
    width: 26px;
    height: 26px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}
.tp-close:hover { background: #f0f0f0; color: var(--tp-ink); }

/* ---- Messages ---- */
.tp-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--tp-canvas);
    scrollbar-width: thin;
}

.tp-msg { display: flex; flex-direction: column; max-width: 92%; gap: 6px; }
.tp-msg.tp-user { align-self: flex-end; align-items: flex-end; }
.tp-msg.tp-bot { align-self: flex-start; }

/* Ame's headshot appears on every message she sends. */
.tp-msg.tp-bot::before {
    content: "";
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-image: url("../assets/cat/ame-headshot.png");
    background-size: cover;
    background-position: 50% 40%;
    border: 1px solid #ddcaa6;
}

.tp-bubble {
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.tp-user .tp-bubble {
    background: var(--tp-accent);
    color: #fff;
    border-top-right-radius: 2px;
}

.tp-bot .tp-bubble {
    background: var(--tp-surface);
    border: 1px solid var(--tp-line);
    color: var(--tp-ink);
    border-top-left-radius: 2px;
}

/* ---- Tool / action trace ---- */
.tp-trace {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 11px;
    border: 1px dashed #cfd2da;
    border-radius: 6px;
    background: #f5f5f8;
    font-size: 0.7rem;
    color: var(--tp-muted);
}

.tp-trace-line { display: flex; gap: 7px; align-items: baseline; }
.tp-trace-line .tp-tool { color: var(--tp-accent); }
.tp-trace-line.is-done .tp-mark { color: #27c93f; }
.tp-trace-line .tp-mark { width: 12px; }

/* ---- Action chip (navigate) ---- */
.tp-action {
    margin-top: 8px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--tp-line);
    background: #fff;
    color: var(--tp-accent);
    font-family: var(--tp-mono);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.tp-action:hover { background: var(--tp-accent-soft); border-color: color-mix(in srgb, var(--tp-accent) 30%, var(--tp-line)); }

/* ---- Typing indicator ---- */
.tp-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.tp-typing span {
    width: 6px; height: 6px; border-radius: 50%; background: #b9bec9;
    animation: tp-typing 1.2s infinite ease-in-out;
}
.tp-typing span:nth-child(2) { animation-delay: 0.15s; }
.tp-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tp-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---- Suggestions ---- */
.tp-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tp-chip {
    border: 1px solid var(--tp-line);
    background: #fff;
    color: var(--tp-ink);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--tp-mono);
    font-size: 0.74rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.tp-chip:hover { background: var(--tp-accent-soft); border-color: color-mix(in srgb, var(--tp-accent) 28%, var(--tp-line)); transform: translateY(-1px); }

/* ---- Input (terminal prompt row) ---- */
.tp-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--tp-line);
    background: #fff;
    align-items: flex-end;
}

.tp-prompt-sign {
    font-family: var(--tp-mono);
    color: #27c93f;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    padding-bottom: 10px;
    flex: 0 0 auto;
}

.tp-input {
    flex: 1 1 auto;
    resize: none;
    border: none;
    border-bottom: 1px solid var(--tp-line);
    background: transparent;
    padding: 6px 2px 8px;
    font-family: var(--tp-mono);
    font-size: 0.84rem;
    line-height: 1.4;
    max-height: 110px;
    color: var(--tp-ink);
    transition: border-color 0.15s ease;
}
.tp-input:focus {
    outline: none;
    border-color: var(--tp-accent);
}
.tp-input::placeholder { color: #9aa0aa; }

.tp-send {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid var(--tp-accent);
    border-radius: 6px;
    background: var(--tp-accent);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background 0.15s ease;
}
.tp-send:hover { background: color-mix(in srgb, var(--tp-accent) 85%, #000); }
.tp-send:disabled { background: #c7ccd6; border-color: #c7ccd6; cursor: not-allowed; }
.tp-send svg { width: 16px; height: 16px; }

/* ---- Recruiter link in panel footer ---- */
.tp-recruiter-link {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--tp-muted);
    font-family: var(--tp-mono);
    font-size: 0.66rem;
    padding: 0 14px 8px;
    cursor: pointer;
    text-align: center;
}
.tp-recruiter-link:hover { color: var(--tp-accent); }

.tp-footnote {
    padding: 0 14px 10px;
    background: #fff;
    font-family: var(--tp-mono);
    font-size: 0.64rem;
    color: var(--tp-muted);
    text-align: center;
}

/* ---- Embedded variant (About page) ---- */
.tp-agent--embedded {
    display: flex;
    flex-direction: column;
    height: 520px;
    max-height: 70vh;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    background: var(--tp-surface);
    font-family: var(--tp-mono);
    color: var(--tp-ink);
}
.tp-agent--embedded .tp-messages { background: var(--tp-canvas); }

/* ---- Turnstile mount (kept offscreen; invisible challenge) ---- */
.tp-turnstile {
    position: fixed;
    left: -9999px;
    top: 0;
}

/* ---- Glossary terms + hover tooltips ---- */
.tp-gloss {
    border-bottom: 1px dashed color-mix(in srgb, var(--tp-accent) 55%, transparent);
    cursor: help;
}
a.tp-gloss { color: var(--tp-accent); text-decoration: none; }
a.tp-gloss:hover { border-bottom-style: solid; }

.tp-tooltip {
    position: fixed;
    z-index: 9500;
    max-width: 260px;
    padding: 8px 10px;
    background: #f4ead6;
    color: #5a4a2f;
    border: 1px solid #ddcaa6;
    border-radius: 8px;
    font-family: var(--tp-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    box-shadow: var(--tp-shadow);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.tp-tooltip.tp-show { opacity: 1; }

/* ---- Mobile ---- */
@media (max-width: 560px) {
    .tp-panel {
        right: 10px;
        left: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        width: auto;
        height: min(80dvh, 640px);
        max-height: 80dvh;
    }
    .tp-launcher { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
    .tp-agent--embedded { height: 70dvh; }
}

/* iOS Safari zooms into any input under 16px on focus (and stays zoomed),
   which made the panel feel "zoomed in" on phones. */
@media (max-width: 768px) {
    .tp-input { font-size: 16px; }
}