/* Shared responsive layer. !important overrides the templates' inline styles;
   desktop presentation continues to use the original page styles. */
@media (max-width: 1023px) {
  :root {
    --athar-gutter: clamp(16px, 5vw, 32px);
    --athar-header-height: 64px;
    --athar-lang-gap: 60px;
  }

  html { scroll-padding-top: 80px; }
  .athar-site { overflow-x: clip !important; }
  .athar-container {
    padding-inline: var(--athar-gutter) !important;
    min-width: 0;
  }
  main :where(div, article, aside, section, nav, a) { min-width: 0; }
  main :is(h1, h2, h3) {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: break-word;
  }
  main :is(h1, h2, h3) span { white-space: normal !important; }
  .athar-reading-width { max-width: 100% !important; }
  .athar-flex-copy { flex: 1 1 auto !important; width: 100%; }

  header > .athar-container {
    height: var(--athar-header-height) !important;
    min-height: var(--athar-header-height) !important;
    gap: 16px !important;
  }
  header > div > a:first-child { gap: 3px !important; }
  header > div > a:first-child > span:first-child {
    font-size: 24px !important;
    letter-spacing: 0.18em !important;
  }
  header > div > a:first-child > span:last-child {
    font-size: 11px !important;
    line-height: 1.2 !important;
    letter-spacing: 0.29em !important;
  }
  [data-athar-lang-btn] {
    font-size: 16px !important;
    min-width: 44px;
    min-height: 44px !important;
    justify-content: center;
  }
  [data-athar-lang-btn] > span:last-child { font-size: 12px !important; }
  [data-athar-lang-opt] { min-height: 44px; }
  [aria-controls="athar-menu"] { padding: 10px !important; }

  [role="dialog"][aria-hidden="true"] { visibility: hidden; }
  body:has([role="dialog"][aria-hidden="false"]) { overflow: hidden; }
  body:has([role="dialog"][aria-hidden="false"]) :is([data-athar-lang-toggle], .athar-scroll-controller) {
    visibility: hidden;
  }
  #athar-menu > div:last-child {
    padding: 18px var(--athar-gutter) max(24px, env(safe-area-inset-bottom)) !important;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #athar-menu nav {
    flex: 1 0 auto;
    justify-content: center;
    margin-block: 24px !important;
    gap: 12px !important;
  }
  #athar-menu nav a {
    font-size: clamp(32px, 8vw, 44px) !important;
    line-height: 1.2 !important;
    min-height: 44px;
  }

  .athar-collection-toolbar, .athar-section-nav {
    top: var(--athar-header-height) !important;
  }
  .athar-related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .athar-product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }

  /* Keep the language selector's Arabic text legible at the smaller scale. */
  html[dir="rtl"] header > div > a:first-child > span:last-child { font-size: 16px !important; }
  html[dir="rtl"] [data-athar-lang-btn] { font-size: 22px !important; }
}

