/* ============================================================
   BOOKSBYAMA — utilities.css
   Reusable utility & component classes.
   Depends on: variables.css (must load first)
============================================================ */

/* ─── RESET & BASE ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a  { color: inherit; }
button { cursor: pointer; font-family: inherit; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1,h2,h3,h4,h5,h6 { margin: 0; font-family: var(--font-head); line-height: var(--leading-tight); }
p { margin: 0; }
input, textarea, select, button { font-family: inherit; }

/* ─── CONTAINER ─────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* ─── SECTION PADDING ───────────────────────────────────── */
.section-pad      { padding-block: var(--section-pad-y); }
.section-pad--sm  { padding-block: var(--section-pad-y-sm); }
.section-pad--lg  { padding-block: 128px; }

/* ─── DISPLAY ───────────────────────────────────────────── */
.d-block   { display: block; }
.d-flex    { display: flex; }
.d-grid    { display: grid; }
.d-none    { display: none !important; }
.d-inline  { display: inline; }
.d-inline-flex { display: inline-flex; }

/* ─── FLEX UTILITIES ────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-row     { flex-direction: row; }
.flex-wrap    { flex-wrap: wrap; }
.flex-nowrap  { flex-wrap: nowrap; }
.flex-1       { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-start  { align-items: flex-start; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-start  { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.gap-10 { gap: var(--space-10); }
.gap-12 { gap: var(--space-12); }
.gap-16 { gap: var(--space-16); }

/* ─── GRID UTILITIES ────────────────────────────────────── */
.grid         { display: grid; }
.grid-2       { grid-template-columns: repeat(2, 1fr); }
.grid-3       { grid-template-columns: repeat(3, 1fr); }
.grid-4       { grid-template-columns: repeat(4, 1fr); }
.grid-auto    { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ─── TEXT ALIGNMENT ────────────────────────────────────── */
.text-left    { text-align: left; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

/* ─── TEXT SIZE ─────────────────────────────────────────── */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md   { font-size: var(--text-md); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }
.text-4xl  { font-size: var(--text-4xl); }
.text-5xl  { font-size: var(--text-5xl); }

/* ─── FONT WEIGHT ───────────────────────────────────────── */
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-head    { font-family: var(--font-head); }
.font-body    { font-family: var(--font-body); }

/* ─── TEXT COLOUR ───────────────────────────────────────── */
.text-primary  { color: var(--color-text); }
.text-muted    { color: var(--color-muted); }
.text-light    { color: var(--color-light); }
.text-white    { color: #fff; }
.text-purple   { color: var(--color-purple); }
.text-gold     { color: var(--color-gold); }
.text-green    { color: var(--color-green); }
.text-coral    { color: var(--color-coral); }

/* ─── GRADIENT TEXT ─────────────────────────────────────── */
.text-gradient {
  background: linear-gradient(135deg, var(--color-purple), var(--color-purple-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── BACKGROUND ────────────────────────────────────────── */
.bg-white   { background: #fff; }
.bg-page    { background: var(--color-bg); }
.bg-surface { background: var(--color-surface); }
.bg-purple  { background: var(--color-purple); }
.bg-purple-soft { background: var(--color-purple-soft); }
.bg-gold    { background: var(--color-gold); }
.bg-white   { background: var(--color-surface); }

/* ─── BORDER ────────────────────────────────────────────── */
.border       { border: 1.5px solid var(--color-border); }
.border-top   { border-top: 1.5px solid var(--color-border); }
.border-bottom{ border-bottom: 1.5px solid var(--color-border); }
.rounded-sm  { border-radius: var(--radius-sm); }
.rounded-md  { border-radius: var(--radius-md); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-xl  { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-3xl { border-radius: var(--radius-3xl); }
.rounded-full { border-radius: var(--radius-full); }

/* ─── SHADOW ────────────────────────────────────────────── */
.shadow-xs  { box-shadow: var(--shadow-xs); }
.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow     { box-shadow: var(--shadow-md); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }
.shadow-xl  { box-shadow: var(--shadow-xl); }

/* ─── SPACING HELPERS ───────────────────────────────────── */
.mt-0  { margin-top: 0; }
.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mt-10 { margin-top: var(--space-10); }
.mt-12 { margin-top: var(--space-12); }
.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mx-auto { margin-inline: auto; }
.p-4   { padding: var(--space-4); }
.p-6   { padding: var(--space-6); }
.p-8   { padding: var(--space-8); }
.px-4  { padding-inline: var(--space-4); }
.px-6  { padding-inline: var(--space-6); }
.py-4  { padding-block: var(--space-4); }
.py-6  { padding-block: var(--space-6); }
.py-8  { padding-block: var(--space-8); }
.py-12 { padding-block: var(--space-12); }

/* ─── WIDTH & HEIGHT ────────────────────────────────────── */
.w-full    { width: 100%; }
.h-full    { height: 100%; }
.min-h-screen { min-height: 100dvh; }
.max-w-prose  { max-width: 68ch; }
.max-w-sm     { max-width: 480px; }
.max-w-md     { max-width: 640px; }
.max-w-lg     { max-width: 800px; }

/* ─── OVERFLOW ──────────────────────────────────────────── */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }

/* ─── POSITION ──────────────────────────────────────────── */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }
.inset-0  { inset: 0; }

/* ─── VISUALLY HIDDEN (accessible) ─────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--duration-base) var(--ease-default),
    box-shadow var(--duration-base) var(--ease-default),
    background var(--duration-base) var(--ease-default),
    color var(--duration-base) var(--ease-default);
  outline-offset: 3px;
  user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--color-purple); }
.btn:active        { transform: scale(0.98); }

.btn--primary {
  background: linear-gradient(135deg, var(--color-purple), var(--color-purple-dark));
  color: #fff;
}
.btn--primary:hover {
  background: linear-gradient(135deg, var(--color-purple-dark), #3c3778);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 93, 169, 0.35);
}

.btn--secondary {
  background: var(--color-purple-soft);
  color: var(--color-purple-dark);
  border: 1.5px solid var(--color-purple-tint);
}
.btn--secondary:hover {
  background: var(--color-purple-tint);
  transform: translateY(-2px);
}

.btn--outline {
  background: transparent;
  color: var(--color-purple);
  border: 2px solid var(--color-purple);
}
.btn--outline:hover {
  background: var(--color-purple-soft);
  transform: translateY(-2px);
}

.btn--outline-white {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
}
.btn--outline-white:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--color-muted);
  border: none;
}
.btn--ghost:hover { background: var(--color-purple-soft); color: var(--color-purple); }

.btn--gold {
  background: var(--color-gold);
  color: var(--color-text);
}
.btn--gold:hover {
  background: var(--color-gold-deep);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 201, 59, 0.4);
}

.btn--sm { padding: 8px 16px; font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn--lg { padding: 16px 32px; font-size: var(--text-lg); border-radius: var(--radius-lg); }
.btn--full { width: 100%; }

/* ─── BADGE ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  width: fit-content;
}
.badge--purple {
  background: var(--color-purple-soft);
  color: var(--color-purple-dark);
  border: 1px solid var(--color-purple-tint);
}
.badge--white {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(6px);
}
.badge--gold  { background: #FFF3C4; color: #C99300; }
.badge--green { background: var(--color-green-soft); color: #2E9958; }
.badge__dot   { font-size: 0.55rem; opacity: 0.8; }

/* ─── SECTION HEADER ────────────────────────────────────── */
.section-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  margin-bottom: var(--space-12);
}
.section-heading {
  font-family: var(--font-head);
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 800;
  color: var(--color-text);
  line-height: var(--leading-tight);
  margin: 0;
}
.section-sub {
  font-size: var(--text-lg);
  color: var(--color-muted);
  line-height: var(--leading-relaxed);
  max-width: 600px;
  margin: 0;
}
.section-header__title {
  font-family: var(--font-head);
  font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl));
  font-weight: 800;
  color: var(--color-text);
  margin: 0;
}
.section-header__sub {
  font-size: var(--text-lg);
  color: var(--color-muted);
  line-height: var(--leading-relaxed);
  max-width: 580px;
  margin: 0;
}

/* ─── CARD ──────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  transition: transform var(--duration-slow) var(--ease-default),
              box-shadow var(--duration-slow) var(--ease-default);
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}
.card--flat { background: var(--color-bg); }
.card--raised { box-shadow: var(--shadow-md); }

/* ─── DIVIDER ───────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* ─── TAGS / CHIPS ──────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.tag--purple { background: var(--color-purple-soft); color: var(--color-purple-dark); }
.tag--gold   { background: #FFF3C4; color: #C99300; }
.tag--green  { background: var(--color-green-soft); color: #2E9958; }
.tag--blue   { background: var(--color-blue-soft); color: #3580B8; }
.tag--coral  { background: var(--color-coral-soft); color: #D94040; }

/* ─── FOCUS RING (global keyboard focus) ────────────────── */
:focus-visible {
  outline: 2px solid var(--color-purple);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ─── SCROLL TO TOP BUTTON ──────────────────────────────── */
.scroll-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--z-overlay);
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-purple), var(--color-purple-dark));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 93, 169, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity var(--duration-slow) var(--ease-default),
    transform var(--duration-slow) var(--ease-default),
    box-shadow var(--duration-base) var(--ease-default);
}
.scroll-top.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.scroll-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(99, 93, 169, 0.5);
}

