/* Core: reset, type, buttons, sections and shared pieces, written only against tokens. Every page. */
/* Loaded after the look that sets the tokens: css/platform.css (AutoStacc) and, in a project's pages, its skin. */


* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

h1, h2, h3 { color: var(--heading); text-shadow: var(--glow); }
h1, h2 { font-family: var(--display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); }

::selection { background: var(--accent-2); color: var(--on-accent); text-shadow: none; }

a { color: var(--link); text-decoration: none; text-shadow: var(--glow-2); }
a:hover { color: var(--link-hover); text-shadow: var(--glow); }

/* visible keyboard focus on every interactive element */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

img { max-width: 100%; display: block; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

/* Page titles carry class "glitch" so a project skin can animate them; by default they are plain. */
.glitch { position: relative; display: inline-block; line-height: 1.05; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- scroll reveal (js/motion.js adds .motion, .reveal and .in) ---------- */
.motion .reveal { opacity: 0; }
.motion .reveal.in { animation: rise .45s var(--snap) calc(var(--i, 0) * 70ms) both; }
@keyframes rise {
  from { opacity: 0; translate: 0 18px; }
  to { opacity: 1; translate: 0 0; }
}
@keyframes blink { 50% { opacity: 0; } }

.page-hero { padding: 72px 0 40px; }
.page-hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); margin: 0 0 10px; }
.page-hero p { color: var(--muted); margin: 0; max-width: 70ch; }
/* breadcrumbs: generated item pages and nested platform pages (Settings sections) */
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 0; list-style: none; margin: 0 0 18px; padding: 0; font-size: .85rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin: 0 10px; color: var(--accent-dim); }
.crumbs a { display: inline-block; padding-block: 2px; }
.crumbs [aria-current] { color: var(--accent); text-shadow: var(--glow); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 2px solid var(--btn-bg);
  background: var(--btn-bg);
  color: var(--on-accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-transform: var(--btn-case);
  letter-spacing: var(--btn-tracking);
  text-shadow: none;
  box-shadow: var(--glow-2);
  transition: transform .12s var(--snap), box-shadow .12s var(--snap), background-color .12s, color .12s;
}
.btn::before { content: var(--btn-prefix); }
/* Pieces for signed-in or signed-out visitors only (js/account-nav.js): hidden wins over a component's own display. */
[data-auth][hidden] { display: none; }
.btn:hover {
  color: var(--on-accent);
  text-shadow: none;
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--stack);
}
.btn:active { transform: translate(0, 0) scale(.97); box-shadow: 0 0 0 var(--stack); transition-duration: .05s; }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover, .btn:active { transform: none; }
}
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--ghost-border); box-shadow: none; text-shadow: var(--glow); }
.btn.ghost:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); text-shadow: none; box-shadow: 4px 4px 0 var(--stack); }
.btn[aria-disabled="true"] {
  background: var(--panel);
  border-color: var(--line);
  color: var(--accent-dim);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- sections ---------- */
section { padding: 80px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: var(--section-size);
  margin: 0;
  text-transform: var(--section-case);
}
/* links wipe in an underline on hover */
.section-head a {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .2s var(--snap), color .12s;
}
.section-head a:hover { background-size: 100% 1px; }
.section-head h2::before { content: var(--prompt); color: var(--accent-2); text-shadow: var(--glow-2); }
.alt { background: var(--panel); }

/* ---------- small pieces shared by several pages ---------- */
.price { font-weight: 700; font-size: 1.15rem; color: var(--accent); }
/* A sale (js/store.js, js/cart.js): the catalog price struck through, and the sale's name. */
.price-was { font-weight: 400; color: var(--muted); }
.price-sale { display: inline-block; padding: 0 6px; font-size: .75rem; font-weight: 700; color: var(--on-accent); background: var(--accent); }

.tag {
  display: inline-block;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-2);
  text-shadow: var(--glow-2);
}

