/* ==========================================================================
   Paper Boy Biz — Shared components
   Buttons, forms, badges, product card, category tile, trust strip,
   breadcrumb, shop toolbar, quantity stepper, pack-size options,
   notices, tables, tabs, accordions, pagination.
   Depends on: tokens.css, base.css
   ========================================================================== */

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-6);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--fs-button);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.btn--primary { background: var(--color-action); border-color: var(--color-action-border); color: var(--color-text); }
.btn--primary:hover { background: var(--color-action-hover); color: var(--color-text); }
.btn--secondary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); }
.btn--secondary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: var(--color-text-inverse); }
.btn--outline { background: var(--color-bg); border-color: var(--color-border-strong); color: var(--color-text); }
.btn--outline:hover { border-color: var(--color-text); color: var(--color-text); }
.btn--inverse { background: var(--color-bg); border-color: var(--color-bg); color: var(--color-primary-dark); }
.btn--inverse:hover { background: var(--color-info-bg); color: var(--color-primary-dark); }
.btn:disabled, .btn[aria-disabled="true"], .btn.is-disabled {
  background: var(--color-disabled-bg); border-color: var(--color-border); color: var(--color-disabled-text); cursor: not-allowed;
}
.btn--block { display: flex; width: 100%; }
.btn--sm { min-height: 40px; padding: 0 var(--space-4); font-size: var(--fs-small); }
.btn--card { min-height: var(--tap-target); }
.btn--lg { min-height: 56px; font-size: 1.0625rem; }

.link-arrow { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--fw-semibold); text-decoration: none; }
.link-arrow:hover { text-decoration: underline; }

/* ---- Forms ------------------------------------------------------------- */
.form-grid { display: grid; gap: var(--space-4); }
@media (min-width: 768px) {
  .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label, .field__label { font-size: var(--fs-small); font-weight: var(--fw-semibold); }
.field .required { color: var(--color-error); text-decoration: none; }
.field .optional { font-weight: var(--fw-regular); color: var(--color-text-muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap-target);
  padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: 1rem; /* 16px prevents iOS zoom */
  color: var(--color-text);
}
.textarea { min-height: 140px; padding: var(--space-3); resize: vertical; }
.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23111318' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.field--error .input, .field--error .select, .field--error .textarea, .input[aria-invalid="true"] {
  border: 2px solid var(--color-error); padding-left: calc(var(--space-3) - 1px);
}
.field__error { font-size: 0.8125rem; font-weight: var(--fw-medium); color: var(--color-error); margin: 0; }
.field__hint { font-size: 0.8125rem; color: var(--color-text-muted); margin: 0; }
.check { display: flex; align-items: flex-start; gap: var(--space-3); font-size: 0.9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--color-primary); flex: none; }

/* ---- Badges & seal ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  font-size: var(--fs-badge);
  font-weight: var(--fw-semibold);
  line-height: 1.25;
}
.badge--success { background: var(--color-success-bg); color: var(--color-success); }
.seal {
  position: absolute; top: 0; right: 0; z-index: 1;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border-radius: 50%;
  background: var(--color-action); border: 1px solid var(--color-action-border);
  color: var(--color-text);
  font-size: 0.6875rem; font-weight: var(--fw-heavy); line-height: 1.1; letter-spacing: 0.02em; text-transform: uppercase;
}

/* ---- Price ------------------------------------------------------------- */
.price {
  font-family: var(--font-heading);
  font-size: var(--fs-price);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--color-price);
  margin: 0;
}
.price--lg { font-size: var(--fs-price-lg); }
.price del { color: var(--color-text-muted); font-size: 0.7em; font-weight: var(--fw-bold); margin-right: var(--space-2); }

