/* ============================================================
   MASAR REDESIGN — SHARED TOKEN LAYER (Designs A & B)
   Loaded only on the redesign preview templates.
   8pt spacing system, central tokens, component states.
   ============================================================ */

:root {
  /* Spacing — 8pt scale */
  --m2-s1: 4px;  --m2-s2: 8px;   --m2-s3: 16px; --m2-s4: 24px;
  --m2-s5: 32px; --m2-s6: 48px;  --m2-s7: 64px; --m2-s8: 96px;
  --m2-section: clamp(56px, 9vw, 112px);
  --m2-section-sm: clamp(40px, 6vw, 72px);

  /* Container */
  --m2-container: 1240px;
  --m2-gutter: clamp(20px, 4vw, 48px);

  /* Radii — limited set */
  --m2-r-sm: 6px;
  --m2-r-md: 10px;

  /* Shadows — restrained */
  --m2-shadow-1: 0 1px 2px rgba(1, 25, 53, 0.06), 0 4px 12px rgba(1, 25, 53, 0.06);
  --m2-shadow-2: 0 2px 4px rgba(1, 25, 53, 0.08), 0 12px 28px rgba(1, 25, 53, 0.10);

  /* Motion */
  --m2-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --m2-med: 260ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Header heights */
  --m2-header-h: 66px;
  --m2-header-h-desktop: 82px;

  /* Type scale (fluid) */
  --m2-display: clamp(1.9rem, 1.2rem + 2.9vw, 3.1rem);
  --m2-h2: clamp(1.5rem, 1.15rem + 1.4vw, 2.15rem);
  --m2-h3: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  --m2-body: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --m2-small: 0.875rem;
  --m2-eyebrow: 0.8125rem;

  /* Colors referenced from theme.json presets */
  --m2-navy: var(--wp--preset--color--deep-navy);
  --m2-indigo: var(--wp--preset--color--indigo-navy);
  --m2-blue: var(--wp--preset--color--brand-blue);
  --m2-charcoal: var(--wp--preset--color--charcoal);
  --m2-off: var(--wp--preset--color--off-white);
  --m2-pale: var(--wp--preset--color--pale-blue);
  --m2-gold: var(--wp--preset--color--warm-accent);
  --m2-line: rgba(42, 47, 53, 0.14);
  --m2-line-dark: rgba(255, 255, 255, 0.14);
}

/* ---------- Reset the old visual layer inside redesign templates ---------- */
.m2 a { text-decoration: none; }
.m2 .wp-block-button__link:hover { transform: none; box-shadow: none; }
.m2 p { margin-block: 0 0 var(--m2-s3); }
.m2 :is(h1, h2, h3, h4) { margin-block: 0; }
.m2 figure { margin: 0; }

/* Typography behaviour: RTL right-aligned by default, readable measures */
.m2 { font-size: var(--m2-body); }
.m2:lang(ar) { --m2-underline-origin: right; }
.m2:lang(en) { --m2-underline-origin: left; }
.m2 p { max-width: 62ch; }
.m2:lang(ar) { text-align: right; }
.m2:lang(en) { text-align: left; }
.m2 .m2-center { text-align: center; }
.m2 .m2-center p { margin-inline: auto; }

.m2 .m2-display { font-size: var(--m2-display); font-weight: 700; }
.m2:lang(ar) .m2-display { line-height: 1.45; }
.m2:lang(en) .m2-display { line-height: 1.12; letter-spacing: -0.01em; }
.m2 h2 { font-size: var(--m2-h2); font-weight: 700; }
.m2 h3 { font-size: var(--m2-h3); font-weight: 700; }
.m2 .m2-lead { font-size: calc(var(--m2-body) * 1.08); max-width: 52ch; }

/* Eyebrow: small label + short rule, the section identity device */
.m2 .m2-eyebrow {
  display: inline-flex; align-items: center; gap: var(--m2-s2);
  font-size: var(--m2-eyebrow); font-weight: 500;
  color: var(--m2-blue);
}
.m2:lang(en) .m2-eyebrow { letter-spacing: 0.12em; text-transform: uppercase; }
.m2 .m2-eyebrow::before {
  content: ""; inline-size: 28px; block-size: 2px;
  background: currentColor; border-radius: 1px;
}
.m2 .m2-eyebrow--num::before { content: none; }
.m2 .m2-eyebrow .m2-num {
  font-weight: 700; opacity: 0.55; font-variant-numeric: tabular-nums;
}
.m2-on-dark .m2-eyebrow { color: var(--m2-gold); }

