/* General Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box; /* NEW: Better for layout calculations */
}

html {
  font-family: 'Poppins', sans-serif; /* Poppins was specified but not used */
  color: #f0f0f0;
} 

@media (min-width: 300px) {
  html {
    font-size: 12px;
  }
}

@media (min-width: 400px) {
  html {
    font-size: 13px;
  }
}

@media (min-width: 576px) {
  html {
    font-size: 14px;
  }
}

@media (min-width: 768px) {
  html {
    font-size: 15px;
  }
}

@media (min-width: 992px) {
  html {
    font-size: 16px;
  }
}

@media (min-width: 1200px) {
  html {
    font-size: 17px;
  }
}

@media (min-width: 1400px) {
  html {
    font-size: 18px;
  }
}

@media (min-width: 2100px) {
  html {
    font-size: 19px;
  }
}

body {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  /*  background: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb') no-repeat center center fixed;*/
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;

  color: #a2a5b3;
  display: flex; /* CHANGED: Use flex for better centering */
  flex-direction: column;
  flex-grow: 1;
  align-items: center;
  justify-content: center;
  overflow-x: hidden; /* Prevent horizontal scroll */
  overflow: hidden;
  position: relative;
}

a:link{
  text-decoration: none;
  color: #39916e;
}
a:visited {
  text-decoration: none;
  color: #39916e;  
}
a:hover {
  text-decoration: none;
  color: #39916e;
}
a:active{
  text-decoration: none;
  color: #39916e;
}

svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* Floating Shapes Animation */
.shape {
  animation: float 10s infinite alternate ease-in-out;
  transform-origin: center;
  opacity: 0.4;
}

.shape[data-index] {
  animation-duration: calc(5s + 2s * var(--i));
  animation-delay: calc(0.3s * var(--i));
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(var(--scale)) rotate(var(--rot));
  }
}

/* --- Animated Gradient Border (Sibling Structure) --- */

/* By prefixing every rule with a unique ID, we make these styles
    more specific and prevent them from being overridden by other stylesheets. */

#gradient-card-wrapper .card-container {
    position: relative;
    margin: 1rem auto;
    width: 90%;
    max-width: 450px;
    border-radius: 10px;
    overflow: hidden; /* Ensures the corners are clipped */
    z-index: 6;
}

#gradient-card-wrapper .card-animated-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Sits behind the content */

    background: linear-gradient(
        115deg,
        #ff4545, #ff0095, #006aff, #00ff99, #ff4545
    );
    background-size: 200% 200%;
    -webkit-animation: bg-spin 3s linear infinite;
    animation: bg-spin 3s linear infinite;
}

#gradient-card-wrapper .card-content {
    position: relative;
    z-index: 2; /* Sits on top of the background div */
    background: #1c1f2b; /* Or your page's main background color */
    padding: 2rem;
    border-radius: 7px; /* Slightly smaller radius for the inner box */
    margin: 3px; /* Creates the border effect */

    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* The animation keyframes that move the background */
@-webkit-keyframes bg-spin {
    to {
        background-position: 200% 200%;
    }
}
@keyframes bg-spin {
    to {
        background-position: 200% 200%;
    }
}


#quote-block {
  display: block;
  overflow: visible;
  text-align: center;
}

#quote-text {
  display: block;
  white-space: pre-line;
  overflow: visible;
/*  line-height: 1.6;*/
  word-break: break-word;
  padding: .8rem;
}

h1 {
  color: white;
  font-size: clamp(1rem, 5vw, 1.35rem);
  line-height: 1.3; /* NEW: Improve readability */
  font-weight: 600;

  --max-lines: 8;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--max-lines);
  line-clamp: var(--max-lines);
}

/* Ad Box Styles */
#ad-box {
  position: absolute;
  /* Use a percentage for width, allowing it to be flexible. */
  width: 40%;
  /* Set a max-width to prevent it from becoming too large. 300px is a good max. */
  max-width: 300px;
  overflow: hidden;
  /* Use an aspect ratio to maintain a common ad shape (e.g., 4:3). */
  /* This helps prevent text from overflowing in the ad. */
  aspect-ratio: 4 / 3;
  z-index: 5;
  animation: moveAd 100s infinite linear; 
}

.placeholder-ad {
  background: #fff;
  border: 2px solid #999;
  color: #333;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* Make sure the ad's movement is contained within the screen */
@keyframes moveAd {
  0%   { top: 5%; left: 5%; }
  10%  { top: 60%; left: 30%; }
  20%  { top: 10%; left: calc(100% - 310px); } /* Adjusted for a max-width of 300px */
  30%  { top: 20%; left: 20%; }
  40%  { top: 60%; left: 45%; }
  50%  { top: calc(100% - 250px); left: calc(100% - 310px); }
  60%  { top: 50%; left: 10%; }
  70%  { top: 15%; left: 50%; }
  80%  { top: calc(100% - 250px); left: 10%; }
  90%  { top: 55%; left: 35%; }
  100% { top: 25%; left: 25%; }
}

.book-title,
.book-author {
  word-wrap: break-word;
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  max-width: 90%;
  margin: 0 auto;
  text-align: center;
}

.book-ad.flip-box {
  perspective: 1000px;
  width: 100%;
  height: 100%;
}

/*
  The container remains a flexbox for centering.
  The fixed height is removed to allow it to adapt.

.book-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
*/
/*
  The SVG's size is now fluid.

.book-icon svg {

  /* clamp(MINIMUM_SIZE, PREFERRED_SIZE, MAXIMUM_SIZE) 
  width: clamp(32px, 8vw, 88px);
  height: clamp(32px, 8vw, 88px);
  
  fill: #a2a5b3;
}
*/
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  border-radius: 12px;
  background-image: url('/images/book-ad-bg.jpg');
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 12px rgba(34, 16, 16, 0.3);
}

