/* Driftwood Supply Co. — storefront styles */

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --text: #1d1c1a;
  --muted: #6b665e;
  --border: #e4dfd5;
  --accent: #2f5d50;
  --accent-hover: #244a40;
  --accent-soft: #e3ece8;
  --sale: #b4412c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29, 28, 26, 0.06), 0 8px 24px rgba(29, 28, 26, 0.06);
  --container: 1200px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

/* Make the hidden attribute win over component display rules (grid, flex...) */
[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

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

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--text);
  color: #fff;
  border-radius: 6px;
}

.skip-link:focus {
  top: 12px;
}

/* ─── Buttons & controls ─────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.button:hover {
  background: var(--accent-hover);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button--secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.button--secondary:hover {
  background: var(--surface-2);
}

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

.link-button {
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.stepper button {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.stepper span {
  min-width: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stepper--large button {
  width: 44px;
  height: 46px;
}

.stepper input {
  width: 40px;
  text-align: center;
  border: 0;
  background: none;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border-radius: 999px;
}

.badge--sale {
  color: #fff;
  background: var(--sale);
}

.price-compare {
  margin-left: 8px;
  font-weight: 400;
  color: var(--muted);
}

/* ─── Header ─────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 68px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.logo svg {
  width: 26px;
  fill: var(--accent);
  fill-rule: evenodd;
}

.site-nav {
  display: flex;
  gap: 24px;
  margin-right: auto;
}

.site-nav a {
  font-size: 0.95rem;
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

.cart-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.cart-button svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.cart-button__count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
}

/* ─── Hero ───────────────────────────────────────────────────── */

.hero {
  background: var(--accent);
  color: #fff;
}

.hero__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding-top: 56px;
  padding-bottom: 56px;
}

.hero__inner {
  display: grid;
  gap: 16px;
  justify-items: start;
}

.hero__image {
  width: 100%;
  aspect-ratio: 5 / 4;
  object-fit: cover;
  border-radius: 16px;
}

.hero .eyebrow {
  color: #cfe0d8;
}