/* ---------- Layout primitives ---------- */
.m2 .m2-container {
  max-width: var(--m2-container);
  margin-inline: auto;
  padding-inline: var(--m2-gutter);
}
.m2 .m2-section { padding-block: var(--m2-section); }
.m2 .m2-section--sm { padding-block: var(--m2-section-sm); }

/* Kill stray gaps between template parts and first/last blocks */
.m2-main { margin: 0; }
.m2-main > :first-child { margin-top: 0 !important; }
.m2-main > :last-child { margin-bottom: 0 !important; }

/* ============================================================
   HEADER v2 — compact, one grid row
   ============================================================ */
.m2-header {
  position: sticky; top: 0; z-index: 1000;
  height: var(--m2-header-h);
  display: flex; align-items: center;
  transition: background var(--m2-med), box-shadow var(--m2-med), border-color var(--m2-med);
}
@media (min-width: 1024px) { .m2-header { height: var(--m2-header-h-desktop); } }

.m2-header__row {
  width: 100%;
  display: flex; align-items: center; gap: var(--m2-s4);
}
.m2-header__logo { display: flex; align-items: center; flex: none; }
.m2-header__logo img { height: 30px; width: auto; display: block; }
@media (min-width: 1024px) { .m2-header__logo img { height: 38px; } }

.m2-nav { display: none; }
@media (min-width: 1024px) {
  .m2-nav {
    display: flex; align-items: center; gap: var(--m2-s2);
    margin-inline-start: auto;
  }
  .m2-nav a {
    position: relative;
    padding: 8px 12px; font-size: 0.9375rem; font-weight: 500;
    border-radius: var(--m2-r-sm);
    transition: color var(--m2-fast), background var(--m2-fast);
  }
  .m2-nav a::after {
    content: ""; position: absolute;
    inset-inline: 12px; bottom: 3px; height: 2px;
    background: currentColor; border-radius: 1px;
    transform: scaleX(0); transform-origin: var(--m2-underline-origin, right);
    transition: transform var(--m2-med);
  }
  .m2-nav a:hover::after, .m2-nav a[aria-current="page"]::after { transform: scaleX(1); }
}

/* Language control: quiet text control, part of the nav row */
.m2-lang {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 4px 10px;
  font-size: 0.875rem; font-weight: 500;
  border-radius: var(--m2-r-sm);
  transition: background var(--m2-fast), color var(--m2-fast);
}
@media (min-width: 1024px) { .m2-lang { margin-inline-start: var(--m2-s3); } }

/* Burger: pure SVG icon button */
.m2-burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: none; border: 0; cursor: pointer;
  border-radius: var(--m2-r-sm); color: inherit;
}
@media (min-width: 1024px) { .m2-burger { display: none; } }
.m2-burger svg { width: 22px; height: 22px; display: block; }
.m2-burger .m2-x { display: none; }
.m2-burger[aria-expanded="true"] .m2-bars { display: none; }
.m2-burger[aria-expanded="true"] .m2-x { display: block; }

/* Mobile drawer: full identity panel */
.m2-drawer {
  position: fixed; inset: var(--m2-header-h) 0 0 0; z-index: 999;
  display: flex; flex-direction: column;
  padding: var(--m2-s5) var(--m2-gutter);
  background: var(--m2-navy);
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity var(--m2-med), transform var(--m2-med), visibility 0s linear 260ms;
  overflow-y: auto;
}
.m2-drawer.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.m2-drawer a {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--m2-s3) 0;
  color: #fff; font-size: 1.25rem; font-weight: 500;
  border-bottom: 1px solid var(--m2-line-dark);
}
.m2-drawer a .m2-chevron { opacity: 0.45; }
.m2-drawer a[aria-current="page"] { color: var(--m2-gold); }
.m2-drawer .m2-drawer__cta { margin-top: var(--m2-s5); border: 0; }
.m2-drawer .m2-drawer__meta {
  margin-top: auto; padding-top: var(--m2-s5);
  color: var(--m2-pale); font-size: var(--m2-small);
}
body.m2-drawer-open { overflow: hidden; }
@media (min-width: 1024px) { .m2-drawer { display: none; } }

