/*
 * stickerjar public store — stylesheet.
 *
 * Deliberately plain and semantic. Typography uses the Apple system font stack
 * to match the app, and colours mirror the iOS system palette (systemBackground,
 * label, secondaryLabel, systemBlue, separator) so the site reads like the app.
 * Light and dark are driven entirely by prefers-color-scheme.
 */

:root {
  --bg: #ffffff;
  --bg-secondary: #f2f2f7;
  --bg-elevated: #ffffff;
  --tile-bg: #e9eaee;
  --label: #1c1c1e;
  --label-secondary: #3c3c4399;
  --accent: #007aff;
  --separator: #3c3c434a;
  --radius: 12px;
  --radius-small: 8px;
  --content-width: 75rem;
  --grid-gap: clamp(0.625rem, 1.5vw, 1rem);
  --shadow-hover: 0 6px 20px -8px rgba(0, 0, 0, 0.18);
  --transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --bg-elevated: #1c1c1e;
    --tile-bg: #2c2c2e;
    --label: #f2f2f7;
    --label-secondary: #ebebf599;
    --accent: #0a84ff;
    --separator: #54545899;
    --shadow-hover: 0 6px 20px -8px rgba(0, 0, 0, 0.65);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

img {
  max-width: 100%;
  height: auto;
}

/* Honour a reduced-motion preference: keep colours, drop movement. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

/* Skip link, visible only when focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--bg);
  color: var(--accent);
  z-index: 10;
}

.skip-link:focus {
  left: 0;
}

.site-header {
  padding-block: 2rem 1.25rem;
  border-bottom: 1px solid var(--separator);
}

.site-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-tagline {
  margin: 0.25rem 0 0;
  color: var(--label-secondary);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.9375rem;
}

main {
  display: block;
  padding-block: 1.5rem 3rem;
}

h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-block: 0 1rem;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.status {
  color: var(--label-secondary);
  padding-block: 0.5rem;
}

.status[data-kind="error"] {
  color: var(--label);
}

.retry-button {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  font: inherit;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

/* Visually hidden but available to assistive technology. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* Packs search. Sticky so it stays reachable while scrolling a long store,
   with a translucent backdrop that keeps cards legible as they pass beneath. */
.search {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-block: 0 1.5rem;
  padding-block: 0.75rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.search-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font: inherit;
  color: var(--label);
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition);
}

.search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.search-input::placeholder {
  color: var(--label-secondary);
}

/* Category sections. */
.packs-section + .packs-section {
  margin-top: 2rem;
}

.packs-section-heading {
  margin-block: 0 0.875rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--separator);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--label-secondary);
}

.packs-empty {
  padding-block: 1rem;
}

/* Packs listing. */
.packs-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: var(--grid-gap);
}

.pack-card .pack-card-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  overflow-wrap: anywhere;
}

.pack-card .pack-card-author {
  margin: 0.125rem 0 0;
  color: var(--label-secondary);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Attribution badges: a verified tick on first-party packs, the origin
   platform's logo on converted ones. */
.pack-badge-icon {
  display: inline-flex;
  vertical-align: -0.125em;
}

.pack-badge-icon svg,
.pack-badge-glyph {
  width: 1em;
  height: 1em;
  display: block;
}

.pack-card-name .pack-badge-icon {
  font-size: 0.95em;
}

/* Font Awesome brand fallback icons sit alongside the inline-SVG glyphs. */
.pack-badge-icon i {
  font-size: 1em;
  line-height: 1;
}

i.pack-badge-glyph {
  font-size: 0.9375rem;
  line-height: 1;
}

.pack-badge-icon.is-verified {
  color: var(--accent);
}

.pack-badge-icon.is-source {
  color: var(--label-secondary);
}

/* Pack detail. */
.back-link {
  display: inline-block;
  margin-bottom: 1rem;
}

.pack-header {
  margin-bottom: 1.5rem;
}

.pack-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.pack-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
  padding: 0.125rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
}

