/* components.css - reusable component classes */

/* ========== Buttons ========== */
/* One button design, site-wide: outline, 56px, fills on hover, natural case.
   .btn-primary / .btn-secondary are kept as aliases of .btn so existing markup
   keeps working - there is intentionally only one button style now. */
.btn,
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 56px;
  padding: 0 var(--space-5);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: 0.02em;
  background: var(--color-bg);
  color: var(--color-fg);
  border: 1px solid var(--color-fg);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
  border-radius: var(--radius-sm);
}
.btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: var(--color-fg);
  color: var(--color-bg);
}
.btn:focus-visible {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-available { color: var(--color-status-available); }
.badge-reserved { color: var(--color-status-reserved); font-variant-numeric: tabular-nums; }
.badge-sold {
  color: var(--color-status-sold);
  border-color: var(--color-border);
}

/* ========== Inputs ========== */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
}
.field__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-fg-muted);
}
.input {
  font: inherit;
  font-size: var(--text-base);
  height: 56px;
  padding: 0 var(--space-3);
  background: var(--color-bg-elev);
  border: 1px solid var(--color-border);
  color: var(--color-fg);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}
/* Textareas grow vertically, so 56px is a floor, not a fixed height. */
textarea.input {
  height: auto;
  min-height: 56px;
  padding: var(--space-3);
}
.input:focus {
  outline: none;
  border-color: var(--color-fg);
}
.input.is-error { border-color: var(--color-danger); }
.input:disabled {
  background: var(--color-border);
  opacity: 0.5;
}
.field__error {
  font-size: var(--text-xs);
  color: var(--color-danger);
}

/* ========== Item tile ========== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--space-5);
  row-gap: var(--space-6);
  align-items: end;
}
@media (max-width: 900px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .tile-grid { grid-template-columns: 1fr; } }

.tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0;
  cursor: pointer;
}
.tile__image {
  width: 100%;
  background: var(--color-fg);
  margin-bottom: var(--space-3);
  overflow: hidden;
  position: relative;
  aspect-ratio: var(--ar, 1 / 1);
}
.tile__image-inner {
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  transition: transform var(--transition-base);
}
.tile__image-inner--empty {
  background: linear-gradient(135deg, #2a2622, #1a1714);
}
.tile:hover .tile__image-inner { transform: scale(1.03); }

.tile__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}
.tile__title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin: 0;
}
.tile__price {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
}

/* Aspect-ratio modifiers used to mirror source painting shape - kept for the
   style guide demo. Live tiles use --ar CSS variable set inline. */
.ar-portrait { aspect-ratio: 3 / 4; }
.ar-landscape { aspect-ratio: 4 / 3; }
.ar-square { aspect-ratio: 1 / 1; }
.ar-tall { aspect-ratio: 2 / 3; }
.ar-wide { aspect-ratio: 3 / 2; }

/* ========== Catalog bar (filter + sort above the grid) ========== */
.catalog-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.catalog-controls {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
.catalog-controls label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.catalog-controls select {
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-fg);
  border-radius: var(--radius-sm);
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ========== Auth + account pages ========== */
.auth-page {
  max-width: 460px;
  margin-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.auth-form .field { max-width: none; }

.account-page {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}
.account-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.account-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.notice {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elev);
}
.notice--warn {
  border-color: var(--color-status-reserved);
}

.address-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}
.address-card {
  border: 1px solid var(--color-border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
}
.address-card__actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.add-address summary {
  display: inline-flex;
  cursor: pointer;
  list-style: none;
  width: fit-content;
}
.add-address summary::-webkit-details-marker { display: none; }
.add-address .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}

/* ========== Cart ========== */
.cart-page {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.cart-list {
  display: flex;
  flex-direction: column;
}
.cart-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}
.cart-row__thumb img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  background: var(--color-fg);
}
.cart-row__info { display: flex; flex-direction: column; gap: var(--space-1); }
.cart-row__timer { font-variant-numeric: tabular-nums; color: var(--color-status-reserved); }
.cart-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* Honeypot field - visually hidden but present in the DOM for bots. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Contact messages (admin) */
.message-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.message-card {
  border: 1px solid var(--color-border);
  padding: var(--space-4);
}
.message-card__head {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.message-card__body {
  white-space: pre-wrap;
  margin: 0;
}

/* ========== Style guide helpers (only used on /_styleguide) ========== */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}
.swatch { display: flex; flex-direction: column; }
.swatch__color {
  height: 96px;
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}
.swatch__name { font-size: var(--text-sm); }
.swatch__value {
  font-family: ui-monospace, monospace;
  font-size: var(--text-xs);
  color: var(--color-fg-subtle);
}
.type-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-5);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
  align-items: baseline;
}
.type-row__label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-fg-subtle);
}

