/* ============================================================
   Duskyr UI Kit — layout & component layer.
   Tokens come from ../../colors_and_type.css. This file adds the
   app shell, buttons, cards, chips, inputs and product card.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); color: var(--ink); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
::selection { background: color-mix(in oklab, var(--accent) 24%, transparent); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; }
.tnum { font-variant-numeric: tabular-nums; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.eyebrow { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }

/* scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: color-mix(in oklab, var(--ink) 16%, transparent); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- buttons ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 550; font-size: 14px; line-height: 1; height: 40px; padding: 0 16px;
  border-radius: var(--r-btn); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .18s, box-shadow .18s, border-color .18s, color .18s;
}
.btn-lbl { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--sunken); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: color-mix(in oklab, var(--accent) 22%, var(--surface)); }

/* ---------- cards / badges / inputs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-xs); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550; line-height: 1; padding: 4px 9px; border-radius: 99px; border: 1px solid transparent; }
.badge-neutral { background: var(--sunken); color: var(--muted); border-color: var(--line); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in oklab, var(--success) 30%, transparent); }
.field {
  width: 100%; height: 44px; padding: 0 14px; background: var(--sunken); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-btn); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--faint); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
textarea.field { height: auto; padding: 11px 14px; resize: vertical; line-height: 1.55; min-height: 96px; }

/* ---------- app shell ---------- */
.du-shell { display: flex; min-height: 100vh; background: var(--canvas); }
.du-side {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 2px;
}
.du-side-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.du-side-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 6px; }
.du-side-link {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--r-sm); border: 0; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--ink); background: transparent;
  transition: background .15s, color .15s;
}
.du-side-link:hover { background: var(--sunken); }
.du-side-link[data-on="true"] { background: var(--accent-soft); color: var(--accent); }
.du-side-spacer { flex: 1; }

.du-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.du-topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
  background: color-mix(in oklab, var(--canvas) 82%, transparent);
  backdrop-filter: blur(12px) saturate(160%); -webkit-backdrop-filter: blur(12px) saturate(160%);
}
.du-wrap { max-width: var(--wrap-max); margin: 0 auto; padding: 24px; width: 100%; }

.du-search { flex: 1; max-width: 460px; position: relative; }
.du-search input { width: 100%; height: 38px; padding: 0 14px 0 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--sunken); color: var(--ink); font-size: 13.5px; outline: none; transition: border-color .15s; }
.du-search input:focus { border-color: var(--accent-line); }
.du-search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* search dropdown with recommendations */
.du-search-pop { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; max-height: 420px; overflow: auto; animation: duFade .14s ease both; }
.du-search-h { font: 600 10.5px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 7px; }
.du-search-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px 8px; border-radius: 7px; background: transparent; border: 0; cursor: pointer; text-align: left; }
.du-search-row:hover { background: var(--sunken); }
.du-search-thumb { position: relative; width: 44px; height: 30px; border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.du-search-tt { flex: 1; min-width: 0; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.du-search-pr { font-weight: 700; font-size: 13px; color: var(--ink-strong); }
.du-search-empty { padding: 16px 12px; color: var(--muted); font-size: 13px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--r-btn); background: transparent; border: 0; cursor: pointer; color: var(--muted); position: relative; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.du-cart-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: var(--accent-fg); font-size: 10px; font-weight: 700; display: grid; place-items: center; }

.du-burger { display: none; }
@media (max-width: 900px) {
  .du-side { display: none; }
  .du-burger { display: inline-flex; }
  .du-side.du-side-drawer { display: flex; position: fixed; left: 0; top: 0; bottom: 0; z-index: 700; box-shadow: var(--shadow-lg); animation: duDrawer .26s cubic-bezier(.22,1,.36,1) both; }
  .du-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 600; }
  .du-wrap { padding: 16px; }
}
@keyframes duDrawer { from { transform: translateX(-100%); } to { transform: none; } }

/* ---------- product card ---------- */
.du-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--gap-grid); }
.du-pcard { display: flex; flex-direction: column; overflow: hidden; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); transition: border-color .16s, transform .16s, box-shadow .16s; }
.du-pcard:hover { border-color: var(--accent-line); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.du-pcard-img { position: relative; aspect-ratio: 16 / 10; overflow: hidden; display: grid; place-items: center; }
.du-pcard-badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.du-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 600; backdrop-filter: blur(6px); }
.du-chip-dark { background: rgba(0,0,0,.55); color: #fff; }
.du-chip-hot { background: #ff8a3d; color: #1a0e02; }
.du-chip-new { background: var(--accent); color: var(--accent-fg); }
.du-pcard-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.du-pcard-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--ink-strong); }
.du-pcard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.du-price { font-weight: 700; font-size: 15px; color: var(--ink-strong); }
.du-sold { font-size: 11px; color: var(--subtle); display: inline-flex; align-items: center; gap: 4px; }

