/* PAE Shop "Gaming Magazine" redesign: shared foundation (phase 1).
   Loaded by includes/header-magazine.php on every page except the three game pages, which keep their own themes.
   Everything is scoped under .mag-site / .mag-masthead / .mag-footer / .mag-404 so the legacy app.css rules on the
   same hook classes (menu-toggle, main-nav, header-row, logo ...) do not leak into the new header. */

/* ---------- Tokens ---------- */
:root {
  --mag-paper: #F3EFE6;
  --mag-card: #FBF8F1;
  --mag-ink: #141210;
  --mag-red: #D7261E;
  --mag-yellow: #FFD23F;
  --mag-muted: #4E4943;
  --mag-muted-2: #3B3732;
  --mag-rule: #C9C1B2;
  --mag-deep-red: #8A1A12;
  --mag-black: #0B0A09;
  --mag-masthead: #141210;
  --mag-cream: #F3EFE6;
  --mag-cream-2: #EDE7DB;
  --mag-dim: #B8B0A2;
  --mag-dim-2: #CFC7B8;
  --mag-line-dark: #3A3631;
  --mag-cat-xbox: #0E7A3C;
  --mag-cat-ps: #1F4FD1;
  --mag-cat-iptv: #C2410C;
  --mag-cat-fortnite: #6D28D9;
  --mag-game-gta: #FF2E88;
  --mag-game-mw4: #FFB000;
  --mag-game-fc27: #D4FF3A;
  --mag-f-display: 'Alexandria', 'Noto Sans Arabic', system-ui, sans-serif;
  --mag-f-body: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', system-ui, sans-serif;
  --mag-f-num: 'Big Shoulders Display', 'Alexandria', sans-serif;
  --mag-shadow: 10px 10px 0 var(--mag-ink);
}

/* ---------- Store strip (announcement) ---------- */
.mag-site .mag-strip {
  background: var(--mag-black); color: var(--mag-cream-2); font-family: var(--mag-f-body);
  font-size: 13px; font-weight: 500; text-align: center; padding: 7px 16px; line-height: 1.6;
}
.mag-site .mag-strip span { color: var(--mag-red); }