/* Placeholder tile backgrounds used by the style guide demo */
.ph-1 { background: linear-gradient(135deg, #2a2622, #4a3f37); }
.ph-2 { background: linear-gradient(160deg, #1a1714, #383028); }
.ph-3 { background: linear-gradient(115deg, #3a342c, #1f1b18); }
.ph-4 { background: linear-gradient(145deg, #2c2520, #4f4338); }
.ph-5 { background: linear-gradient(125deg, #1a1614, #2f2823); }
.ph-6 { background: linear-gradient(155deg, #443a32, #1d1916); }

/* ========== Legal pages ========== */
.legal-page {
  max-width: 720px;
  margin-top: var(--space-6);
}
.legal-page p {
  margin-bottom: var(--space-4);
  line-height: 1.65;
}
.legal-page .section__title {
  margin-top: var(--space-6);
}
.legal-list {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  line-height: 1.6;
}
.footer__legal {
  flex-basis: 100%;
  font-size: var(--text-xs);
}

/* ========== Coming-soon (preview gate) landing ========== */
.coming-soon {
  padding: var(--space-9) var(--content-padding-x);
  max-width: 640px;
  text-align: left;
}
.coming-soon__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin: 0 0 var(--space-3);
}
.coming-soon__lede {
  font-size: var(--text-lg);
  color: var(--color-fg-muted);
  margin: 0 0 var(--space-6);
}
.coming-soon__msg {
  font-size: var(--text-base);
  margin: 0 0 var(--space-5);
}

/* Tiny button variant for table-row actions */

/* ========== Flash messages (public + admin) ========== */
.flash {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  border-left: 3px solid var(--color-fg);
  background: var(--color-bg-subtle, #f6f5f1);
  font-size: var(--text-sm);
}
.flash--success {
  border-color: #2c6e49;
  background: #ecf3ee;
}
.flash--error {
  border-color: #b54040;
  background: #f6e8e8;
}

/* ========== Item detail page (split-pane, carousel, collapsible desc) ========== */
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-7);
  padding: var(--space-6) var(--content-padding-x);
  max-width: 1200px;
}
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; gap: var(--space-5); }
}

/* ----- Gallery (left) ----- */
.detail__gallery { min-width: 0; }
.carousel { position: relative; }
.carousel__viewport {
  position: relative;
  background: var(--color-bg-subtle, #f6f5f1);
  /* Viewport sized to the primary image's aspect ratio. Other slides
     (different ratios) fit inside via object-fit: contain - the original
     format is fully visible, never cropped. */
  aspect-ratio: var(--ar, 1 / 1);
  max-height: 80vh;
  overflow: hidden;
}
.carousel__slide {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
  cursor: zoom-in;
  width: 100%;
  height: 100%;
}
.carousel__slide.is-active {
  opacity: 1;
  pointer-events: auto;
}
.carousel__slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.carousel__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-fg);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition-fast), opacity var(--transition-fast);
  opacity: 0.7;
  z-index: 2;
}
.carousel__arrow:hover {
  background: rgba(255, 255, 255, 1);
  opacity: 1;
}
.carousel__arrow--prev { left: var(--space-3); }
.carousel__arrow--next { right: var(--space-3); }

.carousel__thumbs {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}
.carousel__thumb {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid transparent;
  background: var(--color-fg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition-fast), opacity var(--transition-fast);
  opacity: 0.55;
}
.carousel__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.carousel__thumb:hover { opacity: 0.85; }
.carousel__thumb.is-active {
  border-color: var(--color-fg);
  opacity: 1;
}

/* ----- Info (right) ----- */
.detail__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.detail__title {
  font-size: 2.5rem;
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-2);
}
@media (max-width: 720px) {
  .detail__title { font-size: 2rem; }
}
.detail__meta {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
  margin: 0;
}

/* Description - always shown in full. (Old collapsible 4-line clamp removed.) */
.detail__description {
  color: var(--color-fg-muted);
  line-height: var(--leading-normal);
}

/* Single CTA pill (status + price + action) */
.detail__cta { margin-top: var(--space-3); }
.detail__cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  padding: 0 var(--space-5);
  border: 1px solid var(--color-fg);
  background: var(--color-bg);
  color: var(--color-fg);
  font: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.detail__cta-btn--available {
  background: var(--color-bg);
  color: var(--color-fg);
}
.detail__cta-btn--available:hover {
  background: var(--color-fg);
  color: var(--color-bg);
}
.detail__cta-btn--in-cart {
  background: var(--color-bg);
  color: var(--color-fg);
}
.detail__cta-btn--in-cart:hover {
  background: var(--color-fg);
  color: var(--color-bg);
}
.detail__cta-btn--reserved,
.detail__cta-btn--sold {
  background: var(--color-bg);
  color: var(--color-fg-muted);
  cursor: not-allowed;
  border-color: var(--color-border);
}

/* Order card on the account page (merged from old /account/orders) */
.order-card {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
  margin-top: var(--space-4);
}
.order-card:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

/* ========== Lightbox modal (image zoom) ========== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  /* Match the page bg (cream/off-white) at near-opacity. */
  background: rgba(247, 245, 242, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.lightbox[hidden] { display: none; }
.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.lightbox__close,
.lightbox__arrow {
  position: absolute;
  background: var(--color-fg);
  border: none;
  color: var(--color-bg);
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast);
  opacity: 0.75;
  z-index: 1;
}
.lightbox__close:hover,
.lightbox__arrow:hover { opacity: 1; }
.lightbox__close {
  top: var(--space-4);
  right: var(--space-4);
}
.lightbox__arrow--prev { left: var(--space-4); top: 50%; transform: translateY(-50%); }
.lightbox__arrow--next { right: var(--space-4); top: 50%; transform: translateY(-50%); }

/* ========== Header collection dropdown ========== */
.nav-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown__menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--color-bg, #fff);
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-2) 0;
  display: none;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.nav-dropdown:hover .nav-dropdown__menu,
.nav-dropdown:focus-within .nav-dropdown__menu {
  display: block;
}
.nav-dropdown__menu a,
.nav-dropdown__menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-4);
  white-space: nowrap;
  background: none;
  border: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
}
.nav-dropdown__menu button:hover {
  color: var(--color-fg);
}

/* Currency dropdown sits near the right edge; align its menu to the right
   and keep it narrow so it doesn't overflow the viewport. */
.currency-dropdown .nav-dropdown__menu {
  left: auto;
  right: 0;
  min-width: 90px;
}

/* ========== Breadcrumb ========== */
.breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-fg-subtle);
  margin-bottom: var(--space-4);
}
.breadcrumb a { color: var(--color-fg-subtle); }
.breadcrumb a:hover { color: var(--color-fg); }
.breadcrumb span[aria-current] { color: var(--color-fg); }
