/* ══════════════════════════════════════════════════════════════
   DigitalStore — Main Stylesheet
   Theme: Editorial/Refined Minimal — cream + ink + forest green
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --cream: #F5F0E8;
  --ink: #1C1917;
  --forest: #2D5016;
  --forest-light: #3D6B20;
  --gold: #C8962E;
  --muted: #7C7269;
  --border: #DDD8CE;
  --white: #FDFCFA;
  --danger: #C0392B;
  --success: #2D5016;
  --card-bg: #FDFCFA;
  --shadow: 0 2px 16px rgba(28,25,23,0.08);
  --shadow-hover: 0 8px 32px rgba(28,25,23,0.14);
  --radius: 4px;
  --radius-lg: 8px;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --transition: 0.2s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background-color: var(--cream);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-body); }
input, textarea, select { font-family: var(--font-body); }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: 1.3rem; }

/* ── Layout ─────────────────────────────────────────────────── */
.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.page-wrapper { padding-top: 80px; min-height: 100vh; }

/* ── Navigation ─────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(245,240,232,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 64px;
}

.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.nav-brand span { color: var(--forest); }

.nav-links { display: flex; align-items: center; gap: 8px; }

.nav-links a, .nav-links button {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--muted);
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover, .nav-links button:hover {
  color: var(--ink);
  background: var(--border);
}

.nav-links .btn-primary-sm {
  background: var(--forest);
  color: var(--white);
  padding: 8px 18px;
  border-radius: var(--radius);
}

.nav-links .btn-primary-sm:hover { background: var(--forest-light); }

.cart-badge {
  display: inline-flex; align-items: center; gap: 6px;
  position: relative;
}

.cart-count {
  background: var(--gold);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--forest);
  color: var(--white);
}
.btn-primary:hover { background: var(--forest-light); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--ink); background: var(--ink); color: var(--white); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { opacity: 0.88; }

.btn-sm { padding: 8px 18px; font-size: 0.85rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(45,80,22,0.1);
}

.form-textarea { resize: vertical; min-height: 100px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

/* ── Product Grid ────────────────────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.product-card { display: flex; flex-direction: column; }

.product-cover {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--forest) 0%, #4a7c27 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
  overflow: hidden;
}

.product-cover::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 20px,
    rgba(255,255,255,0.03) 20px, rgba(255,255,255,0.03) 40px
  );
}

.product-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.product-category {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--forest); margin-bottom: 8px;
}
.product-title { font-family: var(--font-display); font-size: 1.15rem; margin-bottom: 8px; }
.product-desc { font-size: 0.88rem; color: var(--muted); line-height: 1.5; flex: 1; margin-bottom: 16px; }
.product-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.product-price { font-size: 1.2rem; font-weight: 600; color: var(--ink); }
.product-price.free { color: var(--forest); }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--forest);
  margin-bottom: 16px;
}

.hero h1 { margin-bottom: 20px; color: var(--ink); }

.hero-sub {
  font-size: 1.05rem; color: var(--muted);
  max-width: 520px; margin: 0 auto 40px;
}

/* ── Auth Pages ──────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow);
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 8px;
}
.auth-logo span { color: var(--forest); }

.auth-subtitle {
  text-align: center; color: var(--muted);
  font-size: 0.9rem; margin-bottom: 36px;
}

.auth-divider {
  text-align: center; color: var(--muted);
  font-size: 0.85rem; margin: 20px 0;
}

.auth-switch { text-align: center; font-size: 0.9rem; color: var(--muted); margin-top: 24px; }
.auth-switch a { color: var(--forest); font-weight: 500; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 20px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

/* ── Cart Sidebar ────────────────────────────────────────────── */
.cart-sidebar {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 380px; max-width: 100vw;
  background: var(--white);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0,0,0,0.12);
  z-index: 200;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.cart-sidebar.open { transform: translateX(0); }

.cart-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  z-index: 199; opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.cart-overlay.show { opacity: 1; pointer-events: all; }

.cart-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header h3 { font-family: var(--font-display); }

.cart-close {
  background: none; border: none;
  font-size: 1.4rem; color: var(--muted);
  cursor: pointer; line-height: 1;
}

.cart-items { flex: 1; overflow-y: auto; padding: 16px 24px; }

.cart-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}

.cart-item-icon {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}

.cart-item-info { flex: 1; }
.cart-item-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }
.cart-item-price { font-size: 0.85rem; color: var(--muted); }

.cart-item-remove {
  background: none; border: none;
  color: var(--muted); font-size: 1.1rem;
  cursor: pointer; transition: color var(--transition);
}
.cart-item-remove:hover { color: var(--danger); }

.cart-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.cart-total {
  display: flex; justify-content: space-between;
  font-size: 1rem; font-weight: 600; margin-bottom: 16px;
}

.cart-empty {
  text-align: center; color: var(--muted);
  padding: 40px 0; font-size: 0.95rem;
}

/* ── Orders / Downloads ──────────────────────────────────────── */
.orders-section { padding: 40px 0; }

.order-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.order-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}

.order-ref { font-size: 0.8rem; color: var(--muted); font-family: monospace; }
.order-total { font-weight: 600; font-size: 1.1rem; }

.order-items { display: flex; flex-direction: column; gap: 10px; }
.order-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--cream);
  border-radius: var(--radius);
  gap: 12px;
}

.order-item-title { font-size: 0.9rem; font-weight: 500; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-pdf { background: #FEF3C7; color: #92400E; }

/* ── Section Utilities ───────────────────────────────────────── */
.section { padding: 60px 0; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.section-title { font-family: var(--font-display); }
.text-muted { color: var(--muted); font-size: 0.9rem; }

/* Filter bar */
.filter-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 16px;
}
.filter-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: none;
  font-size: 0.85rem; color: var(--muted);
  cursor: pointer; transition: all var(--transition);
}
.filter-btn.active, .filter-btn:hover {
  border-color: var(--forest); color: var(--forest);
  background: rgba(45,80,22,0.06);
}

/* Loading spinner */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap { display: flex; justify-content: center; padding: 40px; }

/* Toast notification */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--ink); color: var(--white);
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  z-index: 999;
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 80px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .auth-card { padding: 32px 24px; }
  .cart-sidebar { width: 100vw; }
  .nav-links .nav-label { display: none; }
  .products-grid { grid-template-columns: 1fr; }
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-up { animation: fadeUp 0.5s ease forwards; }
.fade-up-delay-1 { animation-delay: 0.1s; opacity: 0; }
.fade-up-delay-2 { animation-delay: 0.2s; opacity: 0; }
.fade-up-delay-3 { animation-delay: 0.3s; opacity: 0; }
