/* ============================================================
   SAYWOOD — Main Stylesheet
   Design System + Global Styles
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Colors */
  --wood:        #8b5e3c;
  --wood-dark:   #6b4423;
  --wood-light:  #c49a6c;
  --wood-pale:   #f0e6d8;
  --dark:        #111111;
  --gray-900:    #222222;
  --gray-800:    #333333;
  --gray-700:    #555555;
  --gray-500:    #777777;
  --gray-400:    #999999;
  --gray-300:    #cccccc;
  --gray-200:    #e5e5e5;
  --gray-100:    #f5f5f5;
  --gray-50:     #fafafa;
  --white:       #ffffff;
  --green-wa:    #25D366;

  /* Typography */
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'DM Sans', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  2.5rem;
  --space-xl:  4rem;
  --space-2xl: 6rem;

  /* Layout */
  --container: 1200px;
  --radius-sm: 2px;
  --radius:    4px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.06);
  --shadow:    0 4px 24px rgba(0,0,0,0.09);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.14);
  --shadow-xl: 0 24px 80px rgba(0,0,0,0.18);

  /* Transitions */
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:    150ms var(--ease);
  --t-base:    280ms var(--ease);
  --t-slow:    450ms var(--ease);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--sans);
  color: var(--gray-800);
  background: var(--white);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button { font-family: var(--sans); cursor: pointer; }
::selection { background: var(--wood-pale); color: var(--wood-dark); }

/* ---- Typography Scale ---- */
h1, h2, h3, h4, h5 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.1;
  color: var(--dark);
}
h1 { font-size: clamp(2.8rem, 6vw, 5.5rem); }
h2 { font-size: clamp(2rem, 4vw, 3.2rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
h4 { font-size: 1.1rem; font-family: var(--sans); font-weight: 600; }
p  { line-height: 1.75; }

.eyebrow {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--wood);
  margin-bottom: var(--space-sm);
}

/* ---- Layout Helpers ---- */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

.section      { padding-block: var(--space-2xl); }
.section-sm   { padding-block: var(--space-xl); }
.section-dark { background: var(--gray-900); color: var(--white); }
.section-light{ background: var(--gray-100); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.9rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition: background var(--t-base), color var(--t-base), border-color var(--t-base), transform var(--t-fast);
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary        { background: var(--wood);     color: var(--white); border-color: var(--wood); }
.btn-primary:hover  { background: var(--wood-dark); border-color: var(--wood-dark); }

.btn-dark           { background: var(--dark);  color: var(--white); border-color: var(--dark); }
.btn-dark:hover     { background: var(--wood);  border-color: var(--wood); }

.btn-outline        { background: transparent; color: var(--dark); border-color: var(--dark); }
.btn-outline:hover  { background: var(--dark); color: var(--white); }

.btn-outline-wood        { background: transparent; color: var(--wood); border-color: var(--wood); }
.btn-outline-wood:hover  { background: var(--wood); color: var(--white); }

.btn-outline-light        { background: transparent; color: var(--white); border-color: rgba(255,255,255,0.55); }
.btn-outline-light:hover  { background: var(--white); color: var(--dark); }

.btn-whatsapp       { background: var(--green-wa); color: var(--white); border-color: var(--green-wa); }
.btn-whatsapp:hover { background: #1da851; border-color: #1da851; }

.btn-sm { padding: 0.55rem 1.2rem; font-size: 0.72rem; }

/* ---- Navigation ---- */
#navbar {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 900;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--gray-200);
  transition: box-shadow var(--t-base);
}
#navbar.scrolled { box-shadow: 0 2px 20px rgba(0,0,0,0.08); }

.nav-inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.logo-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-nav img { height: auto; width: 40px; }
.logo-nav .logo-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.logo-nav .logo-name {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gray-800);
}
.logo-nav .logo-sub {
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray-400);
  margin-top: 2px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}
.nav-links a {
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--gray-700);
  transition: color var(--t-fast);
  cursor: pointer;
  padding-block: 0.25rem;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0;
  width: 0; height: 1.5px;
  background: var(--wood);
  transition: width var(--t-base);
}
.nav-links a:hover { color: var(--wood); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--wood); }
.nav-links a.active::after { width: 100%; }

.nav-cta {
  background: var(--wood) !important;
  color: var(--white) !important;
  padding: 0.55rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--t-base) !important;
  border: none;
}
.nav-cta::after { display: none !important; }
.nav-cta:hover { background: var(--dark) !important; }

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  z-index: 901;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--gray-800);
  border-radius: 1px;
  transition: var(--t-base);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile Nav Drawer ---- */
