/* =============================================
   AAABooks – Stylesheet
   ============================================= */

@font-face {
  font-family: "Times Small Text MT Std";
  src: 
    url(../font/TimesSmallTextMTStdRegular.woff2) format("woff2"),
    url(../font/TimesSmallTextMTStdRegular.otf) format("opentype");
  font-weight: normal;
}

@font-face {
  font-family: "Times Small Text MT Std";
  src: 
    url(../font/TimesSmallTextMTStdBold.woff2) format("woff2"),
    url(../font/TimesSmallTextMTStdBold.otf) format("opentype");
  font-weight: bold;
}

@font-face {
  font-family: "Times Small Text MT Std";
  src:
    url(../font/TimesSmallTextMTStdItalic.woff2) format("woff2"), 
    url(../font/TimesSmallTextMTStdItalic.otf) format("opentype");
  font-style: italic;
}

/* --- Variables --- */


:root {
  --color-bg: #fff;
  --color-text: black;
  --color-gray: #e0e0e0;
  --color-surface: #f0f0f0;

  --font-size-base: 1.25rem;
  --line-height: 1.25;

  --margin-horizontal: 1.5rem;
  --margin-vertical: 1rem;

  --border: .09375rem solid var(--color-text);
  overscroll-behavior: none;
}

/* Dark mode: force a real black background (iOS Safari otherwise falls back
   to a dark gray canvas) and invert text/borders. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #000;
    --color-text: #fff;
    --color-surface: #1a1a1a;
  }
}

/* --- Reset & Base --- */

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

html {
  color-scheme: light dark;
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  hanging-punctuation: first allow-end last;
  scroll-behavior: smooth;
  font-size: calc(.2vw + 13px);
}

body {
  font-family: "Times Small Text MT Std", serif;
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

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

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  font: inherit;
}

/* --- Utilities --- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}



.site-main {
  flex: 1;
}

/* =============================================
   Header / Navigation
   ============================================= */
  
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--margin-vertical) var(--margin-horizontal);
}

body:not(.page--home) .site-header {
  position: absolute;
}

.site-nav {
  display: flex;
  flex-direction: column;
}

.site-nav__links {
  display: flex;
  gap: var(--margin-horizontal);
  align-items: center;
}

.site-nav__links a {
  font-style: normal;
}

.site-nav__links a:hover,
.footer-nav a:hover,
a.is-active:not(.site-nav__logo) {
  font-style: italic;
}

.cart-link {
  display: flex;
  align-items: center;
  gap: calc(var(--font-size-base) * 0.5); 
}

.cart-count {
  &:before {
    content: '(';
  }
  &:after {
    content: ')';
  }
}

/* =============================================
   Home – Scroll-Snap Stage
   ============================================= */

.page--home {
  /* background-color: var(--color-highlight); */
  color: var(--color-highlight);
}

.page--home .site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.page--home .site-main {
  padding-top: 0;
}

.home-stage {
  height: 100vh; /* fallback */
  height: 100svh; /* stable on iOS – ignores the collapsing toolbar */
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  margin-top: 0; /* header is fixed, overlaps */
}

.home-slide {
  scroll-snap-align: start;
  height: 100vh; /* fallback */
  height: 100svh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.home-slide__inner {
  color: var(--color-highlight);
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}

.home-slide__author {
  font-size: clamp(1.8rem, 5vw, 6.375rem);
  line-height: 1.09;
}

.home-slide__title {
  font-size: clamp(1.8rem, 5vw, 6.375rem);
  font-weight: normal;
  font-style: italic;
  line-height: 1.09;

}

/* =============================================
   Live Photo
   ============================================= */

.live-photo {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: pointer;
}

.live-photo__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.live-photo__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 1;
  transition: opacity .35s ease-in-out;
  pointer-events: none;
}

/* =============================================
   Catalog Grid
   ============================================= */

.site-main {
  padding-top: calc(var(--font-size-base) * var(--line-height) * 2 + var(--margin-vertical));
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(463px, 1fr));
  padding: var(--margin-vertical) var(--margin-horizontal);
  gap: var(--margin-horizontal);
  margin: 0 auto;
}

.catalog-item {
  flex: 0 1 calc(33.333% - var(--margin-horizontal));
  min-width: 220px;
}

.catalog-item__link {
  display: block;
  text-decoration: none;
  -webkit-touch-callout: none;
}

.catalog-item__cover {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--color-surface);
  margin-bottom: 0.75rem;
}

