.button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.7em 1.3em;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    border: var(--border-width) solid transparent;
    cursor: pointer;
    transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease),
        border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.button:hover {
    transform: translateY(-1px);
}

.button--primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.button--primary:hover {
    filter: brightness(1.08);
}

.button--ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.button--ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: var(--border-width) solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* A small live/pulsing indicator — used for hero availability, project
   status, and the footer build line. Reads as a real status light, not
   decoration, so it always sits next to text that says what it means. */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    position: relative;
    flex-shrink: 0;
}

.status-dot::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    opacity: 0.55;
    animation: status-pulse 2.6s var(--ease) infinite;
}

.status-dot--sm {
    width: 6px;
    height: 6px;
}

@keyframes status-pulse {
    from {
        transform: scale(0.55);
        opacity: 0.55;
    }

    to {
        transform: scale(1.8);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot::after {
        animation: none;
        display: none;
    }
}

.hero__status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-6) 0 0;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
}

.status-line {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
    margin: 0;
}

.build-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
    margin: var(--space-2) 0 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: var(--space-3) 0 var(--space-4);
}

.tag {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
    border: var(--border-width) solid var(--border);
    border-radius: 6px;
    padding: 0.15em 0.6em;
}

.tag--challenge {
    display: inline-block;
    color: var(--accent);
    background: var(--accent-tint);
    border-color: transparent;
    font-weight: 600;
    margin: 0;
}

.project-card {
    background: var(--bg-elevated);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.project-card--concept {
    background: transparent;
    box-shadow: none;
    border-style: dashed;
}

.project-card__body {
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.project-card__meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.project-card__stack {
    margin: 0;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--text-muted);
}

.project-card h3 {
    margin-bottom: var(--space-2);
}

.project-card__summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    margin-bottom: 0;
}

.project-card__link {
    margin-top: auto;
    padding-top: var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--step--1);
    font-weight: 600;
    text-decoration: none;
}

/* A quiet inline breadcrumb of processing steps — deliberately not a row of
   chips: it's a caption, not a feature, so it should read like one. */
.flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
    list-style: none;
    padding: 0;
    margin: var(--space-3) 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.flow__step {
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.flow__arrow {
    color: var(--border);
}

.case-study__image {
    display: block;
    max-width: 100%;
    height: auto;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    margin: var(--space-4) 0;
}

.case-study__gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: var(--space-5);
    margin-top: var(--space-4);
}

.case-study__gallery figure {
    margin: 0;
}

.case-study__gallery img {
    display: block;
    width: 100%;
    height: auto;
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
}

.case-study__gallery figcaption {
    margin-top: var(--space-2);
    font-size: var(--step--1);
    color: var(--text-muted);
}

.callout {
    background: var(--accent-tint);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: var(--space-5);
}

.learnings {
    background: var(--bg-elevated);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
}

.cv__header {
    border-bottom: var(--border-width) solid var(--border);
    padding-bottom: var(--space-5);
    margin-bottom: var(--space-6);
}

.cv__subtitle {
    color: var(--text-muted);
    font-size: var(--step-0);
}

.cv__contact {
    font-family: var(--font-mono);
    font-size: var(--step--1);
}

.cv-project-list {
    padding-left: 1.1em;
}

.cv-project-list li {
    margin-bottom: var(--space-2);
}

/* --- Signature element ---------------------------------------------------
   Demonstrates the actual engineering thesis (turning uncertain AI output
   into a validated, typed result — see Review Analyzer) instead of an
   abstract stat or a generic terminal screenshot. Animates once on load;
   final state is reached either way via animation-fill-mode. */
