/* ─────────────────────────────────────────────────────────
   ماسکده‌ی میرزا · MÂSKADE — stylesheet
   Single source of truth. Edit variables below.
   ───────────────────────────────────────────────────────── */

:root {
  --bg:        #F6F1E7;   /* Maast-Weiß */
  --ink:       #1A1A1A;
  --ink-soft:  #4A4A4A;
  --rule:      #C9BFA8;
  --accent:    #1F2A44;   /* persische Tinte */
  --safran:    #E2A23B;
  --max:       42rem;     /* lese-spalte */
  --serif:     "EB Garamond", "Iowan Old Style", "Charter", Georgia, serif;
  --fa:        "Vazirmatn", "Vazir", "Tahoma", sans-serif;
  --mono:      "JetBrains Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Language toggle ─────────────────────────────────────── */
html[lang="de"] [data-lang="fa"],
html[lang="fa"] [data-lang="de"] { display: none; }

html[lang="fa"] body { font-family: var(--fa); line-height: 1.85; }
html[lang="fa"] { direction: rtl; }
html[lang="de"] { direction: ltr; }

/* Mixed-content fallback: any element explicitly marked */
[lang="fa"]    { font-family: var(--fa); }
[lang="de"]    { font-family: var(--serif); }

/* ── Layout container ───────────────────────────────────── */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.site-header .wrap {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-family: var(--fa);
  font-size: 1.6rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.brand .latin {
  font-family: var(--serif);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  margin-inline-start: 0.5rem;
  text-transform: uppercase;
}
.lang-toggle {
  display: inline-flex;
  gap: 0;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  overflow: hidden;
}
.lang-toggle > * {
  background: var(--bg);
  border: 0;
  padding: 0.5rem 0.9rem;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-block;
  line-height: 1.2;
}
.lang-toggle > *:first-child { border-inline-end: 1px solid var(--ink); }
.lang-toggle .is-active,
.lang-toggle [aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}
.lang-toggle > *:not(.is-active):hover {
  background: var(--safran);
  color: var(--ink);
}
.lang-toggle .label-fa { font-family: var(--fa); }
.lang-toggle .label-de { font-family: var(--serif); }

/* ── Navigation ─────────────────────────────────────────── */
.site-nav {
  border-bottom: 1px solid var(--rule);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
.site-nav .wrap {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--safran);
}
html[lang="fa"] .site-nav { font-family: var(--fa); }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 500;
  line-height: 1.25;
  margin: 2.5rem 0 0.8rem;
}
h1 { font-size: 2.4rem; margin-top: 1rem; }
h2 { font-size: 1.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.15rem; color: var(--accent); }
h4 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft); }

html[lang="fa"] h1,
html[lang="fa"] h2,
html[lang="fa"] h3,
html[lang="fa"] h4 { font-family: var(--fa); font-weight: 500; }

p { margin: 0 0 1rem; }
.lede { font-size: 1.12rem; color: var(--ink-soft); margin-bottom: 2rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--safran); }

hr.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}
hr.glyph {
  border: 0;
  text-align: center;
  margin: 2.5rem 0;
}
hr.glyph::before {
  content: "❋";
  color: var(--safran);
  font-size: 1rem;
}

/* ── Tables ─────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 2rem;
  font-size: 0.95rem;
}
th, td {
  text-align: start;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom-color: var(--ink);
}
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
html[lang="fa"] table { font-family: var(--fa); font-size: 1rem; }

/* ── Product card grid ──────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.card {
  border: 1px solid var(--rule);
  padding: 1.5rem;
  background: rgba(255,255,255,0.4);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease;
}
.card:hover { border-color: var(--ink); }
.card h3 { margin-top: 0; color: var(--ink); }
.card .card-tag {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--safran);
  margin-bottom: 0.4rem;
}
.card .card-cta {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* ── Spec / datasheet block ─────────────────────────────── */
.spec {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
  margin: 1rem 0 2rem;
  font-size: 0.95rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
}
.spec dt {
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  align-self: start;
  padding-top: 0.15rem;
}
.spec dd { margin: 0; }
html[lang="fa"] .spec { font-family: var(--fa); }
html[lang="fa"] .spec dt { letter-spacing: 0; text-transform: none; font-size: 0.85rem; }

