
*,
*::before,
*::after { box-sizing: border-box; }

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  --pink-50:  #fff0f6;
  --pink-100: #ffe0ec;
  --pink-200: #ffc2d9;
  --pink-300: #ff9ec4;
  --pink-400: #ff6fae;
  --pink-500: #ff4d94;
  --pink-600: #e63b7f;
  --pink-700: #c22a68;

  --text:  #5a1f3d;
  --muted: #8a3f62;     
  --white: #ffffff;

  /* Token khusus teks — kontras 5.45:1 di atas putih (WCAG AA) */
  --pink-text: var(--pink-700);

  --shadow:    0 8px 24px rgba(255, 77, 148, .18);
  --shadow-sm: 0 4px 12px rgba(255, 77, 148, .14);
  --btn-edge:  0 6px 0 var(--pink-700);

  --radius:    20px;
  --radius-sm: 12px;
}

/* ============================================
   BASE
   ============================================ */
body {
  font-family: "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background:
    radial-gradient(circle at 10% 10%, var(--pink-100) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, #ffe6f2 0%, transparent 45%),
    var(--pink-50);
  /* background-attachment: fixed DIHAPUS — janky di mobile & bug di iOS Safari */
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin-top: 0;
  color: var(--pink-text);
  letter-spacing: .3px;
}
h1 { font-weight: 800; }
h2 { font-weight: 700; }

a {
  color: var(--pink-text);
  text-decoration: none;
  font-weight: 700;
  transition: color .2s ease;
}
a:hover {
  color: var(--pink-700);
  text-decoration: underline wavy var(--pink-300);
}

::selection {
  background: var(--pink-200);
  color: var(--pink-700);
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--pink-50); }
::-webkit-scrollbar-thumb {
  background: var(--pink-300);
  border-radius: 999px;
  border: 2px solid var(--pink-50);
}
::-webkit-scrollbar-thumb:hover { background: var(--pink-400); }

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 18px;
}
.container.narrow { max-width: 700px; }
.container.tiny   { max-width: 600px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

/* ============================================
   HEADER
   ============================================ */
header {
  background: linear-gradient(135deg, var(--pink-400), var(--pink-600));
  color: var(--white);
  padding: 18px 24px;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--white);
}

header h1::before {
  content: "🌸";
  font-size: 1.1em;
}

/* ============================================
   CARD
   ============================================ */
.card {
  background: var(--white);
  border: 2px solid var(--pink-100);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
  isolation: isolate;  /* stacking context — biar ::after di bawah teks */
  overflow: hidden;
  animation: pop-in .35s ease both;
}

/* Glow dekoratif — di belakang konten, di atas bg card */
.card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, var(--pink-100), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.card:hover {
  transform: translateY(-4px) rotate(-.4deg);
  box-shadow: var(--shadow);
  border-color: var(--pink-300);
}

.card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

/* Stagger — sekarang berlaku untuk card ke berapapun */
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:nth-child(5) { animation-delay: .24s; }
.card:nth-child(n+6) { animation-delay: .3s; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================
   BUTTONS
   ============================================ */
button,
.btn {
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--pink-400), var(--pink-600));
  color: var(--white);
  box-shadow: var(--btn-edge), var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;


  /* inline-flex = tombol otomatis center, aman untuk <button> & <a class="btn"> */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:hover,
.btn:hover { filter: brightness(1.05); }

button:active,
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--pink-700), var(--shadow-sm);
}

button.small {
  padding: 8px 16px;
  font-size: 14px;
  box-shadow: 0 4px 0 var(--pink-700);
}
button.small:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--pink-700);
}

/* Ghost — satu-satunya varian "kosong" */
.btn-ghost {
  background: var(--pink-100);
  color: var(--pink-700);
  box-shadow: 0 6px 0 var(--pink-200), var(--shadow-sm);
}

/* Danger — shadow disamakan dengan tombol small (0 4px 0) */
.btn.danger {
  background: var(--white);
  color: var(--pink-700);
  border: 2px solid var(--pink-300);
  box-shadow: 0 4px 0 var(--pink-200);
}
.btn.danger:hover { background: var(--pink-50); }

.btn.success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: var(--white);
  box-shadow: 0 4px 0 #047857;
}

a:focus-visible,
button:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--pink-400);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ============================================
   QTY INPUT — satu class untuk semua qty
   ============================================ */
.qty-input {
  width: 72px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--pink-700);
  background: var(--pink-50);
  border: 2px solid var(--pink-200);
  border-radius: 999px;
  outline: none;
  text-align: center;
  transition: border-color .2s ease, box-shadow .2s ease;
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input:focus {
  border-color: var(--pink-400);
  box-shadow: 0 0 0 4px var(--pink-100);
}

.book-action,
.add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================
   FILTERS
   ============================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.filters a {
  background: var(--pink-50);
  border: 2px solid var(--pink-200);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--pink-700);
  text-decoration: none;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
}

.filters a:hover {
  background: var(--pink-100);
  transform: translateY(-2px);
}

.filters a.active {
  background: var(--pink-700);
  border-color: var(--pink-700);
  color: var(--white);
  box-shadow: 0 4px 0 #7d1a42;
}

/* ============================================
   BOOK LIST
   ============================================ */
.book {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 2px dashed var(--pink-100);
  gap: 16px;
}

.book:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.book-info h3 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--pink-text);
}

.book-info small {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  background: var(--pink-50);
  padding: 2px 10px;
  border-radius: 999px;
}

.book-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.book-price {
  font-weight: 800;
  color: var(--pink-text);
  font-size: 16px;
}

/* ============================================
   CART
   ============================================ */
.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--pink-100);
}
.cart-item:last-child { border-bottom: none; }

.cart-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px dashed var(--pink-200);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.total-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--pink-700);
  display: flex;
  justify-content: space-between;
}

.cart-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================
   TABLE
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

table th {
  text-align: left;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--pink-200);
  color: var(--pink-700);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

table td {
  padding: 14px 0;
  border-bottom: 1px solid var(--pink-100);
  vertical-align: middle;
}

table .num { text-align: right; }

/* Remove link — hit area 44×44 tapi visual tetap 28×28 (WCAG 2.5.5) */
.remove-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--pink-100);
  color: var(--pink-700);
  text-decoration: none;
  font-weight: 800;
  position: relative;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.remove-link::before {
  content: "";
  position: absolute;
  inset: -8px;   /* hit area = 44×44 */
}
.remove-link:hover {
  background: var(--pink-700);
  color: var(--white);
  transform: rotate(90deg);
}

/* ============================================
   TOTAL & ACTIONS
   ============================================ */
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px dashed var(--pink-300);
  font-size: 20px;
  font-weight: 800;
  color: var(--pink-700);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.actions .btn { flex: 1; }

/* ============================================
   MEDIA QUERIES — digabung ke satu breakpoint (600px)
   ============================================ */
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; gap: 18px; }

  .book {
    flex-direction: column;
    align-items: flex-start;
  }
  .book-actions {
    align-items: flex-start;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    margin-top: 10px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}