/* NextBookAfter.com - Book Page Structural CSS */

/* STRUCTURAL STYLES - Layout, positioning, spacing, transitions, etc. */

*,*::before,*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  line-height: 1.65;
  min-height: 100vh;
}

a {
  text-decoration: none;
}

.newspaper a, a.watermark {
  transition: all 0.3s ease;
  border-bottom: 1px solid transparent;
}

.newspaper a:hover, a.watermark:hover {
  border-bottom-color: var(--color-accent-light);
}

a.watermark {
  position: absolute;
  top: 12px;
  left: 16px;
  text-decoration: none;
  z-index: 100;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.newspaper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.75rem 1rem;
  padding-inline: max(1.75rem, env(safe-area-inset-left)) max(1.75rem, env(safe-area-inset-right));
  position: relative;
}

/* OPENING LINE */
.opening {
  margin: 0 0 1.5rem 0;
  line-height: 1.3;
}

.opening .source-book {
  font-style: italic;
}

/* MAIN ARTICLE LAYOUT */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 280px 1fr;
  gap: var(--column-gap);
  margin-bottom: 3rem;
  position: relative;
}

.cover-container {
  grid-column: 2;
  text-align: center;
  position: sticky;
  top: 2rem;
  height: fit-content;
}

.mobile-cover-container {
  display: none;
  text-align: center;
  margin: 2rem 0;
}

.mobile-cta-container {
  display: none;
  margin: 0;
}

.cover-art {
  width: 100%;
  max-width: 280px;
  border-radius: var(--border-radius);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
  transition: all 0.4s ease;
  background-color: var(--color-bg);
}
.cover-art:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.18);
}

.rating {
  font-size: 0.9rem;
  margin-top: 1rem;
}

/* COLUMN TEXT */
.column {
  line-height: 1.7;
  text-align: left;
  display: flow-root;
}

.column > p {
  margin: 0 0 1.5rem;
}

.column > p,
.opening,
.inline-quote,
.sidebar-quote-text,
.cta-description,
.mobile-cta-text,
.associated-books-intro,
.book-description {
  hyphens: auto;
  -webkit-hyphens: auto;
}