/* ---------- Masthead ---------- */
.mag-site .mag-masthead { background: var(--mag-masthead); color: var(--mag-cream); font-family: var(--mag-f-body); position: relative; z-index: 50; }
.mag-site .mag-masthead .mag-top { background: var(--mag-masthead); }
.mag-site .mag-masthead .mag-top-row {
  max-width: 1280px; margin: 0 auto; padding: 18px 28px 16px;
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 24px;
  position: static; height: auto; min-height: 0; border: 0;
}
.mag-site .mag-masthead .mag-issue { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mag-site .mag-masthead .mag-issue-label { font-family: var(--mag-f-display); font-weight: 800; font-size: 18px; color: var(--mag-cream); line-height: 1.3; }
.mag-site .mag-masthead .mag-issue-tag { font-size: 13px; font-weight: 500; color: var(--mag-dim); line-height: 1.6; }
.mag-site .mag-masthead .mag-logo { flex: none; display: flex; align-items: center; justify-content: center; min-height: 44px; }
.mag-site .mag-masthead .mag-logo img { display: block; width: 136px; height: 68px; max-width: none; object-fit: cover; object-position: center; }
.mag-site .mag-masthead .mag-search-wrap { flex: 1 1 240px; min-width: 0; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.mag-site .mag-masthead .mag-search {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 6px 0 14px; width: 100%; max-width: 300px;
  border: 1px solid #4A453E; background: transparent; margin: 0;
}
.mag-site .mag-masthead .mag-search-icon { display: flex; color: var(--mag-dim-2); flex: none; }
.mag-site .mag-masthead .mag-search input[type="search"] {
  flex: 1; min-width: 0; height: 40px; background: transparent; border: 0; outline: none; color: var(--mag-cream);
  font-family: var(--mag-f-body); font-size: 15px; box-shadow: none; padding: 0;
}
.mag-site .mag-masthead .mag-search input[type="search"]::placeholder { color: #9B9385; opacity: 1; }
.mag-site .mag-masthead .mag-search-submit {
  min-height: 44px; align-self: stretch; margin: -1px -6px -1px 0; padding: 0 12px; background: var(--mag-yellow); color: var(--mag-ink); border: 0;
  font-family: var(--mag-f-display); font-weight: 800; font-size: 14px; cursor: pointer; flex: none;
}
.mag-site .mag-masthead .mag-search-toggle,
.mag-site .mag-masthead .mag-menu-toggle { display: none; }

/* Nav strip: black band, red bottom border (the accent), squares for the games. */
.mag-site .mag-masthead .mag-nav {
  border-top: 1px solid var(--mag-line-dark); border-bottom: 5px solid var(--mag-red);
  background: var(--mag-masthead); padding: 0; position: static; display: block; box-shadow: none; transform: none; width: auto;
}
.mag-site .mag-masthead .mag-nav-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 28px;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch;
  font-family: var(--mag-f-display); font-weight: 700; font-size: 15px;
}
.mag-site .mag-masthead .mag-nav a {
  color: var(--mag-cream); min-height: 48px; padding: 0 20px; display: flex; align-items: center; gap: 8px;
  border-left: 1px solid var(--mag-line-dark); white-space: nowrap; text-decoration: none; background: transparent;
}
.mag-site .mag-masthead .mag-nav a:first-child { border-left: 0; }
.mag-site .mag-masthead .mag-nav a:hover { color: var(--mag-yellow); }
.mag-site .mag-masthead .mag-nav a.active,
.mag-site .mag-masthead .mag-nav a[aria-current="page"] { color: var(--mag-ink); background: var(--mag-paper); }
.mag-site .mag-masthead .mag-game-link { padding: 0 18px; }
.mag-site .mag-masthead .mag-game-link bdi { direction: ltr; unicode-bidi: isolate; }
.mag-site .mag-masthead .mag-square { width: 8px; height: 8px; flex: none; }

/* ---------- Footer ---------- */
.mag-site .mag-footer {
  background: var(--mag-black); color: var(--mag-dim-2); border-top: 5px solid var(--mag-red);
  font-family: var(--mag-f-body); padding: 0; margin-top: 0; text-align: start;
}
.mag-site .mag-footer-grid {
  max-width: 1280px; margin: 0 auto; padding: 46px 28px 26px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 32px;
}
.mag-site .mag-footer-brand { display: flex; flex-direction: column; gap: 14px; }
.mag-site .mag-footer-logo { width: 132px; height: 64px; object-fit: cover; object-position: center; align-self: flex-start; }
.mag-site .mag-footer p { margin: 0; font-size: 15px; line-height: 1.8; }
.mag-site .mag-footer a.mag-footer-trust { color: var(--mag-cream); font-size: 15px; font-weight: 700; min-height: 44px; line-height: 44px; display: inline-block; text-decoration: none; }
.mag-site .mag-footer-col { display: flex; flex-direction: column; gap: 4px; }
.mag-site .mag-footer-col h2 { font-family: var(--mag-f-display); font-weight: 800; font-size: 20px; color: var(--mag-cream); margin: 0 0 6px; line-height: 1.3; }
.mag-site .mag-footer a { color: var(--mag-dim-2); font-size: 15px; min-height: 44px; display: flex; align-items: center; text-decoration: none; }
.mag-site .mag-footer a:hover { color: var(--mag-yellow); }
/* WhatsApp contact button (shown only when the admin sets a number): yellow block, ink text and border, square. */
.mag-site .mag-footer a.mag-footer-wa {
  align-self: flex-start; max-width: 100%; margin-top: 10px; padding: 0 18px; min-height: 48px; gap: 10px;
  background: var(--mag-yellow); color: var(--mag-ink); border: 2px solid var(--mag-ink);
  font-family: var(--mag-f-display); font-weight: 800; font-size: 15px; line-height: 1.3;
}
.mag-site .mag-footer a.mag-footer-wa svg { flex: none; }
.mag-site .mag-footer a.mag-footer-wa:hover { background: var(--mag-red); border-color: var(--mag-red); color: var(--mag-cream); }
.mag-site .mag-footer-bottom {
  max-width: 1280px; margin: 0 auto; padding: 16px 28px 26px; border-top: 1px solid #2E2A25;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--mag-dim);
}

/* ---------- Shared components ---------- */
.mag-site .mag-kicker {
  display: inline-block; align-self: flex-start; background: var(--mag-ink); color: var(--mag-cream);
  font-family: var(--mag-f-body); font-size: 14px; font-weight: 700; padding: 4px 12px; line-height: 1.5;
}
.mag-site .mag-btn {
  min-height: 54px; padding: 0 26px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--mag-f-display); font-weight: 800; font-size: 16px; line-height: 1.3; text-decoration: none; cursor: pointer;
  border: 2px solid var(--mag-ink); transition: background-color .15s ease, color .15s ease;
}
.mag-site .mag-btn-ink { background: var(--mag-ink); color: var(--mag-cream); }
.mag-site .mag-btn-ink:hover { background: var(--mag-red); border-color: var(--mag-red); color: var(--mag-cream); }
.mag-site .mag-btn-line { background: transparent; color: var(--mag-ink); }
.mag-site .mag-btn-line:hover { background: var(--mag-ink); color: var(--mag-cream); }
.mag-site :focus-visible { outline: 3px solid var(--mag-yellow); outline-offset: 3px; }

/* ---------- 404 ---------- */
.mag-site .mag-404 { background: var(--mag-paper); color: var(--mag-ink); font-family: var(--mag-f-body); padding: 50px 0 90px; }
.mag-site .mag-404-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 28px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 30px 60px;
}
.mag-site .mag-404-sticker {
  flex: 1 1 520px; min-width: 0; position: relative; display: flex; justify-content: center;
}
.mag-site .mag-404-sticker::before {
  content: ''; position: absolute; inset: 0; margin: auto; width: min(100%, 520px); height: 100%;
  background: var(--mag-yellow); border: 4px solid var(--mag-ink); box-shadow: 14px 14px 0 var(--mag-ink);
  transform: rotate(-2deg); z-index: 0;
}
.mag-site .mag-404-code {
  position: relative; z-index: 1; display: block; padding: 20px 34px 10px;
  font-family: var(--mag-f-num); font-weight: 900; font-size: clamp(130px, 22vw, 260px); line-height: .85; letter-spacing: -4px; color: var(--mag-ink);
  transform: rotate(-2deg);
}
.mag-site .mag-404-zero { color: var(--mag-red); }
.mag-site .mag-404-cut {
  position: absolute; z-index: 2; top: 46%; left: 6%; right: 6%; border-top: 4px dashed var(--mag-ink); transform: rotate(-2deg);
}
.mag-site .mag-404-scissors {
  position: absolute; z-index: 2; top: calc(46% - 19px); left: 0; color: var(--mag-ink); background: var(--mag-paper);
}
.mag-site .mag-404-copy { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.mag-site .mag-404-title { margin: 0; font-family: var(--mag-f-display); font-weight: 900; font-size: clamp(36px, 5vw, 56px); line-height: 1.15; color: var(--mag-ink); }
.mag-site .mag-404-text { margin: 0; font-size: 18px; line-height: 1.9; color: var(--mag-muted-2); }
.mag-site .mag-404-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* ---------- Tablet (760–1023px): masthead keeps one row, nav wraps ---------- */
@media (max-width: 1023px) {
  .mag-site .mag-masthead .mag-top-row { padding: 16px 20px 14px; gap: 16px; }
  .mag-site .mag-masthead .mag-logo img { width: 124px; height: 62px; }
  .mag-site .mag-masthead .mag-issue-label { font-size: 16px; }
  .mag-site .mag-masthead .mag-nav-inner { padding: 0 16px; }
  .mag-site .mag-masthead .mag-nav a { padding: 0 14px; font-size: 14px; }
  .mag-site .mag-masthead .mag-game-link { padding: 0 12px; }
  .mag-site .mag-footer-grid { padding: 40px 20px 24px; }
  .mag-site .mag-footer-bottom { padding: 16px 20px 24px; }
  .mag-site .mag-404-inner { padding: 0 20px; }
}

/* ---------- Phone (≤759px): masthead stacks (logo, then the search full width), nav scrolls inside itself ---------- */
@media (max-width: 759px) {
  .mag-site .mag-masthead .mag-top-row {
    flex-wrap: wrap; justify-content: center; padding: 16px 16px 12px; gap: 12px 0;
  }
  .mag-site .mag-masthead .mag-logo { order: 1; flex: 0 0 100%; }
  .mag-site .mag-masthead .mag-logo img { width: 116px; height: 58px; }
  .mag-site .mag-masthead .mag-issue { order: 2; flex: 0 0 100%; align-items: center; text-align: center; }
  .mag-site .mag-masthead .mag-issue-label { font-size: 16px; }
  .mag-site .mag-masthead .mag-issue-tag { font-size: 12px; }
  .mag-site .mag-masthead .mag-search-wrap { order: 3; flex: 0 0 100%; justify-content: stretch; }
  .mag-site .mag-masthead .mag-search { max-width: none; height: 48px; }
  .mag-site .mag-masthead .mag-search-toggle, .mag-site .mag-masthead .mag-menu-toggle { display: none; }
  .mag-site .mag-masthead .mag-nav { overflow: visible; }
  .mag-site .mag-masthead .mag-nav-inner {
    display: flex; flex-wrap: wrap; justify-content: center; overflow: visible;
    padding: 0 8px;
  }
  .mag-site .mag-masthead .mag-nav a { flex: 0 0 auto; min-height: 44px; padding: 0 12px; font-size: 14px; }
  .mag-site .breadcrumb a, .mag-site .breadcrumb span { display: inline-flex; align-items: center; min-height: 44px; }
  .mag-site .mag-footer-grid { padding: 34px 16px 20px; grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .mag-site .mag-footer-bottom { padding: 14px 16px 22px; }
  .mag-site .mag-404 { padding: 36px 0 60px; }
  .mag-site .mag-404-inner { padding: 0 16px; gap: 28px; }
  .mag-site .mag-404-sticker::before { width: min(100%, 360px); }
  .mag-site .mag-404-code { padding: 16px 22px 8px; font-size: clamp(110px, 38vw, 170px); }
  .mag-site .mag-404-text { font-size: 17px; }
  .mag-site .mag-404-actions .mag-btn { flex: 1 1 100%; }
}

/* ---------- Desktop (≥1024px) ---------- */
@media (min-width: 1024px) {
  .mag-site .mag-masthead .mag-nav-inner { flex-wrap: wrap; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .mag-site .mag-btn { transition: none; }
}

/* Phase 2 review fixes: paper shell and nav active state */
html:has(body.mag-site:not(.game-theme-page)) { background: var(--mag-paper); }
.storefront-body.mag-site:not(.game-theme-page) { background: var(--mag-paper); color: var(--mag-ink); }
.mag-site .mag-masthead .mag-nav a { border-radius: 0; }
.mag-site .skip-link:focus, .mag-site .skip-link:focus-visible { min-height: 44px; display: inline-flex; align-items: center; }
.mag-site .mag-masthead .mag-nav a::before, .mag-site .mag-masthead .mag-nav a::after { content: none; display: none; }
/* Phase 7 fix: game order dialog summary rows keep their label/value row layout (game pages only). */
body.game-theme-page .order-dialog .game-order-summary { display: grid; gap: 0; }
body.game-theme-page .order-dialog .game-order-summary > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; min-width: 0; padding: 8px 0; border-bottom: 1px solid rgba(0, 0, 0, .14); }
body.game-theme-page .order-dialog .game-order-summary > div:last-child { border-bottom: 0; }
body.game-theme-page .order-dialog .game-order-summary > div[hidden] { display: none !important; }
body.game-theme-page .order-dialog .game-order-summary > div > span { flex: 0 0 auto; font-size: .78rem; opacity: .75; }
body.game-theme-page .order-dialog .game-order-summary strong { min-width: 0; font-size: .86rem; line-height: 1.45; text-align: left; overflow-wrap: anywhere; color: inherit; }
body.game-theme-page .order-dialog .game-order-summary [data-game-summary-order-price] { white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

/* Tablet: breadcrumb links keep a 44px touch height (this was phone-only, so 768/1024 links measured 21-23px). */
@media (min-width: 760px) and (max-width: 1024px) { .mag-site .breadcrumb a, .mag-site .breadcrumb span { display: inline-flex; align-items: center; min-height: 44px; } }

/* Skip link is at least 44px tall when it appears (it measured 42px). */
.mag-site .skip-link { min-height: 44px; display: inline-flex; align-items: center; }

/* Audit 2: phone header (<=768px). Target total height under 140px: strip 35 + row 60 + menu line 44. */
@media (max-width: 768px) {
  .mag-site .mag-masthead { position: relative; }
  .mag-site .mag-masthead .mag-issue { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .mag-site .mag-masthead .mag-top-row { position: relative; display: flex; align-items: center; gap: 8px; padding: 4px 16px; min-height: 60px; box-sizing: border-box; }
  .mag-site .mag-masthead .mag-logo { order: 0; flex: 0 0 auto; min-height: 44px; }
  .mag-site .mag-masthead .mag-logo img { width: 88px; height: 52px; max-width: none; object-fit: contain; }
  .mag-site .mag-masthead .mag-search-wrap { order: 1; flex: 0 0 auto; margin-inline-start: auto; display: flex; gap: 0; }
  .mag-site .mag-masthead .mag-search { display: none; }
  .mag-site .mag-masthead .mag-search-icon { display: none; }
  .mag-site .mag-masthead .mag-top-row.search-open .mag-search { display: flex; position: absolute; top: 100%; left: 0; right: 0; width: auto; max-width: none; height: auto; margin: 0; padding: 8px 16px; background: var(--mag-masthead); z-index: 70; box-sizing: border-box; }
  .mag-site .mag-masthead .mag-search-toggle, .mag-site .mag-masthead .mag-menu-toggle { display: inline-flex; align-items: center; justify-content: center; order: 2; width: 44px; height: 44px; min-width: 44px; padding: 0; color: var(--mag-cream); background: transparent; border: 1px solid rgba(255,255,255,.2); cursor: pointer; }
  .mag-site .mag-masthead .mag-menu-toggle { order: 3; font-size: 22px; line-height: 1; }
  .mag-site .mag-masthead .mag-search-toggle:focus-visible, .mag-site .mag-masthead .mag-menu-toggle:focus-visible, .mag-site .mag-masthead .mag-search input:focus-visible, .mag-site .mag-masthead .mag-nav a:focus-visible, .mag-site .mag-masthead .mag-search-submit:focus-visible { outline: 3px solid var(--mag-yellow); outline-offset: 2px; }
  .mag-site .mag-masthead .mag-nav { display: flex; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; height: 44px; min-height: 44px; box-shadow: inset 0 1px 0 rgba(255,255,255,.12); -webkit-mask-image: linear-gradient(to left, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%); mask-image: linear-gradient(to left, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%); }
  .mag-site .mag-masthead .mag-nav::-webkit-scrollbar { display: none; }
  .mag-site .mag-masthead .mag-nav.is-folded { display: none; }
  .mag-site .mag-masthead .mag-nav-inner { display: flex; flex-wrap: nowrap; justify-content: flex-start; width: max-content !important; min-width: 100%; padding: 0 16px; box-sizing: border-box; }
  .mag-site .mag-masthead .mag-nav a { flex: 0 0 auto; display: flex; align-items: center; min-height: 44px; white-space: nowrap; }
}

/* Audit 4: the homepage h1 sits in the masthead where the tagline was; same size and height, so the header does not grow. */
.mag-site .mag-masthead h1.mag-issue-tag { margin: 0; font-family: var(--mag-f-body); font-size: 13px; font-weight: 600; line-height: 1.6; color: var(--mag-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
