/* ══════════════════════════════════════════════════════════════
   base.css | v1.0 | MachineDesign.ir — Design System
   CSS Variables, Reset, Typography, Utilities
   ══════════════════════════════════════════════════════════════ */

/* ── COLOR PALETTE ── */
:root {
  --color-bg:            #f7f9f9;
  --color-surface:       #ffffff;
  --color-surface-alt:   #eef4f4;
  --color-primary:       #1a6b6b;
  --color-primary-dark:  #145555;
  --color-primary-light: #e8f4f4;
  --color-cta:           #e07b2a;
  --color-cta-hover:     #c9691a;
  --color-text:          #2d2d2d;
  --color-text-muted:    #6b7280;
  --color-text-inverse:  #ffffff;
  --color-border:        #e2e8e8;
  --color-border-strong: #b2c8c8;
  --color-success:       #16a34a;
  --color-overlay:       rgba(10, 40, 40, 0.65);
}

/* ── TYPOGRAPHY ── */
:root {
  --font:          'Vazirmatn', system-ui, sans-serif;
  --font-size-xs:  0.75rem;    /* 12px */
  --font-size-sm:  0.875rem;   /* 14px */
  --font-size-md:  1rem;       /* 16px */
  --font-size-lg:  1.125rem;   /* 18px */
  --font-size-xl:  1.375rem;   /* 22px */
  --font-size-2xl: 1.75rem;    /* 28px */
  --font-size-3xl: 2.25rem;    /* 36px */
  --font-size-4xl: 2.875rem;   /* 46px */
  --font-size-5xl: 3.5rem;     /* 56px */
  --line-height:   1.8;
  --line-height-heading: 1.35;
  --fw-regular:    400;
  --fw-medium:     500;
  --fw-bold:       700;
}

/* ── SPACING (4px grid) ── */
:root {
  --sp-1:  0.25rem;   /* 4px  */
  --sp-2:  0.5rem;    /* 8px  */
  --sp-3:  0.75rem;   /* 12px */
  --sp-4:  1rem;      /* 16px */
  --sp-5:  1.25rem;   /* 20px */
  --sp-6:  1.5rem;    /* 24px */
  --sp-8:  2rem;      /* 32px */
  --sp-10: 2.5rem;    /* 40px */
  --sp-12: 3rem;      /* 48px */
  --sp-16: 4rem;      /* 64px */
  --sp-20: 5rem;      /* 80px */
  --sp-24: 6rem;      /* 96px */
}

/* ── LAYOUT ── */
:root {
  --container:     1200px;
  --container-sm:  768px;
  --gutter:        var(--sp-6);
  --section-py:    var(--sp-20);
  --radius-sm:     4px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-xl:     20px;
  --radius-full:   9999px;
}

/* ── SHADOWS ── */
:root {
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.13);
  --shadow-xl: 0 16px 40px rgba(0,0,0,0.16);
}

/* ── TRANSITIONS ── */
:root {
  --ease:       0.2s ease;
  --ease-slow:  0.35s ease;
  --ease-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ══════════════════════════════════════════════════════════════
   CSS RESET
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height);
  font-size: var(--font-size-md);
  text-align: right;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* ══════════════════════════════════════════════════════════════
   TYPOGRAPHY SCALE
   ══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-heading);
  color: var(--color-text);
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.75rem, 5vw, var(--font-size-4xl));
  font-weight: var(--fw-bold);
}

h2 {
  font-size: clamp(1.5rem, 4vw, var(--font-size-3xl));
  font-weight: var(--fw-bold);
}

h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--fw-bold);
}

h4 {
  font-size: var(--font-size-lg);
  font-weight: var(--fw-medium);
}

h5 {
  font-size: var(--font-size-md);
  font-weight: var(--fw-medium);
}

p {
  font-size: var(--font-size-md);
  line-height: var(--line-height);
}

/* ══════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════ */

/* ── Container ── */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--sm {
  max-width: var(--container-sm);
}

/* ── Section spacing ── */
.section {
  padding-block: var(--section-py);
}

/* ── Section header (centered) ── */
.section-header {
  text-align: center;
  margin-bottom: var(--sp-12);
  max-width: 640px;
  margin-inline: auto;
}

.section-header h2 {
  margin-bottom: var(--sp-4);
}

.section-header p {
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
}

/* ── Text alignment ── */
.text-center  { text-align: center; }
.text-start   { text-align: right; }
.text-end     { text-align: left; }

/* ── Text color ── */
.text-muted   { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-inverse { color: var(--color-text-inverse); }
.text-cta     { color: var(--color-cta); }

/* ── Flexbox helpers ── */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }
.gap-8  { gap: var(--sp-8); }

/* ── Grid helpers ── */
.grid       { display: grid; }
.grid-2     { grid-template-columns: repeat(2, 1fr); }
.grid-3     { grid-template-columns: repeat(3, 1fr); }
.grid-4     { grid-template-columns: repeat(4, 1fr); }

/* ── Screen reader only ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Reveal animation base ── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ── Image placeholder ── */
.placeholder {
  background-color: var(--color-surface-alt);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder::after {
  content: attr(data-src);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  opacity: 0.6;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: absolute;
  bottom: var(--sp-2);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS (mobile-first overrides)
   ══════════════════════════════════════════════════════════════ */

/* Tablet: 768px and up */
@media (min-width: 768px) {
  .grid-2-tablet { grid-template-columns: repeat(2, 1fr); }
  .grid-3-tablet { grid-template-columns: repeat(3, 1fr); }
  .hide-tablet { display: none; }
}

/* Desktop: 1024px and up */
@media (min-width: 1024px) {
  .grid-2-desktop { grid-template-columns: repeat(2, 1fr); }
  .grid-3-desktop { grid-template-columns: repeat(3, 1fr); }
  .grid-4-desktop { grid-template-columns: repeat(4, 1fr); }
  .hide-desktop { display: none; }
}

/* Mobile only: below 768px */
@media (max-width: 767px) {
  html {
    scroll-padding-top: 64px;
  }

  .hide-mobile { display: none; }

  .section {
    padding-block: var(--sp-12);
  }

  .section-header {
    margin-bottom: var(--sp-8);
  }

  /* Stack grids on mobile */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════
   PRINT STYLES
   ══════════════════════════════════════════════════════════════ */
@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .no-print {
    display: none !important;
  }

  a {
    color: black;
    text-decoration: underline;
  }
}