/* ---------------------------------------------------------------------------
 * Store
 *
 * Self-contained styles for /store/. Does NOT extend or share variables with
 * /assets/css/main.css. Light/dark/auto theming via prefers-color-scheme +
 * explicit [data-theme] override set by the cycle button.
 * ------------------------------------------------------------------------- */

:root {
  --s-bg: #ffffff;
  --s-fg: #111111;
  --s-muted: #6b6b6b;
  --s-line: #e7e7e7;
  --s-line-strong: #cfcfcf;
  --s-surface: #f6f6f6;
  --s-button-bg: #111111;
  --s-button-fg: #ffffff;
  --s-focus: #2a6df4;
  --s-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);

  --s-container: 80rem;
  --s-gap: 1.25rem;
  --s-radius: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --s-bg: #0e0e0e;
    --s-fg: #f2f2f2;
    --s-muted: #9a9a9a;
    --s-line: #1f1f1f;
    --s-line-strong: #2c2c2c;
    --s-surface: #161616;
    --s-button-bg: #f2f2f2;
    --s-button-fg: #0e0e0e;
    --s-focus: #8db4ff;
    --s-shadow: none;
  }
}

[data-theme="light"] {
  --s-bg: #ffffff;
  --s-fg: #111111;
  --s-muted: #6b6b6b;
  --s-line: #e7e7e7;
  --s-line-strong: #cfcfcf;
  --s-surface: #f6f6f6;
  --s-button-bg: #111111;
  --s-button-fg: #ffffff;
  --s-focus: #2a6df4;
  --s-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] {
  --s-bg: #0e0e0e;
  --s-fg: #f2f2f2;
  --s-muted: #9a9a9a;
  --s-line: #1f1f1f;
  --s-line-strong: #2c2c2c;
  --s-surface: #161616;
  --s-button-bg: #f2f2f2;
  --s-button-fg: #0e0e0e;
  --s-focus: #8db4ff;
  --s-shadow: none;
}

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

html,
body.store {
  height: 100%;
}

body.store {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  background: var(--s-bg);
  color: var(--s-fg);
  font-size: 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.store img {
  max-width: 100%;
  height: auto;
  display: block;
}

body.store a {
  color: inherit;
  text-decoration: none;
}

body.store a:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.06em;
}

body.store :focus-visible {
  outline: 2px solid var(--s-focus);
  outline-offset: 2px;
}

.store-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--s-fg);
  color: var(--s-bg);
  padding: 0.5rem 0.75rem;
  z-index: 1000;
}
.store-skip:focus {
  left: 1rem;
  top: 0.5rem;
}

.store-container {
  width: min(100% - 2.5rem, var(--s-container));
  margin-inline: auto;
}

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

.store-link {
  color: inherit;
  border-bottom: 1px solid var(--s-line-strong);
}
.store-link:hover {
  text-decoration: none;
  border-bottom-color: currentColor;
}

/* --- Header --- */

.store-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--s-bg);
  border-bottom: 1px solid var(--s-line);
}

.store-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0;
}

.store-brand {
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 1rem;
}

.store-header__nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.store-cart {
  font-size: 0.95rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.store-cart__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--s-fg);
  color: var(--s-bg);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.store-theme {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--s-line);
  background: transparent;
  color: var(--s-fg);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.store-theme:hover {
  background: var(--s-surface);
}

.store-theme__icon {
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

.store-theme__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Default to auto until JS sets data-mode (matches anti-flash + reflects state) */
.store-theme:not([data-mode]) .store-theme__svg--auto,
.store-theme[data-mode="auto"] .store-theme__svg--auto,
.store-theme[data-mode="light"] .store-theme__svg--light,
.store-theme[data-mode="dark"] .store-theme__svg--dark {
  opacity: 1;
}

/* --- Main / sections --- */

.store-main {
  flex: 1 0 auto;
}

.store-section {
  padding: clamp(1.5rem, 3vw, 2.5rem) 0 clamp(3rem, 6vw, 5rem);
}

.store-hero {
  padding: clamp(0.5rem, 2vw, 1rem) 0 clamp(1.25rem, 3vw, 2rem);
}

.store-hero--small {
  padding-bottom: 1.25rem;
}

.store-hero__sub {
  margin: 0.35rem 0 0;
  max-width: 56ch;
  font-size: 0.95rem;
}

.store-h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  letter-spacing: -0.01em;
  line-height: 1.05;
  font-weight: 600;
}

