/* Shared layout: load AFTER the stylesheet for each page. */
:root { color-scheme: dark; --page-width: 1160px; --page-gutter: clamp(16px, 4vw, 40px); }
html { -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: border-box; }
body { min-width: 0; min-height: 100vh; min-height: 100svh; background-color: #080808; }
[hidden] { display: none !important; }
img, video { max-width: 100%; height: auto; }
button, input, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button, select { touch-action: manipulation; }
button { min-height: 44px; }
input:not([type="checkbox"]):not([type="radio"]), select { font-size: 16px; }
:focus-visible { outline: 2px solid #a994d6; outline-offset: 4px; }
p { overflow-wrap: anywhere; }

/* Every header item occupies its own cell, including the linked logo. */
header:not(.site-header) {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto 48px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 8px 24px;
  padding: 20px var(--page-gutter);
  position: relative;
  z-index: 100;
  isolation: isolate;
  min-height: 120px;
}
header > br { display: none; }
header h1 {
  grid-column: 2; grid-row: 1;
  font-size: clamp(30px, 3.1vw, 42px);
  font-weight: 400; line-height: 1.3; text-align: center; overflow-wrap: anywhere;
}
header > h3, header > p {
  grid-column: 2; grid-row: 2;
  font-size: 16px; font-weight: 400; line-height: 1.55; text-align: center;
  color: #ddd; max-width: 70ch; justify-self: center;
}
header h1:last-child { grid-row: 1 / 3; }
.site-brand { display: block; grid-column: 1; grid-row: 1 / 3; width: 76px; height: 76px; }
.logo-box { position: static; transform: none; width: 100%; height: 100%; background-size: contain; background-repeat: no-repeat; }
.auth { grid-column: 3; grid-row: 1 / 3; position: static; transform: none; min-width: 0; }
.auth-btn { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 10px 14px; }
.dropdown { grid-column: 4; grid-row: 1 / 3; position: relative; top: auto; right: auto; transform: none; justify-self: end; }
.dropdown-btn { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; font-size: 28px; }
.dropdown-content {
  top: calc(100% + 10px); right: 0;
  width: min(260px, calc(100vw - 32px)); min-width: 0;
  max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px; border: 1px solid #3a3a3a; border-radius: 12px;
  font: 16px/1.4 Arial, sans-serif; background: #111; box-shadow: 0 12px 40px #0008;
}
.dropdown-content a, .dropdown-content a:visited { color: #fff; min-height: 48px; padding: 13px 14px; border-radius: 6px; }
.dropdown-content a:hover, .dropdown-content a:focus-visible { background: #303030; }
.dropdown-content a[aria-current="page"] { background: #252025; }

/* Original artwork, with the portrait version on small screens. */
.background-image { inset: 0; width: 100%; height: 100%; background-color: #080808; }
.home-page .background-image { top: var(--header-height, 140px); height: auto; }

/* Product listing */
.products {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start;
  gap: clamp(20px, 4vw, 40px); width: min(100%, 1000px); min-height: 0;
  margin: 0 auto; padding: 32px var(--page-gutter) 56px;
}
.product-item {
  width: 100%; min-width: 0; border: 1px solid #383838; background: #111;
  padding: 0; border-radius: 14px; overflow: hidden; transition: border-color .2s;
}
.product-item:hover { transform: none; }
.product-item > a { display: block; color: #fff; }
.product-image-container { aspect-ratio: 1; background: #fff; }
.product-image-container img { width: 100%; height: 100%; object-fit: contain; }
/* Touch users select front/back explicitly on the detail page. */
.product-image-container:hover .product-image-primary { opacity: 1; }
.product-image-container:hover .product-image-secondary { opacity: 0; }
.product-item .product-info { padding: 18px 20px 22px; }
.product-item h2 { font-size: 20px; line-height: 1.4; margin: 0 0 6px; }
.product-color { color: #c8c3d0; margin-bottom: 12px; font-size: 15px; }
.product-item .product-price { color: #fff; font-size: 20px; }
.product-link-label { display: block; margin-top: 14px; color: #d4c3ee; font-size: 14px; }

/* Product detail and touch-friendly gallery */
.product {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  width: min(100%, var(--page-width)); margin: 0 auto;
  padding: 24px var(--page-gutter) 64px; gap: clamp(24px, 4vw, 48px); align-items: start;
}
.product-gallery, .product > .product-info { min-width: 0; }
.product-gallery { margin: 0; }
.product-image { width: 100%; height: auto; aspect-ratio: 1; background: #fff; border: 1px solid #383838; border-radius: 14px; overflow: hidden; }
.product-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.product-thumbnails { display: flex; gap: 12px; margin-top: 14px; }
.product-thumbnail {
  display: grid; gap: 6px; flex: 0 1 96px; min-width: 0; border: 2px solid #444;
  border-radius: 10px; background: #161616; color: #ddd; padding: 5px; cursor: pointer; font-size: 14px;
}
.product-thumbnail img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 5px; }
.product-thumbnail[aria-pressed="true"] { border-color: #b9a1df; color: #fff; }
.gallery-caption { margin-top: 12px; font-size: 14px; color: #ccc; line-height: 1.5; }
.product > .product-info { max-width: none; padding: clamp(20px, 3vw, 32px); background: #111; border: 1px solid #333; border-radius: 14px; }
.product-info h2 { font-size: clamp(25px, 3vw, 32px); line-height: 1.25; }
.product > .product-info > p { font-size: 16px; line-height: 1.7; }
.product > .product-info > .product-price { font-size: 24px; margin: 10px 0 20px; color: #fff; }
.color-options { margin-top: 24px; padding: 0; border: 0; min-width: 0; }
.color-options legend { margin-bottom: 10px; font-weight: 600; }
.color-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.color-option { display: inline-flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid #555; border-radius: 8px; background: #171717; color: #fff; cursor: pointer; }
.color-option[aria-pressed="true"] { border-color: #c4ade7; box-shadow: inset 0 0 0 1px #c4ade7; }
.color-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #aaa; }
.color-swatch--beige { background: #ecdfce; }
.color-swatch--black { background: linear-gradient(135deg, #080808 55%, #6a4e9a 55%); }
.size-row { margin: 24px 0 12px; flex-wrap: wrap; gap: 10px; }
.size-select { max-width: 100%; min-height: 48px; border-color: #555; background: #fff; color: #111; }
.buy-now-btn { width: 100%; min-height: 50px; margin-top: 16px; background: #fff; color: #111; border-radius: 8px; font-weight: 700; }
.buy-now-btn:hover { background: #e8e0f2; }

/* Sticky cart toolbar: reachable without covering the product. */
.cart-floating {
  position: sticky; top: 0; right: auto; width: min(100%, var(--page-width)); margin: 0 auto;
  padding: 10px var(--page-gutter); display: flex; justify-content: flex-end; background: #080808f5; z-index: 80;
}
.cart-panel {
  position: absolute; top: 100%; right: var(--page-gutter); margin: 0;
  width: min(400px, calc(100vw - 2 * var(--page-gutter)));
  max-height: calc(100vh - 84px); max-height: calc(100dvh - 84px);
  display: flex; flex-direction: column;
}
.cart-panel__header, .cart-footer { flex-shrink: 0; }
.cart-items { min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
.cart-item { grid-template-columns: minmax(0, 1fr) auto; line-height: 1.5; }
.cart-item > div { min-width: 0; overflow-wrap: anywhere; }
.cart-item__btn { min-width: 44px; min-height: 44px; }
.cart-close { min-width: 44px; }
.cart-footer { flex-wrap: wrap; gap: 10px; }
.cart-total { flex: 1 1 100%; font-size: 18px; }
.checkout { min-height: 44px; flex: 1; }
.cart-clear { min-height: 44px; }

/* Readable text blocks over the artwork. */
.descrizione, .privacy-policy-container, .cookie-policy-container {
  width: min(calc(100% - 2 * var(--page-gutter)), 860px); margin: 28px auto;
  padding: clamp(20px, 4vw, 36px); font-family: Arial, sans-serif; font-size: 17px; line-height: 1.75;
  background: #111; border: 1px solid #333; border-radius: 14px; overflow-wrap: anywhere;
}
.social_media {
  position: static; display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch;
  gap: 16px; width: min(100%, var(--page-width)); margin: 0 auto; padding: 16px var(--page-gutter) 40px;
}
.contorno-logo { background: #111; box-shadow: none; border: 1px solid #383838; padding: 10px; }
.social_media a { line-height: 1.4; min-height: 44px; }
.logoIG, .logoTT { width: 36px; height: 36px; }

/* Login and cookies stay scrollable with a small screen / open keyboard. */
.cookie-banner { padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.cookie-banner__box { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; border: 1px solid #444; }
.cookie-banner__text, .cookie-modal__text { font-size: 16px; line-height: 1.55; }
.cookie-btn { min-height: 44px; }
.cookie-modal, .auth-modal { padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.cookie-modal__box, .auth-box { width: min(100%, 420px); min-width: 0; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.cookie-modal__box { color-scheme: light; }
.cookie-toggle { min-height: 48px; }
.cookie-toggle input, .auth-consent input { width: 20px; height: 20px; flex-shrink: 0; }
.auth-box input:not([type="checkbox"]) { width: 100%; min-width: 0; min-height: 48px; background: #fff; color: #111; }
.auth-consent { display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; padding: 6px 0; }
.auth-box button { min-height: 44px; }

/* Checkout keeps its own header. */
.site-header { padding-inline: var(--page-gutter); }
.header-inner { align-items: center; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; }
.wrap { width: min(100%, 1000px); padding: 0 var(--page-gutter) 32px; }
.card { min-width: 0; }
.order-item { grid-template-columns: minmax(0, 1fr) auto; line-height: 1.55; }
.order-item > div { min-width: 0; overflow-wrap: anywhere; }
.totals-row { gap: 12px; }
.totals-row strong { white-space: nowrap; }
.radio { min-height: 48px; line-height: 1.5; }
.radio input { flex-shrink: 0; width: 18px; height: 18px; }
.empty, .pay-note { line-height: 1.6; }

@media (hover: hover) and (pointer: fine) {
  .product-item:hover { border-color: #b9a1df; }
  .product-image-container:hover .product-image-primary { opacity: 0; }
  .product-image-container:hover .product-image-secondary { opacity: 1; }
}
@media (max-width: 900px) {
  header:not(.site-header) { grid-template-columns: minmax(0, 1fr) auto 48px; grid-template-rows: auto auto auto; gap: 12px 16px; padding-block: 16px 22px; min-height: 0; }
  .site-brand { grid-column: 1; grid-row: 1; width: 56px; height: 56px; }
  .auth { grid-column: 2; grid-row: 1; }
  .dropdown { grid-column: 3; grid-row: 1; }
  header h1, header h1:last-child { grid-column: 1 / -1; grid-row: 2; font-size: clamp(30px, 4.8vw, 40px); }
  header > h3, header > p { grid-column: 1 / -1; grid-row: 3; }
  .product { grid-template-columns: minmax(0, 1fr); max-width: 700px; }
}
@media (max-width: 600px) {
  header:not(.site-header) { column-gap: 10px; }
  .site-brand { width: 48px; height: 48px; }
  .auth-btn { max-width: min(160px, 42vw); }
  header h1, header h1:last-child { font-size: clamp(28px, 8vw, 36px); }
  header > h3, header > p { font-size: 15px; }
  .background-image { background-image: url('../Grafiche/BackGorund_SitoMobile.png'); }
  .products { grid-template-columns: minmax(0, 1fr); max-width: 460px; padding-top: 24px; gap: 24px; }
  .product { padding-top: 16px; gap: 24px; }
  .product > .product-info { padding: 20px; }
  .size-row { align-items: stretch; flex-direction: column; }
  .size-select { width: 100%; }
  .descrizione, .privacy-policy-container, .cookie-policy-container { font-size: 16px; padding: 20px; }
  .social_media { display: grid; grid-template-columns: minmax(0, 1fr); }
  .cookie-banner__actions { display: grid; grid-template-columns: 1fr 1fr; }
  #cookie-manage { grid-column: 1 / -1; }
  .cookie-modal__actions > button { flex: 1 1 130px; }
  .brand { font-size: 32px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .cookie-modal, .auth-modal { align-items: start; }
  .cookie-banner__box { max-height: calc(100dvh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
