/* ============================================
   Components — ledger, skills, projects,
   contact, chat popup (intercom-style),
   tooltips, palette, toast
   ============================================ */

/* ---- Now list ---- */
.now-list {
    list-style: none;
    max-width: 40em;
}
.now-list li {
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
    padding: 0.55rem 0.4rem;
    border-bottom: 1px solid var(--rule);
    font-weight: 460;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.now-list li::before {
    content: '→';
    color: var(--accent-ink);
    font-family: var(--font-mono);
    transition: color 0.2s var(--ease), text-shadow 0.2s var(--ease);
}
.now-list li:hover {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--line, var(--accent)) 9%, transparent), transparent 65%);
}
.now-list li:hover::before {
    color: var(--line, var(--accent));
    text-shadow: 0 0 9px var(--line, var(--accent)), 0 0 2px var(--line, var(--accent));
}

/* ---- Work ledger ---- */
/* ledger row: company | role + detail | dates (ambrosino-style table) */
.entry {
    display: grid;
    grid-template-columns: 8.5rem 1fr auto;
    gap: 0.5rem 2rem;
    padding: 1.3rem 0;
    border-bottom: 1px solid var(--rule);
}
.entry:first-child { padding-top: 0; }
.entry .date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--fg-faint);
    padding-top: 0.35em;
    white-space: nowrap;
    text-align: right;
}
.entry h3 {
    font-size: 1.05rem;
    font-weight: 700;
    font-stretch: 108%;
    line-height: 1.3;
    margin-bottom: 0.2rem;
}
.entry .company {
    font-size: 0.85rem;
    font-weight: 550;
    color: var(--fg-dim);
    padding-top: 0.3em;
}
.entry .role-sum {
    color: var(--fg);
    font-size: 0.95rem;
    font-weight: 540;
    margin-bottom: 0.6rem;
    max-width: 40em;
}
.entry ul {
    list-style: none;
    color: var(--fg-dim);
    font-size: 0.92rem;
    font-weight: 440;
}
.entry ul li {
    padding-left: 1.1em;
    position: relative;
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.entry ul li + li { margin-top: 0.3rem; }
.entry ul li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: var(--fg-faint);
    transition: color 0.2s var(--ease), text-shadow 0.2s var(--ease);
}
/* hover: the marker lights up like a server LED in the unit's cable color */
.entry ul li:hover {
    color: var(--fg);
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--line, var(--accent)) 8%, transparent), transparent 65%);
}
.entry ul li:hover::before {
    color: var(--line, var(--accent));
    text-shadow: 0 0 9px var(--line, var(--accent)), 0 0 2px var(--line, var(--accent));
}

@media (max-width: 860px) {
    .entry { grid-template-columns: 1fr; gap: 0.15rem 0; padding: 1.1rem 0; }
    .entry .date { padding-top: 0; text-align: left; order: -1; }
    .entry .company { padding-top: 0; }
    .entry .entry-detail { margin-top: 0.35rem; }
}

/* ---- Skills ---- */
.skill-row {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 2rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--rule);
    align-items: baseline;
}
.skill-row:first-child { padding-top: 0; }
.skill-row { transition: background 0.2s var(--ease); }
.skill-row dt {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-ink);
    transition: text-shadow 0.2s var(--ease);
}
.skill-row dd {
    color: var(--fg-dim);
    font-size: 0.95rem;
    font-weight: 470;
    transition: color 0.2s var(--ease);
}
.skill-row:hover {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--line, var(--accent)) 7%, transparent), transparent 65%);
}
.skill-row:hover dt { text-shadow: 0 0 9px var(--line, var(--accent)); }
.skill-row:hover dd { color: var(--fg); }
@media (max-width: 560px) {
    .skill-row { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* ---- Project cards ---- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
}
.card {
    background: var(--bg);
    padding: 1.25rem 1.35rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: background 0.2s var(--ease);
}
.card:hover { background: var(--bg-elev); }
.card--featured {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--line, var(--accent)) 12%, var(--bg)),
        var(--bg) 62%);
    box-shadow: inset 3px 0 0 var(--line, var(--accent));
}
.card--featured:hover {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--line, var(--accent)) 18%, var(--bg-elev)),
        var(--bg-elev) 62%);
}
/* odd card count: let the last card fill the row instead of leaving a dead cell */
.card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.card-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}
.card h3 { font-size: 0.98rem; font-weight: 700; font-stretch: 108%; }
.card p { color: var(--fg-dim); font-size: 0.88rem; font-weight: 440; }
.card .card-link,
.card .card-status {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.card .card-link { text-decoration: none; color: var(--accent-ink); }
.card .card-link:hover { text-decoration: underline; }
.card .card-status { color: var(--fg-faint); }

/* ---- Contact ---- */
.contact-big {
    font-size: clamp(1.4rem, 4.2vw, 2.4rem);
    font-weight: 800;
    font-stretch: 114%;
    text-transform: uppercase;
    line-height: 1.15;
    max-width: 22em;
}
.contact-big a { text-decoration-thickness: 2px; }
.contact-note {
    margin-top: 0.9rem;
    color: var(--fg-dim);
    font-size: 0.95rem;
    font-weight: 450;
    max-width: 38em;
}
.contact-row {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    border: 1px solid var(--rule-strong);
    width: fit-content;
}
.contact-row li + li { border-left: 1px solid var(--rule-strong); }
.contact-row a {
    display: block;
    padding: 0.55rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--fg-dim);
}
.contact-row a:hover { background: var(--fg); color: var(--bg); }

