/* ============================================================
   MEWS Redesign — Tokens & Base Styles
   Refined dark + orange direction · Light/Dark theme support
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

/* ──────── DEFAULT (DARK) ──────── */
:root,
[data-theme="dark"] {
  --bg:        #0a0a0a;
  --bg-alt:    #111111;
  --bg-elev:   #161616;
  --bg-card:   #131313;

  --fg:        #ffffff;
  --fg-muted:  rgba(255, 255, 255, 0.62);
  --fg-faint:  rgba(255, 255, 255, 0.38);
  --fg-fainter:rgba(255, 255, 255, 0.20);

  --line:      rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --accent:        #f47920;
  --accent-hover:  #ff8a30;
  --accent-tint:   rgba(244, 121, 32, 0.10);
  --accent-tint-strong: rgba(244, 121, 32, 0.20);

  --on-accent: #ffffff;
  --shadow-soft: 0 30px 60px -20px rgba(0,0,0,0.7);
  --grid-overlay: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] {
  --bg:        #fbfaf6;
  --bg-alt:    #ffffff;
  --bg-elev:   #ffffff;
  --bg-card:   #ffffff;

  --fg:        #0a0a0a;
  --fg-muted:  #4a4a4a;
  --fg-faint:  #777;
  --fg-fainter:#b2b2b2;

  --line:      #ece9e0;
  --line-strong: #d8d4c8;

  --accent:        #f47920;
  --accent-hover:  #d96510;
  --accent-tint:   rgba(244, 121, 32, 0.08);
  --accent-tint-strong: rgba(244, 121, 32, 0.18);

  --on-accent: #ffffff;
  --shadow-soft: 0 30px 60px -20px rgba(20, 20, 20, 0.12);
  --grid-overlay: rgba(0, 0, 0, 0.025);
}

/* ──────── TYPE ──────── */
:root {
  --font: 'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --fs-display: clamp(56px, 8.2vw, 132px);
  --fs-h1:      clamp(40px, 5.2vw, 80px);
  --fs-h2:      clamp(30px, 3.6vw, 56px);
  --fs-h3:      clamp(22px, 1.8vw, 28px);
  --fs-h4:      18px;
  --fs-lead:    clamp(18px, 1.4vw, 22px);
  --fs-body:    16px;
  --fs-sm:      14px;
  --fs-xs:      12px;
  --fs-eyebrow: 12px;

  /* spacing */
  --pad-section:  clamp(80px, 12vw, 180px);
  --pad-section-sm: clamp(56px, 7vw, 110px);
  --pad-x:        clamp(24px, 5vw, 80px);
  --max-w:        1280px;
  --max-w-text:   720px;
}

