/* 3D Hearth: shared styles (shop, account, admin). System fonts only: no third-party requests (GDPR). */
:root {
  --bg: #faf6f1;
  --surface: #ffffff;
  --surface-2: #f3ece4;
  --text: #2a211c;
  --muted: #76675c;
  --border: #e8ddd2;
  --accent: #c2502a;
  --accent-hover: #a8431f;
  --accent-ink: #ffffff;
  --accent-soft: #f7e4da;
  --ok: #2f7d4f;
  --ok-soft: #e1f2e7;
  --warn: #9a6b00;
  --warn-soft: #fbf0d4;
  --info: #2c5f8f;
  --info-soft: #e1ecf7;
  --danger: #b3261e;
  --danger-soft: #fbe3e1;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(42 33 28 / 0.06), 0 8px 24px rgb(42 33 28 / 0.07);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: ui-serif, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --max: 1120px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18130f;
    --surface: #221b17;
    --surface-2: #2b231e;
    --text: #f3ebe4;
    --muted: #b2a497;
    --border: #3a2f28;
    --accent: #e7774c;
    --accent-hover: #f08a62;
    --accent-ink: #1b120d;
    --accent-soft: #3d2519;
    --ok: #74c995;
    --ok-soft: #1f3327;
    --warn: #e5b94f;
    --warn-soft: #362c14;
    --info: #8db9e6;
    --info-soft: #1c2a38;
    --danger: #f28b82;
    --danger-soft: #3b1f1d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 24px; } }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.brand:hover { color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); }
.brand-mark svg { width: 20px; height: 20px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: 0.95rem; }
.nav a:hover { background: var(--surface-2); }

/* --- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.cart-btn { position: relative; }
.badge-count {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.badge-count:empty { display: none; }

/* --- Hero */
.hero { padding-block: 48px 32px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); max-width: 14ch; }
.hero p { font-size: 1.125rem; color: var(--muted); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
@media (min-width: 720px) { .hero { padding-block: 80px 48px; } }

/* --- Product grid */
.section { padding-block: 24px 56px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { font-size: 1.75rem; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.product { display: flex; flex-direction: column; overflow: hidden; }
.product-media { aspect-ratio: 1; background: var(--surface-2); }
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.placeholder svg { width: 40%; height: 40%; opacity: 0.45; }
.product-body { display: flex; flex-direction: column; gap: 6px; padding: 12px; flex: 1; }
@media (min-width: 720px) { .product-body { padding: 16px; } }
.product-body h3 { font-size: 1rem; margin: 0; }
.product-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.price { font-weight: 700; font-size: 1.05rem; }
.product-custom { font-size: 0.8rem; color: var(--muted); }
.product-custom:hover { color: var(--accent); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); aspect-ratio: 3 / 4; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Custom band */
.band { background: var(--accent-soft); border-radius: var(--radius); padding: 28px 20px; display: grid; gap: 16px; align-items: center; margin-bottom: 56px; }
.band h2 { font-size: 1.5rem; margin: 0 0 4px; }
.band p { margin: 0; color: var(--muted); }
@media (min-width: 720px) { .band { grid-template-columns: 1fr auto; padding: 36px 40px; } }

/* --- Cart drawer (native <dialog>) */
dialog.drawer {
  margin: 0 0 0 auto;
  height: 100%;
  max-height: 100%;
  width: min(420px, 100%);
  max-width: 100%;
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog.drawer[open] { display: flex; flex-direction: column; animation: slide-in 0.2s ease-out; }
dialog.drawer::backdrop { background: rgb(20 14 10 / 0.45); }
@keyframes slide-in { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { dialog.drawer[open] { animation: none; } html { scroll-behavior: auto; } }
.drawer-head, .drawer-foot { padding: 16px 20px; border-color: var(--border); border-style: solid; border-width: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; border-bottom-width: 1px; }
.drawer-head h2 { margin: 0; font-size: 1.35rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px; }
.drawer-foot { border-top-width: 1px; display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cart-list { list-style: none; margin: 0; padding: 0; }
.cart-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: 0; }
.cart-thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-item h3 { font-size: 0.95rem; margin: 0 0 6px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; }
.qty button { width: 32px; height: 32px; border: 0; background: transparent; color: var(--text); font-size: 1.1rem; cursor: pointer; border-radius: 999px; }
.qty button:hover { background: var(--surface-2); }
.qty span { min-width: 24px; text-align: center; font-weight: 600; font-size: 0.9rem; }
.cart-item .line-total { font-weight: 700; text-align: right; }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font: inherit; font-size: 0.8rem; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--danger); }
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

/* --- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100% - 32px);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Forms */
label { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type='checkbox'] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 720px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1 1 220px; }

/* --- Narrow page (account, success) */
.narrow { max-width: 720px; margin: 0 auto; padding: 32px 16px 56px; }
.panel { padding: 24px; }
@media (min-width: 720px) { .panel { padding: 32px; } }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--info); font-size: 0.95rem; }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice:empty { display: none; }