.verify-card {
    background: var(--bg-elevated);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.verify-card__label {
    margin: 0 0 var(--space-4);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.verify-card__endpoint {
    margin: 0 0 var(--space-3);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
    animation: verify-in 450ms var(--ease) both;
}

.verify-card__method {
    color: var(--accent);
    margin-right: 0.4em;
}

.verify-card__line {
    margin: 0 0 var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    font-family: var(--font-mono);
}

.verify-card__line--raw {
    background: color-mix(in srgb, var(--text) 5%, transparent);
    color: var(--text-muted);
    animation: verify-in 450ms var(--ease) both;
    animation-delay: 400ms;
}

.verify-card__arrow {
    margin: var(--space-2) 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    animation: verify-in 450ms var(--ease) both;
    animation-delay: 900ms;
}

.verify-card__line--resolved {
    background: var(--accent-tint);
    color: var(--text);
    border: var(--border-width) solid color-mix(in srgb, var(--accent) 35%, transparent);
    animation: verify-in 450ms var(--ease) both;
    animation-delay: 1250ms;
}

.verify-card__status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    color: var(--accent);
    font-weight: 600;
    animation: verify-in 450ms var(--ease) both;
    animation-delay: 1700ms;
}

.verify-card__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.7em;
}

@keyframes verify-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .verify-card__endpoint,
    .verify-card__line--raw,
    .verify-card__arrow,
    .verify-card__line--resolved,
    .verify-card__status {
        animation: none;
    }
}

/* --- Chat widget ----------------------------------------------------------
   A working version of what the hero card only demonstrates: a real
   request/response cycle against Groq, grounded in this site's own content.
   Always present, bottom-right, on every page (see fragments :: chatWidget). */
.chat-widget {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-5);
    z-index: 40;
}

.chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--accent-contrast);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform var(--duration) var(--ease);
}

.chat-toggle:hover {
    transform: scale(1.05);
}

.chat-toggle__icon {
    display: flex;
}

.chat-toggle__icon--close {
    display: none;
}

.chat-toggle[aria-expanded="true"] .chat-toggle__icon--chat {
    display: none;
}

.chat-toggle[aria-expanded="true"] .chat-toggle__icon--close {
    display: flex;
}

.chat-toggle__dot {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    background: var(--accent-contrast);
}

.chat-toggle__dot::after {
    border-color: var(--accent-contrast);
}

.chat-toggle[aria-expanded="true"] .chat-toggle__dot {
    display: none;
}

.chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + var(--space-3));
    width: min(24rem, calc(100vw - 2 * var(--space-5)));
    max-height: min(32rem, calc(100vh - 8rem));
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border: var(--border-width) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-5);
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.chat-panel.is-open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .chat-panel {
        transition: none;
    }

    .chat-toggle:hover {
        transform: none;
    }
}

.chat-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.chat-panel__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
}

.chat-panel__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 50%;
    border: var(--border-width) solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.chat-panel__close:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.chat__log {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 18rem;
    overflow-y: auto;
    margin-bottom: var(--space-4);
}

.chat__message {
    max-width: 85%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    font-size: var(--step--1);
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat__message--user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-contrast);
}

.chat__message--assistant {
    align-self: flex-start;
    background: color-mix(in srgb, var(--text) 5%, transparent);
    color: var(--text);
}

.chat__message--error {
    align-self: flex-start;
    max-width: 100%;
    background: transparent;
    border: var(--border-width) dashed var(--border);
    color: var(--text-muted);
}

.chat__form {
    display: flex;
    gap: var(--space-3);
}

.chat__input {
    flex: 1;
    min-width: 0;
    padding: 0.7em 1em;
    border-radius: var(--radius-sm);
    border: var(--border-width) solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--step--1);
}

.chat__input:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 1px;
}

.chat__input:disabled {
    opacity: 0.6;
}

.chat__hint {
    margin: var(--space-3) 0 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.chat__typing {
    display: inline-flex;
    gap: 0.3em;
    padding: 0.2em 0;
}

.chat__typing span {
    width: 0.4em;
    height: 0.4em;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chat-typing 1s ease-in-out infinite;
}

.chat__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .chat__typing span {
        animation: none;
        opacity: 0.6;
    }
}
