:root {
  --brand: #0073e5;
  --brand-dark: #005bb8;
  --brand-soft: #e8f2fd;
  --ink: #0b1b2e;
  --muted-ink: #5a6b7e;
  --paper: #f4f8fd;
  --surface: #ffffff;
  --line: #d8e5f4;
  --radius: 18px;
  --content: 1200px;
  --header-h: 76px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.has-selection {
  padding-bottom: 112px;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 30;
  padding: 10px 14px;
  color: #fff;
  background: var(--brand);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  width: min(calc(100% - 40px), var(--content));
  min-height: var(--header-h);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  flex: 0 0 auto;
  display: block;
  height: 46px;
  aspect-ratio: 256 / 81;
  background: url("storelogo.avif") center / 156.25% auto no-repeat;
}

.category-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav a {
  min-height: 44px;
  padding: 8px 18px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--muted-ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  transition: color 180ms ease, background-color 180ms ease;
}

.category-nav a:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

.category-nav a:focus-visible,
.brand:focus-visible,
.sticker-card:focus-visible,
.bar-clear:focus-visible,
.bar-send:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 3px;
}

/* ---------- Intro ---------- */

main {
  width: 100%;
}

.intro {
  color: #fff;
  background: var(--brand);
}

.intro-inner {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
  padding: clamp(40px, 7vw, 84px) 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
}

.intro-copy {
  margin: 14px 0 0;
  max-width: 520px;
  color: rgba(255, 255, 255, .88);
  font-size: clamp(1rem, 1.8vw, 1.15rem);
}

/* ---------- Status tabs (approved / rejected / new) ---------- */

.status-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 15;
  background: rgba(244, 248, 253, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.status-tabs {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
  padding: 10px 0;
  display: flex;
  gap: 8px;
}

.status-tab {
  min-height: 46px;
  padding: 8px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1 1 0;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-ink);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.status-tab:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.status-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 3px;
}

.status-tab[aria-selected="true"] {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.status-count {
  min-width: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  line-height: 24px;
  text-align: center;
}

.status-tab[aria-selected="true"] .status-count {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

.empty-state {
  width: min(calc(100% - 40px), var(--content));
  margin: clamp(40px, 8vw, 96px) auto;
  padding: 40px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted-ink);
  font-weight: 600;
  text-align: center;
}

.sticker-class[hidden],
.sticker-card[hidden],
.category-nav a[hidden],
.empty-state[hidden] {
  display: none;
}

/* ---------- Sticker sections ---------- */

.sticker-class {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
  padding: clamp(40px, 6vw, 72px) 0 0;
  scroll-margin-top: calc(var(--header-h) + 56px);
}

.sticker-class:last-of-type {
  padding-bottom: clamp(48px, 7vw, 88px);
}

.section-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
}

.count {
  margin: 0;
  color: var(--muted-ink);
  font-size: 14px;
  font-weight: 600;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

/* One card per sticker. Copy this block into index.html when adding a sticker.

  <button class="sticker-card" type="button" aria-pressed="false" data-id="001" data-name="اسم الستيكر">
    <span class="sticker-preview">
      <img src="class-01/001-sticker-name.png" alt="وصف قصير" loading="lazy">
      <span class="check" aria-hidden="true"></span>
      <span class="sticker-badge">قديم</span> <!-- only for older versions; also keep "(قديم)" in data-name -->
    </span>
    <span class="sticker-meta">
      <span class="sticker-number">001</span>
      <span class="sticker-name">اسم الستيكر</span>
    </span>
  </button>
*/

.sticker-card {
  min-width: 0;
  padding: 0;
  display: block;
  overflow: hidden;
  color: inherit;
  text-align: start;
  cursor: pointer;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.sticker-card:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  transform: translateY(-2px);
}

.sticker-card:active {
  transform: scale(.985);
}

.sticker-card[aria-pressed="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}

.sticker-preview {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--brand-soft);
  transition: background-color 160ms ease;
}

.sticker-card[aria-pressed="true"] .sticker-preview {
  background: color-mix(in srgb, var(--brand) 14%, #fff);
}

.sticker-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 26px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.check {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .9);
  border: 2px solid #b7cbe2;
  border-radius: 50%;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.check::after {
  content: "";
  width: 12px;
  height: 7px;
  margin-top: -3px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg) scale(0);
  transition: transform 160ms ease;
}

.sticker-card[aria-pressed="true"] .check {
  background: var(--brand);
  border-color: var(--brand);
}

.sticker-card[aria-pressed="true"] .check::after {
  transform: rotate(-45deg) scale(1);
}

/* Small status tag on the preview (e.g. "قديم"), same look as a Flowbite "Warning" badge. */
.sticker-badge {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  padding: 2px 6px;
  color: #93370d;
  background: #fff4e5;
  border: 1px solid #fed7aa;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
}

.sticker-meta {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.sticker-number {
  flex: 0 0 auto;
  min-width: 46px;
  padding: 3px 10px;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  direction: ltr;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

.sticker-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

/* ---------- Selection bar ---------- */

.selection-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 25;
  padding: 0 0 env(safe-area-inset-bottom);
  color: #fff;
  background: var(--ink);
  box-shadow: 0 -8px 30px rgba(11, 27, 46, .22);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform 260ms cubic-bezier(.2, .8, .2, 1), visibility 0s linear 260ms;
}

.selection-bar.is-visible {
  transform: translateY(0);
  visibility: visible;
  transition-delay: 0s;
}

.bar-inner {
  width: min(calc(100% - 40px), var(--content));
  margin-inline: auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.bar-summary {
  min-width: 0;
  flex: 1 1 auto;
}

.bar-count {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
}

.bar-numbers {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, .7);
  direction: ltr;
  text-align: start;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[dir="rtl"] .bar-numbers {
  text-align: right;
}

.bar-clear {
  min-height: 48px;
  padding: 8px 16px;
  color: rgba(255, 255, 255, .85);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.bar-clear:hover {
  background: rgba(255, 255, 255, .1);
}

.bar-send {
  min-height: 48px;
  padding: 8px 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  background: var(--brand);
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 160ms ease;
}

.bar-send:hover {
  background: #1a86f0;
}

.bar-send svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  :root {
    --header-h: 8px;
  }

  .site-header {
    position: static;
  }

  .header-inner {
    width: calc(100% - 28px);
    padding: 12px 0 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .category-nav {
    width: 100%;
  }

  .category-nav a {
    padding-inline: 16px;
  }

  .intro-inner,
  .sticker-class,
  .bar-inner {
    width: calc(100% - 28px);
  }

  .sticker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .sticker-preview img {
    padding: 16px;
  }

  .check {
    top: 8px;
    inset-inline-start: 8px;
    width: 28px;
    height: 28px;
  }

  .sticker-badge {
    top: 8px;
    inset-inline-end: 8px;
  }

  .sticker-meta {
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .sticker-name {
    width: 100%;
    font-size: 14px;
  }

  .bar-inner {
    gap: 10px;
  }

  .bar-clear {
    padding-inline: 12px;
  }

  .bar-send {
    padding-inline: 16px;
  }
}

@media (max-width: 400px) {
  .bar-inner {
    flex-wrap: wrap;
  }

  .bar-summary {
    flex-basis: 100%;
  }

  .bar-send {
    flex: 1 1 auto;
    justify-content: center;
  }

  body.has-selection {
    padding-bottom: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
  }
}

#library-panel {
  padding-bottom: clamp(48px, 7vw, 88px);
}
