/* ============================================================
   iKitchen Cabinetry — Design Assistant widget
   Built to the locked brand system in ikitchen.css:
   Ink · Slate · Brass · Bone · Paper. Square corners. No shadows.
   Depth comes from hairlines and the ink field, never from a shadow.
   ============================================================ */

.ik-ai {
  /* Fall back to literals so the widget still looks right if it is ever
     dropped onto a page that does not load ikitchen.css. */
  --ai-ink: var(--ink, #1d2129);
  --ai-slate: var(--slate, #3f4652);
  --ai-brass: var(--brass, #b98a4b);
  --ai-deep-brass: var(--deep-brass, #8a6b39);
  --ai-bone: var(--bone, #f0ece5);
  --ai-paper: var(--paper, #faf8f5);
  --ai-muted: var(--muted, #5c6472);
  --ai-hair: var(--hair, #e4e1dc);
  --ai-sans: var(--sans, 'Archivo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif);
  --ai-serif: var(--serif, 'Instrument Serif', Georgia, serif);
  --ai-mono: var(--mono, 'IBM Plex Mono', ui-monospace, Menlo, monospace);
  --ai-panel-w: 420px;
  --ai-z: 2147483000;
  font-family: var(--ai-sans);
}

.ik-ai *, .ik-ai *::before, .ik-ai *::after { box-sizing: border-box; }

/* ---------------------------------------------------------- launcher */

.ik-ai-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--ai-z);
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  padding: .875rem 1.125rem;
  border: 1px solid var(--ai-ink);
  border-radius: 0;
  background: var(--ai-ink);
  color: var(--ai-paper);
  font-family: var(--ai-sans);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.ik-ai-launcher:hover,
.ik-ai-launcher:focus-visible {
  background: var(--ai-brass);
  border-color: var(--ai-brass);
  color: var(--ai-ink);
}
.ik-ai-launcher:focus-visible { outline: 2px solid var(--ai-brass); outline-offset: 3px; }
.ik-ai-launcher[hidden] { display: none; }
.ik-ai-launcher .ik-ai-spark { width: 15px; height: 15px; flex: none; }

@media (max-width: 640px) {
  .ik-ai-launcher {
    right: 16px;
    bottom: 16px;
    padding: 0;
    /* 44x44 is the minimum comfortable tap target; the label is dropped so the
       icon-only button stays square rather than becoming a thin pill. */
    width: 48px;
    height: 48px;
    justify-content: center;
    gap: 0;
  }
  .ik-ai-launcher .ik-ai-launcher-label { display: none; }
  .ik-ai-launcher .ik-ai-spark { width: 19px; height: 19px; }
}

/* ---------------------------------------------------------- panel */

.ik-ai-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--ai-z);
  width: var(--ai-panel-w);
  max-width: calc(100vw - 32px);
  height: min(680px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: var(--ai-paper);
  border: 1px solid var(--ai-ink);
  border-radius: 0;
}
.ik-ai-panel[hidden] { display: none; }

@media (max-width: 640px) {
  .ik-ai-panel {
    right: 0; bottom: 0; left: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
}

/* header */

.ik-ai-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .875rem 1rem .875rem 1.125rem;
  background: var(--ai-ink);
  color: var(--ai-paper);
}
.ik-ai-head h2 {
  margin: 0;
  font-family: var(--ai-serif);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.2;
}
.ik-ai-head p {
  margin: .125rem 0 0;
  font-family: var(--ai-mono);
  font-size: .625rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ai-brass);
}
.ik-ai-close {
  flex: none;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: none;
  border: 1px solid rgba(255,255,255,.22);
  color: var(--ai-paper);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 0;
}
.ik-ai-close:hover { border-color: var(--ai-brass); color: var(--ai-brass); }
.ik-ai-close:focus-visible { outline: 2px solid var(--ai-brass); outline-offset: 2px; }

/* log */

.ik-ai-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ik-ai-msg { font-size: .9375rem; line-height: 1.6; }

.ik-ai-msg--user {
  align-self: flex-end;
  max-width: 88%;
  padding: .625rem .875rem;
  background: var(--ai-bone);
  border: 1px solid var(--ai-hair);
  color: var(--ai-ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.ik-ai-msg--bot { color: var(--ai-slate); }
.ik-ai-msg--bot p { margin: 0 0 .625rem; }
.ik-ai-msg--bot p:last-child { margin-bottom: 0; }
.ik-ai-msg--bot ul { margin: 0 0 .625rem; padding-left: 1.125rem; }
.ik-ai-msg--bot li { margin-bottom: .25rem; }
.ik-ai-msg--bot strong { color: var(--ai-ink); font-weight: 600; }
.ik-ai-msg--bot a {
  color: var(--ai-deep-brass);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ik-ai-msg--bot a:hover { color: var(--ai-ink); }

.ik-ai-msg--error {
  padding: .625rem .875rem;
  border-left: 2px solid var(--ai-brass);
  background: var(--ai-bone);
  color: var(--ai-ink);
  font-size: .875rem;
}

/* the "looking that up" line */

.ik-ai-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--ai-mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ai-muted);
}
.ik-ai-status::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--ai-brass);
  animation: ik-ai-pulse 1.1s ease-in-out infinite;
}
@keyframes ik-ai-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ik-ai-status::before { animation: none; opacity: .8; }
}

/* finish cards */

.ik-ai-finishes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: .625rem;
  margin-top: .25rem;
}
.ik-ai-finish {
  display: block;
  border: 1px solid var(--ai-hair);
  background: var(--ai-white, #fff);
  color: inherit;
  text-decoration: none;
  transition: border-color .18s ease;
}
.ik-ai-finish:hover { border-color: var(--ai-brass); }
.ik-ai-finish:focus-visible { outline: 2px solid var(--ai-brass); outline-offset: 2px; }
.ik-ai-finish-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--ai-bone);
}
.ik-ai-finish-swatch {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--ai-bone);
  font-family: var(--ai-mono);
  font-size: .5625rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ai-muted);
  text-align: center;
  padding: .25rem;
}
.ik-ai-finish-meta { padding: .5rem .5rem .625rem; }
.ik-ai-finish-name {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ai-ink);
}
.ik-ai-finish-code {
  display: block;
  margin-top: .125rem;
  font-family: var(--ai-mono);
  font-size: .625rem;
  letter-spacing: .04em;
  color: var(--ai-muted);
}