/* --- Grid --- */

.store-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: var(--s-gap);
  row-gap: clamp(1.5rem, 3vw, 2.25rem);
}

@media (max-width: 960px) {
  .store-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 700px) {
  .store-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.store-card {
  display: block;
  color: inherit;
}
.store-card:hover {
  text-decoration: none;
}

.store-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--s-surface);
  overflow: hidden;
}

.store-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.store-card:hover .store-card__img {
  transform: scale(1.02);
}

.store-card__overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--s-bg);
  color: var(--s-fg);
  border-top: 1px solid var(--s-line);
  text-align: center;
}

.store-grid__item.is-sold-out .store-card__img {
  opacity: 0.55;
}

.store-card__body {
  padding: 0.65rem 0.1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.store-card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
}

.store-card__price {
  margin: 0;
  font-size: 0.9rem;
  color: var(--s-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Product detail --- */

.store-product {
  padding: clamp(1.25rem, 3vw, 2rem) 0 clamp(3rem, 6vw, 5rem);
}

.store-product__back {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.store-product__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

@media (max-width: 880px) {
  .store-product__layout {
    grid-template-columns: 1fr;
  }
}

.store-gallery {
  margin: 0;
}

.store-gallery__main {
  background: var(--s-surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.store-gallery__img {
  display: block;
  width: 100%;
  height: auto;
  /* Sticky header is ~4rem; leave a little air below so the
     thumbnail rail peeks into view when the image is portrait. */
  max-height: calc(100vh - 5rem);
  object-fit: contain;
  background: var(--s-surface);
}

@media (max-width: 880px) {
  .store-gallery__img {
    /* On mobile the info column stacks below; don't let the image
       eat the whole screen. */
    max-height: 78vh;
  }
}

.store-gallery__thumbs {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.store-gallery__thumb {
  appearance: none;
  padding: 0;
  border: 1px solid var(--s-line);
  background: var(--s-surface);
  width: 4.5rem;
  height: 4.5rem;
  cursor: pointer;
  overflow: hidden;
}
.store-gallery__thumb.is-active {
  border-color: var(--s-fg);
}
.store-gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.store-product__info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 5rem;
  align-self: start;
}

@media (max-width: 880px) {
  .store-product__info {
    position: static;
  }
}

.store-product__title {
  margin: 0;
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.15;
}

.store-product__price {
  margin: 0;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.store-product__form {
  display: grid;
  gap: 0.85rem;
  padding-block: 0.35rem 0.5rem;
  border-top: 1px solid var(--s-line);
  border-bottom: 1px solid var(--s-line);
  padding-top: 1rem;
  padding-bottom: 1.25rem;
  margin-top: 0.25rem;
}

.store-field {
  display: grid;
  gap: 0.35rem;
}

.store-field--qty {
  max-width: 8rem;
}

.store-field__label {
  font-size: 0.78rem;
  color: var(--s-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.store-field__select,
.store-field__input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--s-line-strong);
  background: var(--s-bg);
  color: var(--s-fg);
  font: inherit;
  border-radius: 0;
  appearance: none;
}

.store-field__select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--s-fg) 50%),
    linear-gradient(135deg, var(--s-fg) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.store-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--s-button-bg);
  background: var(--s-button-bg);
  color: var(--s-button-fg);
  font: inherit;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: opacity 0.15s ease;
  width: 100%;
}
.store-button:hover {
  opacity: 0.88;
}
.store-button.is-disabled,
.store-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.store-button--primary {
  width: 100%;
}

.store-product__feedback {
  margin: 0;
  font-size: 0.9rem;
  color: var(--s-muted);
}
.store-product__feedback[data-tone="ok"] {
  color: var(--s-fg);
}
.store-product__feedback[data-tone="err"] {
  color: #c4344e;
}

.store-prose {
  max-width: 60ch;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--s-fg);
}
.store-prose p {
  margin: 0 0 0.85rem 0;
}
.store-prose p:last-child {
  margin-bottom: 0;
}

.store-meta {
  display: grid;
  gap: 0.4rem;
  margin: 0.25rem 0 0;
  padding: 0;
  font-size: 0.9rem;
}
.store-meta div {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1rem;
}
.store-meta dt {
  color: var(--s-muted);
}
.store-meta dd {
  margin: 0;
}

/* --- Cart --- */

.store-cart__content {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
@media (max-width: 880px) {
  .store-cart__content {
    grid-template-columns: 1fr;
  }
}

.store-cart__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--s-line);
}

.store-cart-item {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--s-line);
  align-items: start;
}

