/*
 Theme Name: PieceCraft
 Theme URI: https://piececraft.example
 Description: Premium jigsaw puzzle store for adults, built for WooCommerce.
 Author: WorkBuddy
 Version: 1.0.0
 Requires at least: 6.0
 Tested up to: 6.6
 Requires PHP: 7.4
 Text Domain: piececraft
 Tags: e-commerce, woocommerce, custom-colors, custom-menu, featured-images
*/

/* =========================================================
   PieceCraft — Adult Jigsaw Puzzle Store
   WordPress + WooCommerce theme. Visual design matches the
   standalone HTML prototype (ink / cream / gold).
   ========================================================= */

:root {
  --ink: #1c1c28;
  --ink-soft: #2a2a38;
  --cream: #f7f4ef;
  --paper: #ffffff;
  --gold: #c9a24b;
  --gold-dark: #a9863a;
  --muted: #6b6b76;
  --line: #e6e1d8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 28, 40, 0.08);
  --shadow-hover: 0 18px 44px rgba(28, 28, 40, 0.16);
  --maxw: 1200px;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

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

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
  white-space: nowrap;
  color: var(--ink);
  background: var(--paper);
}
.btn:active { transform: translateY(1px); }
.btn--gold { background: var(--gold); color: #1c1c28; }
.btn--gold:hover { background: var(--gold-dark); box-shadow: var(--shadow-hover); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--sm { padding: 9px 16px; font-size: 13.5px; }

/* ---------- Announcement bar ---------- */
.announce {
  background: var(--ink);
  color: #efe9dc;
  font-size: 13px;
  letter-spacing: .2px;
}
.announce__inner {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 9px 22px;
  flex-wrap: wrap;
  text-align: center;
}
.announce strong { color: var(--gold); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 244, 239, 0.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .25s ease;
}
.site-header.is-scrolled { box-shadow: var(--shadow); }
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 16px;
}
.logo {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .3px;
}
.logo span { color: var(--gold); }
.logo--light { color: #f7f4ef; }
.logo--light span { color: var(--gold); }

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}
/* WP 菜单输出 <ul> — 强制横排 */
.main-nav > ul,
.main-nav > div > ul {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.main-nav li { list-style: none; }
.main-nav a {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-soft);
  position: relative;
  padding: 4px 0;
  white-space: nowrap;
}
.main-nav a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--gold);
  transition: width .2s ease;
}
.main-nav a:hover::after { width: 100%; }
.main-nav a:hover { color: var(--ink); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  display: grid; place-items: center;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
.icon-btn:hover { border-color: var(--ink); color: var(--gold-dark); }
.cart-count {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--gold);
  color: #1c1c28;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 999px;
  display: grid; place-items: center;
  padding: 0 4px;
}
.nav-toggle { display: none; }

/* ---------- Hero Carousel ---------- */
.hero { background: var(--ink); }
.carousel {
  position: relative;
  height: 540px;
  overflow: hidden;
}
.slide {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .7s ease, transform 1.2s ease;
  display: flex;
  align-items: center;
}
.slide.is-active { opacity: 1; transform: scale(1); }
.slide__overlay {
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 75% 20%, transparent, rgba(0,0,0,.45));
}
.slide__content {
  position: relative;
  color: #fff;
  max-width: 560px;
}
.slide__eyebrow {
  display: inline-block;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}
.slide__title {
  font-family: var(--serif);
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.05;
  font-weight: 700;
  margin-bottom: 16px;
}
.slide__text {
  font-size: 17px;
  color: rgba(255,255,255,.86);
  margin-bottom: 26px;
  max-width: 460px;
}
.carousel__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background .2s ease;
  z-index: 3;
}
.carousel__arrow:hover { background: rgba(255,255,255,.32); }
.carousel__arrow--prev { left: 22px; }
.carousel__arrow--next { right: 22px; }
.carousel__dots {
  position: absolute;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
  z-index: 3;
}
.carousel__dots button {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.4);
  cursor: pointer;
  transition: background .2s ease, width .2s ease;
}
.carousel__dots button.is-active { background: var(--gold); width: 26px; border-radius: 999px; }

/* ---------- Generic Section ---------- */
.section { padding: 76px 0; }
.section--alt { background: var(--paper); }
.section__head { text-align: center; margin-bottom: 44px; }
.section__title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
}
.section__sub { color: var(--muted); margin-top: 8px; font-size: 16px; }