/* suggestion chips */

.ik-ai-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
}
.ik-ai-chip {
  padding: .4375rem .6875rem;
  border: 1px solid var(--ai-hair);
  background: transparent;
  color: var(--ai-slate);
  font-family: var(--ai-sans);
  font-size: .75rem;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
  transition: border-color .18s ease, color .18s ease;
}
.ik-ai-chip:hover { border-color: var(--ai-brass); color: var(--ai-ink); }
.ik-ai-chip:focus-visible { outline: 2px solid var(--ai-brass); outline-offset: 2px; }

/* composer */

.ik-ai-foot { flex: none; border-top: 1px solid var(--ai-hair); background: var(--ai-paper); }

.ik-ai-form {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .75rem;
}
.ik-ai-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 132px;
  padding: .625rem .75rem;
  border: 1px solid var(--ai-hair);
  border-radius: 0;
  background: #fff;
  color: var(--ai-ink);
  font-family: var(--ai-sans);
  font-size: .9375rem;
  line-height: 1.45;
  resize: none;
}
.ik-ai-input:focus { outline: none; border-color: var(--ai-brass); }
.ik-ai-input::placeholder { color: var(--ai-muted); }

.ik-ai-send {
  flex: none;
  height: 42px;
  padding: 0 1rem;
  border: 1px solid var(--ai-ink);
  border-radius: 0;
  background: var(--ai-ink);
  color: var(--ai-paper);
  font-family: var(--ai-sans);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.ik-ai-send:hover:not(:disabled) { background: var(--ai-brass); border-color: var(--ai-brass); color: var(--ai-ink); }
.ik-ai-send:disabled { opacity: .4; cursor: default; }
.ik-ai-send:focus-visible { outline: 2px solid var(--ai-brass); outline-offset: 2px; }

.ik-ai-legal {
  padding: 0 .75rem .625rem;
  font-family: var(--ai-mono);
  font-size: .5625rem;
  letter-spacing: .05em;
  line-height: 1.5;
  color: var(--ai-muted);
}
.ik-ai-legal a { color: var(--ai-muted); }

/* iOS Safari zooms the whole page when a focused field is under 16px. */
@media (max-width: 640px) {
  .ik-ai-input { font-size: 16px; }
}

/* ---------------------------------------------------------- inline mode
   The same assistant embedded in the page — used as the finish search bar.
   Drop <div data-ikitchen-ai="inline"></div> anywhere. */

.ik-ai-inline {
  border: 1px solid var(--ai-hair);
  background: var(--ai-paper);
}
.ik-ai-inline .ik-ai-head { background: var(--ai-ink); }
.ik-ai-inline .ik-ai-log {
  max-height: 420px;
  min-height: 0;
  padding: 1rem 1.125rem;
}
.ik-ai-inline .ik-ai-log:empty { display: none; }
.ik-ai-inline .ik-ai-close { display: none; }

/* visually-hidden, for the live region and labels */
.ik-ai-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
