/* ==========================================================================
   C.S. Haven Co. — design tokens + component styles
   ========================================================================== */

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Motion */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 1080px;
  --content-wide: 1280px;

  /* Fonts */
  --font-display: 'Zodiak', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Work Sans', 'Helvetica Neue', sans-serif;
}

/* ---- Light mode (default) — warm ivory + sage, wellness palette ---- */
:root,
[data-theme='light'] {
  --color-bg: #faf7f1;
  --color-surface: #ffffff;
  --color-surface-2: #f5f1e8;
  --color-surface-offset: #efe9dc;
  --color-surface-offset-2: #e7e0cf;
  --color-divider: #e6dfcc;
  --color-border: #dcd2b9;

  --color-text: #2c2a21;
  --color-text-muted: #6d6851;
  --color-text-faint: #ab a284; /* placeholder to fix below */
  --color-text-faint: #aba284;
  --color-text-inverse: #faf7f1;

  --color-primary: #66794f;
  --color-primary-hover: #52633f;
  --color-primary-active: #414f32;
  --color-primary-highlight: #dfe6d1;

  --color-accent: #b97452;
  --color-accent-hover: #9c5e3f;
  --color-accent-highlight: #efddcd;

  --color-success: #5c8a56;
  --color-success-highlight: #dbe8d6;
  --color-error: #a6524a;
  --color-error-highlight: #ecd8d4;

  --shadow-sm: 0 1px 2px oklch(0.25 0.02 100 / 0.06);
  --shadow-md: 0 6px 18px oklch(0.25 0.02 100 / 0.09);
  --shadow-lg: 0 16px 40px oklch(0.25 0.02 100 / 0.14);
}

/* ---- Dark mode ---- */
[data-theme='dark'] {
  --color-bg: #1a1913;
  --color-surface: #201e17;
  --color-surface-2: #26231a;
  --color-surface-offset: #2b281c;
  --color-surface-offset-2: #322e1f;
  --color-divider: #34301f;
  --color-border: #3c3720;

  --color-text: #eae4d3;
  --color-text-muted: #aba284;
  --color-text-faint: #726a52;
  --color-text-inverse: #201e17;

  --color-primary: #97ab80;
  --color-primary-hover: #83976c;
  --color-primary-active: #71835c;
  --color-primary-highlight: #34402a;

  --color-accent: #d19a78;
  --color-accent-hover: #dcac8c;
  --color-accent-highlight: #423325;

  --color-success: #83b378;
  --color-success-highlight: #2e3b28;
  --color-error: #cf8b82;
  --color-error-highlight: #3f2c29;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-md: 0 6px 18px oklch(0 0 0 / 0.35);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #1a1913;
    --color-surface: #201e17;
    --color-surface-2: #26231a;
    --color-surface-offset: #2b281c;
    --color-surface-offset-2: #322e1f;
    --color-divider: #34301f;
    --color-border: #3c3720;
    --color-text: #eae4d3;
    --color-text-muted: #aba284;
    --color-text-faint: #726a52;
    --color-text-inverse: #201e17;
    --color-primary: #97ab80;
    --color-primary-hover: #83976c;
    --color-primary-active: #71835c;
    --color-primary-highlight: #34402a;
    --color-accent: #d19a78;
    --color-accent-hover: #dcac8c;
    --color-accent-highlight: #423325;
    --color-success: #83b378;
    --color-success-highlight: #2e3b28;
    --color-error: #cf8b82;
    --color-error-highlight: #3f2c29;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-md: 0 6px 18px oklch(0 0 0 / 0.35);
    --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.45);
  }
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

section {
  padding-block: clamp(var(--space-16), 8vw, var(--space-32));
}

.eyebrow {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--color-text);
}

.section-heading {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-top: var(--space-3);
  max-width: 30ch;
}

.section-intro {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-12);
}

.section-sub {
  color: var(--color-text-muted);
  max-width: 56ch;
  font-size: var(--text-base);
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: oklch(from var(--color-bg) l c h / 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-divider);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
  gap: var(--space-6);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
  text-decoration: none;
}

.brand__logo {
  height: 40px;
  width: auto;
  display: block;
}

.footer__brand .brand__logo {
  height: 40px;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.nav__links {
  display: flex;
  gap: var(--space-6);
  list-style: none;
}

.nav__links a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 500;
}

.nav__links a:hover {
  color: var(--color-primary);
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--color-text);
  position: relative;
}

.icon-btn:hover {
  background: var(--color-surface-offset);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.cart-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 17px;
  height: 17px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 3px;
}

.nav-toggle {
  display: none;
}

@media (min-width: 761px) {
  .nav-toggle {
    display: none;
  }
}

@media (max-width: 760px) {
  .nav-toggle {
    display: inline-flex;
  }

  .brand__logo {
    height: 28px;
  }

  .nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-2) var(--space-5) var(--space-4);
    box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.15);
  }

  .nav__links.is-open {
    display: flex;
  }

  .nav__links li {
    width: 100%;
  }

  .nav__links a {
    display: block;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
  }

  .nav__links li:last-child a {
    border-bottom: none;
  }

  .header {
    position: relative;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  white-space: nowrap;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  background: var(--color-primary-hover);
}
.btn--primary:active {
  background: var(--color-primary-active);
}
.btn--primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover {
  background: var(--color-surface-offset);
}

