@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&display=swap");

/*
 * Shared HENDI visual system. The charcoal, lime, and neutral values are
 * sampled from hendi.eu; semantic status colors remain independent because
 * their job is to communicate state rather than brand.
 */
:root {
  --primary: #222221;
  --primary-soft: #4e4e4d;
  --on-primary: #ffffff;
  --on-primary-muted: #d8d8d8;
  --on-primary-secondary: #b8b8b8;
  --accent: #b9bf15;
  --accent-hover: #a2a717;
  --accent-ink: #5f6210;
  --accent-soft: #d6d973;
  --accent-wash: #f7f8e8;
  --on-accent: #222221;

  --bg: #f0f0f0;
  --card: #ffffff;
  --fg: #222221;
  --muted: #f0f0f0;
  --muted-fg: #696c69;
  --border: #e5e5e5;
  --border-strong: #8f8f8f;
  --overlay: rgba(34, 34, 33, 0.45);
  --focus: #767a11;
  --focus-ring: rgba(118, 122, 17, 0.25);

  --success: #047857;
  --success-bg: #ecfdf5;
  --warning: #a16207;
  --warning-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --info: #0958d9;
  --info-bg: #e6f4ff;

  --font-display: "Barlow", Helvetica, Arial, sans-serif;
  --font-body: "Barlow", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-sm: 2px;
  --radius: 3px;
  --radius-lg: 6px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(34, 34, 33, 0.08);
  --shadow: 0 2px 6px rgba(34, 34, 33, 0.1);
  --shadow-lg: 0 8px 20px rgba(34, 34, 33, 0.14);
  --shadow-xl: 0 18px 42px rgba(34, 34, 33, 0.2);

  --fast: 150ms ease;
  --normal: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  --header-h: 64px;
  --content-max: 1320px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.015em;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* A visible ring on every focusable thing. Removing it is the single most
   common way a keyboard user is locked out of an otherwise fine interface. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--fast), border-color var(--fast),
    color var(--fast), transform var(--fast);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--dark {
  background: var(--primary);
  color: var(--on-primary);
}

.btn--dark:hover {
  background: var(--primary-soft);
}

.btn--ghost {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--fg);
}

.btn--ghost:hover {
  background: var(--muted);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.field {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.field:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill--stock {
  background: var(--success-bg);
  color: var(--success);
}

.pill--out {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill--muted {
  background: var(--muted);
  color: var(--muted-fg);
}

.pill--info {
  background: var(--info-bg);
  color: var(--info);
}

.pill--warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.pill--line {
  background: var(--fg);
  color: var(--bg);
  letter-spacing: 0.02em;
}

/* Sits over the photo rather than in the body, so the grade reads at a glance
   while scanning a grid and costs the card no vertical space. */
.card__grade {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--normal), transform var(--normal),
    border-color var(--normal);
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--muted);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-3);
  transition: transform var(--normal);
}

.card:hover .card__media img {
  transform: scale(1.04);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  flex: 1;
}

.card__cat {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-fg);
}

.card__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
}

.card__price {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.skeleton {
  background: linear-gradient(90deg, var(--muted), var(--card), var(--muted));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--muted-fg);
}

.turns {
  list-style: none;
  margin: 0;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
}

.turn {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;
  animation: rise var(--normal) both;
}

.turn .body {
  display: block;
}

.turn .body p {
  margin: 0;
}

.turn .body p + p,
.turn .body p + ul,
.turn .body ul + p {
  margin-top: var(--space-3);
}

.turn .body ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}

.turn .body li {
  padding-left: var(--space-1);
}

.turn .body li + li {
  margin-top: var(--space-2);
}

.turn .body a {
  color: var(--info);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Text that is quoted rather than interpreted — what was typed, and what an
   error said — so the line breaks it arrived with are the ones it keeps. */
.turn .body--plain,
.turn__failure {
  white-space: pre-wrap;
}

.turn__failure {
  margin: var(--space-3) 0 0;
}

.turn__failure:first-child {
  margin-top: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.turn--user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: var(--radius-sm);
}

.turn--advisor {
  align-self: flex-start;
  background: var(--muted);
  border-bottom-left-radius: var(--radius-sm);
}

.turn--error {
  align-self: flex-start;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-fg);
}

.tool::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.chat-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 24px;
  color: var(--muted-fg);
  font-size: 13px;
}

.chat-progress__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: chat-spin 700ms linear infinite;
}

@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}

.composer {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--card);
}

.composer input {
  flex: 1;
}

.chat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.chat-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  padding: var(--space-2);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  font: inherit;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.chat-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.chat-card:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.chat-card img {
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--muted);
  border-radius: var(--radius-sm);
}

.chat-card__name {
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-card__price {
  font-weight: 700;
  font-size: 13px;
}

/* Whether it can be ordered. Never how many are left — the card payload
   carries no count, and on the website there is none to give. */
.chat-card__stock {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
}

.chat-card__stock--out {
  color: var(--muted-fg);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* The two protected pages are reached through a login, so they need a way back
   out. Injected by `mountSessionBar`, which is why the rules live here rather
   than in either page's own sheet. */
.session-bar {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px 8px 14px;
  font-size: 0.78rem;
  color: var(--on-primary);
  background: var(--primary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
}

.session-bar__out {
  padding: 5px 12px;
  font: inherit;
  font-weight: 700;
  color: var(--on-accent);
  cursor: pointer;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-full);
}

.session-bar__out:hover {
  background: var(--accent-hover);
}
