/* SourceKadeh — light, typographic, developer-facing.
   Deliberately unlike the AVAX storefront: paper background instead of dark
   navy, emerald instead of indigo, tight corners instead of pill shapes, and
   monospace used for anything that is literally code. */

:root {
  --paper: #f6f5f1;
  --paper-2: #efeee8;
  --card: #ffffff;
  --ink: #161c1a;
  --ink-soft: #4c5a55;
  --muted: #7d8b85;
  --line: #e0dfd7;
  --line-strong: #cfcec4;
  --brand: #0f7a5a;
  --brand-soft: #e6f2ec;
  --brand-ink: #0a5c44;
  --amber: #b4761a;
  --amber-soft: #fbf1e0;
  --danger: #b3452f;
  --radius: 10px;
  --radius-sm: 7px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Vazirmatn", system-ui, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px;
  background: rgba(246, 245, 241, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: #f3fbf7;
  border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.brand-text { font-weight: 800; font-size: 17px; line-height: 1.15; }
.brand-text small {
  display: block; font-family: var(--mono); font-size: 10px;
  font-weight: 400; letter-spacing: .14em; color: var(--muted);
}
.search-wrap { flex: 1; max-width: 460px; }
.search-wrap input {
  width: 100%; padding: 10px 14px; font: inherit; font-size: 14px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
.search-wrap input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s;
}
.btn-solid { background: var(--brand); color: #fff; }
.btn-solid:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 14px; background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
}
.user-chip button {
  font: inherit; font-size: 12px; cursor: pointer; color: var(--danger);
  background: none; border: 0; padding: 2px 4px;
}

/* ---------- hero ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 30px 28px 60px; }
.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 34px; align-items: center;
  padding: 34px; margin-bottom: 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 10px;
}
.hero h1 { font-size: 33px; font-weight: 800; line-height: 1.35; letter-spacing: -.5px; }
.hero-sub { color: var(--ink-soft); font-size: 15px; margin-top: 12px; max-width: 52ch; }
.hero-stats { display: flex; gap: 30px; margin-top: 22px; }
.hero-stats strong { display: block; font-size: 24px; font-weight: 800; }
.hero-stats span { font-size: 12px; color: var(--muted); }

.term { background: #12201b; border-radius: var(--radius); overflow: hidden; box-shadow: 0 18px 40px rgba(18, 32, 27, .18); }
.term-bar { display: flex; gap: 6px; padding: 11px 14px; background: #0d1814; }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2f4c41; }
.term-body {
  margin: 0; padding: 16px 18px 20px; direction: ltr; text-align: left;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.9; color: #cfe6dc;
  white-space: pre-wrap;
}
.c-dim { color: #5c7a6d; } .c-ok { color: #4fd39b; } .c-key { color: #e0b155; }

/* ---------- filters ---------- */
.filters { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; flex: 1; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--line-strong);
}
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sort-select {
  font: inherit; font-size: 13px; padding: 8px 12px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: 0 14px 30px rgba(22, 28, 26, .07); }
.card-media { position: relative; aspect-ratio: 16 / 9; background: var(--paper-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background:
    repeating-linear-gradient(45deg, transparent 0 11px, rgba(15, 122, 90, .045) 11px 22px),
    var(--paper-2);
}
.ph-glyph {
  font-family: var(--mono); font-size: 40px; font-weight: 600;
  color: var(--brand); opacity: .5; line-height: 1;
}
.ph-lang {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  color: var(--muted);
}
.detail-media .placeholder { aspect-ratio: 16 / 10; border-radius: var(--radius-sm); }
.detail-media .placeholder .ph-glyph { font-size: 58px; }

.card-media .shots {
  position: absolute; inset-inline-end: 9px; inset-block-end: 9px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(18, 32, 27, .82); color: #dff0e8;
  font-family: var(--mono); font-size: 10.5px;
}
.card-body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-ink);
}
.badge.owned { background: var(--amber-soft); color: var(--amber); }
.card h3 { font-size: 16px; font-weight: 700; }
.card p { font-size: 13px; color: var(--ink-soft); flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.price { font-weight: 800; font-size: 15px; }
.price small { font-weight: 500; font-size: 11px; color: var(--muted); margin-inline-start: 3px; }
.card-foot .btn { padding: 7px 14px; font-size: 13px; }

.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 22px;
  background: rgba(22, 28, 26, .42); backdrop-filter: blur(3px);
}
/* `display` on .overlay outranks the browser's own [hidden] rule, so without
   this every dialog would sit permanently open and refuse to close. */