.store-cart-item__img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  background: var(--s-surface);
}

.store-cart-item__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.store-cart-item__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
}
.store-cart-item__title a {
  color: inherit;
}

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

.store-cart-item__qty {
  display: inline-flex;
  align-items: center;
  margin-top: 0.5rem;
  border: 1px solid var(--s-line-strong);
  width: max-content;
}
.store-cart-item__qty button {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.store-cart-item__qty button:hover {
  background: var(--s-surface);
}
.store-cart-item__qty span {
  min-width: 2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.store-cart-item__remove {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--s-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.store-cart-item__remove:hover {
  color: var(--s-fg);
}

.store-cart-item__price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}

.store-cart__summary {
  position: sticky;
  top: 5rem;
  display: grid;
  gap: 0.85rem;
  padding: 1.25rem;
  border: 1px solid var(--s-line);
  background: var(--s-surface);
}
@media (max-width: 880px) {
  .store-cart__summary {
    position: static;
  }
}

.store-cart__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.store-cart__note {
  margin: 0;
  font-size: 0.85rem;
}

.store-cart__error {
  margin: 0;
  font-size: 0.9rem;
  color: #c4344e;
}

.store-thanks {
  max-width: 56ch;
  display: grid;
  gap: 0.85rem;
}

/* --- Footer --- */

.store-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--s-line);
  margin-top: auto;
  padding: 1.5rem 0;
}

.store-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.store-footer__inner p {
  margin: 0;
}

.store-footer__nav {
  display: flex;
  gap: 1.25rem;
}

@media (max-width: 520px) {
  .store-footer__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* --- Long-form documents (privacy, terms, etc.) --- */

.store-doc {
  max-width: 70ch;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--s-fg);
}

.store-doc h1 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}

.store-doc h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2.25rem 0 0.5rem;
  line-height: 1.3;
}

.store-doc h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.4rem;
}

.store-doc p {
  margin: 0 0 0.85rem;
}

.store-doc ul,
.store-doc ol {
  margin: 0 0 0.85rem;
  padding-left: 1.4rem;
}

.store-doc li {
  margin: 0.2rem 0;
}

.store-doc strong {
  font-weight: 600;
}

.store-doc a {
  color: inherit;
  border-bottom: 1px solid var(--s-line-strong);
}
.store-doc a:hover {
  border-bottom-color: currentColor;
  text-decoration: none;
}

.store-doc hr {
  border: 0;
  border-top: 1px solid var(--s-line);
  margin: 2rem 0;
}

.store-doc__meta {
  color: var(--s-muted);
  font-size: 0.9rem;
  margin: 0 0 2rem !important;
}

@media (prefers-reduced-motion: reduce) {
  .store-card__img,
  .store-button,
  .store-theme__svg {
    transition: none;
  }
}
