/* ============================================================
   Tilio · Conversational Homepage
   Chat-specific styles. Shared chrome (topbar/footer/tokens)
   lives in common.css.
   ============================================================ */

body {
    background:
        radial-gradient(ellipse 100% 55% at 50% 0%, rgba(74,142,212,0.05) 0%, transparent 55%),
        var(--bg);
    min-height: 100vh;
}

/* ============================================================
   CHAT COLUMN
   ============================================================ */
.chat {
    max-width: 760px;
    margin: 0 auto;
    padding: 6.5rem 1.5rem 3rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-spacer { flex: 1; }

.session-meta {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text4);
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: 0.04em;
}

/* ============================================================
   MESSAGES
   ============================================================ */
.msg {
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.75rem;
    opacity: 0;
    transform: translateY(10px);
}

.msg.in { animation: msgIn 0.4s ease forwards; }

@keyframes msgIn {
    to { opacity: 1; transform: translateY(0); }
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 600;
}

.avatar.user {
    background: var(--bubble-user);
    color: var(--accent-light);
    border: 1px solid var(--line);
}

.avatar.ai {
    background: var(--accent);
    color: var(--white);
}

.bubble-wrap { flex: 1; min-width: 0; }

.msg-name {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text4);
    margin-bottom: 0.35rem;
    letter-spacing: 0.04em;
}

.bubble {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
}

.msg.user {
    flex-direction: row-reverse;
}

.msg.user .bubble-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.msg.user .msg-name {
    text-align: right;
}

.msg.user .bubble {
    background: var(--bubble-user);
    border: 1px solid var(--line);
    padding: 0.8rem 1.05rem;
    border-radius: 12px 4px 12px 12px;
    display: inline-block;
    font-weight: 400;
    color: var(--text);
    max-width: 85%;
    text-align: left;
}

.msg.ai .bubble { font-weight: 300; }
.msg.ai .bubble strong { color: var(--accent-light); font-weight: 500; }
.msg.ai .bubble .lead {
    font-size: 1.06rem;
    color: var(--text);
    font-weight: 400;
    margin-bottom: 0.85rem;
}
.msg.ai .bubble p {
    margin-bottom: 0.7rem;
    color: var(--text2);
}
.msg.ai .bubble p:last-child { margin-bottom: 0; }

.msg.ai .bubble .hint {
    color: var(--text4);
    font-size: 0.85rem;
    font-style: italic;
    font-weight: 300;
}

/* terminal block cursor while "tilio" is composing */
.typing {
    display: inline-block;
    padding: 0.2rem 0;
    font-family: var(--mono);
    font-size: 0.95rem;
    color: var(--accent-light);
    animation: cursorblink 0.9s steps(2, start) infinite;
}

@keyframes cursorblink {
    50% { opacity: 0; }
}

/* ============================================================
   RESPONSE BLOCKS
   ============================================================ */
.resp-block {
    margin: 0.9rem 0;
    opacity: 0;
}
.resp-block.in { animation: msgIn 0.4s ease forwards; }
.resp-block:last-child { margin-bottom: 0; }

/* service grid (small chips) */
.svc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.svc-chip {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 0.75rem 0.9rem;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

button.svc-chip:hover,
button.svc-chip:focus-visible {
    background: var(--panel2);
    border-color: var(--accent-dim);
    transform: translateY(-1px);
}

button.svc-chip::after {
    content: ' →';
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.85rem;
}

button.svc-chip:hover::after,
button.svc-chip:focus-visible::after {
    opacity: 0.7;
}

.svc-chip .n {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--accent-dim);
}

.svc-chip b {
    display: block;
    color: var(--text);
    font-weight: 500;
    font-size: 0.88rem;
    margin-top: 0.15rem;
}

.svc-chip span.desc,
.svc-chip > span:not(.n) {
    color: var(--text3);
    font-size: 0.77rem;
    line-height: 1.45;
    display: block;
    margin-top: 0.1rem;
}

/* service list (full) */
.svc-list { list-style: none; }
.svc-list li { display: block; }

.svc-row {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--line-soft);
    padding: 0.75rem 0.5rem;
    display: flex;
    gap: 0.85rem;
    align-items: baseline;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    border-radius: 3px;
    transition: background 0.2s;
}