.overlay[hidden] { display: none; }
[hidden] { display: none !important; }
.sheet {
  position: relative; width: 100%; max-width: 430px; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: var(--radius); padding: 28px;
  box-shadow: 0 30px 70px rgba(22, 28, 26, .25);
}
.sheet-wide { max-width: 960px; }
.sheet h2 { font-size: 21px; font-weight: 800; margin-bottom: 6px; }
.sheet-close {
  position: absolute; inset-block-start: 14px; inset-inline-start: 16px;
  font: inherit; font-size: 13px; cursor: pointer; color: var(--muted);
  background: none; border: 0;
}
.sheet-close:hover { color: var(--ink); }

.detail-body { display: grid; grid-template-columns: 1.25fr 1fr; gap: 26px; }
.detail-media img {
  width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--paper-2); display: block;
}
.thumbs { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.thumbs img {
  width: 64px; height: 42px; object-fit: cover; cursor: pointer;
  border-radius: 5px; border: 2px solid transparent; opacity: .62;
}
.thumbs img.active, .thumbs img:hover { opacity: 1; border-color: var(--brand); }
.detail-info { display: flex; flex-direction: column; gap: 11px; }
.detail-info h2 { font-size: 23px; }
.facts { display: flex; gap: 26px; padding: 13px 0; border-block: 1px solid var(--line); }
.facts dt { font-size: 11px; color: var(--muted); }
.facts dd { font-weight: 700; font-size: 14px; }
.detail-buy { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 4px; }
.detail-buy .price { font-size: 20px; }
.repo-link { font-size: 13px; color: var(--brand); text-decoration: none; }
.repo-link:hover { text-decoration: underline; }

form label { display: block; font-size: 13px; font-weight: 600; margin-top: 14px; }
form input {
  width: 100%; margin-top: 6px; padding: 10px 13px; font: inherit; font-size: 14px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
form .btn { width: 100%; margin-top: 20px; }
.error {
  margin-top: 14px; padding: 10px 13px; font-size: 13px;
  background: #fbeeeb; color: var(--danger); border-radius: var(--radius-sm);
}
.switch { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }
.switch button { font: inherit; font-weight: 700; color: var(--brand); background: none; border: 0; cursor: pointer; }

.library-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.library-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 15px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.library-row strong { font-size: 14px; }
.library-row .mono { font-size: 11px; color: var(--muted); }

.toast {
  position: fixed; inset-block-end: 24px; inset-inline-start: 50%;
  transform: translateX(50%); z-index: 80;
  padding: 12px 20px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 600;
  box-shadow: 0 14px 34px rgba(22, 28, 26, .3);
}

.footer {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 22px 28px 40px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px;
}
.footer-text { display: flex; flex-direction: column; gap: 4px; }
/* The seal is served by Enamad at its own fixed size; box it so a slow or
   blocked load does not shift the footer around it. */
.trust-seal {
  flex: none; display: grid; place-items: center;
  min-width: 96px; min-height: 96px;
  padding: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.trust-seal img { max-width: 100px; height: auto; display: block; }

@media (max-width: 1080px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-panel { display: none; }
  .detail-body { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  main { padding: 20px 16px 48px; }
  .grid { grid-template-columns: 1fr; }
  .hero { padding: 24px; }
  .hero h1 { font-size: 26px; }
}
