@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@400;700&display=swap');

:root {
  --primary-color: #5f0f40; /* Imperial Purple */
  --secondary-color: #9a031e; /* Roman Red */
  --accent-color: #fb8b24; /* Gold */
  --background-color: #f5f5f5; /* Marble White */
  --text-color: #373737; /* Charcoal */
  --font-heading: 'Cinzel', serif;
  --font-body: 'Lato', sans-serif;
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* --- Global Resets & Base Styles --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--background-color);
  background-image: url('https://www.transparenttextures.com/patterns/white-marble.png');
  color: var(--text-color);
  line-height: 1.6;
  /* Custom cursor for default state */
  cursor: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/9632/stylus.png'),
    auto;
}

/* Custom cursor for interactive elements */
a,
button,
.btn,
.product-card,
.category-card,
.carousel-prev,
.carousel-next {
  cursor: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/9632/hand.png'),
    pointer;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-feature-settings: 'clig' on, 'liga' on;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--secondary-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--accent-color);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Layout & General Components --- */
.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: 700;
  border-radius: 4px;
  border: 2px solid transparent;
  text-align: center;
  transition: all 0.3s ease;
}

.cta-button {
  background-color: var(--accent-color);
  color: #fff;
  padding: 0.8rem 2rem;
  border-color: var(--accent-color);
  position: relative;
  overflow: hidden;
}

.cta-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 20%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 80%
  );
  transform: translateX(-110%);
}

.cta-button:hover {
  background-color: transparent;
  color: var(--accent-color);
}

.cta-button:hover::after {
  animation: shimmer-once 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Header & Navigation --- */
.main-header {
  background-color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.5rem 0;
}

.main-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo a {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
}
.logo a:hover {
  color: var(--primary-color);
}

.main-nav .nav-menu {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: 400;
  color: var(--text-color);
  padding-bottom: 0.25rem;
  position: relative;
}

.main-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--accent-color);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.main-nav a:hover::after,
.main-nav a.active::after {
  transform: scaleX(1);
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--accent-color);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-form {
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 20px;
  overflow: hidden;
}

.search-input {
  border: none;
  padding: 0.4rem 0.8rem;
  font-family: var(--font-body);
  width: 150px;
  transition: width 0.3s ease;
}

.search-input:focus {
  outline: none;
  width: 200px;
}

.search-button {
  background: none;
  border: none;
  padding: 0 0.8rem;
  color: var(--text-color);
}

/* Changed from .cart-icon to match HTML */
.cart-icon-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-color);
  position: relative;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -12px;
  background-color: var(--secondary-color);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 2rem;
  z-index: 1001; /* Above nav menu */
  color: var(--primary-color);
  width: 2rem; /* Set fixed size for transform */
  height: 2rem; /* Set fixed size for transform */
  position: relative;
}

.nav-toggle .fa-bars {
  transition: opacity 0.2s ease-in-out;
}

.nav-toggle::before,
.nav-toggle::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 3px;
  background-color: var(--primary-color);
  left: 0;
  transition: transform 0.3s ease-in-out, top 0.3s ease-in-out;
  opacity: 0;
  transform-origin: center;
}

/* State when menu is open */
.nav-toggle[aria-expanded='true'] .fa-bars {
  opacity: 0;
}
.nav-toggle[aria-expanded='true']::before {
  opacity: 1;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}
.nav-toggle[aria-expanded='true']::after {
  opacity: 1;
  top: 50%;
  transform: translateY(-50%) rotate(-45deg);
}

/* --- Hero Section --- */
.hero-carousel {
  position: relative;
  background-color: var(--text-color);
  color: var(--background-color);
  height: 60vh;
  min-height: 400px;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s ease, visibility 1s ease;
}

.carousel-slide::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.carousel-slide.active {
  opacity: 1;
  visibility: visible;
}

.carousel-slide:nth-child(1) {
  background-image: url('https://via.placeholder.com/1600x900.png/373737/F5F5F5?text=Roman+Architecture');
}
.carousel-slide:nth-child(2) {
  background-image: url('https://via.placeholder.com/1600x900.png/5F0F40/F5F5F5?text=Legionary+Armor');
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-content h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  color: #fff;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
}

.hero-content p {
  font-size: 1.2rem;
  max-width: 600px;
  margin: 1rem auto 2rem;
}

.carousel-prev,
.carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  padding: 16px;
  color: white;
  font-weight: bold;
  font-size: 24px;
  transition: 0.3s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.3);
  border: none;
  z-index: 5;
}

