/* Shared base for the WebiQQ demo sites. Each site sets the tokens in its own styles.css. */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html.has-dialog { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: inherit; }
p { margin: 0; }
ul[role='list'], ol[role='list'] { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--focus, var(--accent)); outline-offset: 3px; }
[tabindex='-1']:focus { outline: none; }
::selection { background: var(--accent); color: var(--accent-ink, #fff); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 1rem; top: -4rem; z-index: 100; padding: .75rem 1rem;
  background: var(--fg); color: var(--bg); border-radius: var(--radius-sm, 4px); transition: top .2s;
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(100% - 2 * var(--gutter), var(--max, 1320px)); margin-inline: auto; }

/* reveal */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(var(--reveal-y, 28px));
  transition: opacity .9s var(--ease), transform 1s var(--ease);
  transition-delay: calc(var(--d, 0) * 90ms);
}
html.js [data-reveal].is-in { opacity: 1; transform: none; }

/* route enter (fallback when View Transitions are unavailable) */
#main > * { animation: route-in .6s var(--ease) both; }
@keyframes route-in { from { opacity: 0; transform: translateY(12px); } }
::view-transition-old(root) { animation: vt-out .32s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .55s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-10px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); } }

/* header hide-on-scroll */
.site-header { transition: transform .45s var(--ease), background-color .3s, box-shadow .3s; }
.site-header.is-hidden { transform: translateY(-110%); }

/* dialogs */
dialog { padding: 0; border: 0; color: var(--fg); max-width: none; max-height: none; }
dialog::backdrop { background: rgb(10 10 10 / .5); backdrop-filter: blur(3px); animation: fade-in .3s ease both; }
dialog.is-closing::backdrop { animation: fade-out .26s ease both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

.drawer {
  margin: 0 0 0 auto; height: 100dvh; width: min(440px, 100vw);
  background: var(--surface, var(--bg)); flex-direction: column;
  animation: drawer-in .45s var(--ease) both;
}
.drawer[open] { display: flex; }
.drawer.is-closing { animation: drawer-out .26s ease both; }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line); }
.drawer__body { flex: 1; overflow: auto; padding: 1rem 1.5rem; }
.drawer__foot { padding: 1.25rem 1.5rem 1.5rem; border-top: 1px solid var(--line); display: grid; gap: .9rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; font-size: 1.25rem; line-height: 1;
  transition: background-color .2s, transform .2s var(--ease);
}
.icon-btn:hover { background: var(--fg); color: var(--bg); }
.icon-btn:active { transform: scale(.94); }

.cart-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.cart-line { display: grid; grid-template-columns: 72px 1fr auto; gap: 1rem; align-items: start; animation: route-in .4s var(--ease) both; }
.cart-line__img { width: 72px; aspect-ratio: 4 / 5; border-radius: var(--radius-sm, 4px); overflow: hidden; background: var(--line); }
.cart-line__img img, .cart-line__img svg { width: 100%; height: 100%; object-fit: cover; }
.cart-line__title { font-weight: 600; line-height: 1.3; }
.cart-line__meta { font-size: .85rem; color: var(--muted); margin: .15rem 0 .5rem; }
.cart-line__end { text-align: right; display: grid; gap: .4rem; justify-items: end; }
.cart-line__price { font-variant-numeric: tabular-nums; font-weight: 600; }
.cart-empty { text-align: center; padding: 3rem 1rem; color: var(--muted); display: grid; gap: 1rem; justify-items: center; }
.cart-ship { font-size: .85rem; display: grid; gap: .45rem; }
.cart-ship::after {
  content: ''; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) calc(var(--p, 0) * 100%), var(--line) 0);
  transition: background .4s;
}
.cart-total { display: flex; justify-content: space-between; font-weight: 600; font-size: 1.1rem; }
.cart-note { font-size: .78rem; color: var(--muted); }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.qty button { width: 2.25rem; height: 2.25rem; border: 0; background: none; border-radius: 50%; font-size: 1.05rem; }
.qty button:hover { background: var(--line); }
.qty output { min-width: 1.75rem; text-align: center; font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: .85rem; }
.link-btn:hover { color: var(--fg); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 90; translate: -50% 150%;
  background: var(--fg); color: var(--bg); padding: .85rem 1.25rem; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 12px 40px rgb(0 0 0 / .2); transition: translate .5s var(--ease); max-width: calc(100vw - 2rem);
}
.toast.is-on { translate: -50% 0; }