@media (max-width: 767px) {
  :root { --athar-gutter: clamp(16px, 5vw, 24px); }
  body { font-size: 18px; }

  .athar-eyebrow {
    font-size: 14px !important;
    line-height: 1.45 !important;
    letter-spacing: 0.12em !important;
    white-space: normal !important;
    gap: 10px !important;
  }
  .athar-copy {
    font-size: 18px !important;
    line-height: 1.6 !important;
    letter-spacing: 0 !important;
  }
  .athar-intro { font-size: 22px !important; line-height: 1.4 !important; }
  .athar-quote { font-size: 28px !important; line-height: 1.28 !important; }
  .athar-meta { font-size: 16px !important; line-height: 1.45 !important; }
  main h1 {
    font-size: clamp(40px, 11vw, 52px) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.035em !important;
  }
  main h2 {
    font-size: clamp(30px, 8.2vw, 36px) !important;
    line-height: 1.15 !important;
    letter-spacing: -0.025em !important;
  }
  main h3 { font-size: 26px !important; line-height: 1.2 !important; }
  main h1 > span { overflow: visible !important; }
  main h1 > span:not(:last-child) { padding-bottom: 0.03em !important; }
  main :is(button, input:not([type="checkbox"]), select) { min-height: 44px; }
  main a.athar-eyebrow { min-height: 44px; align-items: center; }
  .athar-section { padding-block: 52px !important; }
  .athar-content-gap { margin-top: 28px !important; }
  .athar-layout-gap { gap: 24px !important; }
  .athar-heading-row { flex-direction: column !important; align-items: stretch !important; }

  /* Compact introductions, with a clear route to the page's main content. */
  .athar-hero {
    min-height: 0 !important;
    padding-top: 100px !important;
    padding-bottom: 28px !important;
    gap: 24px;
  }
  .athar-hero-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .athar-hero > .athar-hero-grid {
    flex: 0 0 auto !important;
    align-items: start !important;
    gap: 28px !important;
    padding-bottom: 0 !important;
  }
  .athar-hero .athar-copy { margin-top: 20px !important; }
  .athar-hero .athar-eyebrow { max-width: 100%; }
  .athar-hero > .athar-container:last-child { padding-bottom: 0 !important; }
  .athar-home-visual {
    width: 100%;
    max-width: 340px;
    height: 180px !important;
    justify-self: center;
    align-self: center !important;
  }
  .athar-home-visual > span { display: none !important; }
  .athar-home-visual > img { max-height: 100% !important; max-width: 85% !important; }
  .athar-home-stats {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-block: 20px 0 !important;
  }
  .athar-home-stats > div {
    min-width: 0 !important;
    padding-inline: 8px !important;
  }
  .athar-home-stats > div:first-child { padding-inline-start: 0 !important; }
  .athar-home-stats > div > div:first-child { font-size: 28px !important; }
  .athar-home-stats .athar-eyebrow { font-size: 12px !important; letter-spacing: 0.04em !important; }
  .athar-collection-stats {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px !important;
  }
  .athar-collection-stats > div > div:first-child { font-size: 26px !important; }
  .athar-collection-stats .athar-eyebrow { font-size: 11px !important; letter-spacing: 0.07em !important; }

  /* Collection controls stay inside the viewport in both reading directions. */
  [data-screen-label="Collection intro"] { padding-block: 32px 16px !important; }
  .athar-collection-toolbar > .athar-container {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px !important;
    padding-block: 8px !important;
  }
  .athar-collection-toolbar > div > div:nth-child(1) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0 !important;
    font-size: 12px !important;
    letter-spacing: 0.06em !important;
    text-align: end;
  }
  .athar-collection-toolbar > div > div:nth-child(2) {
    grid-column: 1;
    grid-row: 1;
    padding-block: 0 !important;
  }
  .athar-collection-toolbar input { font-size: 16px !important; text-overflow: ellipsis; }
  .athar-collection-toolbar > div > div:nth-child(3) {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0 !important;
    justify-content: space-between;
    gap: 12px !important;
  }
  .athar-collection-toolbar button { font-size: 13px !important; letter-spacing: 0.06em !important; }
  .athar-collection-toolbar [role="menu"] {
    right: 0 !important;
    left: auto !important;
    min-width: 200px !important;
    max-width: calc(100vw - 2 * var(--athar-gutter));
  }
  html[dir="rtl"] .athar-collection-toolbar [role="menu"] { right: auto !important; left: 0 !important; }
  .athar-collection-toolbar [role="menuitem"] { text-align: start !important; }
  .athar-collection-toolbar button[aria-expanded="false"] + [role="menu"] { visibility: hidden; }
  #collection-grid { padding-top: 24px !important; scroll-margin-top: 112px; }
  .athar-product-grid, .athar-related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 28px 14px !important;
  }
  [data-page="collection"] [role="dialog"] > div:last-child { max-height: 100dvh; }
  [data-page="collection"] [role="dialog"] fieldset label { min-height: 48px !important; }
  [data-page="collection"] [role="dialog"] input[type="checkbox"] { width: 18px !important; height: 18px !important; }

  /* Editorial sections retain their rhythm without oversized empty areas. */
  .athar-accord-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    gap: 12px !important;
  }
  .athar-accord-grid > a { min-height: 180px !important; padding: 22px !important; }
  .athar-accord-grid > a:first-child { min-height: 220px !important; }
  .athar-manifesto-lines { gap: 24px !important; }
  [data-screen-label="Trace image"] { height: 300px !important; }
  .athar-perspective-image { aspect-ratio: 4 / 3 !important; max-height: 300px; }
  .athar-about-stats { gap: 24px 16px !important; }
  .athar-about-stats > div { grid-column: auto !important; }
  .athar-about-stats > div > div:first-child { font-size: 42px !important; }
  .athar-about-stats > div:last-child > div:first-child { font-size: 27px !important; }

  /* Product imagery, summary and actions form one compact mobile introduction. */
  [data-screen-label="Product hero"] { min-height: 0 !important; padding-top: var(--athar-header-height); background: #6d1423; }
  .athar-product-visual { min-height: 0 !important; padding: 24px var(--athar-gutter) !important; }
  .athar-product-visual > [role="img"] { height: 280px !important; max-width: 280px !important; aspect-ratio: auto !important; }
  .athar-product-visual > div:last-child { margin-top: 18px !important; }
  .athar-product-summary { padding: 24px var(--athar-gutter) 32px !important; }
  .athar-product-summary > div { padding-top: 20px !important; }
  .athar-product-summary h1 { font-size: clamp(34px, 9vw, 46px) !important; }
  .athar-product-summary [data-athar-wa] {
    justify-content: center;
    width: 100%;
    padding: 12px 14px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    letter-spacing: 0.08em !important;
  }
  .athar-product-facts { margin-top: 28px !important; }
  .athar-product-facts dd { font-size: 21px !important; }
  .athar-product-facts dt { font-size: 11px !important; }
  .athar-section-nav > div { min-height: 48px !important; gap: 22px !important; }
  .athar-section-nav a { font-size: 12px !important; white-space: nowrap !important; flex: 0 0 auto; }
  [data-page="product"] main section[id] { scroll-margin-top: 56px; }
  .athar-performance-grid > div { padding: 24px 20px !important; }
  .athar-performance-grid .athar-copy { font-size: 16px !important; }
  [data-screen-label="Previous and next"] a { padding: 28px var(--athar-gutter) !important; }

  /* Stable field labels and comfortable touch targets on small screens. */
  .athar-contact-form { gap: 26px !important; }
  .athar-form-field { padding-top: 0 !important; }
  .athar-field-label {
    position: static !important;
    display: block;
    padding-inline-end: 76px;
    margin-bottom: 8px;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: 0.08em !important;
    line-height: 1.4 !important;
    text-transform: uppercase !important;
    white-space: normal !important;
    color: #6d1423 !important;
  }
  .athar-field-hint {
    top: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    font-size: 11px !important;
    opacity: 0.6 !important;
    transform: none !important;
  }
  .athar-contact-form input:not([type="checkbox"]), .athar-contact-form textarea {
    font-size: 18px !important;
    line-height: 1.5 !important;
    border-radius: 0;
    min-height: 48px;
  }
  .athar-contact-form textarea { min-height: 132px; resize: vertical; }
  .athar-contact-form button[type="submit"] { width: 100%; padding: 16px !important; }
  .athar-contact-form fieldset label { font-size: 12px !important; letter-spacing: 0.06em !important; }
  .athar-contact-form fieldset label:focus-within { outline: 2px solid #7e5c07; outline-offset: 2px; }

  footer { padding-block: 44px max(64px, env(safe-area-inset-bottom)) !important; }
  footer > .athar-container > div:first-child { display: grid !important; grid-template-columns: minmax(0, 1fr); gap: 24px !important; }
  footer nav { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px !important; }
  footer nav a { display: flex; align-items: center; min-height: 44px; }
  footer > .athar-container > div:last-child { margin-top: 28px !important; font-size: 11px !important; line-height: 1.6 !important; letter-spacing: 0.07em !important; }
  .athar-scroll-controller { width: 44px; right: max(8px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .athar-scroll-controller__branch { width: 30px; height: 75px; }
  body:has(input:focus, textarea:focus) .athar-scroll-controller { visibility: hidden; }

  html[dir="rtl"] .athar-eyebrow { letter-spacing: normal !important; font-size: 17px !important; }
  html[dir="rtl"] .athar-copy { font-size: 21px !important; line-height: 1.65 !important; }
  html[dir="rtl"] .athar-meta { font-size: 18px !important; }
  html[dir="rtl"] .athar-field-label { font-size: 17px !important; letter-spacing: normal !important; }
  html[dir="rtl"] .athar-home-stats .athar-eyebrow,
  html[dir="rtl"] .athar-collection-stats .athar-eyebrow { font-size: 14px !important; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .athar-hero { min-height: 0 !important; padding-block: 112px 36px !important; }
  [data-page="home"] .athar-hero-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .athar-home-visual { height: 280px !important; width: 100%; }
  .athar-secondary-visual { height: 300px !important; }
  .athar-eyebrow { font-size: 15px !important; letter-spacing: 0.12em !important; }
  .athar-copy { font-size: 20px !important; line-height: 1.6 !important; }
  .athar-section { padding-block: 64px !important; }
  .athar-product-visual { min-height: 0 !important; padding-block: 96px 32px !important; }
  .athar-product-visual > [role="img"] { height: 340px; max-width: 300px !important; }
}