.btn--block {
  width: 100%;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  padding-top: clamp(var(--space-12), 6vw, var(--space-20));
  padding-bottom: clamp(var(--space-16), 8vw, var(--space-24));
}

.hero__grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: var(--space-16);
  align-items: center;
}

.hero__heading {
  font-size: var(--text-2xl);
  font-weight: 500;
  margin-top: var(--space-4);
  letter-spacing: -0.01em;
}

.hero__lede {
  margin-top: var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  max-width: 44ch;
}

.hero__actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-8);
  flex-wrap: wrap;
}

.hero__figure {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  aspect-ratio: 4 / 3;
}

.hero__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  .hero__grid {
    grid-template-columns: 1fr;
  }
  .hero__figure {
    aspect-ratio: 16 / 10;
    order: -1;
  }
}

/* ==========================================================================
   Values strip
   ========================================================================== */

.values {
  padding-block: var(--space-16);
  border-top: 1px solid var(--color-divider);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
}

.values__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-10);
}

.value {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.value__icon {
  width: 40px;
  height: 40px;
  color: var(--color-primary);
}

.value h3 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
}

.value p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

@media (max-width: 760px) {
  .values__grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }
}

/* ==========================================================================
   Shop
   ========================================================================== */

.filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-10);
  flex-wrap: wrap;
}

.filter-btn {
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.filter-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-btn[aria-pressed='true'] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}

@media (max-width: 980px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 620px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

.product-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition:
    transform var(--transition-interactive),
    box-shadow var(--transition-interactive);
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.product-card__figure {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-2);
}

.product-card__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card__body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.product-card__category {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-accent);
  font-weight: 600;
}

.product-card__name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
}

.product-card__desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  flex: 1;
}

.product-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
  gap: var(--space-3);
}

.product-card__price {
  font-size: var(--text-base);
  font-weight: 600;
}

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary-active);
}

.add-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ==========================================================================
   About
   ========================================================================== */

.about__grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: var(--space-16);
  align-items: center;
}

.about__figure {
  border-radius: var(--radius-xl);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow-md);
}

.about__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about__copy p {
  color: var(--color-text-muted);
  margin-top: var(--space-4);
}

.about__copy p:first-of-type {
  margin-top: var(--space-4);
}

.about__grid--reverse {
  grid-template-columns: 1.1fr 0.9fr;
}

@media (max-width: 900px) {
  .about__grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Trust strip
   ========================================================================== */

.trust {
  display: flex;
  gap: var(--space-10);
  flex-wrap: wrap;
  justify-content: center;
  padding-block: var(--space-10);
  border-top: 1px solid var(--color-divider);
}

.trust__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.trust__item svg {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
  flex-shrink: 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface-2);
  padding-block: var(--space-16) var(--space-8);
}

.footer__grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--space-10);
}

.footer__brand p {
  color: var(--color-text-muted);
  margin-top: var(--space-3);
  max-width: 32ch;
  font-size: var(--text-sm);
}

.footer h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.footer ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
}

.footer a:hover {
  color: var(--color-primary);
}

.footer__bottom {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

@media (max-width: 700px) {
  .footer__grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   Cart drawer
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0.01 90 / 0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-interactive);
}

.overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--color-surface);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 320ms var(--ease-standard);
  box-shadow: var(--shadow-lg);
}

.cart-drawer.is-open {
  transform: translateX(0);
}

.cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
}

.cart-drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
}

.cart-drawer__items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.cart-item {
  display: flex;
  gap: var(--space-3);
}

.cart-item__figure {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--color-surface-2);
}

.cart-item__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.cart-item__name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.cart-item__price {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.cart-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-1);
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.qty-stepper button {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.qty-stepper button:hover {
  background: var(--color-surface-offset);
}

.qty-stepper span {
  min-width: 24px;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 600;
}

.cart-item__remove {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-decoration: underline;
}

.cart-item__remove:hover {
  color: var(--color-error);
}

.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  height: 100%;
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-10);
}

.cart-empty svg {
  width: 46px;
  height: 46px;
  color: var(--color-text-faint);
}

.cart-drawer__footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cart-drawer__subtotal {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-base);
  font-weight: 600;
}

.cart-drawer__note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.checkout-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  background: var(--color-error-highlight);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  display: none;
}

.checkout-error.is-visible {
  display: block;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translate(-50%, 16px);
  background: var(--color-text);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 220ms var(--ease-standard),
    transform 220ms var(--ease-standard);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   Success overlay
   ========================================================================== */

.success-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: none;
  align-items: center;
  justify-content: center;
  background: oklch(0.2 0.01 90 / 0.5);
  padding: var(--space-6);
}

.success-overlay.is-open {
  display: flex;
}

.success-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.success-card svg {
  width: 48px;
  height: 48px;
  color: var(--color-success);
}

.success-card h3 {
  font-size: var(--text-lg);
}

.success-card p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================
   Theme toggle
   ========================================================================== */

[data-theme-toggle] svg {
  width: 18px;
  height: 18px;
}