.pack-badge.is-source {
  color: var(--label-secondary);
  border-color: var(--separator);
}

.pack-badge .pack-badge-glyph {
  width: 0.9375rem;
  height: 0.9375rem;
}

.pack-meta {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

.pack-meta dt {
  color: var(--label-secondary);
  font-size: 0.9375rem;
}

.pack-meta dd {
  margin: 0;
}

.stickers-heading {
  margin-block: 1.5rem 1rem;
}

.stickers-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: var(--grid-gap);
}

.sticker-figure {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.625rem;
  font: inherit;
  color: inherit;
  background: var(--bg-secondary);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.sticker-figure:hover {
  transform: translateY(-2px);
  border-color: var(--separator);
  box-shadow: var(--shadow-hover);
}

.sticker-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.sticker-figure .sticker-caption {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--label-secondary);
  overflow-wrap: anywhere;
}

/* Sticker modal: an enlarged view of one sticker with an action to add just
   that sticker to the app, opened by clicking a sticker in the grid above. */
body.has-open-modal {
  overflow: hidden;
}

.sticker-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.sticker-modal[hidden] {
  display: none;
}

.sticker-modal-backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
}

.sticker-modal-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 22rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem 1.5rem 1.5rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.5);
}

.sticker-modal-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--label-secondary);
  background: var(--bg-secondary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.sticker-modal-close:hover {
  color: var(--label);
}

.sticker-modal-image {
  display: block;
  width: 100%;
  max-width: 16rem;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.sticker-modal-caption {
  margin: 0;
  text-align: center;
  overflow-wrap: anywhere;
}

.sticker-modal-add {
  display: inline-block;
  padding: 0.625rem 1.5rem;
  font-weight: 600;
  text-align: center;
  color: var(--bg, Canvas);
  background: var(--accent);
  border-radius: 999px;
  transition: opacity var(--transition);
}

.sticker-modal-add:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* Pack card icon, layout, and app links. */
.pack-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pack-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  color: var(--label);
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.pack-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.pack-icon {
  aspect-ratio: 1 / 1;
  display: grid;
  gap: 3px;
  padding: 8px;
  background: var(--tile-bg);
}

/* The icon holds a fixed square (aspect-ratio above), and the 2x2 grid splits
   it into four equal square cells with minmax(0, 1fr). The image only fills its
   cell — its own intrinsic size never drives the layout — so an oddly-shaped,
   broken, or not-yet-loaded sticker can't stretch a row and knock the composite
   out of square. */
.pack-icon.is-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.pack-icon img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  border-radius: 4px;
}

.pack-icon.is-single {
  display: block;
}

.pack-card-body {
  padding: 0.625rem 0.75rem 0.75rem;
}

.pack-card-open,
.pack-open {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.pack-open {
  margin: 0 0 1rem;
}

.pack-card-open:hover,
.pack-open:hover,
.get-app-badge:hover {
  text-decoration: none;
  background: var(--accent);
  color: var(--bg, Canvas);
}

.get-app {
  margin: 0.75rem 0 0;
}

.get-app-badge {
  display: inline-block;
  padding: 0.5rem 1.125rem;
  font-weight: 600;
  color: var(--bg, Canvas);
  background: var(--accent);
  border-radius: 999px;
  transition: opacity var(--transition);
}

.site-footer {
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--separator);
  color: var(--label-secondary);
  font-size: 0.9375rem;
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 0.35rem;
}

.site-footer-links a {
  white-space: nowrap;
}

/* The "what is stickerjar" feature section on the dedicated About page. */
.about {
  padding-block: clamp(1.5rem, 4vw, 2.5rem) 0.5rem;
}

.about h2 {
  margin: 0 0 0.5rem;
}

.about-intro {
  margin: 0 0 1.5rem;
  max-width: 46rem;
  color: var(--label-secondary);
}

.about-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--grid-gap);
}

.about-features li {
  padding: 1rem 1.125rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.about-features h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.about-features p {
  margin: 0;
  color: var(--label-secondary);
  font-size: 0.9375rem;
}