/* ---------- Categories ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.cat-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 180px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}
.cat-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.5), transparent 60%);
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.cat-card > * { position: relative; z-index: 1; }
.cat-card__icon { font-size: 34px; margin-bottom: auto; }
.cat-card h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.cat-card__count { font-size: 13px; color: rgba(255,255,255,.8); }

/* ---------- Product Grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.product-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, box-shadow .25s ease, border-color .2s ease;
}
.product-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); border-color: transparent; }
.product-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--g1, #2b2d42), var(--g2, #5a3e85));
  display: block;
}
.product-card__media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.product-card__media::after {
  content: "🧩";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 46px;
  opacity: .5;
  z-index: 0;
}
.badge {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 2;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
}
.badge--hot { background: #ffe3d3; color: #b3491b; }
.badge--new { background: #d9f0e4; color: #1f7a4d; }
.product-card__body { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card__title { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.product-card__title a:hover { color: var(--gold-dark); }
.product-card__meta { font-size: 13px; color: var(--muted); }
.product-card__rating { font-size: 14px; color: var(--gold); }
.product-card__rating span { color: var(--muted); font-size: 12px; margin-left: 4px; }
.product-card__foot {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.price { font-weight: 700; font-size: 17px; }

/* ---------- Promotions ---------- */
.promo-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 20px;
}
.promo-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 230px;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #fff;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease;
}
.promo-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.promo-card::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent 65%);
}
.promo-card__body { position: relative; z-index: 1; padding: 26px; }
.promo-card__tag {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.promo-card h3 { font-family: var(--serif); font-size: 26px; font-weight: 600; margin-bottom: 8px; }
.promo-card p { font-size: 14.5px; color: rgba(255,255,255,.88); margin-bottom: 16px; }

/* ---------- Newsletter ---------- */
.newsletter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  flex-wrap: wrap;
}
.newsletter__text h2 { font-family: var(--serif); font-size: 30px; font-weight: 700; }
.newsletter__text p { color: var(--muted); margin-top: 6px; }
.newsletter__form { display: flex; gap: 10px; flex: 1; min-width: 300px; max-width: 460px; }
.newsletter__form input {
  flex: 1;
  padding: 13px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 15px;
  outline: none;
}
.newsletter__form input:focus { border-color: var(--gold); }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #d9d4ca; padding-top: 56px; }
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 30px;
  padding-bottom: 40px;
}
.footer-col h4 { color: #fff; font-size: 15px; margin-bottom: 14px; }
.footer-col a { display: block; font-size: 14px; color: #b9b4aa; padding: 4px 0; }
.footer-col a:hover { color: var(--gold); }
.footer-col__about { font-size: 14px; color: #a9a49a; margin-top: 12px; max-width: 320px; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.1);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: #8f8a80;
}
.footer-bottom__legal a:hover { color: var(--gold); }

/* ---------- Toast (cart feedback) ---------- */
.toast {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- WooCommerce overrides ---------- */
.woocommerce .star-rating { color: var(--gold); font-size: 14px; }
.woocommerce .star-rating::before { color: #d8d2c6; }
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product { margin-bottom: 0; }
.woocommerce #respond input#submit,
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button { border-radius: 999px; }
.woocommerce span.onsale {
  background: var(--gold); color: #1c1c28; border-radius: 999px;
  top: 12px; left: 12px; min-width: auto; padding: 4px 10px; font-weight: 600;
}
.woocommerce-message, .woocommerce-info { border-top-color: var(--gold); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .promo-grid { grid-template-columns: 1fr 1fr; }
  .promo-card--wide { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .main-nav,
  .main-nav > ul,
  .main-nav > div > ul {
    position: fixed;
    top: 68px; left: 0; right: 0;
    background: var(--cream);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 22px 16px;
    border-bottom: 1px solid var(--line);
    transform: translateY(-130%);
    transition: transform .3s ease;
    box-shadow: var(--shadow);
  }
  .main-nav.is-open,
  .main-nav.is-open > ul,
  .main-nav.is-open > div > ul { transform: translateY(0); }
  .main-nav a { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .nav-toggle { display: inline-flex; }
  .announce__hide-mobile { display: none; }
  .carousel { height: 440px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 56px 0; }
}
@media (max-width: 480px) {
  .product-grid { grid-template-columns: 1fr; }
  .promo-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .newsletter__form { flex-direction: column; }
}
