/* ==========================================================================
   Carrie La Seur — Static Site Stylesheet
   Replicates the original Nodebud Authors / Headway visual design while
   fixing the broken Author & Books dropdown menus, Divi columns, and forms.
   ========================================================================== */

@layer base, layout, components, utilities;

@layer base {
  html, body {
    margin: 0;
    padding: 0;
    border: 0;
  }

  body {
    background-color: #ffffff;
    background-image: url('/images/uploads/bg1-rev.jpg');
    background-repeat: no-repeat;
    background-position: center top;
    font-family: "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 1rem;
    line-height: 1.8;
    color: #000000;
  }

  :where(a:any-link, button, input, textarea):focus-visible {
    outline: 3px solid #1f4e5f;
    outline-offset: 3px;
  }
}

@layer layout {
  #whitewrap {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-image: url('/images/uploads/headway-imported-image1.jpg');
    background-repeat: no-repeat;
    background-position: center bottom;
  }

  .site-container {
    box-sizing: border-box;
    width: 100%;
    max-width: 1032px;
    margin: 30px auto 0 auto;
    padding: 15px 24px 0 24px;
  }

  .header-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 80px;
    margin-bottom: 10px;
  }

  .site-banner {
    text-align: center;
    margin-top: 20px;
  }

  .site-banner a {
    font-family: "Special Elite", cursive, serif;
    font-size: 3.375rem;
    line-height: 1;
    color: #000000;
    text-decoration: none;
    letter-spacing: 0;
  }

  .social-icons-container {
    position: absolute;
    right: 0;
    top: 0;
  }

  .social-icons {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .social-icons li {
    display: inline-block;
  }

  .social-icons a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 32px;
    min-block-size: 32px;
  }

  .social-icons img {
    width: 30px;
    height: auto;
    display: block;
    opacity: 0.85;
    transition: opacity 150ms ease;
  }

  .social-icons img:hover {
    opacity: 1;
  }

  .main-content-wrapper {
    box-sizing: border-box;
    width: 100%;
    max-width: 1032px;
    margin: 0 auto;
    padding: 10px 24px 180px 24px;
    flex: 1;
  }

  .home-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 36px;
    align-items: start;
    margin-top: 20px;
  }

  .book-feature-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 32px;
    align-items: start;
  }

  .anthologies-grid {
    display: grid;
    grid-template-columns: 230px 1fr 230px;
    gap: 28px;
    align-items: start;
    margin-top: 20px;
  }

  .site-footer {
    box-sizing: border-box;
    width: 100%;
    max-width: 1032px;
    margin: 0 auto;
    padding: 20px 24px 28px 24px;
    border-top: 1px solid #eeeeee;
    text-align: center;
  }

  @media (max-width: 820px) {
    .home-grid,
    .book-feature-grid,
    .anthologies-grid {
      grid-template-columns: 1fr;
    }
    .social-icons-container {
      position: static;
      margin-top: 10px;
    }
    .header-row {
      flex-direction: column;
      align-items: center;
    }
  }
}