.svc-row:hover,
.svc-row:focus-visible {
    background: rgba(74, 142, 212, 0.06);
}

.svc-list li:last-child .svc-row { border-bottom: none; }

.svc-row .n {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--accent-dim);
    flex-shrink: 0;
}

.svc-row b {
    color: var(--text);
    font-weight: 500;
}

.svc-row .d {
    color: var(--text2);
    font-size: 0.88rem;
    font-weight: 300;
}

.svc-row::after {
    content: '→';
    color: var(--accent);
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    align-self: center;
}

.svc-row:hover::after,
.svc-row:focus-visible::after {
    opacity: 0.7;
    transform: translateX(2px);
}

/* scope card */
.scope-card {
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 1.15rem 1.3rem;
    margin: 0.6rem 0;
}

.scope-card .sc-head {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--accent-light);
    margin-bottom: 0.7rem;
    letter-spacing: 0.05em;
}

.scope-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    font-size: 0.86rem;
    border-bottom: 1px solid var(--line-soft);
}

.scope-row:last-of-type { border-bottom: none; }

.scope-row .lbl {
    color: var(--text3);
    font-family: var(--mono);
    font-size: 0.74rem;
}

.scope-row .v {
    color: var(--text);
    text-align: right;
}

.scope-row .v.hl {
    color: var(--accent-light);
    font-weight: 500;
}

.scope-foot {
    margin-top: 0.85rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.74rem;
    color: var(--text3);
}

.scope-foot .ok { color: var(--accent-light); }

/* pricing mini */
.price-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.price-mini .pm {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 0.85rem 0.95rem;
}

.price-mini .pm b {
    display: block;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.price-mini .pm span {
    color: var(--text3);
    font-size: 0.78rem;
    line-height: 1.5;
}

/* value cards */
.val-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.val-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 0.9rem 1rem;
}

.val-card b {
    display: block;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.val-card span {
    color: var(--text3);
    font-size: 0.8rem;
    line-height: 1.55;
}

/* check list */
.check-list { list-style: none; margin: 0.6rem 0; }

.check-list li {
    padding: 0.42rem 0 0.42rem 1.5rem;
    position: relative;
    color: var(--text2);
    font-size: 0.94rem;
    font-weight: 300;
}

.check-list li::before {
    content: '?';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-family: var(--mono);
    font-weight: 600;
}

/* link card */
.link-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.95rem 1.1rem;
    margin: 0.6rem 0;
    text-decoration: none;
    transition: border-color 0.25s, background 0.25s, transform 0.25s;
}

.link-card:hover {
    border-color: var(--accent-dim);
    background: var(--panel2);
    transform: translateY(-1px);
}

.link-card .lc-eyebrow {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.link-card .lc-title {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.link-card .lc-title::after {
    content: ' →';
    color: var(--accent);
}

/* contact action */
.contact-action { margin: 0.7rem 0; }

.contact-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--accent);
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.85rem 1.7rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.25s, transform 0.25s, box-shadow 0.25s;
}

.contact-cta:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(74, 142, 212, 0.25);
}

.contact-cta svg {
    width: 15px;
    height: 15px;
}

.contact-email {
    display: block;
    margin-top: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
    font-family: var(--mono);
}

.contact-email:hover { color: var(--accent-light); }

/* flow diagram */
.flow-mini { margin: 0.8rem 0; }

.flow-mini svg {
    width: 100%;
    max-width: 540px;
    height: auto;
    overflow: visible;
    display: block;
}

.col-label {
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    fill: var(--text3);
}

.src-node { animation: jitter 3.2s ease-in-out infinite; }
.src-node:nth-child(2) { animation-delay: 0.5s; }
.src-node:nth-child(3) { animation-delay: 0.9s; }
.src-node:nth-child(4) { animation-delay: 1.3s; }

@keyframes jitter {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(1px, -1.5px); }
    50% { transform: translate(-1px, 1px); }
    75% { transform: translate(0.5px, 1px); }
}

.particle { animation: flowp 2.8s linear infinite; }