/* ---- Product grid & card ---------------------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  list-style: none; margin: 0; padding: 0;
}
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.product-grid--3 { }
@media (min-width: 1024px) { .product-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.product-card {
  position: relative;
  display: flex; flex-direction: column; gap: var(--space-3);
  height: 100%;
  padding: var(--space-3);
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.product-card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-sm); }
.product-card .badge { align-self: flex-start; }
.product-card__media { position: relative; aspect-ratio: 1 / 1; background: var(--color-bg); }
.product-card__media img { width: 100%; height: 100%; object-fit: contain; }
.product-card__title { font-family: var(--font-body); font-size: 0.9375rem; font-weight: var(--fw-semibold); line-height: 1.4; margin: 0; }
.product-card__title a { color: var(--color-text); text-decoration: none; }
.product-card__title a::after { content: ""; position: absolute; inset: 0; z-index: 0; } /* whole card clickable */
.product-card__title a:hover { text-decoration: underline; }
.product-card__body { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.product-card .price { margin-top: auto; }
.product-card .btn { position: relative; z-index: 1; width: 100%; }
.product-card .seal { width: 52px; height: 52px; font-size: 0.625rem; }
@media (min-width: 768px) {
  .product-card { padding: var(--space-4); }
  .product-card .seal { width: 64px; height: 64px; font-size: 0.6875rem; }
}

/* ---- Category tiles ---------------------------------------------------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  list-style: none; margin: 0; padding: 0;
}
@media (min-width: 768px) { .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); } }
@media (min-width: 1024px) { .category-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.category-tile {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  height: 100%;
  padding: var(--space-4) var(--space-3);
  background: var(--color-primary);
  border-radius: var(--radius-md);
  color: var(--color-text-inverse);
  text-decoration: none;
  text-align: center;
  transition: background-color var(--duration) var(--ease);
}
.category-tile:hover { background: var(--color-primary-dark); color: var(--color-text-inverse); }
.category-tile__plate {
  width: 100%; max-width: 160px; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-bg); border-radius: var(--radius-md); overflow: hidden;
}
.category-tile__plate img { width: 88%; height: 88%; object-fit: contain; }
.category-tile__name { font-family: var(--font-heading); font-size: 1.0625rem; font-weight: var(--fw-bold); line-height: 1.2; }
.category-tile__count { font-size: var(--fs-xs); color: var(--color-text-inverse-muted); }
.product-card .btn { padding: 0 var(--space-2); font-size: 0.9375rem; white-space: nowrap; }
/* Mobile: tiles become a compact horizontal scroll strip so products stay near the top */
@media (max-width: 767px) {
  .category-grid {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 136px;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter);
  }
  .category-grid::-webkit-scrollbar { display: none; }
  .category-grid > li { scroll-snap-align: start; }
  .category-tile { padding: var(--space-3) var(--space-2); gap: var(--space-2); }
  .category-tile__plate { max-width: 104px; }
  .category-tile__name { font-size: 0.9375rem; }
}
@media (min-width: 1024px) { .category-tile__name { font-size: 1.1875rem; } }

/* ---- Trust strip ------------------------------------------------------- */
.trust-strip { background: var(--color-primary); color: var(--color-text-inverse); }
.trust-strip__list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none; margin: 0 auto; padding: 0;
}
.trust-strip__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
  text-align: center; font-size: var(--fs-small); font-weight: var(--fw-bold); line-height: 1.3;
}
.trust-strip__item .icon { color: var(--color-action); width: 26px; height: 26px; }
.trust-strip__item span small { display: block; font-weight: var(--fw-regular); color: var(--color-text-inverse-muted); margin-top: 2px; }
@media (min-width: 768px) {
  .trust-strip__list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .trust-strip__item { flex-direction: row; text-align: left; padding: var(--space-5) var(--space-3); font-size: 0.9375rem; }
  .trust-strip__item + .trust-strip__item { border-left: 1px solid rgba(255, 255, 255, 0.25); }
}

/* ---- Breadcrumb -------------------------------------------------------- */
.breadcrumb { font-size: var(--fs-small); color: var(--color-text-muted); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); list-style: none; margin: 0; padding: 0; }
.breadcrumb li { display: flex; align-items: center; gap: var(--space-2); }
.breadcrumb li + li::before { content: "/"; color: var(--color-border-strong); }
.breadcrumb a { color: var(--color-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--color-text); }

/* ---- Shop toolbar (result count + sort) ------------------------------- */
.shop-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding-block: var(--space-3);
  border-block: var(--border-width) solid var(--color-border);
  margin-bottom: var(--space-5);
}
.shop-toolbar__count { margin: 0; font-size: var(--fs-small); color: var(--color-text-muted); }
.shop-toolbar__sort { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-small); font-weight: var(--fw-semibold); }
.shop-toolbar__sort .select { min-height: 40px; width: auto; font-size: var(--fs-small); }

/* ---- Quantity stepper -------------------------------------------------- */
.qty {
  display: inline-flex; align-items: stretch;
  height: 48px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg);
}
.qty button {
  width: var(--tap-target); border: 0; background: var(--color-bg-light);
  font-size: 1.25rem; font-weight: var(--fw-semibold); line-height: 1; color: var(--color-text);
}
.qty button:hover { background: var(--color-border); }
.qty input {
  width: 52px; border: 0;
  border-inline: var(--border-width) solid var(--color-border-strong);
  text-align: center; font-weight: var(--fw-semibold); font-size: 1rem;
  -moz-appearance: textfield; appearance: textfield;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty--sm { height: 40px; }
.qty--sm button { width: 36px; }
.qty--sm input { width: 44px; }

/* ---- Pack-size options ------------------------------------------------- */
.options { display: flex; flex-direction: column; gap: var(--space-2); }
.options__legend { font-size: var(--fs-small); font-weight: var(--fw-bold); margin-bottom: var(--space-2); }
.options__legend span { font-weight: var(--fw-regular); }
.options__list { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.option-pill { position: relative; }
.option-pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.option-pill label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 var(--space-4);
  border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-bg); font-size: var(--fs-small); font-weight: var(--fw-semibold); cursor: pointer;
}
.option-pill input:checked + label { border: 2px solid var(--color-primary); padding-inline: calc(var(--space-4) - 1px); background: var(--color-badge-bg); color: var(--color-badge-text); }
.option-pill input:focus-visible + label { box-shadow: var(--focus-ring); }
.option-pill input:disabled + label { border-style: dashed; background: var(--color-bg-light); color: var(--color-disabled-text); text-decoration: line-through; cursor: not-allowed; }