.catalog-item__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-item__cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--color-surface);
}

.catalog-item__info {
  display: flex;
  flex-direction: column;
  color: var(--color-highlight);
}

.catalog-item__title {
  font-style: italic;
  font-weight: normal;
  font-size: var(--font-size-base);
}

/* =============================================
   Publication
   ============================================= */

.publication {
  margin: 0 auto;
  padding: calc(var(--font-size-base) * var(--line-height)) var(--margin-horizontal);

}

.publication__header {
  display: flex;
  flex-direction: column;
  color: var(--color-text);
  margin-bottom: calc(var(--margin-vertical) * .5);
}

.publication__body {
  display: flex;
  flex-direction: column;
}

.publication__title {
  font-size: var(--font-size-base);
  font-weight: normal;
  font-style: italic;
  span {
    font-style: normal;
  }
}

.publication__purchase,
.publication__info_append {
  margin-top: var(--font-size-base);
}

.publication__info_append a {
  text-decoration: underline;
}

/* Desktop: note and Add to Cart each on their own line */
.publication__buy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Mobile: button flows inline right after the note text, wrapping with it */
@media (max-width: 600px) {
  .publication__buy {
    display: block;
  }
  .publication__buy .btn-add-to-cart {
    display: inline;
  }
  /* keep a space between the last word and the button */
  .publication__buy-note::after {
    content: " ";
  }
}

.btn-add-to-cart {
  all: unset;
  color: var(--color-highlight);
  cursor: pointer;
  line-height: 1;
  padding: .25rem 0;
  text-decoration: underline;
}

/*

.btn-add-to-cart:hover {
  background: var(--color-highlight);
  color: #fff;
}

.btn-add-to-cart.is-added {
  background: var(--color-highlight);
  color: #fff;
}

*/

.publication__body {
  display: flex;
  gap: calc(var(--font-size-base) * var(--line-height) * 1 - .25rem);
}

.publication__text {
  flex: 1;
  display: flex;
  gap: var(--margin-horizontal);

  a {
    color: var(--color-highlight);
  }
}

.publication__info {
  flex: 1 0 calc(33.3% - var(--margin-horizontal) / 2 - .25rem);
}

/* Galleries */

.publication__gallery--mood {
  aspect-ratio: 0.75;
}


.publication__gallery {
  width: 100%;
  .gallery-overlay {
    position: sticky;
    top: 0;
    right: 0;
    left: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    height: 0;
    .gallery-caption,
    .gallery-counter {
      line-height: 1;
      padding: 0 var(--margin-horizontal);
      color: white;
      padding-top: var(--margin-horizontal);
      margin-bottom: 5rem;
    }
  }
  
  .gallery-grid {
    position: relative;
    width: 100%;
    height: 100%;
    max-height: inherit;
    aspect-ratio: inherit;
    background-color: #000;
    figure {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: contain;
      img {
        width: 100%;
        height: 100%;
        object-fit: contain;
      }
    }
  }

  &.publication__gallery--book {
    position: relative;
    .gallery-overlay {
      position: absolute;
    }
  }

  &.publication__gallery--book .gallery-grid {
    /* Book: the grid owns its aspect-ratio (no parent aspect-ratio + percentage
       height chain, which left a stale intrinsic height cached on resize from
       the stacked mobile layout back up to desktop). */
    height: auto;
    aspect-ratio: 1.5;
    max-height: 95vh;
    figure {
      img {
        /* 25px min on mobile, scaling up with no cap */
        padding: max(1.5625rem, 4vw);
      }
    };
  }

  &.publication__gallery--mood .gallery-grid {
    figure {
      img {
        object-fit: cover;
      }
    };
  }
}

/* Captioned book gallery (editions): stays a slideshow on desktop — the
   per-image <figcaption> is only used for the stacked mobile view below, so
   hide it here; the desktop caption comes from the overlay (top-left). */
.publication__gallery--captioned .gallery-item__caption {
  display: none;
}

/* Related */

.publication__related h3 {
  font-size: var(--font-size-base);
  font-weight: normal;
  margin-bottom: calc(var(--margin-vertical) * .5);
}

.catalog-grid--related {
  padding: 0;
}

/* =============================================
   Newsletter
   ============================================= */

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  input[type="text"] {
    padding: .4rem 0 .25rem .75rem;
    border: var(--border);
    border-color: var(--color-gray);
    font-size: var(--font-size-base);
    font-family: inherit;
  }
  
  .choice-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    input {
      flex-shrink: 0;
    }
    label {
      padding-top: .25rem;
    }
  }

  input[type="checkbox"] {
    height: calc(var(--line-height) * var(--font-size-base));
    width: calc(var(--line-height) * var(--font-size-base));
  }
