/* Ahangar - storefront + consoles.
   One stylesheet, no build step, no framework. Someone has to maintain this
   in two years with no toolchain; that person should be able to read it.

   Direction: the site is about iron. Warm paper ground, charcoal type, a
   single brass accent. Photography carries the page; the chrome gets out of
   its way. Everything works identically in LTR and RTL via logical
   properties (margin-inline, padding-block, inset-inline) - there is no
   mirrored stylesheet to keep in sync. */

@font-face { font-family: Vazirmatn; src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
             font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
             font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
             font-weight: 700; font-display: swap; }

:root {
  --paper:      #f7f4ef;
  --paper-2:    #efeae1;
  --ink:        #241f1b;
  --ink-soft:   #5e564e;
  --ink-faint:  #8d8378;
  --line:       #ddd4c7;
  --brass:      #8a6534;
  --brass-lit:  #a87d45;
  --iron:       #2b2926;
  --ok:         #2f6b46;
  --warn:       #8a5a1e;
  --err:        #99332b;
  --err-bg:     #fbeceb;
  --ok-bg:      #ecf4ef;
  --radius:     3px;
  --shadow:     0 1px 2px rgba(36,31,27,.06), 0 8px 24px rgba(36,31,27,.05);
  --serif:      "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:       ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fa:         Vazirmatn, Tahoma, "Iranian Sans", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] textarea,
[dir="rtl"] select, [dir="rtl"] button { font-family: var(--fa); }
/* Farsi needs more leading than Latin at the same size or it feels cramped. */
[dir="rtl"] { line-height: 1.85; }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--brass); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brass-lit); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2;
             margin: 0 0 .5em; letter-spacing: -.01em; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 {
  font-family: var(--fa); font-weight: 700; letter-spacing: 0; line-height: 1.5; }
h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p  { margin: 0 0 1em; }

.wrap { max-width: 1160px; margin-inline: auto; padding-inline: 20px; }
.narrow { max-width: 720px; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-block-start: var(--gap, 1rem); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
/* Visually hidden but still read by screen readers and still submitted by
   forms. NEVER hide with left:-9999px - in RTL that overflow is in the
   reading direction and drags the viewport off the page. */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden;
      clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* --- header ----------------------------------------------------------- */
.site-head {
  border-block-end: 1px solid var(--line); background: var(--paper);
  position: sticky; top: 0; z-index: 40;
}
.site-head .wrap { display: flex; align-items: center; gap: 20px;
                   min-height: 68px; }
.brand { font-family: var(--serif); font-size: 1.35rem; letter-spacing: .04em;
         color: var(--ink); text-decoration: none; white-space: nowrap; }
[dir="rtl"] .brand { font-family: var(--fa); letter-spacing: 0; }
.brand:hover { color: var(--brass); }
.site-nav { display: flex; gap: 22px; margin-inline-start: auto; align-items: center; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: .94rem; }
.site-nav a:hover, .site-nav a.on { color: var(--ink); }
.site-nav a.cart-pill { display: inline-flex; align-items: center; gap: 6px;
             background: var(--iron); color: #f3ece2; padding: 7px 14px;
             border-radius: 99px; font-size: .86rem; text-decoration: none; }
.site-nav a.cart-pill:hover { background: var(--brass); color: #fff; }
.site-nav a.lang-btn { border: 1px solid var(--line); background: transparent;
            color: var(--ink-soft); padding: 5px 11px; border-radius: 99px;
            font-size: .82rem; text-decoration: none; }
.site-nav a.lang-btn:hover { border-color: var(--brass); color: var(--brass); }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.4rem;
              cursor: pointer; color: var(--ink); padding: 4px 8px; }

/* --- hero ------------------------------------------------------------- */
.hero { padding-block: clamp(48px, 9vw, 96px) clamp(32px, 6vw, 64px);
        border-block-end: 1px solid var(--line); }
.hero .wrap { display: grid; gap: clamp(24px, 5vw, 56px); align-items: center;
              grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); }