/* ──────── BASE ──────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  line-height: 1.55;
  font-size: var(--fs-body);
  transition: background 0.4s ease, color 0.4s ease;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; }

/* ──────── TYPOGRAPHY UTILITIES ──────── */
.display {
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.h1 { font-size: var(--fs-h1); font-weight: 700; line-height: 0.98; letter-spacing: -0.03em; }
.h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.02; letter-spacing: -0.025em; }
.h3 { font-size: var(--fs-h3); font-weight: 700; line-height: 1.2; letter-spacing: -0.015em; }
.h4 { font-size: var(--fs-h4); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.lead { font-size: var(--fs-lead); line-height: 1.55; color: var(--fg-muted); text-wrap: pretty; }
.body { font-size: var(--fs-body); line-height: 1.7; color: var(--fg-muted); }
.small { font-size: var(--fs-sm); color: var(--fg-muted); }

.eyebrow {
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-block;
}
.accent { color: var(--accent); }
.muted { color: var(--fg-muted); }

/* ──────── LAYOUT ──────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
  width: 100%;
}
section { padding: var(--pad-section) 0; position: relative; }
section.compact { padding: var(--pad-section-sm) 0; }
section.bg-alt { background: var(--bg-alt); }
section.bg-elev { background: var(--bg-elev); }

.divider { border-top: 1px solid var(--line); }

/* ──────── COMPONENTS ──────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 14px 22px;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn.lg { font-size: 14px; padding: 17px 28px; }
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--fg);
}
.btn-ghost:hover {
  border-color: var(--fg);
}
.btn-invert {
  background: var(--fg);
  color: var(--bg);
}
.btn-invert:hover { background: var(--accent); color: var(--on-accent); }
.btn .arr {
  transition: transform 0.25s ease;
}
.btn:hover .arr { transform: translateX(3px); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg-muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 100px;
}
.tag.accent {
  color: var(--accent);
  border-color: var(--accent-tint-strong);
  background: var(--accent-tint);
}
.tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 32px;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.card:hover { border-color: var(--line-strong); }

/* link with underline animation */
.link {
  position: relative;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  padding-bottom: 2px;
}
.link::after {
  content: ''; position: absolute;
  left: 0; bottom: 0; height: 1px;
  width: 100%;
  background: var(--accent);
  transform: scaleX(1); transform-origin: left;
  transition: transform 0.3s ease;
}
.link:hover::after { transform: scaleX(0); transform-origin: right; }

/* ──────── ANIMATIONS ──────── */
@keyframes mewsFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up {
  opacity: 1;
  transform: none;
  animation: mewsFadeUp 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.fade-up.d1 { animation-delay: 0.1s; }
.fade-up.d2 { animation-delay: 0.2s; }
.fade-up.d3 { animation-delay: 0.35s; }
.fade-up.d4 { animation-delay: 0.5s; }

/* ──────── MOBILE SIDE-BY-SIDE COMPARE ──────── */
body[data-compare="on"] #app {
  display: grid;
  grid-template-columns: 1fr 420px;
  height: 100vh;
  overflow: hidden;
}
body[data-compare="on"] #app > .desktop-view {
  overflow-y: auto;
  overflow-x: hidden;
}
body[data-compare="on"] #app > .mobile-view {
  border-left: 1px solid var(--line-strong);
  background: var(--bg-alt);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
body[data-compare="on"] #app > .mobile-view .frame {
  width: 360px;
  height: calc(100vh - 48px);
  max-height: 780px;
  border-radius: 36px;
  border: 8px solid #1a1a1a;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 40px 60px -20px rgba(0,0,0,0.5);
  position: relative;
}
body[data-compare="on"] #app > .mobile-view .frame iframe {
  width: 100%; height: 100%; border: 0;
}

/* responsive defaults — when mobile-narrow */
@media (max-width: 880px) {
  .hide-mobile { display: none !important; }
}
.hide-desktop { display: none; }
@media (max-width: 880px) {
  .hide-desktop { display: initial; }
}

/* ============================================================
   MOBILE RESPONSIVENESS — comprehensive overrides
   ============================================================ */

