/* ==========================================================================
   Viola — Structural layout: header, footer, grids
   All directional rules use logical properties so they resolve correctly
   for dir="rtl" without left/right hacks.
   ========================================================================== */

/* ---- Site header ---- */
/* 2026-09-08: <header id="site-header"> ships EMPTY — layout.js injects the
   bar and only then adds the .site-header class. Until that runs the element
   is 0px tall, so filling it shoved the whole page down 86px: measured CLS
   0.115 ≈ 86 / 812 viewport. Reserving the box on the ID (which is present in
   the HTML from the first byte) removes that shift. Same value the inner
   .site-header__bar already uses, so nothing moves once JS lands. */
#site-header {
  min-block-size: var(--header-height);
}

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 40;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-block-end: 2px solid transparent;
  transition: border-color var(--dur-base) var(--ease-brand), box-shadow var(--dur-base) var(--ease-brand);
}

.site-header.is-scrolled {
  border-block-end-color: var(--color-border-soft);
  box-shadow: var(--header-shadow);
}

.site-header__bar {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
  min-block-size: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-header__logo {
  display: inline-flex;
  align-items: center;
  transition: transform var(--dur-fast) var(--ease-bounce);
}

.site-header__logo:hover {
  transform: rotate(-2deg) scale(1.04);
}

.site-header__logo img {
  block-size: 38px;
  inline-size: auto;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.site-nav__link {
  position: relative;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--nav-link-color);
  padding-block: var(--space-2);
}

.site-nav__link::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-end: 0;
  inline-size: 0;
  block-size: 3px;
  background: var(--color-brand-primary);
  border-radius: var(--radius-pill);
  transition: inline-size var(--dur-base) var(--ease-brand);
}

.site-nav__link:hover::after,
.site-nav__link[aria-current="page"]::after {
  inline-size: 100%;
}

.site-nav__link[aria-current="page"] {
  color: var(--nav-link-active);
}

/* Header CTA — hidden inside the mobile drawer list, shown on desktop bar */
.site-header__cta {
  flex: none;
}

/* "تماس با ما" appears as the CTA button on desktop; the plain list item
   only shows inside the mobile drawer. */
.site-nav__contact-item {
  display: none;
}

@media (max-width: 860px) {
  .site-nav__contact-item {
    display: block;
  }
}

.nav-toggle {
  display: none;
  inline-size: 44px;
  block-size: 44px;
  border-radius: var(--radius-sm);
}

.nav-toggle__bar,
.nav-toggle__bar::before,
.nav-toggle__bar::after {
  content: "";
  display: block;
  inline-size: 24px;
  block-size: 2.5px;
  border-radius: var(--radius-pill);
  background: var(--color-brand-primary);
  margin-inline: auto;
  transition: transform var(--dur-fast) var(--ease-brand), opacity var(--dur-fast);
}

.nav-toggle__bar::before {
  transform: translateY(-7px);
}

.nav-toggle__bar::after {
  transform: translateY(5px);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar::before {
  transform: translateY(0) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar::after {
  transform: translateY(-2.5px) rotate(-45deg);
}

@media (max-width: 860px) {
  .nav-toggle {
    display: block;
  }

  /* Extra ancestor keeps this stronger than components.css's `.btn`
     (same specificity, later sheet) which would otherwise re-show it */
  .site-header__bar .site-header__cta {
    display: none;
  }

  /* NOTE: the header's backdrop-filter makes it the containing block for
     fixed descendants, so the drawer uses absolute positioning off the
     header box itself (sticky header = positioned ancestor). */
  .site-nav {
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 0;
    block-size: calc(100vh - var(--header-height));
    overflow-y: auto;
    background: var(--color-surface);
    background-image: var(--pattern-url);
    background-size: 300px auto;
    padding: var(--space-5) var(--space-4);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--dur-base) var(--ease-brand), opacity var(--dur-base);
  }

  /* Soften the pattern behind the drawer links */
  .site-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.93);
  }

  .site-nav.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .site-nav__list {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .site-nav__link {
    font-size: var(--fs-lg);
  }
}

/* ---- Site footer ---- */
.site-footer {
  position: relative;
  overflow: hidden;
  background: var(--footer-bg);
  color: var(--footer-text);
  margin-block-start: var(--space-7);
}

.site-footer__inner {
  position: relative;
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-6) var(--space-4) var(--space-5);
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: var(--space-5);
}

@media (max-width: 960px) {
  .site-footer__inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .site-footer__inner {
    grid-template-columns: 1fr;
  }
}

.site-footer__brand img {
  block-size: 110px;
  inline-size: auto;
  margin-block-end: var(--space-3);
  /* single-purple asset flipped to white for the dark footer */
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

.site-footer__brand p {
  font-size: var(--fs-sm);
  max-width: 34ch;
}

.site-footer__heading {
  color: #fff;
  font-size: var(--fs-base);
  margin-block-end: var(--space-3);
}

.site-footer__list {
  display: grid;
  gap: var(--space-2);
  font-size: var(--fs-sm);
}

.site-footer__list a {
  transition: color var(--dur-fast);
}

.site-footer__list a:hover {
  color: #fff;
}

.site-footer__social {
  display: flex;
  gap: var(--space-2);
}

.site-footer__social a {
  inline-size: 42px;
  block-size: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: background var(--dur-fast) var(--ease-brand), transform var(--dur-fast) var(--ease-bounce);
}

.site-footer__social a:hover {
  background: var(--color-brand-primary);
  transform: translateY(-4px) rotate(-6deg);
}

.site-footer__bottom {
  position: relative;
  border-block-start: 1px solid rgba(255, 255, 255, 0.14);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  font-size: var(--fs-xs);
}

/* ---- Generic grids ---- */
.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 960px) {
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
  }
}

.section {
  padding-block: var(--space-6);
}

.section--tint {
  position: relative;
  background: var(--color-surface-alt);
}