/* forms */
.field { display: grid; gap: .4rem; min-width: 0; }
.field label, .field legend { font-size: .85rem; font-weight: 600; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; padding: .85rem 1rem; border: 1px solid var(--field-line, var(--line)); border-radius: var(--radius-sm, 4px);
  background: var(--field-bg, transparent); transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 8rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.field [aria-invalid='true'] { border-color: var(--error, #b42318); }
.field-error { color: var(--error, #b42318); font-size: .82rem; min-height: 0; }
.field-error:empty { display: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; }
.choice input { width: 1.1rem; height: 1.1rem; margin-top: .2rem; accent-color: var(--accent); flex: none; }
.form-status { color: var(--error, #b42318); font-weight: 600; font-size: .9rem; }
.form-status:empty { display: none; }
.form-success { animation: route-in .6s var(--ease) both; outline: none; }
.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2px solid var(--btn-fg, currentColor); border-right-color: transparent; animation: spin .7s linear infinite;
  color: var(--bg);
}
@keyframes spin { to { rotate: 360deg; } }

/* lightbox */
.lightbox { width: 100vw; height: 100dvh; background: rgb(12 12 12 / .96); color: #fff; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox__stage { width: 100%; height: 100%; display: grid; place-items: center; padding: 4rem 4.5rem; }
.lightbox figure { margin: 0; display: grid; gap: .9rem; justify-items: center; }
.lightbox img { max-height: calc(100dvh - 10rem); width: auto; max-width: 100%; object-fit: contain; }
.lightbox.is-swap img { animation: fade-in .45s ease both; }
.lightbox figcaption { font-size: .9rem; opacity: .75; text-align: center; max-width: 60ch; }
.lightbox__count { position: absolute; top: 1.4rem; left: 1.5rem; font-size: .85rem; opacity: .7; font-variant-numeric: tabular-nums; }
.lightbox__btn, .lightbox__close {
  position: absolute; width: 3rem; height: 3rem; border-radius: 50%; border: 1px solid rgb(255 255 255 / .3);
  background: rgb(0 0 0 / .3); color: #fff; font-size: 1.2rem; transition: background .2s;
}
.lightbox__btn:hover, .lightbox__close:hover { background: rgb(255 255 255 / .15); }
.lightbox__prev { left: 1rem; top: 50%; translate: 0 -50%; }
.lightbox__next { right: 1rem; top: 50%; translate: 0 -50%; }
.lightbox__close { top: 1rem; right: 1rem; font-size: 1.6rem; }
@media (max-width: 640px) {
  .lightbox__stage { padding: 4rem 1rem 6rem; }
  .lightbox__prev, .lightbox__next { top: auto; bottom: 1.25rem; translate: none; }
  .lightbox__prev { left: calc(50% - 3.5rem); }
  .lightbox__next { right: calc(50% - 3.5rem); }
}

/* sample Instagram-style feed */
.ig { padding-block: clamp(3rem, 7vw, 5.5rem); }
.ig__head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.ig__avatar {
  display: inline-grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--accent-ink, #fff); font-family: var(--font-display); font-size: 1.3rem;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.ig__title { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.2; }
.ig__handle { font-size: .85rem; color: var(--muted); }
.ig__badge {
  margin-left: auto; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem .75rem; color: var(--muted);
}
.ig__grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.ig__post { position: relative; display: block; width: 100%; padding: 0; border: 0; overflow: hidden; border-radius: var(--radius-sm, 4px); aspect-ratio: 1; background: var(--line); }
.ig__post img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease), filter .4s; }
.ig__meta {
  position: absolute; inset: 0; display: flex; gap: 1rem; align-items: center; justify-content: center;
  background: rgb(0 0 0 / .38); color: #fff; font-size: .85rem; font-weight: 600; opacity: 0; transition: opacity .3s;
}
.ig__post:hover img, .ig__post:focus-visible img { transform: scale(1.06); }
.ig__post:hover .ig__meta, .ig__post:focus-visible .ig__meta { opacity: 1; }
@media (max-width: 760px) { .ig__grid { grid-template-columns: repeat(3, 1fr); } .ig__badge { margin-left: 0; } }

.ig-modal { width: min(880px, calc(100vw - 2rem)); background: var(--surface, var(--bg)); border-radius: var(--radius, 8px); animation: pop-in .4s var(--ease) both; }
.ig-modal.is-closing { animation: pop-out .26s ease both; }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(10px); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }
.ig-modal__card { display: grid; grid-template-columns: 1.1fr 1fr; position: relative; }
.ig-modal__img img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; }
.ig-modal__body { padding: 1.5rem; display: grid; gap: 1rem; align-content: start; }
.ig-modal__user { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .9rem; }
.ig-modal__user .ig__avatar { width: 2rem; height: 2rem; font-size: .95rem; }
.ig-modal__user em { font-style: normal; font-weight: 500; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border: 1px solid var(--line); padding: .15rem .45rem; border-radius: 999px; }
.ig-modal__tags { color: var(--muted); font-size: .85rem; }
.ig-modal__actions { display: flex; align-items: center; gap: 1rem; font-size: .9rem; color: var(--muted); }
.ig-like { border: 1px solid var(--line); background: none; border-radius: 999px; padding: .45rem .9rem; transition: color .2s, background .2s, transform .2s var(--ease); }
.ig-like[aria-pressed='true'] { color: #e0245e; border-color: currentColor; }
.ig-like:active { transform: scale(.92); }
.ig-modal__note { font-size: .75rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .9rem; }
.ig-modal__close { position: absolute; top: .6rem; right: .6rem; width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 0; background: var(--bg); font-size: 1.4rem; }
@media (max-width: 700px) { .ig-modal__card { grid-template-columns: 1fr; } .ig-modal__img img { aspect-ratio: 4 / 3; } }

/* demo disclosure */
.demo-note { font-size: .78rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  html { scroll-behavior: auto; }
  html.js [data-reveal] { opacity: 1; transform: none; }
}
