/* Full-page chat: an alternative interface to the portfolio (uses tokens and fonts from site.css) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body.chat { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
body.chat > *:not(.particles) { position: relative; z-index: 1; }

/* Top bar */
.chat-top { display: flex; justify-content: space-between; align-items: center; padding: 1.4rem 2rem 1rem; }
.chat-back { font-family: var(--f-menu); font-size: .8889rem; letter-spacing: .0278rem; color: var(--text); text-decoration: none; }
.chat-back span { display: inline-block; padding-bottom: .4rem; border-bottom: 1px solid var(--text); transition: border-width .8s ease-out, color .2s ease; }
.chat-back:hover span { border-bottom-width: 4px; }
.chat-reset { font: inherit; font-family: var(--f-menu); font-size: .85rem; letter-spacing: .05em; color: var(--muted); background: none; border: 0; cursor: pointer; padding: .3rem 0; }
.chat-reset:hover { color: var(--link); }

/* Conversation area */
.chat-main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 1.5rem; scroll-padding-top: 1rem; }
.chat-log, .chat-intro, .chat-dock > * { max-width: 760px; margin-left: auto; margin-right: auto; }

/* Empty state */
.chat-intro { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 2rem 0 1rem; }
.chat-intro h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; }
.chat-intro h1 span { color: var(--link); }
.chat-intro p { color: var(--muted); margin-top: 1rem; max-width: 34rem; }
body:not(.is-empty) .chat-intro { display: none; }

/* Messages */
.chat-log { padding: 1rem 0 2rem; display: flex; flex-direction: column; gap: 1.6rem; }
.msg { animation: msg-in .35s ease both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; max-width: 80%; background: var(--surface); border: 1px solid var(--line); padding: .7rem 1rem; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.msg.bot { display: grid; grid-template-columns: 1.6rem 1fr; gap: .8rem; }
.msg.bot .who { width: 1.6rem; height: 1.6rem; margin-top: .1rem; }
.msg.bot .who svg { display: block; width: 100%; height: 100%; }
.msg.bot .content { min-width: 0; display: flex; flex-direction: column; gap: .9rem; }
.msg.bot .content > * { animation: msg-in .4s ease both; }
.msg.bot p { line-height: 1.65; }
.msg.bot h3 { font-size: 1.15rem; margin-top: .3rem; }
.msg.bot a:not(.btn):not(.card) { color: var(--link); }
.msg.bot strong { font-family: var(--f-head); font-weight: 600; font-size: 1.05em; }

.list { list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.list li { padding-left: 1.3rem; position: relative; line-height: 1.55; }
.list li::before { content: "→"; position: absolute; left: 0; color: var(--link); }

.jobs-c { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.jobs-c div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.jobs-c b { font-family: var(--f-head); font-weight: 600; font-size: 1rem; }
.jobs-c span { grid-column: 1; color: var(--muted); }
.jobs-c small { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); align-self: center; white-space: nowrap; }

.steps-c { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .8rem; counter-reset: s; }
.steps-c div { border-top: 2px solid var(--c, var(--link)); padding-top: .6rem; }
.steps-c b { display: block; font-family: var(--f-head); font-weight: 600; font-size: 1rem; margin-bottom: .3rem; }
.steps-c b::before { counter-increment: s; content: "0" counter(s) " "; color: var(--muted); font-family: var(--f-body); font-weight: 400; font-size: .75rem; }
.steps-c p { font-size: .8rem; color: var(--muted); line-height: 1.5; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.card { display: flex; flex-direction: column; text-decoration: none; border: 1px solid var(--line); background: rgba(29, 31, 37, .7); transition: border-color .25s ease; }
.card:hover { border-color: var(--link); }
.card .thumb { aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.card:hover .thumb img { transform: scale(1.03); }
.card .txt { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .35rem; }
.card b { font-family: var(--f-head); font-weight: 500; font-size: 1rem; line-height: 1.3; }
.card small { color: var(--muted); font-size: .75rem; }
.card small i { font-style: normal; color: var(--link); }
.card.pdf .thumb { display: grid; place-items: center; font-size: 2.4rem; aspect-ratio: 16 / 7; }

.actions { display: flex; flex-wrap: wrap; gap: .8rem; }
.actions .btn { font-size: .85rem; padding: .65rem 1rem; }

/* Typing indicator */
.typing { display: flex; gap: .3rem; padding: .55rem 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* Dock: suggestions + input */
.chat-dock { padding: .6rem 1.5rem calc(.9rem + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(29, 31, 37, 0), var(--bg) 1.2rem); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .7rem; }
.chips.inline { margin: 0; }
.chip { font: inherit; font-size: .78rem; color: var(--text); background: rgba(29, 31, 37, .8); border: 1px solid var(--line); padding: .45rem .75rem; cursor: pointer; transition: border-color .2s ease, color .2s ease; }
.chip:hover, .chip:focus-visible { border-color: var(--link); color: var(--link); outline: none; }
.composer { display: flex; align-items: flex-end; gap: .6rem; background: var(--surface); border: 1px solid var(--line); padding: .55rem .55rem .55rem 1rem; transition: border-color .2s ease; }
.composer:focus-within { border-color: rgba(255, 255, 255, .45); }
.composer textarea { flex: 1; resize: none; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: .95rem; line-height: 1.5; padding: .45rem 0; max-height: 9rem; }
.composer textarea::placeholder { color: var(--muted); }
.composer button { flex: none; width: 2.5rem; height: 2.5rem; display: grid; place-items: center; background: var(--link); color: var(--bg); border: 0; cursor: pointer; transition: opacity .2s ease; }
.composer button:disabled { opacity: .3; cursor: default; }
.chat-note { font-size: .7rem; color: var(--muted); margin-top: .55rem; text-align: center; }

@media (max-width: 640px) {
  .chat-top { padding: 1rem 1rem .6rem; }
  .chat-main { padding: 0 1rem; }
  .chat-dock { padding-left: 1rem; padding-right: 1rem; }
  .cards { grid-template-columns: 1fr; }
  .msg.bot { grid-template-columns: 1fr; gap: .4rem; }
  .msg.user { max-width: 90%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-right: -1rem; padding-right: 1rem; scrollbar-width: none; }
  .chip { flex: none; }
  .chips.inline { flex-wrap: wrap; overflow: visible; margin-right: 0; padding-right: 0; }
  .composer textarea { font-size: 16px; } /* avoid iOS zoom */
}
/* Slide transitions with the homepage */
body.swipe-down .chat-main, body.swipe-down .chat-dock { transform: translateY(55vh); opacity: 0; transition: transform .7s cubic-bezier(.65, 0, .35, 1), opacity .55s ease .1s; }
body.swipe-down .chat-top { opacity: 0; transition: opacity .35s ease; }
html.enter-from-below body > * { animation: none; }
html.enter-from-below .chat-main, html.enter-from-below .chat-dock { animation: from-below .75s cubic-bezier(.22, 1, .36, 1) backwards; }
html.enter-from-below .chat-top { animation: page-in .5s ease .35s backwards; }
@keyframes from-below { from { transform: translateY(45vh); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  body.swipe-down .chat-main, body.swipe-down .chat-dock { transform: none; }
  html.enter-from-below .chat-main, html.enter-from-below .chat-dock { animation: none; }
  .msg, .msg.bot .content > *, .typing i { animation: none; }
}