.column > h1:first-child::first-letter, .column > p:first-child::first-letter {
  float: left;
  line-height: 3rem;
  padding-right: 6px;
  margin-top: 6px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* INLINE QUOTES */
.inline-quote {
  float: right;
  width: 40%;
  margin: 0 0 1.5rem 1.75rem;
  padding: 1.5rem;
  padding-bottom: 0.5rem;
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  font-style: italic;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 2;
  overflow: hidden;
  font-size: 0.95rem;
}

.column.left .inline-quote {
  float: left;
  margin: 0 1.75rem 1.5rem 0;
  border-left: none;
  border-right: 4px solid var(--color-accent);
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.inline-quote-text {
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.inline-quote-source {
  font-style: normal;
}

/* TYPOGRAPHY VARIATIONS */
.highlight {
  background: linear-gradient(120deg, var(--color-accent-light) 0%, var(--color-accent-light) 100%);
  background-repeat: no-repeat;
  background-size: 100% 0.4em;
  background-position: 0 85%;
  padding: 2px 4px;
  border-radius: 3px;
}

/* AIM for 2 subheadings in the column content */
h2.subheading {
  margin: 1.5rem 0 1rem;
  letter-spacing: 0.5px;
  position: relative;
  padding-left: 1rem;
  hyphens: auto;
  -webkit-hyphens: auto;
}

h2.subheading::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
}

/* prevents visual artefacts */
.left .inline-quote + h2.subheading::before {
  content: unset;
}

.column .inline-quote + p + h2.subheading {
  clear: both;
}

/* Chrome/Chromium-only wrapping tweak */
@supports (-webkit-app-region: none) {
  .inline-quote + h2.subheading {
    overflow-wrap: break-word;
  }
}

/* CALL TO ACTION */
.cta-box {
  padding: 1rem;
  margin: 3rem 0;
  text-align: center;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 30px var(--color-shadow);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.mobile-cta-text {
  /* font-size: 1.1rem; */
  margin-bottom: 1rem;
  /* font-family: var(--font-display); */
}

.cta-description {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-style: italic;
}

.cta-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(45deg, rgba(152,158,158,0.1) 0%, transparent 100%);
  pointer-events: none;
}

.buy-button {
  display: inline-block;
  padding: 0.8rem 2rem;
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
  border: 2px solid var(--color-accent);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.buy-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: var(--color-primary);
}

/* SIDEBAR ELEMENTS */
.sidebar-quote {
  padding: 2rem;
  margin: 2rem 0;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.sidebar-quote-text {
  margin: 0 0 0.5rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--color-primary);
}

.sidebar-quote-text::before {
  content: '“';
}
.sidebar-quote-text::after {
  content: '”';
}

.sidebar-quote-source {
  font-size: 0.8rem;
  color: var(--color-muted);
  font-style: normal;
  font-weight: 500;
}

/* RESPONSIVE DESIGN */
@media (max-width: 480px) and (orientation: portrait) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0rem;
  }

  .cover-container {
    display: none;
  }

  .mobile-cover-container {
    display: block;
  }

  .mobile-cta-container {
    display: block;
  }

  .inline-quote {
    float: none;
    width: 100%;
    margin: 1rem 0;
    overflow: hidden;
  }

  .inline-quote.left {
    float: none;
    margin: 1rem 0;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  .newspaper {
    padding: 2.75rem 1.4rem 0;
    padding-inline: max(1.4rem, env(safe-area-inset-left)) max(1.4rem, env(safe-area-inset-right));
  }

  .opening {
    margin-bottom: 1.25rem;
  }

  .mobile-cover-container {
    display: block;
    float: right;
    width: min(68vw, 205px);
    margin: 0 -0.25rem 0 1rem;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    shape-outside: inset(0 round calc(var(--border-radius) * 1.1));
    shape-margin: 0.55rem;
  }

  .mobile-cover-container a {
    display: block;
  }

  .mobile-cover-container .cover-art {
    max-width: none;
    width: 100%;
    border-radius: calc(var(--border-radius) * 1.25);
    box-shadow: 0 10px 28px rgb(0 0 0 / 0.18);
  }

  .mobile-cover-container .rating {
    margin: 0.25rem 0 0.1rem;
    font-size: 0.85rem;
    letter-spacing: 0.4px;
  }

  .column > h2.subheading {
    clear: none;
    margin-top: 1.75rem;
  }

  .column > h2.subheading::before {
    width: 3px;
    border-radius: 1.5px;
  }

  .column > h2.subheading:first-of-type {
    margin-top: 1rem;
  }

  .inline-quote.left + h2.subheading {
    clear: both;
    margin-top: 1.6rem;
  }

  .inline-quote {
    float: right;
    width: min(58vw, 210px);
    margin: 0 0 1.25rem 1.1rem;
    padding: 1.25rem;
    border-radius: calc(var(--border-radius) * 1.2);
    shape-outside: inset(0 round calc(var(--border-radius) * 1.2));
    shape-margin: 0.85rem;
  }

  .inline-quote.left {
    float: left;
    margin: 0 1.1rem 1.25rem -12vw;
  }

  .column.left .inline-quote {
    float: left;
    margin: 0 1.1rem 1.25rem -1.4rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .column.right .inline-quote {
    margin: 0 -1.4rem 1.25rem 1.1rem;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  .mobile-cta-container {
    clear: both;
    margin-top: 0;
  }

  .cta-box {
    margin: 0;
    padding: 0.85rem 1rem 1.1rem;
  }

  .article-layout {
    margin-bottom: 0;
  }

  .mobile-cta-container .mobile-cta-text {
    margin-bottom: 0.75rem;
  }
}

@media (max-width: 900px) and (orientation: landscape),
       (min-width: 481px) and (max-width: 900px) and (orientation: portrait),
       (max-height: 520px) and (orientation: landscape) {
  html body {
    font-size: calc(var(--body-font-size, 17px) * 0.85);
  }

  .newspaper {
    padding: 2.5rem 1.5rem 0.5rem;
    padding-inline: max(1.5rem, env(safe-area-inset-left)) max(1.5rem, env(safe-area-inset-right));
  }

  .article-layout {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 28vw) minmax(0, 1fr);
    gap: 1.75rem;
    margin-bottom: 2.25rem;
  }

  .cover-container {
    top: 1.5rem;
  }

  .cover-art {
    max-width: 220px;
  }

  .column > p {
    margin: 0 0 1.25rem;
  }

  .inline-quote {
    width: 55%;
    margin: 0 -1.35rem 1.1rem 1rem;
    padding: 1rem;
    font-size: 0.85rem;
  }

  .inline-quote.left, .column.left .inline-quote {
    margin: 0 1rem 1.1rem -1.35rem;
  }

  .column.right .inline-quote {
    margin: 0 -1.35rem 1.1rem 1rem;
  }

  h2.subheading {
    hyphens: auto;
    -webkit-hyphens: auto;
    font-size: 1.3rem;
    line-height: 1.3;
  }

  h1.opening {
    font-size: 1.5rem;
  }

  .cta-box, .sidebar-quote {
    margin: 1.5rem 0;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  html body {
    font-size: calc(var(--body-font-size, 17px) * 0.78);
  }

  .article-layout {
    gap: 1.35rem;
  }

  .inline-quote {
    font-size: 0.8rem;
    width: 50%;
  }

  h2.subheading {
    font-size: 1.2rem;
  }

  h1.opening {
    font-size: 1.35rem;
  }
}

@media (min-width: 1000px) {
  .newspaper {
    padding: 3rem 2rem 0.5rem;
    padding-inline: max(2rem, env(safe-area-inset-left)) max(2rem, env(safe-area-inset-right));
  }
}

/* Associated Books Section */
.associated-books-section {
  margin-top: 3rem;
  border-top: 3px double var(--color-primary);
  padding-top: 2rem;
}
.associated-books-section h2 {
  text-align: center;
}

.associated-books-intro {
  text-align: center;
  margin-bottom: 2rem;
  font-style: italic;
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.book-card {
  text-align: center;
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  position: relative;
}

.book-card:hover {
  box-shadow: 0 4px 15px var(--color-shadow);
}

.book-card a {
  text-decoration: none;
}

.book-cover {
  width: 140px;
  height: 210px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px var(--color-shadow);
}

.book-title {
  margin: 1rem 0 0.5rem;
}

.book-description {
  margin: 0;
  line-height: 1.4;
  font-style: italic;
}

/* Micro-interactions & accessibility */
.buy-button {
  transition: color var(--transition), background-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.buy-button:focus,
.buy-button:focus-visible,
a:focus,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}
.buy-button:hover { transform: translateY(-1px); }
.inline-quote:hover { box-shadow: 0 4px 18px var(--color-shadow); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.associated-books-section {
  background: rgba(0,0,0,0.75);
  background: hsl(from var(--color-bg) h 15% 14%);
  margin: 2rem 0 0;
  padding: 2rem 1rem;
  box-shadow: inset 0 16px 36px -12px rgba(0,0,0,0.65);
  font-family: 'Chivo', sans-serif;
  font-weight: 300;
  border: 0;
}
.associated-books-content {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  align-items: flex-start;
  justify-content: center;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}
.associated-books-copy {
  /* flex: 1 1 260px; */
  max-width: 360px;
}

.associated-books-section h2,
.associated-books-section .associated-books-intro {
  text-align: left;
  margin: 0;
  color: rgba(255,255,255,0.9);
}
.associated-books-section .associated-books-intro {
  margin-top: 0.75rem;
  opacity: 0.85;
  line-height: 1.5;
}

.associated-books-grid {
  display: flex;
  gap: 2.5rem;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 0;
}
.associated-books-grid a {
  text-align: center;
  color: rgba(255,255,255,0.9);
  flex: 1 1 140px;
  max-width: 150px;
}
.associated-books-grid a:hover {
  color: white;
}
.associated-books-grid a:hover {
  border: 0;
  text-decoration: underline;
}
.associated-books-grid img.book-cover {
  height: auto;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--border-radius);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}
.associated-books-grid .book-title {
  color: var(--color-paper);
}
.associated-books-grid .book-description {
  color: rgba(255,255,255,0.9);
  opacity: 0.8;
  text-transform: capitalize;
}

.site-footer {
  padding: 1.5rem 2rem;
  text-align: center;
  margin-top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-footer .footer-links {
  margin-bottom: 0;
}
.site-footer a {
  color: var(--color-primary);
  margin: 0 0.5rem;
  text-decoration: none;
  font-size: 0.85rem;
}
.site-footer a:hover {
  text-decoration: underline;
  border: 0;
}
.site-footer .footer-copy {
  font-size: 0.85rem;
}
.site-footer + p {
  font-size: 0.75rem;
  margin: -0.75rem 2rem 1rem;
  opacity: 50%;
}

@media (max-width: 768px) {
  .associated-books-content {
    flex-direction: column;
    align-items: center;
  }
  .associated-books-copy {
    max-width: 100%;
  }
  .associated-books-section h2,
  .associated-books-section .associated-books-intro {
    text-align: center;
  }
  .associated-books-grid {
    justify-content: center;
    margin-top: 0.75rem;
  }
  .associated-books-grid a:nth-of-type(3) {
    display: none;
  }
  .site-footer {
    flex-direction: column;
    align-items: unset;
    gap: 0.75rem;
    text-align: left;
  }
  .site-footer .footer-copy {
    align-items: left;
  }
  .site-footer .footer-links {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    /* justify-content: center; */
    gap: 0.35rem 1rem;
  }
  .site-footer a {
    margin: 0;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  .associated-books-content {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: space-between;
    padding-inline: clamp(0.75rem, 2vw, 1.25rem);
  }
  .associated-books-copy {
    flex: 0 0 clamp(240px, 28vw, 280px);
    max-width: 320px;
    padding-right: clamp(0.75rem, 2vw, 1.5rem);
  }
  .associated-books-section h2,
  .associated-books-section .associated-books-intro {
    text-align: left;
  }
  .associated-books-grid {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
    margin-left: auto;
    margin-top: 0;
    padding-left: clamp(0.75rem, 2vw, 1.5rem);
    gap: clamp(1rem, 3vw, 2.5rem);
  }
  .associated-books-grid a {
    flex: 0 0 clamp(110px, 18vw, 150px);
  }
}
