/* =========================================================================
   NÖR — Base styles, tokens, reset, typography
   ========================================================================= */

/* Global horizontal-overflow lockdown.
   `overflow-x: clip` is preferred over `hidden` because it doesn't establish
   a scroll container (so sticky positioning still works inside). Falls back
   to `hidden` on browsers that don't support clip. */
html, body {
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100vw;
}
*, *::before, *::after { box-sizing: border-box; }
img, video, svg, iframe { max-width: 100%; height: auto; }
/* Long unbroken URLs/strings shouldn't blow out their containers. */
p, li, h1, h2, h3, h4, .lead, .muted { overflow-wrap: anywhere; word-break: normal; }

:root {
  /* Brand palette — Nordic premium */
  --ink:           #0D1B2A;   /* primary text, deep navy-black */
  --ink-soft:      #2B3A4A;   /* secondary text */
  --ink-muted:     #6B7787;   /* tertiary text, captions */
  --paper:         #FAFAF8;   /* page background */
  --paper-warm:    #F4F0EB;   /* alt section bg, warm */
  --paper-cool:    #EEF2F5;   /* alt section bg, cool */
  --line:          #E0E6ED;   /* borders, dividers */
  --line-soft:     #EDF1F4;
  --accent:        #4A90D9;   /* Nordic blue — links, CTAs */
  --accent-deep:   #2E6FB8;   /* hover state */
  --wood:          #B08968;   /* warm wood undertone */
  --steel:         #8B95A1;   /* stainless undertone */
  --success:       #2F7D5B;
  --warn:          #C9893F;
  --danger:        #B5462E;

  /* Type */
  --font-display:  'Cormorant Garamond', 'Garamond', 'Times New Roman', serif;
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:     ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Scale */
  --text-xs:    0.75rem;     /*  12px */
  --text-sm:    0.875rem;    /*  14px */
  --text-base:  1rem;        /*  16px */
  --text-lg:    1.125rem;    /*  18px */
  --text-xl:    1.375rem;    /*  22px */
  --text-2xl:   1.75rem;     /*  28px */
  --text-3xl:   2.25rem;     /*  36px */
  --text-4xl:   3rem;        /*  48px */
  --text-5xl:   4rem;        /*  64px */
  --text-6xl:   5.5rem;      /*  88px */

  /* Spacing */
  --space-1:   0.25rem;
  --space-2:   0.5rem;
  --space-3:   0.75rem;
  --space-4:   1rem;
  --space-5:   1.5rem;
  --space-6:   2rem;
  --space-7:   3rem;
  --space-8:   4rem;
  --space-9:   6rem;
  --space-10:  8rem;

  /* Layout */
  --max-w:        1320px;
  --max-w-narrow:  880px;
  --max-w-text:    680px;
  --gutter:        max(1.25rem, 4vw);
  --radius-sm:     4px;
  --radius:        8px;
  --radius-lg:     16px;
  --radius-pill:   999px;

  /* Motion */
  --ease:          cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast:        160ms;
  --t-base:        260ms;
  --t-slow:        420ms;

  /* Shadows — subtle, Nordic */
  --shadow-sm:  0 1px 2px rgba(13, 27, 42, 0.04), 0 1px 1px rgba(13, 27, 42, 0.03);
  --shadow:     0 4px 16px rgba(13, 27, 42, 0.06), 0 1px 2px rgba(13, 27, 42, 0.04);
  --shadow-lg:  0 24px 48px rgba(13, 27, 42, 0.08), 0 4px 12px rgba(13, 27, 42, 0.04);
}

/* -- Reset ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.005em;
}

img, svg, video, picture { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-6) 0; }

/* -- Typography ---------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 var(--space-4);
  color: var(--ink);
}

h1 { font-size: clamp(2.5rem, 5.5vw, var(--text-6xl)); font-weight: 400; }
h2 { font-size: clamp(2rem, 4vw, var(--text-4xl)); font-weight: 400; }
h3 { font-size: clamp(1.5rem, 2.6vw, var(--text-3xl)); font-weight: 500; }
h4 { font-size: var(--text-2xl); font-weight: 500; }
h5 { font-size: var(--text-xl); font-weight: 600; }
h6 { font-size: var(--text-lg); font-weight: 600; }

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
  display: inline-block;
}

.lead { font-size: clamp(1.125rem, 1.6vw, var(--text-xl)); color: var(--ink-soft); line-height: 1.55; }
.fine { font-size: var(--text-sm); color: var(--ink-muted); }
.muted { color: var(--ink-muted); }
.serif { font-family: var(--font-display); }
.upper { text-transform: uppercase; letter-spacing: 0.1em; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent-deep); }

/* Inline link variant for body copy */
.body-text a {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: border-color var(--t-fast) var(--ease);
}
.body-text a:hover { border-color: var(--ink); color: var(--ink); }