/* --- Animated hamburger button (always visible on mobile) --- */
.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
  cursor: pointer;
  padding: 0;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s ease;
}
.nav-toggle:hover { border-color: var(--fg); }
.nav-toggle .bar {
  position: absolute;
  left: 50%;
  width: 18px;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav-toggle .bar-1 { top: 14px; }
.nav-toggle .bar-2 { top: 21px; }
.nav-toggle .bar-3 { top: 28px; }
.nav-toggle .bar-1.open { top: 21px; transform: translateX(-50%) rotate(45deg); }
.nav-toggle .bar-2.open { opacity: 0; }
.nav-toggle .bar-3.open { top: 21px; transform: translateX(-50%) rotate(-45deg); }

@media (max-width: 880px) {
  .nav-toggle { display: inline-block !important; }
}

/* --- Mobile drawer --- */
.mobile-drawer {
  position: fixed;
  top: 64px; left: 0; right: 0; bottom: 0;
  z-index: 79;
  background: var(--bg);
  padding: 32px 24px;
  display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
  animation: drawerSlide 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes drawerSlide {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Tighten nav on mobile so hamburger fits + content clears it --- */
@media (max-width: 880px) {
  nav { padding: 12px 20px !important; }
  nav img { height: 28px !important; }
}

/* --- HERO — home page (special: full viewport, centered) --- */
@media (max-width: 880px) {
  /* The hero <section> is display:grid; its grid item defaults to
     min-width:auto and won't shrink below its content, which on a
     phone makes the centered content wider than the viewport and
     pushes it off to the right (then clipped by overflow:hidden).
     minmax(0,1fr) + min-width:0 let the track and content shrink. */
  section[style*="100vh"] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .home-hero-content {
    padding: 96px 20px 48px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .home-hero-content > *,
  .home-hero-content h1.display,
  .home-hero-content .lead {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .home-hero-content .tag {
    white-space: normal;
    max-width: 100%;
  }
  .home-hero-content h1.display {
    font-size: clamp(40px, 10vw, 56px) !important;
    line-height: 1.0 !important;
  }
  .home-hero-content .lead {
    font-size: 16px !important;
  }
}

/* --- INNER PAGE HEROES — first <section> of any page after Nav --- */
@media (max-width: 880px) {
  main > section:first-child[style*="padding-top: 200"],
  main > section:first-child[style*="padding-top:200"],
  main > section:first-child[style*="paddingTop: 200"],
  main > section:first-child[style*="padding-top: 180"],
  main > section:first-child[style*="padding-top:180"] {
    padding-top: 96px !important;
  }
  /* generic fallback — every first section of inner pages */
  main > section:first-child { padding-top: 96px !important; padding-bottom: 24px !important; }

  /* All sections — softer vertical rhythm */
  section { padding-top: clamp(48px, 10vw, 72px) !important; padding-bottom: clamp(48px, 10vw, 72px) !important; }

  /* Bottom stat strip in home hero shrinks gracefully via auto-fit but force smaller padding */
  section[style*="100vh"] > div[style*="border-top"][style*="padding: 32px"] {
    padding: 20px 20px !important;
  }
}

/* --- Display + heading type scale tightening on small screens --- */
@media (max-width: 880px) {
  :root {
    --fs-display: clamp(38px, 9.5vw, 64px);
    --fs-h1: clamp(34px, 8vw, 52px);
    --fs-h2: clamp(26px, 6vw, 38px);
    --fs-h3: 20px;
  }
}

/* --- Footer — single-column at small widths --- */
@media (max-width: 880px) {
  footer { padding: 64px 20px 24px !important; }
  footer .footer-bottom { flex-direction: column !important; gap: 12px !important; align-items: flex-start !important; }
}

/* --- Service / portfolio rows that use rigid grid templates — let them stack --- */
@media (max-width: 880px) {
  /* These specific grid templates from services/work pages */
  [style*="grid-template-columns: 120px 1fr 280px 60px"],
  [style*="grid-template-columns: 140px 1fr 1fr 60px"],
  [style*="grid-template-columns: 180px 1fr 1fr"],
  [style*="grid-template-columns: 100px 1fr auto"],
  [style*="grid-template-columns: 80px 1fr 200px 200px 60px"],
  [style*="grid-template-columns: 240px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  /* Hide redundant arrows on stacked rows */
  [style*="grid-template-columns: 80px 1fr 200px 200px 60px"] > div:last-child,
  [style*="grid-template-columns: 120px 1fr 280px 60px"] > div:last-child {
    display: none !important;
  }
}

/* --- Forms / generic 2-col layouts collapse --- */
@media (max-width: 880px) {
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 1.1fr 1fr"],
  [style*="grid-template-columns: 1.6fr 1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 320px"],
  [style*="grid-template-columns: 1.3fr 1fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* --- Sticky filter bars sit right under nav on mobile --- */
@media (max-width: 880px) {
  div[style*="position: sticky"][style*="top: 70px"] {
    top: 56px !important;
    padding: 12px 16px !important;
  }
  div[style*="position: sticky"][style*="top: 70px"] > div {
    flex-direction: column !important; align-items: flex-start !important; gap: 10px !important;
  }
}

/* --- Tweaks panel — make sure it doesn't cover content on mobile --- */
@media (max-width: 880px) {
  body[data-compare="on"] #app { grid-template-columns: 1fr !important; }
}

/* --- Small screens / phones in portrait --- */
@media (max-width: 480px) {
  :root {
    --fs-display: 34px;
    --fs-h1: 28px;
    --fs-h2: 22px;
    --pad-x: 18px;
  }
  .home-hero-content {
    padding: 88px 18px 40px !important;
  }
  .home-hero-content h1.display {
    font-size: 34px !important;
    line-height: 1.05 !important;
  }
}

/* --- Bulletproof word-wrap on big display type so nothing ever overflows --- */
.display, h1, h2, h3, .h1, .h2, .h3 {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}
body, main { overflow-x: hidden; }

/* --- Portfolio (Work) page: one project per row on phones --- */
@media (max-width: 640px) {
  main[data-screen-label="work"] [style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
}