/* ─── LOADING SPINNER ───────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--color-purple-tint);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--sm  { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg  { width: 40px; height: 40px; border-width: 4px; }
.spinner--white {
  border-color: rgba(255,255,255,.3);
  border-top-color: #fff;
}

/* ─── PAGE LOADER OVERLAY ───────────────────────────────── */
.page-loader {
  position: fixed; inset: 0;
  background: var(--color-surface);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: var(--space-4);
  transition: opacity var(--duration-slower) var(--ease-default),
              visibility var(--duration-slower) var(--ease-default);
}
.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.page-loader__logo { font-family: var(--font-head); font-size: 1.2rem; font-weight: 800; color: var(--color-text); }
.page-loader__logo span { color: var(--color-purple); }

/* ─── BREADCRUMB ────────────────────────────────────────── */
.breadcrumb { padding: 14px 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.breadcrumb__list { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 0; font-size: var(--text-sm); }
.breadcrumb__link { color: var(--color-muted); text-decoration: none; transition: color var(--duration-base) var(--ease-default); }
.breadcrumb__link:hover { color: var(--color-purple); }
.breadcrumb__sep  { color: var(--color-light); }
.breadcrumb__current { color: var(--color-text); font-weight: 500; }

/* ─── PAGE BANNER (inner pages) ─────────────────────────── */
.page-banner {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-purple-dark) 0%, var(--color-purple) 55%, #7B75C2 100%);
  padding: 80px 0 64px;
  text-align: center;
}
.page-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.page-banner__inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }
.page-banner__title { font-family: var(--font-head); font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl)); font-weight: 800; color: #fff; margin: 0; }
.page-banner__sub   { font-size: var(--text-lg); color: rgba(255,255,255,.82); max-width: 560px; line-height: var(--leading-relaxed); margin: 0; }

/* ─── STORE BUTTONS (global pattern) ───────────────────── */
.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 14px;
  text-decoration: none;
  min-width: 155px;
  transition: transform var(--duration-base) var(--ease-default),
              box-shadow var(--duration-base) var(--ease-default);
}
.store-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0,0,0,.22); }
.store-btn--dark  { background: #2D2A4A; color: #fff; }
.store-btn--light { background: #fff; color: var(--color-text); }
.store-btn__icon  { flex-shrink: 0; display: flex; }
.store-btn__text  { display: flex; flex-direction: column; gap: 1px; }
.store-btn__sub   { font-size: .58rem; font-weight: 600; letter-spacing: .06em; opacity: .7; text-transform: uppercase; }
.store-btn__name  { font-size: .9rem; font-weight: 700; font-family: var(--font-head); line-height: 1; }

/* ─── RESPONSIVE HELPERS ────────────────────────────────── */
@media (max-width: 1280px) { .container { padding-inline: 20px; } }
@media (max-width: 768px)  {
  .container { padding-inline: 16px; }
  .section-pad { padding-block: var(--section-pad-y-sm); }
  .hide-mobile { display: none !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) { .hide-desktop { display: none !important; } }