@keyframes flowp {
    from { offset-distance: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    to { offset-distance: 100%; opacity: 0; }
}

.platform-core {
    animation: breathe 4s ease-in-out infinite;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes breathe {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

.out-bar {
    transform-origin: bottom;
    transform-box: fill-box;
    animation: riseb 3s ease-in-out infinite;
}

.out-bar:nth-child(2) { animation-delay: 0.3s; }
.out-bar:nth-child(3) { animation-delay: 0.6s; }

@keyframes riseb {
    0%, 100% { transform: scaleY(0.92); }
    50% { transform: scaleY(1); }
}

/* chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.4rem 0 0.5rem 3.65rem;
}

/* chips cascade in one by one (delay set per chip in JS via --chip-d);
   `translate` is used instead of `transform` so the hover transform
   isn't overridden by the animation fill */
.chips .chip {
    opacity: 0;
    translate: 0 8px;
}

.chips.in .chip {
    animation: chipIn 0.35s ease forwards;
    animation-delay: var(--chip-d, 0ms);
}

@keyframes chipIn {
    to { opacity: 1; translate: 0 0; }
}

.chip {
    font-family: var(--body);
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--accent-light);
    padding: 0.6rem 1rem;
    font-size: 0.86rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
    text-decoration: none;
    line-height: 1.2;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
}

.chip:hover {
    background: var(--panel2);
    border-color: var(--accent-dim);
    transform: translateY(-1px);
}

.chip.ext::after {
    content: ' ↗';
    opacity: 0.6;
    margin-left: 0.25rem;
}

.chip.soft { color: var(--text3); }
.chip.soft:hover { color: var(--text); }

/* replay */
.replay {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    z-index: 80;
    font-family: var(--mono);
    font-size: 0.72rem;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--text3);
    padding: 0.55rem 0.85rem;
    border-radius: 5px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, opacity 0.2s;
    opacity: 0;
    pointer-events: none;
}

.replay.in {
    opacity: 1;
    pointer-events: auto;
}

.replay:hover {
    color: var(--accent);
    border-color: var(--accent-dim);
}

/* ============================================================
   NOSCRIPT FALLBACK
   ============================================================ */
.ns-section {
    max-width: 760px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    border-bottom: 1px solid var(--line-soft);
}

.ns-section:first-of-type { padding-top: 7rem; }
.ns-section:last-of-type { border-bottom: none; }

.ns-hero h1 {
    font-family: var(--serif);
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    font-weight: 400;
    line-height: 1.15;
    color: var(--white);
    margin: 0.5rem 0 1.25rem;
}

.ns-hero h1 em {
    font-style: italic;
    color: var(--accent-light);
}

.ns-eyebrow {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent);
}

.ns-lead {
    font-size: 1.1rem;
    color: var(--text2);
    line-height: 1.75;
    max-width: 580px;
    margin-bottom: 1.5rem;
}

.ns-cta {
    display: inline-block;
    background: var(--accent);
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.85rem 1.7rem;
    border-radius: 4px;
    text-decoration: none;
    margin-top: 0.5rem;
}

.ns-section h2 {
    font-family: var(--serif);
    font-size: 1.8rem;
    color: var(--white);
    margin-bottom: 1rem;
    font-weight: 400;
}

.ns-section h3 {
    font-size: 1rem;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 0.35rem;
    margin-top: 1rem;
}

.ns-section p {
    color: var(--text2);
    margin-bottom: 0.85rem;
    line-height: 1.75;
}

.ns-list {
    padding-left: 1.25rem;
    color: var(--text2);
}

.ns-list li { margin-bottom: 1rem; line-height: 1.7; }

.ns-section a {
    color: var(--accent-light);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ns-section a:hover { color: var(--accent); }

/* ============================================================
   REDUCED MOTION (chat-specific overrides)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .msg, .resp-block, .chips { opacity: 1; transform: none; }
    .chips .chip { opacity: 1; translate: none; animation: none; }
}

/* ============================================================
   RESPONSIVE (chat-specific)
   ============================================================ */
@media (max-width: 768px) {
    .chat { padding-top: 6rem; padding-left: 1rem; padding-right: 1rem; }
    .chips { margin-left: 0; }
    .svc-grid,
    .val-grid,
    .price-mini { grid-template-columns: 1fr; }
    .replay { bottom: 0.8rem; right: 0.8rem; }
}

@media (max-width: 420px) {
    .msg { gap: 0.65rem; }
    .avatar { width: 26px; height: 26px; font-size: 0.62rem; }
}
