/* =========================================================
   MERIDIAN ARMS — Shared base styles
   Used by index.html, category.html, product.html, cart.html, checkout.php, confirmation.html
   ========================================================= */

:root {
  --ink: #0c0d0a;
  --bone: #ebe7df;
  --bone-2: #d9d4c8;
  --paper: #f4f1ea;
  --steel: #6b6a64;
  --rust: #b8412a;
  --rust-deep: #8a2f1f;
  --brass: #a88959;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--ink);
  color: var(--bone);
  font-family: 'Fraunces', serif;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  position: relative;
  /* Order matters: hidden is the fallback for old browsers; clip overrides
     on modern ones. iOS Safari `overflow:hidden` silently breaks when any
     descendant is `position: sticky` — `overflow:clip` does not. */
  overflow-x: hidden;
  overflow-x: clip;
}

/* Belt-and-suspenders: never let an image or media element push the viewport */
img, svg, video, canvas, iframe {
  max-width: 100%;
}

/* Long unbreakable strings (SKUs, UPCs, FFL numbers) should wrap, not overflow */
.spec-row span, .product .sub, .product h5,
.line-body h4, .line-body .sub, .line-body .meta,
.dealer-card .name, .dealer-card .meta,
.summary-line .name, .summary-line .meta {
  overflow-wrap: break-word;
  word-break: break-word;
}

body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(184,65,42,0.05), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(168,137,89,0.04), transparent 50%);
  background-attachment: fixed;
}

::selection { background: var(--rust); color: var(--bone); }

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

a { color: inherit; text-decoration: none; }

/* GRAIN OVERLAY */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* COMPLIANCE BAR */
.compliance {
  background: var(--bone);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 8px 32px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--ink);
}
.compliance span { display: flex; align-items: center; gap: 8px; }
.pulse { width: 6px; height: 6px; background: var(--rust); border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* NAV */
nav.site-nav {
  position: sticky; top: 0;
  z-index: 50;
  background: var(--ink);
  border-bottom: 1px solid rgba(235,231,223,0.1);
  padding: 18px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.nav-left { display: flex; gap: 28px; font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
.nav-left a { position: relative; padding: 4px 0; transition: color 0.2s; }
.nav-left a::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 0; height: 1px; background: var(--rust);
  transition: width 0.3s ease;
}
.nav-left a:hover::after { width: 100%; }
.nav-left a:hover { color: var(--bone); }

.logo {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.32em;
  font-style: italic;
}
.logo span { color: var(--rust); font-style: normal; }

.nav-right { display: flex; justify-content: flex-end; gap: 24px; align-items: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
.cart {
  border: 1px solid var(--bone);
  padding: 8px 16px;
  display: flex; gap: 10px; align-items: center;
  transition: all 0.25s;
}
.cart:hover { background: var(--bone); color: var(--ink); }
.cart-count { background: var(--rust); color: var(--bone); padding: 1px 6px; font-size: 10px; }

/* BUTTONS */
.btn-primary {
  background: var(--bone);
  color: var(--ink);
  padding: 16px 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border: 1px solid var(--bone);
  transition: all 0.25s;
  cursor: pointer;
}
.btn-primary:hover { background: var(--rust); border-color: var(--rust); color: var(--bone); }

.btn-secondary {
  color: var(--bone);
  padding: 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  border-bottom: 1px solid rgba(235,231,223,0.3);
  cursor: pointer;
  background: none;
}
.btn-secondary:hover { color: var(--rust); border-color: var(--rust); }

/* FOOTER */
footer.site-footer {
  padding: 80px 32px 32px;
  background: var(--ink);
  border-top: 1px solid rgba(235,231,223,0.1);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 64px;
  border-bottom: 1px solid rgba(235,231,223,0.1);
}
.footer-brand .logo { display: block; margin-bottom: 24px; }
.footer-brand p {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--bone-2);
  max-width: 320px;
}
.footer-col h6 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--rust);
  margin-bottom: 20px;
}
.footer-col ul { list-style: none; }
.footer-col li {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  margin-bottom: 10px;
  color: var(--bone-2);
  cursor: pointer;
  transition: color 0.2s;
}
.footer-col li:hover { color: var(--rust); }
.footer-col li a { display: block; color: inherit; }
.footer-bottom {
  padding-top: 32px;
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.15em;
  color: var(--steel);
  text-transform: uppercase;
}

/* ANIMATIONS */
.fade-up { animation: fadeUp 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.d1 { animation-delay: 0.1s; }
.d2 { animation-delay: 0.25s; }
.d3 { animation-delay: 0.4s; }
.d4 { animation-delay: 0.55s; }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  /* Keep the cart visible, hide secondary nav links */
  .nav-left { display: none; }
  .nav-right a:not(.cart) { display: none; }
  .nav-right { gap: 0; justify-content: flex-end; }
  nav.site-nav {
    grid-template-columns: 1fr auto;
    padding: 12px 16px;
    gap: 12px;
  }
  .logo { font-size: 18px; letter-spacing: 0.22em; }
  .cart { padding: 7px 12px; gap: 8px; font-size: 10px; }

  /* Compliance bar wraps text instead of overflowing */
  .compliance {
    font-size: 9px;
    padding: 6px 12px;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .compliance span:nth-child(2),
  .compliance span:nth-child(3) { display: none; }

  /* Footer tightens up on mobile */
  footer.site-footer { padding: 48px 16px 24px; }
  .footer-grid { gap: 28px; padding-bottom: 32px; }
  .footer-bottom {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    font-size: 9.5px;
  }
}
