/* =========================================================
   Portfolio — style.css
   ========================================================= */

:root {
  --bg: #f4f4ef;
  --surface: #ffffff;
  --ink: #1b1f1d;
  --ink-soft: #3a3f3c;
  --muted: #70756f;
  --line: #dcdcd3;
  --sage: #e3e6d9;
  --sage-deep: #d9ddcc;
  --lavender: #e5e4ee;
  --dark: #1c2320;
  --dark-line: #3a433f;
  --dark-muted: #a3aaa5;
  --lime: #d9f57a;
  --lime-text: #c9ef6a;
  --green: #4fae4a;
  --green-deep: #1f7a3a;

  --font-display: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 10px;
  --radius-lg: 16px;
  --container: 1200px;
  --gutter: clamp(20px, 4vw, 48px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; letter-spacing: -0.035em; line-height: 1.02; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }

.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }

.label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.small { font-size: 13px; }
.muted { color: var(--muted); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 3px; border-radius: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 22px;
  border-radius: 6px;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-dark { background: var(--dark); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-outline { border-color: var(--line); background: transparent; }
.btn-outline:hover { border-color: var(--ink); }
.btn-sm { padding: 10px 18px; font-size: 13px; }
.btn-lg { padding: 16px 26px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 244, 239, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  height: 72px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.brand-tag { font-size: 10px; }
.nav { display: flex; gap: 48px; font-size: 14px; }
.nav a { position: relative; }
.nav a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; width: 100%; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
.nav a:hover::after { transform: scaleX(1); }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
  padding-top: clamp(40px, 6vw, 56px);
  padding-bottom: clamp(48px, 6vw, 64px);
}
.status { display: flex; align-items: center; gap: 12px; font-size: 10px; margin-bottom: 28px; }
.hero-title { font-size: clamp(48px, 7.2vw, 96px); letter-spacing: -0.045em; line-height: 0.98; }
.hero-title span { display: block; }
.hero-lead { margin-top: 32px; font-size: clamp(17px, 1.6vw, 21px); font-weight: 500; letter-spacing: -0.01em; }
.hero-text { margin-top: 16px; max-width: 520px; font-size: 15px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero-tags { margin-top: 44px; font-size: 11px; }
.hero-tags span + span::before { content: " / "; }

/* ---------- Chat ---------- */
.chat-frame {
  background: var(--sage);
  border-radius: var(--radius-lg);
  padding: 12px 12px 18px;
}
.chat {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(27,31,29,.06);
  overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #ecece6;
}
.chat-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--green-deep); color: #e9ffd6; font-size: 18px; line-height: 1;
}
.chat-id { display: flex; flex-direction: column; flex: 1; line-height: 1.3; }
.chat-id strong { font-size: 14px; font-weight: 600; }
.chat-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.chat-status .dot { width: 5px; height: 5px; }
.chat-toggle {
  background: none; border: 0; cursor: pointer; font-size: 18px; color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px;
}
.chat-toggle:hover { background: var(--bg); }
.chat.is-collapsed .chat-body { display: none; }

.chat-body { padding: 16px 20px 18px; }
.chat-label { font-size: 9.5px; margin-bottom: 12px; }
.chat-messages {
  display: flex; flex-direction: column; gap: 10px;
  height: 280px; overflow-y: auto;
  padding-right: 4px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px; line-height: 1.5;
  white-space: pre-line;
  word-wrap: break-word;
  animation: msg-in .25s ease;
}
.msg-bot { align-self: flex-start; background: #f2f3ec; color: var(--ink-soft); }
.msg-user { align-self: flex-end; background: var(--dark); color: #fff; }
.msg-error { align-self: flex-start; background: #fbeeee; color: #8a2b2b; }
.msg-typing { display: inline-flex; gap: 4px; padding: 14px; }
.msg-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .4;
  animation: typing 1s infinite ease-in-out;
}
.msg-typing i:nth-child(2) { animation-delay: .15s; }
.msg-typing i:nth-child(3) { animation-delay: .3s; }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px;
  font-size: 12px; cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.chip:hover { border-color: var(--ink); background: var(--bg); }

.chat-form {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 6px 6px 14px;
  transition: border-color .2s ease;
}
.chat-form:focus-within { border-color: var(--ink); }
.chat-form input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 13px; padding: 6px 0; min-width: 0; }
.chat-send {
  width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 6px; cursor: pointer;
  background: var(--dark); color: var(--lime); font-size: 15px; font-weight: 600;
}
.chat-send:disabled { opacity: .5; cursor: not-allowed; }
.chat-caption { margin-top: 14px; padding-left: 8px; font-size: 11px; }

@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Toolkit ---------- */
.toolkit-top {
  display: flex; justify-content: space-between;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  font-size: 10px;
}
.toolkit-top a:hover { color: var(--ink); }
.toolkit-row {
  display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 24px;
  padding: 32px 0 16px;
}
.toolkit-row .label { font-size: 10px; }
.toolkit-list {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px 32px;
  font-family: var(--font-display); font-size: clamp(16px, 1.5vw, 20px); font-weight: 500; letter-spacing: -0.01em;
}

/* ---------- Sections ---------- */
.section { padding-top: clamp(64px, 8vw, 104px); padding-bottom: clamp(64px, 8vw, 104px); }
.section-title { font-size: clamp(32px, 3.8vw, 52px); margin-top: 18px; }
.section-text { margin-top: 18px; font-size: 14px; }

/* ---------- Projects ---------- */
.projects {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(20px, 2.5vw, 32px);
  margin-top: 48px;
}
.project { cursor: pointer; }
.project-visual {
  position: relative;
  aspect-ratio: 16 / 10.4;
  border-radius: 12px;
  padding: 18px 24px 22px;
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform .3s ease;
}
.project:hover .project-visual { transform: translateY(-3px); }
.project-visual.theme-sage { background: var(--sage); }
.project-visual.theme-lavender { background: var(--lavender); }
.project-shot {
  flex: 1; min-height: 0;
  margin-top: 22px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(27,31,29,.08);
}
.project-shot img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.pill {
  align-self: flex-start; position: relative; z-index: 1;
  background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 9.5px;
}
.mock {
  background: var(--surface); border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  margin-top: 22px;
  flex: 1;
  font-size: 11px;
  min-height: 0;
}

/* Pipeline mock */
.mock-pipeline { padding: 16px 16px; display: flex; flex-direction: column; }
.mock-row { display: flex; justify-content: space-between; align-items: center; }
.mock-app { font-weight: 600; font-size: 12px; }
.mock-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 9.5px; background: #eef5e4; color: #3e6b2d; padding: 4px 10px; border-radius: 999px; }
.mock-badge .dot { width: 5px; height: 5px; }
.mock-headline { font-size: clamp(13px, 1.25vw, 17px); font-weight: 500; margin-top: 18px; letter-spacing: -0.01em; }
.mock-sub { font-size: 9.5px; color: var(--muted); margin-top: 4px; }
.mock-steps { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 14px; }
.mock-step { flex: 1; background: #f4f4ef; border-radius: 6px; padding: 10px 12px; }
.mock-step b { display: block; font-weight: 500; font-size: 12px; margin-top: 4px; }
.mock-step small { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; }
.mock-step .num { font-size: 8.5px; color: var(--muted); }
.mock-arrow { color: var(--muted); }
.mock-caption { margin-top: 10px; font-size: 9px; position: relative; z-index: 1; }

/* Knowledge mock */
.mock-knowledge { display: grid; grid-template-columns: 34% 1fr; }
.mock-side { border-right: 1px solid #ecece6; padding: 16px 14px; display: flex; flex-direction: column; }
.mock-side .mock-app { font-size: 14px; margin-bottom: 14px; }
.mock-side .label { font-size: 8px; margin-bottom: 6px; }
.mock-side li { font-size: 9.5px; color: var(--muted); padding: 5px 0; }
.mock-side li::before { content: "↳ "; }
.mock-sources { margin-top: auto; background: #f4f4ef; border-radius: 999px; font-size: 9px; color: var(--muted); padding: 5px 10px; text-align: center; }
.mock-main { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mock-main .mock-headline { margin-top: 0; }
.mock-q { align-self: flex-end; background: var(--dark); color: #fff; font-size: 9.5px; padding: 7px 10px; border-radius: 5px; }
.mock-a { background: #f4f4ef; font-size: 9.5px; padding: 9px 10px; border-radius: 5px; color: var(--ink-soft); }
.mock-cite { display: inline-block; margin-top: 6px; background: #e9eadf; border-radius: 999px; padding: 3px 8px; font-size: 8.5px; color: var(--muted); }
.mock-input { margin-top: auto; font-size: 9.5px; color: var(--muted); border-top: 1px solid #ecece6; padding-top: 8px; }

/* Extract mock (document → fields) */
.mock-extract { display: grid; grid-template-columns: 38% 1fr; gap: 14px; padding: 14px; }
.mock-doc {
  background: #f7f7f2; border: 1px solid #ecece6; border-radius: 6px;
  padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.mock-doc-title { font-size: 9px; font-weight: 600; letter-spacing: .12em; color: var(--ink-soft); margin-bottom: 4px; }
.mock-doc i { display: block; height: 5px; width: 100%; border-radius: 3px; background: #e2e3da; }
.mock-doc-gap { flex: 1; min-height: 6px; }
.mock-doc-total { border-top: 1px solid #e2e3da; padding-top: 7px; display: flex; justify-content: flex-end; }
.mock-doc-total i { background: #cfd3c4; }
.mock-fields { display: flex; flex-direction: column; min-width: 0; }
.mock-fields dl { margin: 10px 0 0; display: grid; gap: 0; }
.mock-fields dl div { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f0f0ea; font-size: 9.5px; }
.mock-fields dt { color: var(--muted); }
.mock-fields dd { margin: 0; font-weight: 500; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mock-btn { margin-top: auto; align-self: flex-start; background: var(--dark); color: #fff; font-size: 9.5px; padding: 6px 10px; border-radius: 5px; }

.project-info {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 4px 8px;
  margin-top: 24px;
}
.project-num { font-size: 11px; color: var(--muted); padding-top: 6px; }
.project-title { font-size: clamp(18px, 1.6vw, 22px); letter-spacing: -0.02em; line-height: 1.3; }
.project-summary { grid-column: 2 / 4; font-size: 13px; color: var(--muted); margin-top: 8px; max-width: 520px; }
.tags { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.tag { background: #e8e9e1; border-radius: 999px; padding: 4px 12px; font-size: 10.5px; color: var(--ink-soft); }
.projects-note { margin-top: 48px; font-size: 10px; }
.projects-note:empty { display: none; }

/* ---------- Services (dark) ---------- */
.section-dark { background: var(--dark); color: #f3f4ef; }
.section-dark .label { color: var(--dark-muted); }
.label-lime { color: var(--lime-text) !important; }
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(24px, 3vw, 40px); margin-top: 56px; }
.service { border-top: 1px solid var(--dark-line); padding-top: 18px; display: flex; flex-direction: column; }
.service-top { display: flex; justify-content: space-between; align-items: center; }
.service-top .num { font-size: 11px; color: var(--dark-muted); }
.service h3 { font-size: clamp(18px, 1.6vw, 22px); letter-spacing: -0.02em; margin-top: 26px; line-height: 1.25; }
.service p { font-size: 13px; color: var(--dark-muted); margin-top: 16px; max-width: 340px; }
.service-tags { margin-top: 28px; font-size: 11px; color: var(--lime-text); }

/* ---------- Process ---------- */
.process-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.process-head .small { max-width: 50%; padding-bottom: 8px; width: 50%; }
.process { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(20px, 2.5vw, 32px); margin-top: 56px; counter-reset: step; }
.process li { border-top: 1px solid var(--line); padding-top: 18px; }
.process .num { font-size: 11px; color: var(--muted); }
.process h3 { font-size: 20px; letter-spacing: -0.02em; margin-top: 14px; }
.process p { font-size: 13px; color: var(--muted); margin-top: 16px; max-width: 240px; }

/* ---------- About ---------- */
.about { border-top: 1px solid var(--line); }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); margin-top: 28px; }
.about-title { font-size: clamp(40px, 5vw, 68px); letter-spacing: -0.04em; }
.about-title span { display: block; }
.about-copy { display: flex; flex-direction: column; gap: 22px; padding-top: 6px; }
.about-lead { font-size: clamp(17px, 1.6vw, 21px); font-weight: 500; letter-spacing: -0.01em; line-height: 1.45; }
.about-copy .muted { font-size: 14px; max-width: 480px; }
.about-copy .label { font-size: 10px; }

/* ---------- CTA (lime) ---------- */
.section-lime { background: var(--lime); }
.cta { padding-top: clamp(56px, 7vw, 88px); padding-bottom: clamp(56px, 7vw, 80px); }
.label-ink { color: var(--ink) !important; }
.cta-grid { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: end; margin-top: 28px; }
.cta-title { font-size: clamp(40px, 5.6vw, 76px); letter-spacing: -0.04em; }
.cta-title span { display: block; }
.cta-text { margin-top: 28px; font-size: 15px; }
.cta-contact { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-top: 28px; }
.cta-email, .cta-copy { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.cta-copy { font-size: 12px; border-bottom: 1px solid currentColor; line-height: 1.4; }
.cta-copy:hover { opacity: .7; }
.cta-buttons { display: grid; gap: 12px; width: 280px; max-width: 100%; }
.btn-outline-ink { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-outline-ink:hover { background: rgba(27, 31, 29, 0.07); }
.cta-email { display: inline-block; font-size: clamp(17px, 1.6vw, 20px); font-weight: 500; border-bottom: 1px solid transparent; }
.cta-email:hover { border-color: var(--ink); }
.cta-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 40px; padding-bottom: 8px; }
.cta-ask { font-size: 12px; border-bottom: 1px solid transparent; }
.cta-ask:hover { border-color: var(--ink); }

/* ---------- Footer ---------- */
.footer-inner { display: flex; justify-content: center; align-items: center; padding-top: 28px; padding-bottom: 28px; font-size: 12px; text-align: center; }

/* ---------- Project dialog ---------- */
.project-dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  border: 0; border-radius: var(--radius-lg);
  padding: 40px clamp(24px, 4vw, 44px);
  background: var(--bg); color: var(--ink);
  box-shadow: 0 24px 60px rgba(0,0,0,.2);
}
.project-dialog::backdrop { background: rgba(28, 35, 32, 0.55); backdrop-filter: blur(3px); }
.project-dialog[open] { animation: msg-in .25s ease; }
.dialog-close {
  position: absolute; top: 14px; right: 16px;
  width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent;
  font-size: 24px; cursor: pointer;
}
.dialog-close:hover { background: var(--sage); }
.dialog-shot {
  width: 100%; height: auto; max-height: 360px; object-fit: cover; object-position: center top;
  border-radius: 10px; margin-bottom: 24px;
  border: 1px solid var(--line);
}
.dialog-content h3 { font-size: clamp(26px, 3vw, 34px); margin-top: 12px; }
.dialog-content .lead { margin-top: 16px; font-size: 16px; }
.dialog-content .details { margin-top: 14px; color: var(--muted); font-size: 14px; }
.dialog-content ul { margin-top: 20px; display: grid; gap: 10px; }
.dialog-content li { font-size: 14px; padding-left: 22px; position: relative; }
.dialog-content li::before { content: "→"; position: absolute; left: 0; color: var(--green-deep); }
.dialog-content .tags { margin-top: 24px; }
.dialog-content .btn { margin-top: 28px; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .nav { gap: 32px; }
  .hero { grid-template-columns: 1fr; }
  .chat-frame { max-width: 560px; }
  .services { grid-template-columns: 1fr 1fr; }
  .process { grid-template-columns: 1fr 1fr; row-gap: 40px; }
}

@media (max-width: 760px) {
  .nav { display: none; }
  .brand-tag { display: none; }
  .projects { grid-template-columns: 1fr; }
  .project-visual { aspect-ratio: auto; min-height: 300px; }
  .services { grid-template-columns: 1fr; }
  .process-head .small { width: 100%; max-width: none; }
  .about-grid { grid-template-columns: 1fr; }
  .cta-grid { grid-template-columns: 1fr; }
  .cta-actions { gap: 20px; }
  .toolkit-row { grid-template-columns: 1fr; gap: 16px; }
  .toolkit-list { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .process { grid-template-columns: 1fr; }
  .mock-knowledge { grid-template-columns: 1fr; }
  .mock-side { display: none; }
  .mock-extract { grid-template-columns: 1fr; }
  .mock-doc { display: none; }
  .hero-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
