/* ==========================================================================
   Brian Wilson — author site
   1. Tokens         4. Hero          7. Bio
   2. Base           5. Buttons       8. Contact + footer
   3. Header / nav   6. Catalogue     9. Responsive
   ========================================================================== */

/* 1. Tokens ------------------------------------------------------------- */

:root {
  --ink: #173448;
  --ink-deep: #102a3a;
  --muted: #52636d;
  --paper: #fbfaf6;
  --line: #d8dfdf;
  --gold: #d9b16e;
  --white: #fff;
  --shadow: 0 12px 30px rgba(19, 43, 55, .13);
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', Arial, Helvetica, sans-serif;

  /* Set at build time from data/site.json */
  --hero-image: url('assets/images/hero/lake-and-mountains.webp');

  /* Hero darkening. Lower values show more of the photo. The left side carries
     the headline, so --hero-tint-left is the one that affects legibility most:
     much below .5 and white text starts to struggle against the sky and lake. */
  --hero-tint: 10, 34, 48;
  --hero-tint-left: .60;
  --hero-tint-right: .12;
  --hero-tint-bottom: .20;
  --hero-shade: .22;
}

/* 2. Base --------------------------------------------------------------- */

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-deep);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; }

h2, h3, h4 {
  font-family: var(--serif);
  line-height: 1.2;
}

h2 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin: 0;
  letter-spacing: -.025em;
}

h3 { font-size: 1.45rem; margin: 0; }

.wrap {
  width: min(1160px, calc(100% - 48px));
  margin-inline: auto;
}

.section { padding-block: 72px; }

.section-heading {
  display: grid;
  grid-template-columns: minmax(190px, .55fr) 1fr;
  align-items: end;
  gap: 36px;
  margin-bottom: 36px;
}

.section-intro {
  color: var(--muted);
  max-width: 510px;
  margin: 0 0 4px;
  font-size: 1.02rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: #e8c88f;
}

.eyebrow.dark-eyebrow {
  color: #9a7135;
  margin-bottom: 5px;
}

.note {
  font-size: .83rem;
  color: #5d6b70;
  background: #f2efe7;
  border-left: 3px solid var(--gold);
  padding: 13px 16px;
  margin: 28px 0 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--white);
  padding: 10px;
  z-index: 100;
}

.skip-link:focus { left: 8px; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* 3. Header / navigation ------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(251, 250, 246, .94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(23, 52, 72, .1);
}

.nav-wrap {
  width: min(1160px, calc(100% - 48px));
  height: 72px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 34px;
}

.site-nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: .93rem;
  padding: 23px 0 20px;
  border-bottom: 3px solid transparent;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current='page'] { border-color: var(--gold); }

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

/* 4. Hero --------------------------------------------------------------- */

.hero {
  position: relative;
  min-height: 510px;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--white);
  background:
    linear-gradient(90deg,
      rgba(var(--hero-tint), var(--hero-tint-left)),
      rgba(var(--hero-tint), var(--hero-tint-right))),
    linear-gradient(0deg,
      rgba(var(--hero-tint), var(--hero-tint-bottom)), transparent 60%),
    var(--hero-image) center 54% / cover no-repeat,
    var(--ink-deep);
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(8, 29, 42, var(--hero-shade)), transparent 78%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  padding-block: 84px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(3.3rem, 7vw, 5.7rem);
  line-height: 1.03;
  letter-spacing: -.04em;
  margin: 0 0 10px;
  max-width: 760px;
}

.hero-subtitle {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  margin: 0 0 18px;
}

.hero-copy {
  max-width: 420px;
  font-size: 1.08rem;
  margin: 0 0 26px;
  color: rgba(255, 255, 255, .92);
}

.hero-caption {
  position: absolute;
  right: max(24px, calc((100vw - 1160px) / 2));
  bottom: 24px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .7rem;
  color: rgba(255, 255, 255, .8);
}