.flip-box:hover .flip-inner {
  transform: rotateY(180deg);
}

/* Front and back faces */
.flip-front,
.flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  color: white;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
}

.flip-front .book-icon {
  font-size: clamp(3rem, 4vw, 7rem);
  margin-bottom: clamp(0.7rem, 3vw, 1rem);
}

.flip-front .book-title {
  font-size: clamp(0.6rem, 3vw, 1.1rem);
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.flip-front .book-author {
  font-size: clamp(0.4rem, 3vw, 0.95rem);
  opacity: 0.85;
}

.flip-back {
  transform: rotateY(180deg);
  font-size: clamp(0.4rem, 3vw, 0.95rem);
  line-height: 1.4;
}

.flip-back .book-description {
  color: #f0f0f0;
  --max-lines: 3;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--max-lines);
  line-clamp: var(--max-lines);
}

.expand-btn {
  appearance: none;
  border: 1px solid black;
  padding: .5em;
  border-radius: .25em;
  cursor: pointer;
  margin-top: 1rem;
}

.expand-btn:hover {
  background-color: #CCC;
}

.expand-btn::before {
  content: 'Expand';
}

.expand-btn:checked::before{
  content: 'Collapse';
}


.amazon-logo {
  /* Use min() to set a responsive width with a maximum cap */
  /* width: min(50%, 120px); */
  min-width: 72px;
  max-width: 72px;

  /* Let the height adjust automatically to maintain the logo's shape */
  height: auto;

  /* Helps ensure consistent block-level layout for centering */
  display: block;

  /* Center the logo horizontally within the link */
  margin: 0 auto;
  margin-top: min(5%, 1rem);
}

.amazon-button {
  display: inline-block;
  background-color: #FF9900; /* Amazon's classic orange */
  color: #111111;
  padding: 12px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  margin-top: min(5%, 1rem);
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: background-color 0.2s;
}

.amazon-button:hover {
  background-color: #FFAA33; /* A slightly lighter orange for hover */
}

footer {
  position: absolute;
  bottom: 0;
}

footer a:link,
footer a:visited,
footer a:hover,
footer a:active {
  text-decoration: none;
}

footer p {
  color: white;
  font-size:0.8rem;
  font-weight: 500;
  padding: 5px;
}

footer a:link, 
footer a:hover,
footer a:visited,
footer a:active {
  color: lightsteelblue;
  text-decoration: none;
  font-size:0.8rem;
  font-weight: 500;
}

footer a:hover {
  color: lightskyblue;
}

@media (max-width: 360px), (max-height: 360px) and (orientation: landscape) {
  /* Your CSS rules for small devices in any orientation go here */
  /* On mobile, hide the ad box so it doesn't clutter the view */
  
  #ad-box {
    display: none;
  }

  /* --- Animated Gradient Border (Sibling Structure) --- */

  /* By prefixing every rule with a unique ID, we make these styles
      more specific and prevent them from being overridden by other stylesheets. */

  #gradient-card-wrapper .card-container {
      margin: 1rem auto;
      width: 90%;
      max-width: 300px;
  }

  /* Make the floating shapes smaller and less distracting */
  /*
  .shape {
    transform: scale(0.7);
    opacity: 0.2;
  }
*/
}

@media (max-width: 480px), (max-height: 480px) and (orientation: landscape) {
  /* Your CSS rules for small devices in any orientation go here */
  /* On mobile, hide the ad box so it doesn't clutter the view */
  
  #ad-box {
    display: none;
  }

  /* --- Animated Gradient Border (Sibling Structure) --- */

  /* By prefixing every rule with a unique ID, we make these styles
      more specific and prevent them from being overridden by other stylesheets. */

  #gradient-card-wrapper .card-container {
      margin: 1rem auto;
      width: 90%;
      max-width: 400px;
  }

  /* Make the floating shapes smaller and less distracting */
  /*
  .shape {
    transform: scale(0.7);
    opacity: 0.2;
  }
  */
}

/* ========================================= */
/* NEW: Media Query for smaller screens      */
/* ========================================= */
@media (min-width: 768px) {
  /* On mobile, hide the ad box so it doesn't clutter the view */
  
  /* Make the floating shapes smaller and less distracting */
  .shape {
    transform: scale(2);
    opacity: 0.5;
  }
}