/* ============================================================
   GLOBAL.CSS  –  THREAD & CO. E-COMMERCE
   Shared styles: reset, variables, typography, navbar,
   sidebar, footer, utilities
   ============================================================ */

/* ── Google Fonts ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --clr-bg:         #F7F4EF;
  --clr-surface:    #FFFFFF;
  --clr-dark:       #1A1714;
  --clr-mid:        #4A4540;
  --clr-muted:      #8C8480;
  --clr-border:     #E0DAD4;
  --clr-accent:     #B87333;       /* warm copper */
  --clr-accent-lt:  #D4956A;
  --clr-accent-dk:  #8B5A20;
  --clr-success:    #4A7C59;
  --clr-danger:     #C0392B;
  --clr-warn:       #E67E22;

  --ff-display: 'Cormorant Garamond', Georgia, serif;
  --ff-body:    'DM Sans', sans-serif;

  --nav-h:   68px;
  --sidebar-w: 260px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 4px rgba(26,23,20,.08);
  --shadow-md: 0 4px 16px rgba(26,23,20,.12);
  --shadow-lg: 0 8px 32px rgba(26,23,20,.16);

  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ff-body);
  background: var(--clr-bg);
  color: var(--clr-dark);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a  { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Utility Classes ─────────────────────────────────────── */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.sr-only    { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.flex       { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: var(--transition);
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--clr-dark);
  color: #fff;
}
.btn-primary:hover { background: var(--clr-accent); }

.btn-outline {
  background: transparent;
  color: var(--clr-dark);
  border: 1.5px solid var(--clr-dark);
}
.btn-outline:hover { background: var(--clr-dark); color: #fff; }

.btn-accent {
  background: var(--clr-accent);
  color: #fff;
}
.btn-accent:hover { background: var(--clr-accent-dk); }

.btn-ghost {
  background: transparent;
  color: var(--clr-mid);
  border: 1.5px solid var(--clr-border);
}
.btn-ghost:hover { border-color: var(--clr-dark); color: var(--clr-dark); }

.section-title {
  font-family: var(--ff-display);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 400;
  letter-spacing: -.02em;
  color: var(--clr-dark);
}
.section-subtitle {
  color: var(--clr-muted);
  font-size: 14px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════════════════════ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: rgba(247,244,239,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--clr-border);
  z-index: 1000;
  display: flex;
  align-items: center;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Logo */
.nav-logo {
  font-family: var(--ff-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--clr-dark);
  white-space: nowrap;
}
.nav-logo span { color: var(--clr-accent); }

/* Nav links (right) */
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav-links a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--clr-mid);
  transition: color var(--transition);
  padding: 4px 0;
  position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1.5px;
  background: var(--clr-accent);
  transition: width var(--transition);
}
.nav-links a:hover { color: var(--clr-dark); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--clr-dark); }
.nav-links a.active::after { width: 100%; }

/* Basket */
.basket-btn {
  position: relative;
  background: none;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-dark);
  transition: background var(--transition);
  flex-shrink: 0;
}
.basket-btn:hover { background: var(--clr-border); }
.basket-btn svg { width: 22px; height: 22px; }
.basket-count {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--clr-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform .2s;
}
.basket-count.bump { transform: scale(1.4); }

/* Hamburger */
.hamburger {
  display: none;
  background: none;
  border: none;
  flex-direction: column;
  gap: 5px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--clr-dark);
  border-radius: 2px;
  transition: var(--transition);
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,.45);
  z-index: 900;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar-overlay.visible { display: block; }
.sidebar-overlay.active  { opacity: 1; }

.sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  overflow-y: auto;
  z-index: 950;
  transform: translateX(-100%);
  transition: transform var(--transition);
  padding-bottom: 40px;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  padding: 20px 20px 12px;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--clr-muted);
  border-bottom: 1px solid var(--clr-border);
}

.sidebar-nav { padding: 8px 0; }

/* Category items */
.sidebar-item { position: relative; }
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--clr-mid);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  user-select: none;
}
.sidebar-link:hover { background: var(--clr-bg); color: var(--clr-dark); }
.sidebar-link.active { color: var(--clr-accent); }
.sidebar-link .chevron {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.sidebar-link.open .chevron { transform: rotate(180deg); }

/* Sub-menu */
.sidebar-submenu {
  display: none;
  background: var(--clr-bg);
  border-top: 1px solid var(--clr-border);
  border-bottom: 1px solid var(--clr-border);
}
.sidebar-submenu.open { display: block; }
.sidebar-submenu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 10px 36px;
  font-size: 13px;
  color: var(--clr-mid);
  transition: color var(--transition), background var(--transition);
}
.sidebar-submenu a:hover { color: var(--clr-accent); background: rgba(184,115,51,.06); }
.sidebar-submenu a::before {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--clr-accent);
  opacity: .5;
  flex-shrink: 0;
}