/*
  input[type="checkbox"] {
    -webkit-appearance: none;
    margin-right: 0.5rem;
    height: calc(var(--line-height) * var(--font-size-base) * 1.75);
    width: calc(var(--line-height) * var(--font-size-base) * 1.75);
    border: var(--border);
    border-color: var(--color-gray);
    border-radius: calc(var(--line-height) * var(--font-size-base) * 1.75);
  }
*/

  button[type="submit"] {
    padding: .4rem 0 .25rem 0;
    background: var(--color-gray);
    color: var(--color-highlight);
    border: none;
    font-size: var(--font-size-base);
    cursor: pointer;
    border-radius: var(--font-size-base);
    line-height: 1.4;
  }
}

/* =============================================
   Text Pages (About / Imprint)
   ============================================= */

.text-page {
  margin: 0 auto;
  padding: calc(var(--font-size-base) * var(--line-height)) var(--margin-horizontal);
  
  a {
    color: var(--color-highlight);
  }

  .text-content {
    width: 70%;
  }

  .highlight {
    color: var(--color-highlight);
  }
}


/* =============================================
   Cart
   ============================================= */

.cart {
  padding: calc(var(--font-size-base) * var(--line-height)) var(--margin-horizontal);
}

.cart__empty a {
  color: var(--color-highlight);
}

.cart-list {
  list-style: none;
  padding: 0;
  border-top: var(--border);
}

.cart-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: var(--border);
  gap: 1rem;
  font-size: var(--font-size-base);
}

/* Give the title all the room it needs (it may wrap); keep the qty control
   and price group at the right, non-shrinking and never breaking. */
.cart-item__title {
  flex: 0 1 auto;
  min-width: 0;
}

.cart-item__right {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  white-space: nowrap;
  min-width: 7.675rem;
}

.cart-shipping__selected-right {
  min-width: 7.675rem;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  padding: .75rem 0;
  border-bottom: var(--border);
}

.cart-total-row--grand {
  font-weight: normal;
}

.cart-shipping {
  padding: .75rem 0;
  border-bottom: var(--border);
}

.cart-shipping__toggle {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 100%;
  cursor: pointer;
  font-size: var(--font-size-base);
  color: var(--color-highlight);
}

.cart-shipping__toggle[hidden] {
  display: none;
}

/* State 2: prompt drops to normal text once the options are showing */
.cart-shipping__toggle[aria-expanded="true"] {
  color: var(--color-text);
}

.cart-shipping__menu {
  list-style: none;
  /* margin: .5rem 0 0; */
  padding: 0;
}

.cart-shipping__menu[hidden] {
  display: none;
}

.cart-shipping__option {
  display: flex;
  align-items: center;
  /* padding: .5rem 0; */
  cursor: pointer;
  color: var(--color-highlight);
}

/* State 3: chosen region + clear "×" + price */
.cart-shipping__selected {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: var(--font-size-base);
}

.cart-shipping__selected[hidden] {
  display: none;
}

/* Price + clear "×" grouped at the right, matching .cart-item__right so the
   amount lines up with the item prices and the "×" sits flush right. */
.cart-shipping__selected-right {
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  white-space: nowrap;
}

.cart-shipping__clear {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  color: var(--color-highlight);
  line-height: 1;
  width: 1rem;
}

.qty-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  flex: none;
}

.qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  background: none;
  font-size: var(--font-size-base);
  line-height: 1;
  cursor: pointer;
  border: none;
  color: var(--color-highlight);
}

.qty-value {
  min-width: 1.5rem;
  text-align: center;
  font-size: var(--font-size-base);
}

.btn-remove {
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem 0;
  width: 1rem;
  color: var(--color-highlight);
}

.cart-amount {
  padding-right: 1.75rem;
}

.cart-checkout {
  display: flex;
  justify-content: center;
  flex-direction: column;
  padding-top: 1.25rem;
}

.btn-checkout {
  padding: 0.75rem 2rem;
  background: #111;
  color: #fff;
  border: 1px solid #111;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#paypal-button-container {
  display: flex;
  justify-content: center;
  > .paypal-buttons {
    width: auto;;
  }
}

.btn-checkout:hover {
  background: #fff;
  color: #111;
}