/* ============================================================
   BUTTON SYSTEM
   ============================================================ */
.m2-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--m2-s2);
  height: 48px; padding-inline: var(--m2-s4);
  font: inherit; font-size: 0.9875rem; font-weight: 700;
  border-radius: var(--m2-r-sm); border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--m2-fast), color var(--m2-fast), border-color var(--m2-fast), box-shadow var(--m2-fast);
}
.m2-btn--sm { height: 42px; padding-inline: var(--m2-s3); font-size: 0.9375rem; }
.m2-btn svg { width: 18px; height: 18px; flex: none; }
:lang(ar) .m2-btn svg.m2-chevron, :lang(ar) .m2-tertiary svg.m2-chevron { transform: scaleX(-1); }

.m2-btn--primary { background: var(--m2-blue); color: #fff; }
.m2-btn--primary:hover { background: #2c5691; }
.m2-btn--primary:active { background: #24487c; }

.m2-btn--ghost { background: transparent; color: inherit; border-color: currentColor; }
.m2-btn--ghost:hover { background: rgba(57, 108, 181, 0.08); }
.m2-on-dark .m2-btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

.m2-btn--light { background: #fff; color: var(--m2-navy); }
.m2-btn--light:hover { background: var(--m2-pale); }

/* Tertiary / text action: label + chevron in ONE unit, no underline */
.m2-tertiary {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  font-weight: 700; font-size: 0.9375rem;
  color: var(--m2-blue);
}
.m2-tertiary svg { width: 16px; height: 16px; transition: transform var(--m2-fast); }
.m2-tertiary:hover svg { transform: translateX(var(--m2-chevron-shift, 3px)); }
:lang(ar) .m2-tertiary:hover svg { transform: scaleX(-1) translateX(3px); }
.m2-on-dark .m2-tertiary { color: var(--m2-gold); }

/* Focus: one refined ring everywhere */
.m2 :is(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--m2-blue);
  outline-offset: 3px;
  border-radius: var(--m2-r-sm);
}
.m2-on-dark :is(a, button):focus-visible, .m2-drawer :is(a, button):focus-visible {
  outline-color: var(--m2-gold);
}

/* ============================================================
   FORM SYSTEM (shared restyle of [masar_lead_form])
   ============================================================ */
.m2 .masar-form { gap: var(--m2-s3); }
.m2 .masar-form label { font-size: var(--m2-small); font-weight: 700; color: var(--m2-charcoal); }
.m2 .masar-form input[type="text"], .m2 .masar-form input[type="tel"],
.m2 .masar-form input[type="email"], .m2 .masar-form select, .m2 .masar-form textarea {
  border: 1px solid var(--m2-line); border-radius: var(--m2-r-sm);
  min-height: 50px; padding: 12px 14px; background: #fff;
  transition: border-color var(--m2-fast), box-shadow var(--m2-fast);
}
.m2 .masar-form :is(input, select, textarea):hover { border-color: rgba(42, 47, 53, 0.32); }
.m2 .masar-form :is(input, select, textarea):focus {
  border-color: var(--m2-blue);
  box-shadow: 0 0 0 3px rgba(57, 108, 181, 0.18);
  outline: none;
}
.m2 .masar-form button[type="submit"] {
  height: 50px; border-radius: var(--m2-r-sm); font-weight: 700;
  background: var(--m2-blue);
  transition: background var(--m2-fast);
}
.m2 .masar-form button[type="submit"]:hover { background: #2c5691; transform: none; }
.m2 .masar-form-notice { border-inline-start: 3px solid; border-block: 0; border-inline-end: 0; border-radius: var(--m2-r-sm); }

/* ============================================================
   FOOTER v2
   ============================================================ */
.m2-footer { background: var(--m2-navy); color: var(--m2-pale); }
.m2-footer__grid {
  display: grid; gap: var(--m2-s6);
  grid-template-columns: 1fr;
  padding-block: var(--m2-s7) var(--m2-s5);
}
@media (min-width: 768px) { .m2-footer__grid { grid-template-columns: 1.4fr 1fr 1.2fr; } }
.m2-footer__brand img { height: 40px; width: auto; }
.m2-footer__brand p { margin-top: var(--m2-s3); max-width: 34ch; font-size: var(--m2-small); line-height: 1.9; }
.m2-footer h2 {
  font-size: var(--m2-eyebrow); font-weight: 700; color: #fff;
  margin-bottom: var(--m2-s3);
}
.m2-footer:lang(en) h2 { letter-spacing: 0.12em; text-transform: uppercase; }
.m2-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--m2-s2); }
.m2-footer a { color: var(--m2-pale); transition: color var(--m2-fast); font-size: 0.9375rem; }
.m2-footer a:hover { color: #fff; }
.m2-footer__contact li { display: flex; gap: 10px; align-items: baseline; font-size: 0.9375rem; }
.m2-footer__contact svg { width: 15px; height: 15px; flex: none; translate: 0 2px; color: var(--m2-gold); }
.m2-footer__bar {
  display: flex; flex-wrap: wrap; gap: var(--m2-s2) var(--m2-s4);
  justify-content: space-between;
  padding-block: var(--m2-s3);
  border-top: 1px solid var(--m2-line-dark);
  font-size: 0.8125rem; color: rgba(220, 231, 248, 0.65);
}
.m2-footer__strip { height: 3px; background: linear-gradient(90deg, var(--m2-blue), var(--m2-gold)); opacity: 0.85; }

/* ============================================================
   Motion — reveal (JS adds .is-visible)
   ============================================================ */
.m2-reveal { opacity: 0; transform: translateY(14px); transition: opacity 420ms ease, transform 420ms ease; }
.m2-reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .m2-reveal { opacity: 1; transform: none; }
  .m2 * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* ============================================================
   Arabic measure overrides: `ch` collapses with GE Dinar One
   (near-zero-width "0" glyph). Use em-based measures for AR.
   ============================================================ */
.m2:lang(ar) p { max-width: 34em; }
.m2:lang(ar) .m2-lead { max-width: 27em; }
.m2:lang(ar) .m2-display { max-width: 12.5em; }
.m2 h2 { max-width: 26ch; }
.m2:lang(ar) h2 { max-width: 16em; }
.m2:lang(ar) { --m2-display: clamp(1.7rem, 1.05rem + 2.3vw, 2.7rem); }

/* Drawer link chevrons */
.m2-drawer a svg { width: 20px; height: 20px; flex: none; }
.m2:lang(ar) .m2-drawer a svg.m2-chevron { transform: scaleX(-1); }

/* Drawer CTA is a button, not a nav row */
.m2-drawer a.m2-drawer__cta { justify-content: center; padding: 0 var(--m2-s4); border-bottom: 0; }

/* Footer social icons — small, quiet, gold on hover (under the Contact column) */
.m2-footer__social { display: flex; align-items: center; gap: 6px; margin-top: var(--m2-s4); }
.m2-footer__social a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  color: rgba(220, 231, 248, 0.75);
  border: 1px solid var(--m2-line-dark); border-radius: var(--m2-r-sm);
  transition: color var(--m2-fast), border-color var(--m2-fast), background var(--m2-fast);
}
.m2-footer__social a:hover { color: var(--m2-gold); border-color: rgba(242, 180, 90, 0.5); background: rgba(242, 180, 90, 0.06); }
.m2-footer__social svg { width: 17px; height: 17px; }


/* File field (optional drawing upload) */
.m2 .masar-field--file input[type="file"] {
  width: 100%; padding: 10px 12px; font: inherit; font-size: var(--m2-small);
  border: 1px dashed rgba(42, 47, 53, 0.3); border-radius: var(--m2-r-sm);
  background: #fff; color: var(--m2-charcoal); cursor: pointer;
  transition: border-color var(--m2-fast);
}
.m2 .masar-field--file input[type="file"]:hover { border-color: var(--m2-blue); }
.m2 .masar-field--file input[type="file"]::file-selector-button {
  font: inherit; font-weight: 700; font-size: var(--m2-small);
  color: var(--m2-blue); background: rgba(57, 108, 181, 0.08);
  border: 0; border-radius: var(--m2-r-sm); padding: 8px 14px;
  margin-inline-end: 12px; cursor: pointer;
}
.m2 .masar-field-hint { font-size: 0.8125rem; color: rgba(42, 47, 53, 0.55); }