.nav-drawer {
  display: none;
  position: fixed;
  inset: 72px 0 0 0;
  background: var(--white);
  z-index: 899;
  padding: 2rem clamp(1rem,4vw,2rem);
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--gray-200);
  overflow-y: auto;
}
.nav-drawer.open { display: flex; }
.nav-drawer a {
  display: block;
  padding: 1rem 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--gray-800);
  text-decoration: none;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: color var(--t-fast);
}
.nav-drawer a:hover { color: var(--wood); }
.nav-drawer .drawer-cta {
  margin-top: 1.5rem;
  border-bottom: none;
  border-left: none;
  padding: 0.85rem 1.9rem;
  background: var(--wood);
  color: var(--white) !important;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  text-align: center;
  justify-content: center;
  transition: background var(--t-base);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.nav-drawer .drawer-cta:hover {
  color: var(--white) !important;
  background: var(--dark);
  padding-left: 1.9rem; /* prevent the active state from shifting it */
  border-left: none;
}

.nav-drawer .drawer-cta.active {
  background: var(--wood); /* prevent active state from overriding button style */
  border-left: none;
  padding-left: 1.9rem;
  color: var(--white) !important;
}
.nav-drawer a.active {
  color: var(--wood);
  font-weight: 600;
  padding-left: 1rem;
  border-left: 3px solid var(--wood);
}
/* ---- WhatsApp FAB ---- */
.whatsapp-fab {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 800;
  width: 54px;
  height: 54px;
  background: var(--green-wa);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(37,211,102,0.38);
  text-decoration: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  animation: fab-pulse 3.5s ease-in-out infinite;
}
.whatsapp-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(37,211,102,0.55);
  animation: none;
}
.whatsapp-fab svg { width: 26px; height: 26px; fill: white; flex-shrink: 0; }
@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(37,211,102,0.38); }
  50%       { box-shadow: 0 4px 32px rgba(37,211,102,0.6), 0 0 0 8px rgba(37,211,102,0.08); }
}

/* ---- Page Wrapper ---- */
.page { display: none; animation: fadeIn 0.35s var(--ease); }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Page Header (inner pages) ---- */
.page-header {
  padding-block: 9rem 4.5rem;
  background: var(--gray-100);
  position: relative;
  overflow: hidden;
}
.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 55%, rgba(139,94,60,0.07) 100%);
  pointer-events: none;
}
.page-header .container { position: relative; }
.page-header p {
  max-width: 500px;
  color: var(--gray-700);
  font-size: 1rem;
  margin-top: 0.75rem;
}

/* ---- Marquee ---- */
.marquee-section {
  background: var(--gray-900);
  padding-block: 1.1rem;
  overflow: hidden;
  border-top: 3px solid var(--wood);
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 30s linear infinite;
}
.marquee-item {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  padding-inline: 2rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
  white-space: nowrap;
}
.marquee-dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--wood-light);
  flex-shrink: 0;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ---- Footer ---- */
footer {
  background: var(--dark);
  padding-block: 5rem 2rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.6fr;
  gap: 4rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.footer-logo { height: auto; width: 120px; margin-bottom: 1.25rem; }
.footer-brand p {
  font-size: 0.86rem;
  color: rgba(255,255,255,0.42);
  line-height: 1.85;
  max-width: 280px;
  margin-bottom: 1.5rem;
}
.footer-social {
  display: flex;
  gap: 0.6rem;
}
.footer-social a {
  width: 36px; height: 36px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--t-base), background var(--t-base);
  text-decoration: none;
}
.footer-social a svg { width: 16px; height: 16px; fill: rgba(255,255,255,0.48); transition: fill var(--t-base); }
.footer-social a:hover { border-color: var(--wood-light); background: rgba(196,154,108,0.1); }
.footer-social a:hover svg { fill: var(--wood-light); }

.footer-col h4 {
  font-family: var(--sans);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  margin-bottom: 1.5rem;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }
.footer-col ul a {
  text-decoration: none;
  font-size: 0.86rem;
  color: rgba(255,255,255,0.48);
  transition: color var(--t-fast);
  cursor: pointer;
}
.footer-col ul a:hover { color: var(--wood-light); }

.footer-contact-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.footer-contact-row svg {
  width: 15px; height: 15px;
  stroke: var(--wood-light);
  flex-shrink: 0;
  margin-top: 3px;
}
.footer-contact-row span,
.footer-contact-row a {
  font-size: 0.84rem;
  color: rgba(255,255,255,0.48);
  line-height: 1.55;
  text-decoration: none;
  transition: color var(--t-fast);
}
.footer-contact-row a:hover { color: var(--wood-light); }

.footer-bottom {
  padding-top: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.footer-bottom p { font-size: 0.76rem; color: rgba(255,255,255,0.22); }

/* ---- CTA Banner ---- */
.cta-banner {
  background: var(--wood);
  padding-block: 5.5rem;
  text-align: center;
}
.cta-banner .eyebrow { color: rgba(255,255,255,0.55); }
.cta-banner h2 { color: var(--white); margin-bottom: 1rem; }
.cta-banner p {
  color: rgba(255,255,255,0.72);
  max-width: 480px;
  margin: 0 auto 2.5rem;
  font-size: 1rem;
}
.cta-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ---- Utility ---- */
.text-wood    { color: var(--wood); }
.text-muted   { color: var(--gray-500); }
.text-center  { text-align: center; }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE — Breakpoints
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2.5rem; }
}