/* -- Layout primitives --------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: var(--max-w-narrow); }
.container--text   { max-width: var(--max-w-text); }

.section {
  padding-block: clamp(3rem, 8vw, var(--space-10));
}
.section--tight { padding-block: clamp(2rem, 5vw, var(--space-7)); }
.section--warm { background: var(--paper-warm); }
.section--cool { background: var(--paper-cool); }
.section--dark { background: var(--ink); color: var(--paper); }
.section--dark h1, .section--dark h2, .section--dark h3, .section--dark h4 { color: var(--paper); }
.section--dark .muted { color: rgba(250, 250, 248, 0.65); }

.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid--3, .grid--4, .grid--5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid--2, .grid--3, .grid--4, .grid--5 { grid-template-columns: 1fr; } }

.stack > * + * { margin-top: var(--space-4); }
.stack--lg > * + * { margin-top: var(--space-6); }
.stack--sm > * + * { margin-top: var(--space-2); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.center-text { text-align: center; }

/* -- Utility ------------------------------------------------------------- */

.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;
}

.divider { height: 1px; background: var(--line); margin-block: var(--space-6); }

[hidden] { display: none !important; }

/* -- Selection ------------------------------------------------------------ */

::selection { background: var(--ink); color: var(--paper); }

/* -- Focus -------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* -- RTL support (loaded on Arabic locales) ------------------------------ */

[dir="rtl"] .cluster { flex-direction: row-reverse; }
[dir="rtl"] body { font-family: 'Tajawal', var(--font-body); }

/* -- Print --------------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .topbar { display: none; }
}

/* =========================================================================
   RTL + Arabic typography
   ========================================================================= */
html[dir="rtl"] body {
  font-family: 'Tajawal', 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  text-align: right;
}
html[dir="rtl"] .breadcrumbs,
html[dir="rtl"] .hero__cta,
html[dir="rtl"] .cluster {
  direction: rtl;
}
html[dir="rtl"] .site-header__inner { direction: rtl; }
html[dir="rtl"] .nor-drawer__panel { left: 0; right: auto; transform: translateX(-100%); }
html[dir="rtl"] .nor-drawer.is-open .nor-drawer__panel { transform: translateX(0); }
/* Hero italic emphasis: Cormorant Garamond doesn't ship Arabic glyphs.
   Use a serif-style Arabic font for headings via font-family fallback. */
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] .hero h1, html[dir="rtl"] .video-band__title {
  font-family: 'Amiri', 'Cormorant Garamond', serif;
}

/* =========================================================================
   MOBILE LAYOUT FIXES (≤ 640px)
   Targeted fixes for elements that overflow viewport on phones.
   ========================================================================= */
@media (max-width: 640px) {
  /* Container: tight gutters + hard width cap */
  .container { padding-left: 16px; padding-right: 16px; max-width: 100vw; }

  /* Cart line — collapse to image + content stack */
  .cart-line {
    grid-template-columns: 80px 1fr !important;
    gap: 12px !important;
    padding: 14px !important;
  }
  .cart-line__name {
    font-size: 1.1rem !important;
    line-height: 1.25 !important;
    word-break: break-word;
  }
  .cart-line__price { font-size: 0.95rem !important; }
  .cart-line [data-line-total] {
    grid-column: 1 / -1;
    margin-top: 8px;
    text-align: right;
    font-size: 1rem;
  }
  .cart-line__controls {
    grid-column: 1 / -1;
    justify-content: space-between;
    margin-top: 8px;
  }

  /* Cart summary total numbers don't overflow */
  .cart-summary__row span:last-child { text-align: right; word-break: break-word; }
  .cart-summary__row--total { font-size: 1.2rem !important; }

  /* Newsletter (footer) — stack input + button */
  .newsletter {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 6px !important;
  }
  .newsletter input { width: 100% !important; padding: 12px 16px !important; }
  .newsletter button {
    width: 100% !important;
    padding: 14px 18px !important;
    border-radius: 999px !important;
  }

  /* PDP buybox CTAs — stack so neither truncates */
  .buybox__cta-row {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .buybox__cta-row .btn { width: 100%; }

  /* Hero CTAs — stack */
  .hero__cta { flex-direction: column !important; align-items: stretch !important; }
  .hero__cta .btn { width: 100%; text-align: center; }

  /* CTA band buttons — stack */
  .cta-band__buttons {
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
  }
  .cta-band__buttons .btn { width: 100%; }

  /* Footer — make sure long paragraphs respect viewport */
  .site-footer__tagline,
  .site-footer__col p,
  .site-footer p {
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .site-footer__certs {
    flex-wrap: wrap;
    gap: 8px !important;
    justify-content: center;
  }
  .site-footer__bottom { flex-direction: column; gap: 12px; text-align: center; }

  /* Trust strip — wrap items, smaller padding */
  .trust-strip__inner { flex-wrap: wrap; gap: 16px !important; }
  .trust-item { flex: 1 1 calc(50% - 8px); min-width: 0; }

  /* Page header padding */
  .page-header { padding: var(--space-5) 0 !important; }
  .page-header h1 { font-size: clamp(1.6rem, 8vw, 2.5rem) !important; line-height: 1.15 !important; }

  /* Topbar message — hide on mobile, keep region button + delivery icon visible */
  .topbar__msg { display: none; }

  /* Generic button safety: don't blow out width */
  .btn { max-width: 100%; white-space: normal; }

  /* Headlines shouldn't exceed viewport */
  h1, h2, h3 { max-width: 100%; }
}