/* ---- Notices (WooCommerce messages) ----------------------------------- */
.notice {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: var(--border-width) solid; border-radius: var(--radius-sm);
  font-size: 0.9375rem; margin-bottom: var(--space-5);
}
.notice .icon { margin-top: 1px; }
.notice p { margin: 0; }
.notice--success { background: var(--color-success-bg); border-color: var(--color-success); }
.notice--success .icon { color: var(--color-success); }
.notice--error { background: var(--color-error-bg); border-color: var(--color-error); }
.notice--error .icon { color: var(--color-error); }
.notice--info { background: var(--color-info-bg); border-color: var(--color-primary); }
.notice--info .icon { color: var(--color-primary); }
.notice a { font-weight: var(--fw-semibold); }

/* ---- Tables ------------------------------------------------------------ */
.table { width: 100%; font-size: 0.9375rem; }
.table th, .table td { padding: var(--space-3); border-bottom: var(--border-width) solid var(--color-border); text-align: left; vertical-align: middle; }
.table th { font-size: var(--fs-small); font-weight: var(--fw-bold); background: var(--color-bg-light); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md); }

/* ---- Panel / card shell ----------------------------------------------- */
.panel { border: var(--border-width) solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-5); background: var(--color-bg); }
.panel--light { background: var(--color-bg-light); }
.panel__title { font-size: var(--fs-h5); margin-bottom: var(--space-4); }
@media (min-width: 768px) { .panel { padding: var(--space-6); } }

/* ---- Tabs (product page) ---------------------------------------------- */
.tabs__list { display: flex; gap: var(--space-1); border-bottom: var(--border-width) solid var(--color-border); overflow-x: auto; }
.tabs__tab {
  min-height: var(--tap-target); padding: 0 var(--space-4);
  border: 0; border-bottom: 3px solid transparent; background: none;
  font-weight: var(--fw-semibold); color: var(--color-text-muted); white-space: nowrap;
}
.tabs__tab[aria-selected="true"] { color: var(--color-text); border-bottom-color: var(--color-primary); }
.tabs__panel { padding-block: var(--space-6); }

/* ---- Accordion (FAQ) — native <details> ------------------------------- */
.accordion { border-top: var(--border-width) solid var(--color-border); }
.accordion details { border-bottom: var(--border-width) solid var(--color-border); }
.accordion summary {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  min-height: 56px; padding: var(--space-3) 0;
  font-weight: var(--fw-semibold); cursor: pointer; list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after { content: "+"; font-size: 1.5rem; font-weight: var(--fw-regular); color: var(--color-primary); line-height: 1; }
.accordion details[open] summary::after { content: "–"; }
.accordion details > div { padding: 0 0 var(--space-4); color: var(--color-text-muted); max-width: 72ch; }

/* ---- Pagination -------------------------------------------------------- */
.pagination { display: flex; justify-content: center; margin-top: var(--space-8); }
.pagination ul { display: flex; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap-target); height: var(--tap-target); padding: 0 var(--space-3);
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-sm);
  text-decoration: none; font-weight: var(--fw-semibold); color: var(--color-text);
}
.pagination a:hover { border-color: var(--color-border-strong); }
.pagination [aria-current="page"] { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); }

/* ---- Feature list (icon + title + text) ------------------------------- */
.features { display: grid; gap: var(--space-5); list-style: none; margin: 0; padding: 0; }
@media (min-width: 768px) { .features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.feature { display: flex; gap: var(--space-3); }
.feature__icon {
  width: 44px; height: 44px; flex: none; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-badge-bg); color: var(--color-primary);
}
.feature h3, .feature h4 { font-family: var(--font-body); font-size: 1rem; font-weight: var(--fw-bold); margin: 0 0 var(--space-1); }
.feature p { margin: 0; font-size: var(--fs-small); color: var(--color-text-muted); }

/* ---- Promo card (shop sidebar) ---------------------------------------- */
.promo-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-5); border-radius: var(--radius-md);
  background: var(--color-primary); color: var(--color-text-inverse); text-decoration: none;
}
.promo-card:hover { background: var(--color-primary-dark); color: var(--color-text-inverse); }
.promo-card__title { font-family: var(--font-heading); font-size: 1.25rem; font-weight: var(--fw-heavy); line-height: 1.2; }
.promo-card--light { background: var(--color-badge-bg); color: var(--color-text); border: var(--border-width) solid var(--color-border); }
.promo-card--light:hover { background: var(--color-bg-light); color: var(--color-text); }