/* ---------- banner / stats / chips ---------- */
.du-banner { position: relative; overflow: hidden; border-radius: var(--r-xl); border: 1px solid var(--line); min-height: 200px; display: flex; align-items: center; padding: 32px; }
.du-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.du-stat { background: var(--surface); padding: 18px 20px; }
.du-stat-v { font-size: 26px; font-weight: 700; color: var(--ink-strong); letter-spacing: -.02em; font-family: var(--font-display); }
.du-stat-l { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 720px) { .du-stats { grid-template-columns: repeat(2, 1fr); } }
.du-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.du-fchip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: pointer; border: 1px solid var(--line); background: var(--sunken); color: var(--muted); transition: all .15s; }
.du-fchip[data-on="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.du-fchip:hover[data-on="false"] { border-color: var(--line-strong); color: var(--ink); }

/* segmented toggle */
.du-seg { display: inline-flex; padding: 3px; border-radius: var(--r-btn); background: var(--sunken); border: 1px solid var(--line); gap: 2px; }
.du-seg button { height: 32px; padding: 0 14px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.du-seg button[data-on="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

/* skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--sunken); border-radius: 8px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--ink) 8%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* entrance + page transitions (transform-only so content is never left invisible in snapshots) */
@keyframes duFadeUp { from { opacity: .25; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.app-enter { animation: duPage .42s ease both; }
@keyframes duPage { from { opacity: .2; } to { opacity: 1; } }
@keyframes duFade { from { opacity: .3; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .05ms !important; } }

/* auth split → single column on small screens */
@media (max-width: 820px) {
  .du-auth { grid-template-columns: 1fr !important; }
  .du-auth-brand { display: none !important; }
}

/* seller chat drawer */
.du-chat-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 800; animation: duFade .18s ease both; }
.du-chat { position: fixed; right: 0; top: 0; bottom: 0; width: 372px; max-width: 92vw; background: var(--surface); border-left: 1px solid var(--line); z-index: 810; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: duDrawerR .3s cubic-bezier(.22,1,.36,1) both; }
@keyframes duDrawerR { from { transform: translateX(100%); } to { transform: none; } }
.du-chat-head { display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.du-chat-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; background: var(--canvas); }
.du-chat-day { align-self: center; font: 500 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.du-pop { animation: duBubble .18s ease both; }
.du-bubble { max-width: 80%; padding: 9px 13px; border-radius: 13px; font-size: 13.5px; line-height: 1.5; animation: duBubble .24s cubic-bezier(.2,.7,.3,1) both; }
@keyframes duBubble { from { opacity: .3; transform: translateY(7px) scale(.98); } to { opacity: 1; transform: none; } }
.du-bubble.them { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 4px; }
.du-bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-fg); border-bottom-right-radius: 4px; }
.du-chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.du-chat-input input { flex: 1; height: 40px; padding: 0 14px; background: var(--sunken); border: 1px solid var(--line-strong); border-radius: 7px; color: var(--ink); outline: none; font-size: 13.5px; font-family: inherit; }
.du-chat-input input:focus { border-color: var(--accent); }

/* dropdown menu (language switcher) */
.du-menu { position: absolute; top: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-lg); padding: 5px; z-index: 70; min-width: 172px; animation: duFade .14s ease both; }
.du-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 6px; background: transparent; border: 0; cursor: pointer; font-size: 13.5px; color: var(--ink); text-align: left; }
.du-menu-item:hover { background: var(--sunken); }
.du-menu-item[data-on="true"] { color: var(--ink-strong); font-weight: 600; }

/* auth login ↔ signup transition */
.animfield { overflow: hidden; max-height: 0; opacity: 0; transition: max-height .32s cubic-bezier(.2,.7,.3,1), opacity .26s ease, margin-bottom .32s ease; }
.animfield[data-open="true"] { max-height: 92px; opacity: 1; margin-bottom: 14px; }
.auth-fade { animation: duFade .3s ease both; }

/* messages / chat page */
.du-msg { display: grid; grid-template-columns: 280px 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; height: 600px; background: var(--surface); }
.du-msg-list { border-right: 1px solid var(--line); overflow: auto; padding: 6px; }
.du-convo { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px; border-radius: 8px; background: transparent; border: 0; cursor: pointer; text-align: left; }
.du-convo:hover { background: var(--sunken); }
.du-convo[data-on="true"] { background: var(--accent-soft); }
.du-convo-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.du-convo-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-fg); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.du-msg-main { display: flex; flex-direction: column; min-width: 0; }
.du-msg-head { display: flex; align-items: center; gap: 11px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.du-msg-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; background: var(--canvas); }
.du-read { display: inline-flex; align-items: center; margin-left: 8px; vertical-align: middle; }
.du-prodpill { display: flex; align-items: center; gap: 11px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.du-prodpill-img { position: relative; width: 54px; height: 36px; border-radius: 6px; overflow: hidden; flex-shrink: 0; }
@media (max-width: 760px) { .du-msg { grid-template-columns: 1fr; height: 520px; } .du-msg-list { display: none; } }