.carousel-prev {
  left: 0;
  border-radius: 3px 0 0 3px;
}
.carousel-next {
  right: 0;
  border-radius: 3px 0 0 3px;
}
.carousel-prev:hover,
.carousel-next:hover {
  background-color: rgba(0, 0, 0, 0.6);
}

/* --- Sections --- */
.products-section,
.category-highlights,
.scriptorium-section,
.testimonials-section {
  padding: 4rem 0;
}

h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
}

/* --- Scroll-triggered Animations --- */
.product-card,
.category-card,
.scriptorium-post,
.testimonial-card {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.product-card.visible,
.category-card.visible,
.scriptorium-post.visible,
.testimonial-card.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Product Grid --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.product-card {
  background-color: #fff;
  border: 1px solid #ddd;
  text-align: center;
  /* transition is now for scroll animation */
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.product-card:hover {
  transform: translateY(-8px)
    scale(1.02) !important; /* !important to override .visible transform */
  box-shadow: 0 15px 30px rgba(55, 55, 55, 0.15);
}

.product-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.product-info {
  padding: 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-info h3 {
  font-size: 1.2rem;
  color: var(--text-color);
  margin-bottom: 0.5rem;
}

.product-price {
  color: var(--secondary-color);
  font-weight: 700;
  font-size: 1.1rem;
}

.product-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.product-card:hover .product-actions {
  transform: translateY(0);
  opacity: 1;
}

.product-actions .btn {
  flex: 1;
}

.product-actions .quick-view-btn {
  background-color: var(--text-color);
  color: #fff;
}
.product-actions .add-to-cart-btn {
  background-color: var(--primary-color);
  color: #fff;
}
/* "Chiseling" effect on hover */
.product-actions .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.product-actions .add-to-cart-btn:hover {
  background-color: var(--secondary-color);
}

/* --- Category Highlights --- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.category-card {
  position: relative;
  display: block;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  border-radius: 4px;
  height: 250px;
}

.category-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.category-card:hover img {
  transform: scale(1.1);
}

.category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent 50%);
  z-index: 1;
}

.category-content {
  position: absolute;
  z-index: 2;
  width: 100%;
  padding: 1rem;
  text-align: center;
  bottom: 0;
  left: 0;
}
.category-content h3 {
  color: #fff;
  margin: 0;
}

/* --- Scriptorium Section --- */
.scriptorium-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.scriptorium-post {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}

.scriptorium-content {
  padding: 1.5rem;
}

.read-more {
  font-family: var(--font-heading);
  text-transform: uppercase;
  font-weight: bold;
}

/* --- Testimonials Section --- */
.testimonials-section {
  background-color: #fdf5e6; /* Parchment color */
  border-top: 4px double #d3c9b6;
  border-bottom: 4px double #d3c9b6;
  padding: 4rem 0 5rem 0;
  /* Parallax effect */
  background-image: url('https://www.transparenttextures.com/patterns/rocky-wall.png');
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
  position: relative;
}

.testimonials-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(253, 245, 230, 0.92); /* Parchment overlay */
  z-index: 0;
}

.testimonials-grid,
.testimonials-section > h2 {
  position: relative;
  z-index: 1;
}

.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2.5rem;
}

.testimonial-card {
  background: rgba(255, 255, 255, 0.6);
  padding: 2rem;
  border: 1px solid #d3c9b6;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.testimonial-card blockquote {
  margin: 0;
  font-style: italic;
  position: relative;
  padding-left: 2.5rem;
  color: #555;
  margin-bottom: 1rem;
}

.testimonial-card blockquote::before {
  content: '“';
  font-family: var(--font-heading);
  font-size: 4rem;
  position: absolute;
  left: -0.5rem;
  top: -1.5rem;
  color: var(--accent-color);
  opacity: 0.5;
  line-height: 1;
}

.testimonial-card cite {
  display: block;
  text-align: right;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--primary-color);
}

.testimonial-card cite::before {
  content: '— ';
}

/* --- Footer --- */
.main-footer {
  background-color: var(--text-color);
  color: var(--background-color);
  padding: 3rem 0 0;
  margin-top: 4rem;
}

.main-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
}

.footer-section {
  flex: 1;
  min-width: 220px;
}

.footer-section h4 {
  color: var(--accent-color);
  margin-bottom: 1rem;
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  margin-bottom: 0.5rem;
}

