@import url("/theme.css");

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 400 var(--t-md)/1.75 var(--font);
  direction: rtl; min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; font-weight: 750; letter-spacing: 0; }
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
p { margin: 0 0 1em; max-width: 68ch; }
:focus-visible { outline: 2px solid var(--measure); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--on-ronas); }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.num { font-feature-settings: "tnum"; color: var(--measure); font-weight: 650; }
.display { font-family: var(--display); font-weight: 400; line-height: 2.1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── the border (حاشیه): the page is framed the way a rug is ───────────────────────── */
.hashie {
  height: 18px; flex: none;
  /* A guard stripe and a band of reciprocal «سرمه‌ای» triangles: the border of the page is
     the border of a rug. Fixed colours: it is woven, it does not change with the theme. */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='18'%3E%3Crect width='36' height='18' fill='%231b2a4a'/%3E%3Crect width='36' height='2.5' fill='%238e1f1a'/%3E%3Crect y='15.5' width='36' height='2.5' fill='%238e1f1a'/%3E%3Cpath d='M0 13.5 9 4.5 18 13.5Z' fill='%23efe6d2'/%3E%3Cpath d='M18 4.5 27 13.5 36 4.5Z' fill='%23efe6d2'/%3E%3Cpath d='M6 13.5 9 10.5 12 13.5ZM24 4.5 27 7.5 30 4.5Z' fill='%238e1f1a'/%3E%3Ccircle cx='18' cy='9' r='1.4' fill='%23c9962e'/%3E%3Ccircle cx='0' cy='9' r='1.4' fill='%23c9962e'/%3E%3Ccircle cx='36' cy='9' r='1.4' fill='%23c9962e'/%3E%3C/svg%3E") repeat-x;
}

/* ── header ───────────────────────────────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 20px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand .mark { width: 30px; height: 30px; flex: none; }
.brand b { font-family: var(--display); font-weight: 400; font-size: 1.75rem; line-height: 1.45; white-space: nowrap; }
/* Nastaliq hangs far below its baseline; the tagline sits under the descenders, not in them. */
.brand .sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 9px; white-space: nowrap; line-height: 1.2; }
.brand .words { display: grid; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: var(--t-sm); font-weight: 550; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.nav a.ar-link { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg, .btn svg, .dock svg { width: 22px; height: 22px; }
.badge { position: absolute; top: 5px; inset-inline-end: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--on-ronas); font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

.dock { display: none; }
@media (max-width: 860px) {
  .nav, .top .hide-sm { display: none; }
  .dock { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .dock a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; min-height: 56px;
    text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
  .dock a[aria-current="page"] { color: var(--text); }
  .dock a[aria-current="page"]::before { content: ""; position: absolute; top: 0; inset-inline: 30%; height: 2px; background: var(--accent); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

footer.site { margin-top: 72px; }
footer.site .wrap { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-top: 36px; padding-bottom: 40px; }
footer.site h4 { margin: 0 0 8px; font-size: var(--t-sm); color: var(--text-2); }
footer.site ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: var(--t-sm); }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--text); }
@media (max-width: 700px) { footer.site .wrap { grid-template-columns: 1fr 1fr; } footer.site .about { grid-column: 1 / -1; } }

/* ── buttons & fields ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px;
  border-radius: var(--r-md); border: 1px solid var(--line-2); background: transparent; color: var(--text);
  font: 650 var(--t-sm)/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface); border-color: var(--text-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-ronas); }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.quiet { border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: var(--t-xs); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.lg { min-height: 54px; padding: 0 26px; font-size: var(--t-md); }

label.field { display: grid; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--text-2); }
label.field .hint { font-weight: 400; color: var(--muted); font-size: var(--t-xs); }
input, select, textarea { font: 400 16px/1.5 var(--font); color: var(--text); background: var(--raised);
  border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 12px; min-height: 46px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--measure); box-shadow: 0 0 0 3px color-mix(in srgb, var(--measure) 25%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font: 550 var(--t-sm)/1 var(--font); cursor: pointer; text-decoration: none; }
.chip:hover { color: var(--text); border-color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.swatch { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); flex: none; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.toast { position: fixed; inset-inline: 16px; bottom: 84px; margin: 0 auto; max-width: 420px; z-index: 60; background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: var(--r-md); font-size: var(--t-sm); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.bad { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty h3 { color: var(--text); }
.skel { background: linear-gradient(90deg, var(--surface), var(--raised), var(--surface)); background-size: 200% 100%; animation: sk 1.4s infinite linear; border-radius: var(--r-md); }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ── rug cards ────────────────────────────────────────────────────────────────────── */
.rug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 28px 20px; }
.rug-card { display: grid; gap: 10px; text-decoration: none; color: inherit; position: relative; }
.rug-card .pic { aspect-ratio: 3 / 4; display: grid; place-items: center; background: var(--surface); border-radius: var(--r-md); padding: 14px; position: relative; overflow: hidden; }
.rug-card .pic img { max-height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0,0,0,.35)); transition: transform .25s; }
.rug-card:hover .pic img { transform: translateY(-3px); }
.rug-card h3 { font-size: var(--t-md); font-weight: 650; margin: 0; line-height: 1.5; }
.rug-card .facts { display: flex; justify-content: space-between; gap: 8px; font-size: var(--t-sm); color: var(--muted); }
.rug-card .price { color: var(--text); font-weight: 650; }
.rug-card .tag { z-index: 1; position: absolute; top: 10px; inset-inline-start: 10px; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 4px;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--line); }
.rug-card .tag.sold { background: var(--bad); color: #fff; border: 0; }
.save-btn { position: absolute; top: 6px; inset-inline-end: 6px; z-index: 2; }
.save-btn[aria-pressed="true"] { color: var(--accent); }
.save-btn[aria-pressed="true"] svg { fill: currentColor; }

/* True scale: every rug drawn at the same centimetres-per-pixel, laid out like a bazaar floor. */
.scale-floor { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 22px 18px; padding: 24px; border-radius: var(--r-lg);
  background: repeating-linear-gradient(90deg, transparent 0 calc(var(--m) - 1px), var(--line) calc(var(--m) - 1px) var(--m)),
              repeating-linear-gradient(0deg, transparent 0 calc(var(--m) - 1px), var(--line) calc(var(--m) - 1px) var(--m)), var(--surface); }
.scale-floor .rug-card { gap: 6px; }
.scale-floor .rug-card .pic { aspect-ratio: auto; padding: 0; background: none; overflow: visible; }
.scale-floor .rug-card .pic img { width: var(--w); height: var(--h); max-height: none; object-fit: fill; }
.scale-floor .rug-card h3 { font-size: var(--t-xs); max-width: max(var(--w), 90px); }
.scale-floor .rug-card .facts, .scale-floor .save-btn, .scale-floor .tag { display: none; }
.scale-note { font-size: var(--t-sm); color: var(--muted); margin: 0 0 12px; }
.scale-note .num { font-weight: 700; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 56px 0 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* ── gallery panel ────────────────────────────────────────────────────────────────── */
.panel-nav { border-bottom: 1px solid var(--line); background: var(--surface); }
.panel-nav .wrap { display: flex; gap: 4px; align-items: center; overflow-x: auto; min-height: 50px; }
.panel-nav a { text-decoration: none; padding: 8px 12px; font-size: var(--t-sm); color: var(--text-2); white-space: nowrap; font-weight: 600; }
.panel-nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.panel-label { font-size: var(--t-xs); color: var(--muted); margin-inline-end: 12px; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stats div { background: var(--bg); padding: 18px; }
.stats b { display: block; font-size: var(--t-2xl); color: var(--measure); font-weight: 700; line-height: 1.3; }
.stats span { font-size: var(--t-sm); color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th, .table td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; }
.table img { width: 46px; height: 60px; object-fit: contain; }
.table-wrap { overflow-x: auto; }
.st { font-size: var(--t-xs); font-weight: 700; padding: 3px 9px; border-radius: 4px; background: var(--surface); white-space: nowrap; }
.st.ready { color: var(--ok); } .st.failed { color: var(--bad); } .st.draft { color: var(--measure); }
@media (max-width: 560px) {
  .rug-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 12px; }
  .rug-card .pic { padding: 8px; }
  .rug-card .facts { flex-direction: column; gap: 0; font-size: var(--t-xs); }
  .rug-card h3 { font-size: var(--t-sm); }
}