/* A Studio creator AutoStacc hasn't verified: on cards and product pages, in a warning colour on every look. */
.tag.unverified { padding: 1px 6px; color: var(--coral, #e0645c); border: 1px solid currentColor; text-shadow: none; }

/* The one card (js/card.js): every area's card is .ui-card plus its own class. Status tags sit as small chips in the
   top-right corner, never on a line of their own; the area's sheet styles everything else. */
.ui-card { position: relative; min-width: 0; }
.ui-card-title { margin: 0; overflow-wrap: anywhere; }
.ui-card-title a { color: inherit; }
.ui-card-sub { margin: 0; color: var(--muted); }
.card-tags { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px;
  max-width: calc(100% - 16px); pointer-events: none; }
.card-tags .tag { padding: 1px 7px; font-size: .64rem; font-weight: 700; letter-spacing: .06em; line-height: 1.6; border-radius: 999px;
  border: 1px solid currentColor; background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--muted); text-shadow: none; }
.card-tags .tag-official, .card-tags .tag-verified { color: var(--accent); }
.card-tags .tag-unofficial { border-style: dashed; }
.card-tags .tag-pinned, .card-tags .tag-team { color: var(--teal, var(--accent)); }
.card-tags .tag-new, .card-tags .tag-soon { color: var(--amber, var(--accent)); }
.card-tags .tag-sale { color: var(--on-accent, #000); background: var(--accent); border-color: var(--accent); }
.card-tags .tag.unverified { color: var(--coral, #e0645c); }
.unverified-note { border-left: 3px solid var(--coral, #e0645c); padding-left: 10px; }

/* STACC'D stamp: product cards, product pages and the library */
.owned-badge {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--display);
  font-size: var(--stamp-size);
  letter-spacing: .12em;
  text-shadow: var(--glow);
  box-shadow: 3px -2px 0 var(--stack);
  transform: rotate(-2deg);
}

/* label/value fact lists (press fact sheet, release and product details) */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 16px 0 0; }
.facts dt { color: var(--accent-2); text-shadow: var(--glow-2); text-transform: uppercase; font-size: .8rem; letter-spacing: .08em; padding-top: 3px; }
.facts dd { margin: 0; }
.facts a { display: inline-block; padding-block: 2px; }
.lede { color: var(--muted); }

.empty { color: var(--accent-dim); font-family: var(--mono); }
.empty a { display: inline-block; padding-block: 2px; }

/* ---------- page changes: a quick cross-fade (a project skin can replace it) ---------- */
@view-transition { navigation: auto; types: page; }
/* Taps feel immediate: no double-tap zoom delay, no grey flash. Anchor jumps and "back to top" glide, unless motion is reduced. */
a, button, summary, label, select, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
/* A page change: the old page dims away, the new one rises a few pixels into place. The sidebar, top bar, phone bar
   and project header (named in css/layout.css, css/project-frame.css) stay perfectly still: no movement, no fade. */
::view-transition-group(side), ::view-transition-group(topbar), ::view-transition-group(tabbar), ::view-transition-group(project-header),
::view-transition-new(side), ::view-transition-new(topbar), ::view-transition-new(tabbar), ::view-transition-new(project-header) { animation: none; }
::view-transition-old(side), ::view-transition-old(topbar), ::view-transition-old(tabbar), ::view-transition-old(project-header) { display: none; }
html:active-view-transition-type(page)::view-transition-old(root) { animation: page-leave .16s ease-in both; }
html:active-view-transition-type(page)::view-transition-new(root) { animation: page-enter .32s var(--snap) both; }
@keyframes page-leave { to { opacity: 0; transform: scale(.992); } }
@keyframes page-enter { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; }
}

/* ---------- phones: tighter rhythm, nothing touching the edges ---------- */
@media (max-width: 600px) {
  .wrap { padding: 0 18px; }
  section { padding: 56px 0; }
  .page-hero { padding: 44px 0 28px; }
  .section-head { margin-bottom: 22px; }
  .btn { padding: 12px 18px; text-align: center; }
}

/* The shared confirmation dialog (GS.confirm, js/util.js): the question, "Not now" and the action. */
.gs-confirm { max-width: min(28rem, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.gs-confirm::backdrop { background: rgba(0, 0, 0, .45); }
.gs-confirm-text { margin: 0 0 16px; line-height: 1.5; }
.gs-confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.gs-confirm-actions .btn { min-height: 44px; }
.btn.danger { background: var(--coral); border-color: var(--coral); color: var(--on-accent); text-shadow: none; }
.btn.danger:hover { background: var(--coral); border-color: var(--coral); color: var(--on-accent); }
@media (prefers-reduced-motion: no-preference) {
  .gs-confirm[open] { animation: gs-confirm-in .16s ease-out; }
  @keyframes gs-confirm-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
}
/* The shared message line (GS.toast, js/util.js): above the phones' bottom bar, never over the page's own controls for long. */
.gs-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(34rem, calc(100vw - 32px)); padding: 10px 12px 10px 16px; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.gs-toast.error { border-left-color: var(--coral); }
.gs-toast[hidden] { display: none; }
.gs-toast p { margin: 0; }
.gs-toast-close { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
@media (max-width: 900px) { .gs-toast { bottom: calc(72px + env(safe-area-inset-bottom)); } }
@media (prefers-reduced-motion: no-preference) { .gs-toast:not([hidden]) { animation: gs-confirm-in .16s ease-out; } }