.hero-art { aspect-ratio: 4/5; border-radius: var(--radius); overflow: hidden;
            background: var(--paper-2); max-height: 460px; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { max-width: 16ch; }
.hero p { max-width: 46ch; font-size: 1.06rem; color: var(--ink-soft); }

/* --- product grid ----------------------------------------------------- */
.grid { display: grid; gap: clamp(18px, 3vw, 32px);
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tile { text-decoration: none; color: inherit; display: block; position: relative; }
.tile-img { aspect-ratio: 4/5; background: var(--paper-2); overflow: hidden;
            border-radius: var(--radius); }
.tile-img img { width: 100%; height: 100%; object-fit: cover;
                transition: transform .5s cubic-bezier(.2,.7,.3,1); }
.tile:hover .tile-img img { transform: scale(1.04); }
.tile-img.empty { display: grid; place-items: center; color: var(--ink-faint);
                  font-size: .8rem; }
.tile h3 { margin: 12px 0 2px; font-size: 1rem; font-weight: 500;
           font-family: inherit; }
.tile .price { color: var(--ink-soft); font-size: .95rem; }
.badge { position: absolute; inset-block-start: 10px; inset-inline-start: 10px;
         background: rgba(43,41,38,.9); color: #f3ece2; font-size: .72rem;
         padding: 4px 9px; border-radius: 2px; letter-spacing: .04em; }
.badge.sold { background: rgba(153,51,43,.92); }
.tile.is-sold .tile-img img { filter: grayscale(.65) opacity(.75); }

/* --- product page ----------------------------------------------------- */
.product { display: grid; gap: clamp(24px, 5vw, 56px);
           grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
           padding-block: 40px; align-items: start; }
.gallery-main { aspect-ratio: 1; background: var(--paper-2);
                border-radius: var(--radius); overflow: hidden; cursor: zoom-in; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
/* No photo yet: say so, and do not offer a zoom cursor on an empty box. */
.gallery-main.empty { cursor: default; display: grid; place-items: center;
                      border: 1px dashed var(--line); text-align: center;
                      padding: 24px; }
.thumbs { display: flex; gap: 10px; margin-block-start: 12px; flex-wrap: wrap; }
.thumbs button { width: 66px; height: 66px; padding: 0; border: 1px solid var(--line);
                 background: none; border-radius: 2px; overflow: hidden; cursor: pointer; }
.thumbs button[aria-current="true"] { border-color: var(--brass); border-width: 2px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.price-big { font-size: 1.6rem; color: var(--ink); font-family: var(--serif); }
[dir="rtl"] .price-big { font-family: var(--fa); }
.spec { border-block-start: 1px solid var(--line); padding-block: 11px;
        display: flex; justify-content: space-between; gap: 16px; font-size: .92rem; }
.spec dt { color: var(--ink-faint); margin: 0; }
.spec dd { margin: 0; text-align: end; }
.note-machine { background: var(--paper-2); border-inline-start: 3px solid var(--brass);
                padding: 10px 14px; font-size: .84rem; color: var(--ink-soft);
                border-radius: 0 2px 2px 0; }
[dir="rtl"] .note-machine { border-radius: 2px 0 0 2px; }

/* --- lightbox --------------------------------------------------------- */
.lightbox { position: fixed; inset: 0; background: rgba(24,21,18,.94); z-index: 100;
            display: grid; place-items: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 90vh; width: auto; object-fit: contain;
                border-radius: 2px; }
.lightbox button { position: absolute; inset-block-start: 16px; inset-inline-end: 20px;
                   background: none; border: 0; color: #f3ece2; font-size: 2rem;
                   cursor: pointer; line-height: 1; }

/* --- forms + buttons -------------------------------------------------- */
label { display: block; font-size: .88rem; color: var(--ink-soft);
        margin-block-end: 5px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; color: var(--ink);
  font: inherit; font-size: .97rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brass); outline-offset: 2px;
}
textarea { min-height: 130px; resize: vertical; line-height: 1.65; }
.field + .field { margin-block-start: 16px; }
.hint { font-size: .82rem; color: var(--ink-faint); margin-block-start: 5px; }
.fields-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

.btn { display: inline-block; border: 0; border-radius: var(--radius); cursor: pointer;
       font: inherit; font-size: .97rem; font-weight: 500; padding: 12px 26px;
       background: var(--iron); color: #f5efe6; text-decoration: none;
       text-align: center; transition: background .15s; }
.btn:hover { background: var(--brass); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.big { padding: 15px 32px; font-size: 1.03rem; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); border-color: var(--brass); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid #e4c4c1; }
.btn.danger:hover { background: var(--err); color: #fff; }
.btn.sm { padding: 7px 14px; font-size: .86rem; }

/* --- tables + panels -------------------------------------------------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
         padding: 20px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: start; font-weight: 600; color: var(--ink-soft); font-size: .82rem;
     letter-spacing: .03em; text-transform: uppercase; padding: 9px 10px;
     border-block-end: 1px solid var(--line); white-space: nowrap; }
[dir="rtl"] th { text-transform: none; letter-spacing: 0; font-size: .88rem; }
td { padding: 11px 10px; border-block-end: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-block-end: 0; }
.num { font-variant-numeric: tabular-nums; text-align: end; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 99px;
        font-size: .78rem; background: var(--paper-2); color: var(--ink-soft);
        white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: #f8f0e2; color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-block-end: 20px;
         font-size: .93rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }

/* --- checkout --------------------------------------------------------- */
/* This lived as an inline style="grid-template-columns:..." on the checkout
   wrapper, which no media query can override without !important - so the form
   and the totals panel stayed side by side on a phone, which is the device
   most of his customers hold. Same minmax(0,...) reason as .console-shell:
   a bare fr floors at min-content and pushes past the viewport. */
.co-layout { display: grid; gap: 32px; padding-block: 36px;
             grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr); }
.co-totals { align-self: start; position: sticky; top: 88px; }

/* --- totals ----------------------------------------------------------- */
.totals { font-size: .96rem; }
.totals .line { display: flex; justify-content: space-between; padding-block: 7px; }
.totals .line.grand { border-block-start: 1px solid var(--line); margin-block-start: 6px;
                      padding-block-start: 13px; font-size: 1.15rem; font-weight: 600; }

/* --- footer ----------------------------------------------------------- */
.site-foot { border-block-start: 1px solid var(--line); margin-block-start: 72px;
             padding-block: 32px; color: var(--ink-faint); font-size: .87rem; }

/* --- console (shared by artisan + admin) ------------------------------ */
/* minmax(0, 1fr), not 1fr: a bare 1fr's minimum is the column's min-content, so a
   wide table inside a .scroll-x panel widened the whole column past the phone's
   viewport (461px and 793px measured at 390px, 2026-09-06) instead of scrolling
   inside its panel. In RTL that overflow grows to the LEFT, off the screen. */
.console-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.console-nav { background: var(--iron); color: #cfc6b9; padding: 22px 0; }
.console-nav .who { padding: 0 22px 20px; border-block-end: 1px solid #3d3a35;
                    margin-block-end: 14px; }
.console-nav .who b { color: #f3ece2; display: block; font-size: 1.05rem; }
.console-nav a { display: flex; align-items: center; justify-content: space-between;
                 gap: 8px; padding: 11px 22px; color: #cfc6b9; text-decoration: none;
                 font-size: .97rem; }
.console-nav a:hover { background: #383430; color: #fff; }
.console-nav a.on { background: var(--brass); color: #fff; }
.console-nav .btn.ghost { color: #cfc6b9; border-color: #4a4640; background: transparent; }
.console-nav .btn.ghost:hover { color: #fff; border-color: var(--brass);
                                background: rgba(255,255,255,.06); }
.console-nav .count { background: rgba(255,255,255,.18); border-radius: 99px;
                      padding: 1px 8px; font-size: .78rem; min-width: 22px;
                      text-align: center; }
.console-nav a.on .count { background: rgba(0,0,0,.22); }
.console-main { padding: clamp(20px, 3vw, 34px); max-width: 1080px; min-width: 0; }
.console-main h1 { font-family: inherit; font-size: 1.55rem; }
[dir="rtl"] .console-main h1 { font-family: var(--fa); }

.cards { display: grid; gap: 16px;
         grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
        padding: 18px; }
.card .k { font-size: .84rem; color: var(--ink-faint); margin-block-end: 6px; }
.card .v { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.card .v.pos { color: var(--ok); }
.card .v.neg { color: var(--err); }
.card .sub { font-size: .8rem; color: var(--ink-faint); margin-block-start: 4px; }

/* Big, thumb-sized targets: he will use this on a phone in a workshop. */
.console-main .btn { padding: 13px 24px; }
.photo-grid { display: grid; gap: 12px;
              grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.photo-cell { position: relative; border: 1px solid var(--line);
              border-radius: var(--radius); overflow: hidden; background: var(--paper-2); }
.photo-cell img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.photo-cell .acts { display: flex; gap: 6px; padding: 7px; background: #fff; }
.photo-cell .acts form { flex: 1; }
.photo-cell .acts .btn { width: 100%; padding: 6px; font-size: .78rem; }
.is-cover { outline: 2px solid var(--brass); outline-offset: -2px; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px;
        text-align: center; color: var(--ink-faint); background: #fff; }
.drop.hot { border-color: var(--brass); background: #fffaf3; color: var(--brass); }

.msg { padding: 13px 16px; border-radius: var(--radius); margin-block-end: 12px;
       max-width: 78%; }
.msg.them { background: #fff; border: 1px solid var(--line); margin-inline-end: auto; }
.msg.us { background: var(--paper-2); margin-inline-start: auto; }
.msg .meta { font-size: .76rem; color: var(--ink-faint); margin-block-end: 5px; }
.msg .orig { font-size: .84rem; color: var(--ink-faint); margin-block-start: 8px;
             padding-block-start: 8px; border-block-start: 1px dashed var(--line); }

/* --- responsive ------------------------------------------------------- */
@media (max-width: 860px) {
  .product { grid-template-columns: 1fr; }
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .console-shell { grid-template-columns: minmax(0, 1fr); }
  .console-nav { display: flex; overflow-x: auto; padding: 0; gap: 0;
                 position: sticky; top: 0; z-index: 30; }
  .console-nav .who { display: none; }
  .console-nav a { padding: 14px 16px; white-space: nowrap; font-size: .9rem; }
  .fields-2 { grid-template-columns: 1fr; }
  .co-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .co-totals { position: static; }
}
@media (max-width: 700px) {
  .nav-toggle { display: block; margin-inline-start: auto; }
  .site-nav { display: none; width: 100%; flex-direction: column;
              align-items: stretch; gap: 0; padding-block-end: 12px; }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px 2px; border-block-start: 1px solid var(--line); }
  .site-head .wrap { flex-wrap: wrap; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media print {
  .site-head, .site-foot, .console-nav, .btn { display: none !important; }
  body { background: #fff; }
}