/* ── Step list ──────────────────────────────────────────── */
ol.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1rem 0 2rem;
}
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding-inline-start: 2.5rem;
  margin-bottom: 1.4rem;
  min-height: 1.8rem;
}
ol.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  inset-inline-start: 0;
  top: 0.05rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--safran);
  letter-spacing: 0.05em;
}
ol.steps strong { display: block; margin-bottom: 0.15rem; }

/* ── Image placeholder ──────────────────────────────────── */
.figure {
  margin: 2rem 0;
  border: 1px dashed var(--rule);
  background: rgba(255,255,255,0.5);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  padding: 1rem;
  overflow: hidden;
}
.figure.has-image {
  border-style: none;
  padding: 0;
  background: transparent;
  display: block;
  aspect-ratio: auto;
  height: auto;
  max-width: 100%;
}
.figure.has-image > img {
  width: 100%;
  height: auto;
  max-height: 75vh;          /* never taller than viewport */
  object-fit: contain;        /* show whole image, never crop */
  aspect-ratio: auto;
  margin: 0 auto;
}
/* placeholder (no image) figure keeps the dashed 4:3 box */
.figure:not(.has-image) img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-orientation: from-image;
  display: block;
}
.figure img {
  image-orientation: from-image; /* honor EXIF rotation */
  display: block;
}

/* ── Hero on index ──────────────────────────────────────── */
.hero {
  margin: 1rem 0 2rem;
  text-align: center;
}
.hero-logo {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin: 0 auto;
  display: block;
}
.hero-jars {
  margin: 1.5rem 0 0;
}
.hero-jars img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  image-orientation: from-image;
  display: block;
  margin: 0 auto;
}
figcaption {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
  text-align: center;
}

/* ── Callout ────────────────────────────────────────────── */
.callout {
  border-inline-start: 3px solid var(--safran);
  padding: 0.6rem 1rem;
  background: rgba(226, 162, 59, 0.06);
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--ink-soft);
}
html[lang="fa"] .callout { font-style: normal; }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 4rem;
}
.site-footer .wrap {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}
.site-footer a { color: var(--ink-soft); }

/* ── Utilities ──────────────────────────────────────────── */
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.todo {
  background: rgba(226, 162, 59, 0.15);
  padding: 0.05em 0.4em;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.78em;
  color: var(--accent);
}
.fa-num { font-variant-numeric: tabular-nums; }

/* ── Print / label-friendly ─────────────────────────────── */
@media print {
  .site-header, .site-nav, .site-footer, .lang-toggle { display: none; }
  html[lang="de"] [data-lang="fa"],
  html[lang="fa"] [data-lang="de"] { display: revert; }
}

/* ── Small screens ──────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 17px; }
  .wrap { padding: 1.5rem 1.1rem 3rem; }
  h1 { font-size: 2rem; }
  .spec { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .spec dt { margin-top: 0.6rem; }

  /* Header: keep brand + toggle on one line, but cheaper on width */
  .site-header .wrap {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
    gap: 0.6rem;
    flex-wrap: nowrap;
  }
  .brand { font-size: 1.2rem; gap: 0.4rem; min-width: 0; }
  .brand-logo { width: 30px; height: 30px; }
  .brand .latin { display: none; }            /* hide Latin subtitle on phones */
  .lang-toggle { font-size: 0.82rem; flex: 0 0 auto; }
  .lang-toggle > * { padding: 0.4rem 0.7rem; }

  /* Hero logo: a touch smaller on phones */
  .hero-logo { width: 140px; height: 140px; }

  /* Nav: tighter spacing so all 4 items fit comfortably */
  .site-nav .wrap { gap: 1rem; }
}