@layer components {
  /* Responsive Site Navigation & Restored Popover Dropdowns */
  .site-nav {
    border-top: 0;
    border-bottom: 0;
    padding-left: 30px;
    margin-bottom: 24px;
    position: relative;
  }

  .menu-button {
    display: none;
    margin: 0 auto;
    padding: 8px 16px;
    min-block-size: 40px;
    font-family: "Arvo", serif;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: #000000;
    background-color: #f4f4f4;
    border: 1px solid #cccccc;
    border-radius: 3px;
    cursor: pointer;
    anchor-name: --menu-button;
  }

  .site-header:not(.is-wide) .menu-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .site-header:not(.is-wide) .site-nav {
    padding-left: 0;
    text-align: center;
  }

  .site-nav ul.site-menu {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .site-header.is-wide .site-nav ul.site-menu {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
  }

  .site-header:not(.is-wide) .site-nav ul.site-menu {
    display: none;
    margin: 8px auto 0 auto;
    padding: 8px 0;
    max-width: 320px;
    background-color: #f4f4f4;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    text-align: left;
  }

  .site-header:not(.is-wide) .site-nav ul.site-menu:is(:popover-open, .\:popover-open) {
    display: block;
  }

  .site-nav ul.site-menu > li {
    position: relative;
    display: inline-block;
  }

  .site-header:not(.is-wide) .site-nav ul.site-menu > li {
    display: block;
  }

  .site-nav ul.site-menu > li > a,
  .site-nav ul.site-menu > li > button.dropdown-trigger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    min-block-size: 40px;
    line-height: 40px;
    padding: 0 12px;
    margin: 0 8px;
    font-family: "Arvo", serif;
    font-size: 0.875rem;
    font-weight: 400;
    color: #000000;
    background: transparent;
    border: none;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }

  .site-nav ul.site-menu > li > a:hover,
  .site-nav ul.site-menu > li > button.dropdown-trigger:hover,
  .site-nav ul.site-menu > li:focus-within > a,
  .site-nav ul.site-menu > li:focus-within > button.dropdown-trigger {
    color: #555555;
  }

  /* Indicate current page with underline + weight rather than color alone (WCAG 1.4.1) */
  .site-nav [aria-current="page"],
  .site-nav button.dropdown-trigger[data-current-group="true"] {
    color: #222222;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 5px;
    text-decoration-thickness: 2px;
  }

  .site-nav button.dropdown-trigger::after {
    content: " ▾";
    font-size: 0.6875rem;
    color: #666666;
    margin-left: 4px;
  }

  /* Dropdown Sub-Menu (Popover API + CSS Anchor Positioning with fallback) */
  .site-nav ul.dropdown-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    min-width: 220px;
    background-color: #f4f4f4;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 200;
    display: none;
  }

  .site-nav ul.dropdown-list:is(:popover-open, .\:popover-open) {
    display: block;
  }

  @supports (position-area: block-end) {
    .site-header.is-wide .site-nav ul.dropdown-list {
      inset: auto;
      position-area: block-end span-inline-end;
      position-try-fallbacks: flip-inline;
      margin-top: 2px;
    }
  }

  @supports not (position-area: block-end) {
    .site-header.is-wide .site-nav ul.dropdown-list {
      position: fixed;
      inset: auto;
      margin: 0;
    }
  }

  .site-header:not(.is-wide) .site-nav ul.dropdown-list {
    position: static;
    border: none;
    box-shadow: none;
    padding-left: 16px;
  }

  .site-nav ul.dropdown-list li {
    display: block;
    width: 100%;
  }

  .site-nav ul.dropdown-list li a {
    box-sizing: border-box;
    display: block;
    min-block-size: 36px;
    padding: 8px 16px;
    font-family: "Arvo", serif;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #222222;
    text-decoration: none;
    text-transform: uppercase;
  }

  .site-nav ul.dropdown-list li a:hover,
  .site-nav ul.dropdown-list li a:focus-visible {
    background-color: #e6e6e6;
    color: #000000;
  }

  /* Homepage & Book Content — Heading 1 (h1) in page body maps to the 27px hero-quote style */
  .entry-content h1,
  .home-hero-quote {
    font-family: "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 1.6875rem;
    font-weight: normal;
    line-height: 1.75;
    color: #000000;
    text-align: left;
    margin: 0 0 18px 0;
    text-wrap: pretty;
  }

  .page-bio .entry-content > p:first-of-type img,
  .page-behind-the-book .entry-content > p:first-of-type img,
  .page-book-clubs .entry-content img {
    display: block;
    margin: 12px auto;
  }

  .page-behind-the-book .entry-content > p:nth-of-type(2) {
    color: #444444;
  }

  .page-news .entry-content {
    text-align: center;
  }

  .page-news .entry-content img {
    display: block;
    margin: 10px auto;
  }

  .page-media-kit .entry-content > p:first-of-type a {
    display: inline-block;
    margin-right: 10px;
    margin-bottom: 8px;
  }

  .page-media-kit .entry-content > p:first-of-type img {
    height: 259px;
    width: auto;
  }

  .page-montana .entry-content > p:first-of-type {
    margin: 0 18px 24px 18px;
    background-color: #e8e8e8;
    font-size: 1.25rem;
    padding: 20px;
    text-align: left;
    overflow: hidden;
  }

  .page-montana .entry-content > p:first-of-type img {
    float: left;
    margin: 4px 20px 12px 0;
    max-width: 305px;
  }

  .home-sidebar {
    text-align: center;
  }

  .home-sidebar .cover-img {
    max-width: 240px;
    height: auto;
    display: block;
    margin: 0 auto 14px auto;
  }

  .home-sidebar .order-btn img {
    max-width: 200px;
    height: auto;
  }

  .entry-header {
    margin-bottom: 18px;
  }

  .entry-title {
    font-family: "Palatino Linotype", Palatino, Georgia, serif;
    font-size: 1.5rem;
    font-weight: normal;
    color: #333333;
    line-height: 1.3;
    margin: 0 0 10px 0;
    text-wrap: balance;
  }

  .entry-content {
    color: #000000;
    font-size: 1rem;
    line-height: 1.8;
  }

  .entry-content p {
    margin: 0 0 16px 0;
    text-wrap: pretty;
  }

  .entry-content h2,
  .entry-content h3 {
    font-size: 1.25rem;
    line-height: 1.6;
    color: #222222;
    margin: 20px 0 12px 0;
    text-wrap: balance;
  }

  .entry-content a {
    color: #444444;
    text-decoration: underline;
  }

  .entry-content a:hover {
    color: #000000;
  }

  .entry-content address {
    margin: 0 0 20px 0;
    font-style: italic;
    color: #444444;
  }

  .entry-content ul,
  .entry-content ol {
    padding-left: 36px;
    margin: 15px 0;
  }

  .entry-content ul li {
    list-style: disc;
    margin-bottom: 10px;
  }

  .entry-content img {
    max-width: 100%;
    height: auto;
  }

  .book-feature-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .book-feature-sidebar img {
    display: block;
    max-width: 240px;
  }

  .retailer-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin: 28px 0;
    clear: both;
  }

  .retailer-badges img {
    max-height: 72px;
    width: auto;
    display: block;
  }

  .anthology-col-left,
  .anthology-col-right {
    text-align: center;
  }

  /* Montana Semantic CSS Grid Gallery (replaces layout <table>) */
  .entry-content ul.montana-gallery {
    list-style: none;
    padding: 0;
    margin: 24px 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px 16px;
  }

  .entry-content ul.montana-gallery > li {
    list-style: none;
    margin: 0;
    text-align: center;
    line-height: 1.5;
  }

  .entry-content ul.montana-gallery > li a {
    display: inline-block;
  }

  /* Contact Form (Replaces broken Contact Form 7 shortcode) */
  .contact-form {
    box-sizing: border-box;
    max-width: 540px;
    margin: 24px auto;
    padding: 24px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #e0e0e0;
    border-radius: 4px;
  }

  .contact-form .form-row {
    margin-bottom: 16px;
  }

  .contact-form label {
    display: block;
    font-family: "Arvo", serif;
    font-size: 0.875rem;
    color: #333333;
    margin-bottom: 6px;
  }

  .contact-form input[type="text"],
  .contact-form input[type="email"],
  .contact-form textarea {
    box-sizing: border-box;
    width: 100%;
    min-block-size: 48px;
    padding: 10px 12px;
    border: 1px solid #767676;
    border-radius: 3px;
    font: inherit;
    font-size: max(1rem, 1em);
    background-color: #ffffff;
    color: #000000;
  }

  .contact-form input:user-invalid,
  .contact-form textarea:user-invalid {
    border-color: #b91c1c;
    background-color: #fef2f2;
  }

  .contact-form button[type="submit"] {
    font-family: "Arvo", serif;
    font-size: 0.875rem;
    text-transform: uppercase;
    background-color: #222222;
    color: #ffffff;
    border: none;
    min-block-size: 48px;
    padding: 10px 24px;
    border-radius: 3px;
    cursor: pointer;
  }

  .contact-form button[type="submit"]:hover {
    background-color: #444444;
  }

  /* Footer */
  .site-footer p.copyright {
    font-family: "Special Elite", cursive, serif;
    font-size: 0.9375rem;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
    margin: 0;
  }

  .site-footer p.copyright a {
    color: #ffffff;
    text-decoration: underline;
  }
}

@layer utilities {
  .alignleft {
    float: left;
    margin: 4px 20px 12px 0;
  }

  .alignright {
    float: right;
    margin: 4px 0 12px 20px;
  }

  .aligncenter {
    display: block;
    margin: 12px auto;
    clear: both;
  }

  .visually-hidden:where(:not(:focus-within, :active)) {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  .skip-link:is(:focus-within, :active) {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 9999;
    padding: 10px 16px;
    background: #18222c;
    color: #ffffff;
    font-family: "Arvo", serif;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  }
}