/* 5. Buttons ------------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 11px 17px;
  background: var(--ink);
  color: var(--white);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 600;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.button:hover {
  background: #244e65;
  border-color: #244e65;
  transform: translateY(-1px);
}

.button-light {
  background: var(--white);
  color: var(--ink);
  border-color: var(--white);
}

.button-light:hover {
  background: #f0e8da;
  color: var(--ink);
  border-color: #f0e8da;
}

.button-small { font-size: .77rem; padding: 8px 11px; }

.button-outline {
  background: transparent;
  color: var(--ink);
  border-color: #aab9be;
}

.button-outline:hover {
  background: #eef2f1;
  color: var(--ink);
  border-color: #aab9be;
}

/* 6. Book catalogue ----------------------------------------------------- */

.catalogue-status { color: var(--muted); }

.catalogue-error {
  background: #f2efe7;
  border-left: 3px solid var(--gold);
  padding: 13px 16px;
}

.book-category { margin-top: 32px; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
  gap: 24px;
  margin-top: 17px;
}

.book-card {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 14px;
  background: rgba(255, 255, 255, .65);
  border: 1px solid #e9e7df;
  border-radius: 8px;
  transition: box-shadow .2s ease, transform .2s ease;
}

.book-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: #e7e5de;
  box-shadow: 0 5px 12px rgba(16, 42, 58, .17);
}

/* Real cover art */
.cover-image img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Designed stand-in, used until real cover art is available */
.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 19px 9px 12px;
  color: var(--white);
  background: linear-gradient(155deg, #16364c 0%, #527f94 48%, #e7a75c 49%, #172d3b 100%);
}

.cover-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 24, 38, .05), rgba(5, 24, 38, .18) 48%, rgba(5, 24, 38, .82));
  z-index: 0;
}

.cover-title,
.cover-author {
  position: relative;
  z-index: 1;
}

.cover-title {
  font-family: var(--serif);
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(.76rem, 1.2vw, 1.02rem);
  line-height: 1.25;
  text-shadow: 0 2px 5px rgba(0, 0, 0, .4);
}

