/* ==========================================================================
   VIRA — Base: reset, fonts, typography, layout primitives, utilities
   ========================================================================== */

/* ---- Fonts ------------------------------------------------------------- */
@font-face {
  font-family: "Kalameh";
  src: url("../fonts/KalamehWeb_thin.woff") format("woff");
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kalameh";
  src: url("../fonts/KalamehWeb_Regular.woff2") format("woff2"),
       url("../fonts/KalamehWeb_Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kalameh";
  src: url("../fonts/KalamehWeb_Bold.woff2") format("woff2"),
       url("../fonts/KalamehWeb_Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kalameh";
  src: url("../fonts/KalamehWeb_Black.woff") format("woff");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
/* Reading font for long-form article text (single posts) */
@font-face {
  font-family: "IRANSans";
  src: url("../fonts/IRANSansWeb.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---- Reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100dvh;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: #fff; }

/* Persian digits everywhere the content allows */
body { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-feature-settings: "ss01"; }

/* ---- Typography -------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 900;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--text);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-md); }
p { text-wrap: pretty; }
.lead { font-size: var(--fs-md); color: var(--text-2); line-height: 1.9; }
.muted { color: var(--muted); }
.accent { color: var(--accent-2); }
.gradient-text {
  background: linear-gradient(120deg, #fff 0%, #fff 45%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
strong, b { font-weight: 700; }

/* Section header pattern */
.section-head { max-width: 760px; margin-bottom: clamp(2rem, 4vw, 3.5rem); }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head .eyebrow { margin-bottom: var(--space-4); }
.section-head h2 + p { margin-top: var(--space-4); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.02em;
}
.eyebrow::before {
  content: "";
  width: 8px; height: 8px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ---- Layout ------------------------------------------------------------ */
.container {
  width: min(100% - var(--gutter) * 2, var(--container));
  margin-inline: auto;
}
.container.wide { max-width: var(--container-wide); width: min(100% - var(--gutter) * 2, var(--container-wide)); }
.container.narrow { width: min(100% - var(--gutter) * 2, var(--container-narrow)); }

.section { position: relative; padding-block: var(--section-y); }
.section.tight { padding-block: calc(var(--section-y) * 0.6); }
.section.bg-2 { background: var(--bg-2); }

.grid { display: grid; gap: var(--space-5); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.flex { display: flex; gap: var(--space-4); align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; inset-block-start: 8px; inset-inline-start: 8px;
  z-index: var(--z-modal);
  padding: 0.6rem 1rem;
  background: var(--accent); color: #fff;
  border-radius: var(--r-sm);
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus { transform: none; }

/* ---- Decorative primitives ------------------------------------------- */
.noise::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

.glow {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  filter: blur(40px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

/* Logo mark as a mask utility (SVG in /img/brand/logo-mark.svg) */
.logo-mask {
  -webkit-mask: url("../img/brand/logo-mark.svg") center / contain no-repeat;
  mask: url("../img/brand/logo-mark.svg") center / contain no-repeat;
}

/* ---- Motion preferences ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Reveal defaults: elements start visible for no-JS / crawlers; JS adds .js */
.js [data-reveal] { opacity: 0; }
.js [data-reveal].is-inview { opacity: 1; }
.js [data-split] .split-line { overflow: clip; }

/* 5 cards in a 3-col grid → last row centered (2 items) instead of a hole */
@media (min-width: 1025px) {
  .grid.cols-3:has(> :nth-child(5):last-child) { grid-template-columns: repeat(6, 1fr); }
  .grid.cols-3:has(> :nth-child(5):last-child) > * { grid-column: span 2; }
  .grid.cols-3:has(> :nth-child(5):last-child) > :nth-child(4) { grid-column: 2 / span 2; }
}