.cart-message {
  font-style: italic;
}

.cart-message--success { color: #1a6b1a; }
.cart-message--error   { color: #9b1a1a; }
.cart-message--info    { color: var(--color-text) }
.cart-message--warn    { color: var(--color-text) }


.cart-item__price,
.cart-shipping__selected-price,
.cart-amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

/* =============================================
   Footer
   ============================================= */

.site-footer {
  padding: var(--margin-vertical) var(--margin-horizontal);
}

.footer-nav {
  display: flex;
  align-items: center;
  gap: 0 var(--margin-horizontal);
  flex-wrap: wrap;
}

/* =============================================
   Responsive
   ============================================= */

@media (max-width: 1200px) {
  .publication__text {
    flex-direction: column;
  }
}


@media (max-width: 600px) {
  html {
    font-size: calc(.5vw + 11px);
  }
  .publication__text {
    flex-direction: column;
    &:not(.edition__text) {
      font-size: calc(var(--font-size-base) * .85);
    }
  }

  .gallery-overlay {
    font-size: calc(var(--font-size-base) * .85);
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .publication__gallery--mood .gallery-grid {
    height: 100%;
    cursor: default;
  }

  .publication__gallery--mood .gallery-item,
  .publication__gallery--mood .gallery-item img {
    position: static;
    width: 100%;
    height: 100%;
  }

  .publication__gallery--mood .gallery-item img {
    object-fit: cover;
  }

  /* Mood gallery: caption at the bottom of the image on mobile */
  .publication__gallery.publication__gallery--mood {
    position: relative;
  }

  .publication__gallery.publication__gallery--mood .gallery-overlay {
    position: absolute;
    inset: 0;
    height: auto;
  }

  .publication__gallery.publication__gallery--mood .gallery-overlay .gallery-caption {
    position: absolute;
    left: 0;
    bottom: 0;
    top: auto;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 1.1rem;
    padding-left: 1.25rem;
    line-height: 1.25;
  }

  .publication__gallery.publication__gallery--mood .gallery-overlay .gallery-counter {
    position: absolute;
    top: 0;
    right: 0;
    padding-top: 1.4rem;
    padding-right: 1.25rem;
  }

  /* Book gallery: stack all images, no slideshow on mobile */
  .publication__gallery--book {
    max-height: none;
    aspect-ratio: auto;
  }

  .publication__gallery.publication__gallery--book .gallery-grid {
    position: static;
    height: auto;
    max-height: none;
    aspect-ratio: auto;
    cursor: default;
    background-color: transparent;
  }

  .publication__gallery.publication__gallery--book .gallery-grid .gallery-item {
    position: static;
    width: 100%;
    height: auto;
    opacity: 1 !important;
    margin-bottom: var(--margin-horizontal);
    background-color: #000;
  }

  .publication__gallery.publication__gallery--book .gallery-grid .gallery-item:last-of-type {
    margin-bottom: 0;
  } 

  .publication__gallery.publication__gallery--book .gallery-grid .gallery-item img {
    width: 100%;
    height: auto;
    padding: 1.5rem;
  }

  .publication__gallery--book .gallery-overlay {
    display: none;
  }

  .text-page .text-content {
    width: 100%;
  }

}

@media (prefers-color-scheme: dark) and (max-width: 600px) {
  .publication__gallery.publication__gallery--book .gallery-grid .gallery-item {
    margin-bottom: 0;
    &:first-child  img{
      padding-top: 0;
    }
  }

  .publication__gallery.publication__gallery--book .gallery-grid .gallery-item img {
    padding: 1.5rem 0;
    padding-bottom: .5rem;
  }
}

/* Edition book gallery on mobile: clean full-width stack (no black frame),
   caption rendered under each image. Placed last so it wins in both schemes. */
@media (max-width: 600px) {
  .publication__gallery.publication__gallery--captioned.publication__gallery--book .gallery-grid .gallery-item {
    background-color: transparent;
    /* margin-bottom: calc(var(--margin-vertical) * 2); */
  }

/*
  .publication__gallery.publication__gallery--captioned.publication__gallery--book .gallery-grid .gallery-item img {
    padding: 0;
  }
*/

  .publication__gallery.publication__gallery--captioned.publication__gallery--book .gallery-grid .gallery-item img {
    background-color: #000;
  }


  .publication__gallery--captioned .gallery-item__caption {
    display: block;
    padding-top: .5rem;
    color: var(--color-text);
  }
}