/* ---- Chat: intercom-style popup ---- */
.chat-launcher {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 900;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--rule-strong);
    background: var(--bg-inset);
    cursor: pointer;
    padding: 0;
    box-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.03);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 44px -12px rgba(0, 0, 0, 0.9), 0 0 14px var(--glow); }
.chat-launcher img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}
.chat-launcher .ping {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
    animation: pulse 2.4s ease-in-out infinite;
}

.chat-pop {
    position: fixed;
    right: 1.25rem;
    bottom: calc(1.25rem + 56px + 0.9rem);
    z-index: 901;
    width: min(376px, calc(100vw - 2rem));
    height: min(560px, 72vh);
    display: flex;
    flex-direction: column;
    background: var(--bg-elev);
    border: 1px solid var(--rule-strong);
    border-radius: 14px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.03);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.chat-pop.open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--rule);
    background: var(--bg-inset);
}
.chat-head img { width: 34px; height: 34px; border-radius: 50%; }
.chat-head .chat-title { font-size: 0.85rem; font-weight: 700; line-height: 1.2; }
.chat-head .chat-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-ink);
}
.chat-close {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--fg-faint);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.3rem;
}
.chat-close:hover { color: var(--fg); }

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.msg { max-width: 88%; font-size: 0.88rem; }
.msg.hidden { display: none; }
.msg.user {
    align-self: flex-end;
    background: var(--accent);
    color: #0c130e;
    font-weight: 520;
    padding: 0.55rem 0.85rem;
    border-radius: 13px 13px 3px 13px;
}
.msg.bot {
    align-self: flex-start;
    background: var(--bg-inset);
    border: 1px solid var(--rule);
    padding: 0.7rem 0.9rem;
    border-radius: 13px 13px 13px 3px;
    color: var(--fg-dim);
    font-weight: 440;
}
.msg.bot p + p { margin-top: 0.55rem; }
.msg.bot strong { color: var(--fg); font-weight: 640; }
.msg.bot a { color: var(--accent-ink); }
.msg.sys {
    align-self: center;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.msg .intro-name { color: var(--fg); font-weight: 700; }
.msg .now-list { max-width: none; }
.msg .now-list li { border-bottom: none; padding: 0.15rem 0; }

.msg.typing {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 0.75rem 0.9rem;
}
.msg.typing i {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--fg-faint);
    animation: blink-dot 1.2s infinite;
}
.msg.typing i:nth-child(2) { animation-delay: 0.2s; }
.msg.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink-dot { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.chat-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.75rem 0.9rem 0.85rem;
    border-top: 1px solid var(--rule);
    background: var(--bg-inset);
}
.chat-quick button {
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--fg-dim);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    transition: color 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.chat-quick button:hover {
    color: var(--accent-ink);
    border-color: var(--accent-ink);
    background: rgba(47, 220, 110, 0.06);
}

/* ---- Tooltips ---- */
.tooltip {
    position: relative;
    cursor: help;
    text-decoration: underline dotted var(--fg-faint);
    text-underline-offset: 0.2em;
}
.tooltip .tooltip-text {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--bg);
    font-size: 0.75rem;
    font-weight: 480;
    line-height: 1.4;
    padding: 0.5rem 0.7rem;
    width: max-content;
    max-width: 240px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s var(--ease);
    z-index: 50;
}
.tooltip:hover .tooltip-text,
.tooltip:focus .tooltip-text,
.tooltip.active .tooltip-text { opacity: 1; visibility: visible; }

/* ---- Command palette ---- */
.palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 9, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 14vh 1rem 0;
}
.palette-overlay[hidden] { display: none; }
.palette {
    width: min(560px, 100%);
    background: var(--bg-elev);
    border: 1px solid var(--rule-strong);
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.4);
}
.palette-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--rule);
}
.palette-sigil { color: var(--accent-ink); font-family: var(--font-mono); }
.palette-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    outline: none;
}
.palette-input::placeholder { color: var(--fg-faint); }
.palette-list { list-style: none; max-height: 320px; overflow-y: auto; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.palette-item[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.palette-item .pi-icon { font-family: var(--font-mono); width: 1.2em; text-align: center; }
.palette-item .pi-hint {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    opacity: 0.55;
}
.palette-empty {
    padding: 1rem;
    color: var(--fg-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.palette-foot {
    display: flex;
    gap: 1.25rem;
    padding: 0.55rem 1rem;
    border-top: 1px solid var(--rule);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.palette-foot kbd {
    font-family: inherit;
    border: 1px solid var(--rule-strong);
    padding: 0 0.3em;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translate(-50%, calc(100% + 2.5rem));
    background: var(--fg);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.65rem 1.1rem;
    z-index: 1500;
    visibility: hidden;
    transition: transform 0.3s var(--ease), visibility 0.3s;
}
.toast.visible { transform: translate(-50%, 0); visibility: visible; }