/* --- Orders */
.order-card { padding: 16px; display: grid; gap: 12px; }
@media (min-width: 720px) { .order-card { padding: 20px; } }
.order-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.order-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.95rem; }
.order-items li { display: flex; justify-content: space-between; gap: 12px; }
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.status.pagato { background: var(--warn-soft); color: var(--warn); }
.status.in_lavorazione { background: var(--info-soft); color: var(--info); }
.status.spedito { background: var(--accent-soft); color: var(--accent); }
.status.consegnato { background: var(--ok-soft); color: var(--ok); }
.status.annullato { background: var(--danger-soft); color: var(--danger); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; list-style: none; margin: 0; padding: 0; font-size: 0.75rem; color: var(--muted); }
.steps li { border-top: 4px solid var(--border); padding-top: 6px; }
.steps li.done { border-color: var(--accent); color: var(--text); font-weight: 600; }
.stack { display: grid; gap: 16px; }

/* --- Success */
.success-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 999px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.success-icon svg { width: 32px; height: 32px; }

/* --- Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 0.875rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer a { color: var(--muted); }

/* --- Admin */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; overflow-x: auto; margin: 0 0 20px; }
.tabs button { flex: 1 0 auto; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar label { min-width: 220px; }
.admin-grid { display: grid; gap: 16px; }
@media (min-width: 960px) { .admin-grid.orders { grid-template-columns: 1fr 1fr; } .admin-grid.products { grid-template-columns: 380px 1fr; align-items: start; } }
.order-edit { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.order-edit .span-2 { grid-column: 1 / -1; }
.kv { display: grid; gap: 2px; font-size: 0.9rem; }
.kv strong { font-weight: 600; }
.product-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.product-row:last-child { border-bottom: 0; }
.product-row .cart-thumb { width: 56px; height: 56px; }
.product-row h3 { font-size: 0.95rem; margin: 0; }
.tag { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.sticky-form { position: sticky; top: 80px; }
.msg { font-size: 0.85rem; color: var(--muted); }
@media (max-width: 719px) {
  .product-foot { flex-direction: column; align-items: stretch; }
}

/* --- Categories */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px; scrollbar-width: none; }
.chips:empty { display: none; }
.chip { flex: 0 0 auto; min-height: 38px; padding: 0 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }
.product-media { display: block; }
.product-cat { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; }
.product-link { color: inherit; text-decoration: none; }
.product-link:hover { color: var(--accent); }

/* --- Product page */
.breadcrumb { color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.product-page { display: grid; gap: 24px; }
@media (min-width: 860px) { .product-page { grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: start; } }
.gallery { display: grid; gap: 10px; }
@media (min-width: 860px) { .gallery { position: sticky; top: 88px; } }
.gallery-main { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; }
.gallery-thumb { flex: 0 0 72px; height: 72px; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); cursor: pointer; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb[aria-pressed='true'] { border-color: var(--accent); }
.product-info h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 4px 0 8px; }
.price.big { font-size: 1.6rem; margin-bottom: 16px; }
.product-text { white-space: pre-line; color: var(--text); }
.buy-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 24px 0; }
.buy-row .qty button { width: 44px; height: 44px; }
.buy-row .btn { flex: 1 1 200px; }
.perks { padding-left: 20px; margin: 0 0 24px; display: grid; gap: 4px; }
.band.compact { padding: 16px 20px; margin: 0; grid-template-columns: 1fr auto; }
.band.compact p { margin: 0; }

/* --- Admin: photos and product list */
.img-manager { display: flex; flex-wrap: wrap; gap: 8px; }
.img-item { position: relative; width: 84px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-item .img-tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; background: rgb(0 0 0 / 0.55); }
.img-item .img-tools button { flex: 1; height: 26px; border: 0; background: transparent; color: #fff; cursor: pointer; font-size: 0.85rem; }
.img-item .img-tools button:hover { background: rgb(255 255 255 / 0.15); }
.img-item .cover { position: absolute; top: 4px; left: 4px; font-size: 0.65rem; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.upload-tile { width: 84px; height: 84px; background: transparent; font: inherit; display: grid; place-items: center; border: 2px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; font-size: 0.75rem; text-align: center; font-weight: 600; }
.upload-tile:hover { border-color: var(--accent); color: var(--accent); }
.list-tools { display: grid; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
@media (min-width: 600px) { .list-tools { grid-template-columns: 1fr auto auto; } }
.product-row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