.cover-author {
  font-size: .48rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.book-info {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  align-items: flex-start;
}

.book-info h4 {
  font-size: 1.17rem;
  margin: 2px 0 4px;
}

.book-subtitle {
  font-family: var(--serif);
  font-style: italic;
  color: #6b7b84;
  font-size: .92rem;
  margin: 0 0 8px;
}

.book-info p {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.55;
  margin: 0 0 17px;
}

/* Co-author, illustrator and contributor credits */
.book-byline {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: #6b7b84;
  margin: 0 0 9px;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* 7. Bio ---------------------------------------------------------------- */

.bio-section {
  background: linear-gradient(105deg, #e6eef0 0%, #dce7e9 63%, #b9cbd0 100%);
  position: relative;
  overflow: hidden;
}

.bio-section::after {
  content: "";
  position: absolute;
  right: -4%;
  bottom: -46%;
  width: 52%;
  height: 125%;
  opacity: .22;
  background:
    linear-gradient(145deg, transparent 0 28%, #fff 28% 31%, transparent 31%),
    linear-gradient(35deg, transparent 0 40%, #647e8a 40% 48%, transparent 48%);
  clip-path: polygon(0 100%, 18% 40%, 30% 62%, 53% 0, 72% 47%, 87% 24%, 100% 100%);
  pointer-events: none;
}

.bio-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: .55fr 1.45fr;
  gap: 40px;
  padding-block: 64px;
}

/* The source photo is only 212px wide, so it is never displayed larger than that. */
.bio-portrait {
  margin-top: 20px;
  max-width: 212px;
}

.bio-portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.bio-copy { max-width: 760px; }

.bio-copy p {
  margin: 0 0 16px;
  color: #334c59;
}

.bio-details {
  display: flex;
  gap: 50px;
  flex-wrap: wrap;
  margin-top: 23px;
}

.bio-details p { font-size: .88rem; }

/* 8. Contact + footer --------------------------------------------------- */

.contact-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.contact-section p:not(.eyebrow) {
  color: var(--muted);
  margin: 12px 0 0;
}

.site-footer {
  background: var(--ink-deep);
  color: var(--white);
  padding: 30px 0;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  align-items: center;
  gap: 24px;
}

.footer-inner h2 { font-size: 1.5rem; }
.footer-inner .eyebrow { margin-bottom: 4px; }

.social-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.social-links > span {
  font-size: .88rem;
  color: #d0dce0;
  margin-right: 8px;
}

.social-links a {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-decoration: none;
  border: 1px solid #526c7a;
  color: var(--white);
  font-weight: 700;
  transition: background .18s ease;
}

.social-links a:hover { background: #31566b; }

.copyright {
  font-size: .75rem;
  color: #b8c7cd;
  text-align: right;
  margin: 0;
}

/* When the footer has no social links, keep the two remaining columns balanced. */
.social-links[hidden] { display: none; }
.footer-inner:has(.social-links[hidden]) { grid-template-columns: 1fr 1fr; }

/* 9. Responsive --------------------------------------------------------- */

@media (min-width: 761px) and (max-width: 1050px) {
  .book-card {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 14px;
    padding: 12px;
  }
  .book-info h4 { font-size: 1.05rem; }
  .book-info p { font-size: .84rem; }
}

@media (max-width: 760px) {
  .wrap,
  .nav-wrap { width: min(100% - 32px, 600px); }

  .nav-wrap { height: 64px; }
  .menu-toggle { display: block; }

  .site-nav {
    display: none;
    position: absolute;
    top: 63px;
    left: 0;
    right: 0;
    padding: 12px 24px 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .site-nav.open { display: flex; }

  .site-nav a {
    padding: 12px 0;
    border-bottom: 1px solid #e6e8e4;
  }

  .site-nav a[aria-current='page'] { border-bottom-color: var(--gold); }

  .hero {
    min-height: 460px;
    background-position: 57% center;
  }
  .hero-content { padding-block: 70px; }
  .hero h1 { font-size: clamp(3rem, 12vw, 4.5rem); }
  .hero-caption { display: none; }

  .section { padding-block: 50px; }
  .section-heading { grid-template-columns: 1fr; gap: 10px; margin-bottom: 28px; }

  .book-grid { grid-template-columns: 1fr; gap: 14px; }
  .book-card { grid-template-columns: 118px minmax(0, 1fr); gap: 15px; padding: 11px; }
  .book-info h4 { font-size: 1.08rem; }
  .book-info p { font-size: .84rem; margin-bottom: 14px; }
  .cover-placeholder { padding: 15px 7px 10px; }
  .cover-title { font-size: .82rem; }

  .bio-inner { grid-template-columns: 1fr; gap: 18px; padding-block: 48px; }
  .bio-section::after { width: 75%; opacity: .12; }
  .bio-details { gap: 16px; flex-direction: column; }
  .bio-details p { margin-bottom: 0; }

  .contact-section { align-items: flex-start; flex-direction: column; }

  .footer-inner,
  .footer-inner:has(.social-links[hidden]) { grid-template-columns: 1fr; gap: 22px; }
  .copyright { text-align: left; }
  .social-links { gap: 10px; }
}

@media (max-width: 480px) {
  .wrap,
  .nav-wrap { width: calc(100% - 28px); }

  .hero { min-height: 420px; }
  .hero-content { padding-block: 56px; }
  .hero-copy { font-size: 1rem; }

  .book-card { grid-template-columns: minmax(88px, 34%) minmax(0, 1fr); gap: 12px; padding: 10px; }
  .book-info h4 { font-size: 1rem; }
  .book-info p { font-size: .82rem; }
  .book-actions { gap: 6px; }
  .button-small { padding: 7px 9px; font-size: .72rem; }
  .cover-placeholder { padding: 12px 5px 9px; }
  .cover-title { font-size: .76rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* 10. 404 ---------------------------------------------------------------- */

.notfound {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.notfound h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  letter-spacing: -.03em;
  margin: 0 0 14px;
}

.notfound .section-intro { margin-bottom: 26px; }