.hero h1 {
  max-width: 14ch;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__text {
  max-width: 44ch;
  font-size: 1.1rem;
  color: #dce8e2;
}

.hero .button {
  margin-top: 8px;
  color: var(--accent);
  background: #fff;
  border-color: #fff;
}

.hero .button:hover {
  background: var(--surface-2);
}

/* ─── Shop ───────────────────────────────────────────────────── */

.shop {
  padding-top: 56px;
  padding-bottom: 56px;
  scroll-margin-top: 68px;
}

.shop__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.shop__head h2 {
  font-size: 1.8rem;
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search {
  position: relative;
  flex: 1;
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.search input,
.select select {
  width: 100%;
  height: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.search input {
  padding: 0 16px 0 42px;
}

.select select {
  appearance: none;
  min-width: 200px;
  padding: 0 40px 0 16px;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b665e' stroke-width='1.6' fill='none'/%3E%3C/svg%3E")
    no-repeat right 16px center / 12px 8px;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--muted);
}

.chip[aria-pressed="true"] {
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.chip__count {
  font-size: 0.78rem;
  color: var(--muted);
}

.chip[aria-pressed="true"] .chip__count {
  color: #cfcac1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: grid;
  gap: 4px;
  text-decoration: none;
}

.card__media {
  position: relative;
  aspect-ratio: 4 / 5;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.card__media img,
.card__media .img-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.card:hover .card__media img {
  transform: scale(1.03);
}

.card__media .badge {
  position: absolute;
  top: 12px;
  left: 12px;
  box-shadow: var(--shadow);
}

.card__type {
  font-size: 0.8rem;
  color: var(--muted);
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
}

.card:hover .card__title {
  text-decoration: underline;
}

.card__price {
  font-weight: 500;
}

.card--skeleton .card__media,
.card--skeleton span {
  background: linear-gradient(90deg, var(--surface-2) 25%, #e9e5dc 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

.card--skeleton span {
  display: block;
  height: 14px;
  width: 70%;
  border-radius: 4px;
}

.card--skeleton span:last-child {
  width: 35%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.img-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--surface-2);
}

.empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 64px 16px;
  text-align: center;
  color: var(--muted);
}

.perks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding-top: 40px;
  padding-bottom: 64px;
  border-top: 1px solid var(--border);
}

.perks h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

/* ─── Product page ───────────────────────────────────────────── */

.product {
  padding-top: 28px;
  padding-bottom: 72px;
}

.breadcrumb {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumb a {
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text);
  text-decoration: underline;
}

.breadcrumb__current {
  color: var(--text);
}

.product__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.gallery {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 12px;
}

.gallery__main {
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.gallery__main img,
.gallery__main .img-placeholder {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.gallery__thumb {
  padding: 0;
  overflow: hidden;
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.gallery__thumb img,
.gallery__thumb .img-placeholder {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.gallery__thumb[aria-pressed="true"] {
  border-color: var(--text);
}

.product__info {
  display: grid;
  gap: 16px;
}

.product__title {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.product__price {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.35rem;
  font-weight: 600;
}

.product__price .badge {
  margin-left: 8px;
}

.purchase {
  display: grid;
  gap: 20px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.options {
  display: grid;
  gap: 18px;
}

.option {
  margin: 0;
  padding: 0;
  border: 0;
}

.option legend {
  margin-bottom: 10px;
  font-weight: 600;
}

.option__value {
  margin-left: 8px;
  font-weight: 400;
  color: var(--muted);
}

.option__values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  position: relative;
  cursor: pointer;
}

.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill span:first-of-type {
  display: inline-block;
  min-width: 52px;
  padding: 9px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.pill:hover span:first-of-type {
  border-color: var(--muted);
}

.pill input:checked + span {
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.pill input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pill--unavailable span:first-of-type {
  color: var(--muted);
  text-decoration: line-through;
}

.purchase__row {
  display: flex;
  gap: 12px;
}

.purchase__add {
  flex: 1;
}

.product__stock {
  font-size: 0.9rem;
  color: var(--accent);
}

.product__stock--out {
  color: var(--sale);
}

.product__description {
  color: #3b3934;
}

.product__perks {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 16px 18px;
  font-size: 0.9rem;
  list-style: none;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.product__perks li::before {
  content: "✓";
  margin-right: 10px;
  color: var(--accent);
  font-weight: 700;
}

.product--loading .product__info > *:not(.product__title) {
  visibility: hidden;
}

.skeleton-text {
  display: block;
  width: 70%;
  height: 1em;
  background: var(--surface-2);
  border-radius: 6px;
}

/* ─── Cart drawer ────────────────────────────────────────────── */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(29, 28, 26, 0.4);
  opacity: 0;
  transition: opacity 0.25s;
}

.drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  background: var(--bg);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.drawer--open .drawer__overlay {
  opacity: 1;
}

.drawer--open .drawer__panel {
  transform: none;
}

.drawer--busy .drawer__body {
  opacity: 0.6;
  pointer-events: none;
}

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer__header h2 {
  font-size: 1.15rem;
}

.drawer__close {
  width: 36px;
  height: 36px;
  font-size: 1.6rem;
  line-height: 1;
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.drawer__close:hover {
  background: var(--surface-2);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
  transition: opacity 0.15s;
}

.drawer__empty {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 64px 0;
  color: var(--muted);
}

.drawer__footer {
  display: grid;
  gap: 10px;
  padding: 18px 20px 22px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.drawer__subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 1.05rem;
}

.cart-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cart-line {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.cart-line:last-child {
  border-bottom: 0;
}

.cart-line__image img,
.cart-line__image .img-placeholder {
  width: 76px;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-2);
}

.cart-line__info {
  display: grid;
  gap: 4px;
  align-content: start;
}

.cart-line__title {
  font-weight: 600;
  text-decoration: none;
}

.cart-line__title:hover {
  text-decoration: underline;
}

.cart-line__options {
  font-size: 0.85rem;
  color: var(--muted);
}

.cart-line__controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 6px;
}

.cart-line__price {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─── Footer & toast ─────────────────────────────────────────── */

.site-footer {
  padding: 28px 0;
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(480px, calc(100% - 32px));
  padding: 12px 18px;
  color: #fff;
  background: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

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

.toast--error {
  background: var(--sale);
}

/* ─── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .hero__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .product__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }
  .gallery {
    position: static;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 14px;
  }
  .site-nav {
    display: none;
  }
  .site-header__inner {
    justify-content: space-between;
  }
  .perks {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  .toolbar {
    flex-direction: column;
  }
  .select select {
    min-width: 0;
  }
  .hero__layout {
    padding-top: 40px;
    padding-bottom: 40px;
  }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .chip {
    flex: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