/* Mobile nav */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
}

/* Mobile */
@media (max-width: 640px) {
  :root { --space-2xl: 4rem; --space-xl: 3rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .cta-banner { padding-block: 4rem; }
}

/* ============================================================
   ACCESSIBILITY & RESPONSIVE IMPROVEMENTS
   ============================================================ */

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--wood);
  color: var(--white);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}
.skip-link:focus { top: 1rem; }

/* ---- Focus visible (keyboard nav) ---- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--wood);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
a:focus-visible, button:focus-visible { outline: 2px solid var(--wood); outline-offset: 3px; }

/* ---- Touch targets: minimum 44×44px ---- */
.btn       { min-height: 44px; }
.nav-links a { min-height: 44px; display: inline-flex; align-items: center; }
.nav-cta   { min-height: 38px; } /* override — it has padding */
.hamburger { min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
.whatsapp-fab { width: 56px; height: 56px; } /* bump from 54 */
.filter-tab, .proj-filter-btn { min-height: 44px; }
.tab-btn   { min-height: 44px; }
.footer-social a { width: 44px; height: 44px; }
.footer-col ul a  { min-height: 36px; display: inline-flex; align-items: center; }
.catalog-cta { min-height: 36px; }

/* ---- Drawer: prevent body scroll when open ---- */
body.nav-open { overflow: hidden; }

/* ---- Nav drawer: smooth slide-in ---- */
.nav-drawer {
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  opacity: 0;
  display: flex !important; /* always in DOM, toggled via transform */
  pointer-events: none;
}
.nav-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---- Prevent horizontal overflow on all screens ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

/* ---- Fluid images in content ---- */
img, svg, video { max-width: 100%; }

/* ---- Better tap highlight on mobile ---- */
a, button { -webkit-tap-highlight-color: rgba(139,94,60,0.15); }

/* ---- Safe area insets (iPhone notch/home bar) ---- */
@supports (padding: max(0px)) {
  .whatsapp-fab {
    bottom: max(1.75rem, env(safe-area-inset-bottom, 1.75rem));
    right:  max(1.75rem, env(safe-area-inset-right, 1.75rem));
  }
  nav .nav-inner {
    padding-left:  max(clamp(1rem,4vw,2rem), env(safe-area-inset-left));
    padding-right: max(clamp(1rem,4vw,2rem), env(safe-area-inset-right));
  }
}

/* ---- Print styles ---- */
@media print {
  .whatsapp-fab, .hamburger, #navbar, .nav-drawer { display: none !important; }
  .page { display: block !important; }
  body { color: #000; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .marquee-track { animation: none; }
}

/* ============================================================
   RESPONSIVE PATCHES
   ============================================================ */

/* ---- 480px — small phones ---- */
@media (max-width: 480px) {
  :root { --space-2xl: 3.5rem; --space-xl: 2.5rem; }

  h1 { font-size: clamp(2.2rem, 9vw, 2.8rem); }
  h2 { font-size: clamp(1.7rem, 7vw, 2.2rem); }

  .container { padding-inline: 1rem; }

  /* Nav */
  .logo-sub { display: none; }

  /* Buttons — full-width stacks */
  .hero-btns  { flex-direction: column; }
  .hero-btns .btn { width: 100%; justify-content: center; }
  .cta-btns { flex-direction: column; align-items: center; }
  .cta-btns .btn { width: auto; min-width: 220px; justify-content: center; }

  /* Stats row */
  .hero-stats { gap: 1.2rem; flex-wrap: wrap; }
  .stat-num   { font-size: 1.8rem; }

  /* About features */
  .about-features { grid-template-columns: 1fr; }

  /* Footer */
  .footer-grid  { grid-template-columns: 1fr; gap: 2rem; }
  .footer-bottom { flex-direction: column; text-align: center; gap: 0.5rem; }
  .footer-brand p { max-width: 100%; }

  /* Why cards */
  .why-grid  { grid-template-columns: 1fr; }

  /* Projects masonry */
  .projects-masonry { grid-template-columns: 1fr; }
  .proj-preview, .proj-preview:first-child { height: 240px; }

  /* Hero visual shorter on tiny screens */
  .hero-visual { height: 60vw; min-height: 220px; }
}

/* ---- 375px — iPhone SE ---- */
@media (max-width: 375px) {
  .logo-nav .logo-name { font-size: 0.7rem; letter-spacing: 0.2em; }
  .hero-title { font-size: 2rem; }
  .hero-stats { gap: 1rem; }
}

/* ---- Landscape mobile fix ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { min-height: auto; }
  .hero-content { padding-block: 1.5rem; }
  .hero-visual { height: 50vw; }
  .hero-stats { display: none; } /* too cramped in landscape */
}

/* ---- High-res / 2x retina ---- */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .hero-img-main, .hero-img-top {
    background-size: cover;
    image-rendering: -webkit-optimize-contrast;
  }
}