.sidebar-divider { height: 1px; background: var(--clr-border); margin: 8px 0; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT WRAPPER (sidebar + main)
═══════════════════════════════════════════════════════════ */
.page-layout {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}
.page-main {
  flex: 1;
  min-width: 0;
}

/* Desktop: sidebar always visible */
@media (min-width: 1025px) {
  .sidebar {
    transform: translateX(0);
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
  }
  .hamburger      { display: none; }
  .sidebar-overlay{ display: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   BASKET POPUP
═══════════════════════════════════════════════════════════ */
.basket-popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,.5);
  z-index: 1100;
  opacity: 0;
  transition: opacity var(--transition);
}
.basket-popup-overlay.visible { display: flex; justify-content: flex-end; }
.basket-popup-overlay.active  { opacity: 1; }

.basket-popup {
  width: min(420px, 100vw);
  height: 100%;
  background: var(--clr-surface);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition);
  box-shadow: var(--shadow-lg);
}
.basket-popup-overlay.active .basket-popup { transform: translateX(0); }

.basket-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--clr-border);
}
.basket-popup-header h3 {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 600;
}
.basket-close {
  background: none;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--clr-mid);
  transition: background var(--transition);
}
.basket-close:hover { background: var(--clr-bg); }

.basket-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}
.basket-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--clr-muted);
}
.basket-empty svg { width: 56px; height: 56px; margin: 0 auto 16px; opacity: .3; }
.basket-empty p { font-size: 15px; }

.basket-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--clr-border);
}
.basket-item-img {
  width: 72px; height: 88px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--clr-bg);
}
.basket-item-info h4 { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.basket-item-info span { font-size: 12px; color: var(--clr-muted); }
.basket-item-price { font-size: 14px; font-weight: 600; white-space: nowrap; }
.basket-item-remove {
  background: none; border: none;
  color: var(--clr-muted);
  font-size: 18px;
  line-height: 1;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}
.basket-item-remove:hover { color: var(--clr-danger); background: #fdf0ef; }

.basket-popup-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--clr-border);
  background: var(--clr-bg);
}
.basket-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
}
.basket-total-row span:last-child { color: var(--clr-accent); font-size: 20px; }

/* ═══════════════════════════════════════════════════════════
   PRODUCT CARD  (shared)
═══════════════════════════════════════════════════════════ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}
.product-card {
  background: var(--clr-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--clr-border);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.product-card-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--clr-bg);
  transition: transform .4s ease;
}
.product-card:hover .product-card-img { transform: scale(1.04); }
.product-card-img-wrap { overflow: hidden; position: relative; }
.product-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--clr-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
}
.product-badge.new   { background: var(--clr-success); }
.product-badge.sale  { background: var(--clr-danger); }

.product-card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-card-cat  { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--clr-muted); }
.product-card-name { font-size: 15px; font-weight: 500; color: var(--clr-dark); }
.product-card-price { font-size: 16px; font-weight: 700; color: var(--clr-accent); margin-top: auto; }
.product-card-price del { font-weight: 400; color: var(--clr-muted); font-size: 13px; margin-right: 6px; }

.product-card-footer {
  padding: 0 16px 16px;
}
.product-card-footer .btn {
  width: 100%;
  padding: 10px;
  font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════ */
.footer {
  background: var(--clr-dark);
  color: rgba(255,255,255,.75);
  padding: 56px 0 0;
  margin-top: 80px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  padding-bottom: 48px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.footer-brand .nav-logo { color: #fff; font-size: 28px; margin-bottom: 12px; }
.footer-brand p { font-size: 13px; line-height: 1.8; max-width: 280px; }
.footer-col h4 {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 16px;
  font-weight: 600;
}
.footer-col ul li { margin-bottom: 10px; }
.footer-col ul li a { font-size: 13px; transition: color var(--transition); }
.footer-col ul li a:hover { color: var(--clr-accent-lt); }
.footer-bottom {
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-bottom a { transition: color var(--transition); }
.footer-bottom a:hover { color: var(--clr-accent-lt); }

/* Social icons */
.social-links { display: flex; gap: 12px; margin-top: 16px; }
.social-links a {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), background var(--transition);
  color: rgba(255,255,255,.7);
}
.social-links a:hover { border-color: var(--clr-accent); background: var(--clr-accent); color: #fff; }
.social-links svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--clr-dark);
  color: #fff;
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease, toastOut .3s ease .5s forwards;
  border-left: 3px solid var(--clr-accent);
  pointer-events: none;
}
@keyframes toastIn  { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 0 16px;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    width: 100%;
    padding: 13px 24px;
    font-size: 14px;
  }
  .nav-links a::after { display: none; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .footer-brand { grid-column: span 2; }

  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
}

@media (max-width: 480px) {
  :root { --nav-h: 60px; }
  .nav-logo { font-size: 22px; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-brand { grid-column: span 1; }
  .container { padding: 0 16px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}