.footer-section a {
  color: #ccc;
}

.footer-section a:hover {
  color: #fff;
}

.social-icons a {
  margin-right: 1rem;
  font-size: 1.5rem;
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.newsletter-form input {
  padding: 0.7rem;
  border: 1px solid #555;
  background: #444;
  color: #fff;
  border-radius: 4px;
}
.newsletter-form button {
  align-self: flex-start;
}

.footer-bottom {
  text-align: center;
  border-top: 1px solid #555;
  padding: 1.5rem 0;
  margin-top: 2rem;
  font-size: 0.9rem;
  width: 100%;
}

/* --- Mini Cart --- */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mini-cart {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: 100%;
  background-color: #fff;
  z-index: 1002;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
}

.mini-cart.active {
  transform: translateX(0);
}

.mini-cart-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mini-cart-header h3 {
  margin: 0;
}

.close-cart {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-color);
  line-height: 1;
}

/* Changed from .cart-items to match JS */
.mini-cart-items {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.cart-empty-msg {
  text-align: center;
  margin-top: 2rem;
  color: #777;
}

.mini-cart-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.cart-item-image {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border: 1px solid #eee;
}

.cart-item-details {
  flex-grow: 1;
}

.cart-item-name {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.cart-item-price,
.cart-item-quantity {
  color: #555;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.remove-from-cart-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #aaa;
  transition: color 0.3s ease;
}
.remove-from-cart-btn:hover {
  color: var(--secondary-color);
}

.mini-cart-footer {
  padding: 1.5rem;
  border-top: 2px solid var(--primary-color);
  background-color: var(--background-color);
}

.mini-cart-footer p {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.mini-cart-footer .checkout-btn {
  width: 100%;
}

/* --- Quick View Modal --- */
/* Updated selectors to match JS */
#quick-view-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#quick-view-overlay.active {
  opacity: 1;
  visibility: visible;
}

#quick-view-modal {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 800px;
  position: relative;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#quick-view-overlay.active #quick-view-modal {
  transform: scale(1);
  opacity: 1;
}

.close-modal-btn {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--text-color);
  background: none;
  border: none;
  line-height: 1;
  z-index: 10;
}

.modal-content {
  display: flex;
  padding: 2.5rem;
}

.modal-product-image {
  flex: 0 0 45%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
}

.modal-details {
  flex: 1;
  padding-left: 2rem;
}

.modal-product-title {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.modal-product-price {
  font-size: 1.5rem;
  color: var(--secondary-color);
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.modal-product-description {
  margin-bottom: 2rem;
}

/* --- Responsiveness --- */
@media (max-width: 1023px) {
  .search-form {
    display: none; /* Hide search bar on tablets */
  }
}

@media (max-width: 767px) {
  h2 {
    font-size: 2rem;
  }
  .main-header .container {
    flex-wrap: wrap;
  }
  .main-nav {
    order: 3;
    width: 100%;
  }
  .main-nav .nav-menu {
    display: none;
    flex-direction: column;
    width: 100%;
    background-color: #fff;
    padding: 1rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    gap: 0;
  }

  .main-nav .nav-menu.active {
    display: flex;
  }

  .main-nav .nav-menu li {
    text-align: center;
    width: 100%;
  }

  .main-nav .nav-menu a {
    display: block;
    padding: 1rem;
  }

  .main-nav a::after {
    display: none;
  }

  .nav-toggle {
    display: block;
  }

  .main-footer .container {
    flex-direction: column;
    text-align: center;
  }

  .newsletter-form button {
    align-self: center;
  }

  .social-icons {
    margin-top: 1rem;
  }

  .scriptorium-post {
    flex-direction: column;
  }

  .modal-content {
    flex-direction: column;
    padding: 2.5rem 1.5rem 1.5rem;
    max-height: 85vh;
    overflow-y: auto;
  }
  .modal-details {
    padding-left: 0;
    padding-top: 1.5rem;
  }
}

@media (min-width: 768px) {
  .scriptorium-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .scriptorium-post {
    flex-direction: row;
  }
  .scriptorium-post img {
    width: 40%;
    object-fit: cover;
  }
}

/* --- Animations & Accessibility --- */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.pulse {
  animation: pulse 0.5s ease-in-out;
}

@keyframes shimmer-once {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(110%);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .product-card,
  .category-card,
  .scriptorium-post,
  .testimonial-card {
    opacity: 1;
    transform: none;
  }
}