/* Just Books — structure.
 *
 * A handbill: no boxes, no rounded corners, no shadows. One heavy rule opens a
 * section, a light rule separates rows. Display faces are for titles, prices,
 * labels and buttons only; anything that is read stays in the body face.
 *
 * Rules target the slots listed in themes/README.md. This file is unlayered,
 * so it wins over the storefront's Tailwind utilities without !important.
 */

/* ---------- Page-wide ---------- */

/* Square everything, except shapes that are meant to be round. */
[data-theme='just-books'] *:not(.rounded-full) {
  border-radius: 0;
}

/* Drop shadows go, focus rings stay: Tailwind draws both with box-shadow, so
   only the drop-shadow part is cleared. */
[data-theme='just-books'] .shadow-sm,
[data-theme='just-books'] .shadow,
[data-theme='just-books'] .shadow-md,
[data-theme='just-books'] .shadow-lg,
[data-theme='just-books'] .shadow-xl,
[data-theme='just-books'] .shadow-2xl {
  --tw-shadow: 0 0 #0000;
}

/* The display faces each have a single weight. Asking for bold makes the
   browser smear a fake one, so headings and prices are set at their own weight. */
[data-theme='just-books'] .font-heading,
[data-theme='just-books'] .font-drama,
[data-theme='just-books'] .font-mono {
  font-weight: 400;
}

[data-theme='just-books'] ::selection {
  background: var(--jb-oxblood);
  color: var(--color-background);
}

/* ---------- Site frame ---------- */

[data-theme='just-books'] [data-slot='site-header'] {
  background: var(--color-background);
  border-bottom: 0.25rem solid var(--color-foreground);
  box-shadow: none;
  backdrop-filter: none;
}

[data-theme='just-books'] [data-slot='site-nav'] a,
[data-theme='just-books'] [data-slot='site-nav'] button {
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-theme='just-books'] [data-slot='site-footer'] {
  background: var(--color-foreground);
  color: var(--color-background);
  border-top: 0;
}

[data-theme='just-books'] [data-slot='site-footer'] * {
  color: inherit;
  border-color: currentColor;
}

[data-theme='just-books'] [data-slot='site-footer'] a:hover {
  text-decoration: underline;
}

[data-theme='just-books'] [data-slot='site-footer-title'] {
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme='just-books'] [data-slot='site-footer-copyright'] {
  font-family: var(--font-drama);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Headings ---------- */

[data-theme='just-books'] [data-slot='page-title'] {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2.25rem, 5vw, 4rem);
  line-height: 1;
  text-wrap: balance;
}

[data-theme='just-books'] [data-slot='hero-title'] {
  font-family: var(--font-drama);
  font-weight: 400;
  font-size: clamp(3rem, 10vw, 7.5rem);
  line-height: 0.92;
  letter-spacing: 0;
  text-transform: uppercase;
}

[data-theme='just-books'] [data-slot='hero-subtitle'] {
  font-family: var(--font-mono);
  color: var(--color-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(1rem, 2vw, 1.375rem);
}

/* Section heading with a single rule either side */
[data-theme='just-books'] [data-slot='section-title'] {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1;
}

[data-theme='just-books'] [data-slot='section-title']::before,
[data-theme='just-books'] [data-slot='section-title']::after {
  content: '';
  flex: 1;
  border-top: 0.1875rem solid var(--color-foreground);
}

/* ---------- Controls ---------- */

[data-theme='just-books'] [data-slot='button'] {
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme='just-books'] [data-slot='button'][data-variant='outline'] {
  background: transparent;
  border: 0.125rem solid var(--color-foreground);
  color: var(--color-foreground);
}

[data-theme='just-books'] [data-slot='button'][data-variant='outline']:hover {
  background: var(--color-foreground);
  color: var(--color-background);
}

/* Text links styled as buttons keep the reading face */
[data-theme='just-books'] [data-slot='button'][data-variant='link'] {
  font-family: var(--font-sans);
  text-transform: none;
  letter-spacing: 0;
}

[data-theme='just-books'] [data-slot='input'],
[data-theme='just-books'] select,
[data-theme='just-books'] textarea,
[data-theme='just-books'] [role='combobox'] {
  background: transparent;
  border: 0.125rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='input']::placeholder,
[data-theme='just-books'] textarea::placeholder {
  color: var(--color-muted-foreground);
}

/* Labels: condensed caps. Shelf and subject tags are plain text, not pills. */
[data-theme='just-books'] [data-slot='badge'] {
  font-family: var(--font-drama);
  font-weight: 400;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 0;
  /* badges carry `rounded-full`, which the page-wide rule above leaves alone */
  border-radius: 0;
}

[data-theme='just-books'] [data-slot='badge'][data-variant='secondary'],
[data-theme='just-books'] [data-slot='badge'][data-variant='outline'] {
  background: transparent;
  color: var(--color-foreground);
  padding-inline: 0;
  font-size: 0.9375rem;
}

/* Oxblood is kept for "look here": stock warnings and errors */
[data-theme='just-books'] [data-slot='badge'][data-variant='warning'],
[data-theme='just-books'] [data-slot='badge'][data-variant='destructive'] {
  background: var(--jb-oxblood);
  color: var(--color-background);
}

[data-theme='just-books'] [data-slot='badge'][data-variant='success'],
[data-theme='just-books'] [data-slot='badge'][data-variant='default'] {
  background: var(--color-foreground);
  color: var(--color-background);
}

/* ---------- Panels ---------- */

/* No boxes. A panel is its content, ruled off above where it opens a section. */
[data-theme='just-books'] [data-slot='card'],
[data-theme='just-books'] [data-slot='book-card'],
[data-theme='just-books'] [data-slot='book-buy'],
[data-theme='just-books'] [data-slot='book-details'] {
  background: transparent;
  border: 0;
  box-shadow: none;
}

[data-theme='just-books'] [data-slot='card'] {
  border-top: 0.1875rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='card-header'],
[data-theme='just-books'] [data-slot='card-content'],
[data-theme='just-books'] [data-slot='card-footer'] {
  padding-inline: 0;
}

[data-theme='just-books'] [data-slot='card-title'] {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Books ---------- */

/* The card clips its contents for rounded corners in other themes. Here that
   only shaves the side borders off a full-width button. */
[data-theme='just-books'] [data-slot='book-card'] {
  overflow: visible;
}

/* Two cards across on a phone leaves about 160px: tighten the button so the
   slab caps fit inside the card. */
[data-theme='just-books'] [data-slot='book-card'] [data-slot='button'] {
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  padding-inline: 0.5rem;
  gap: 0.375rem;
}

/* The card lifts on hover in other themes; a pasted-on cover does not move. */
[data-theme='just-books'] [data-slot='book-card']:hover {
  transform: none;
  box-shadow: none;
}

/* ...and the cover does not zoom inside its frame */
[data-theme='just-books'] [data-slot='book-cover'] img {
  transform: none;
}

[data-theme='just-books'] [data-slot='book-cover'] {
  border: 0.125rem solid var(--color-foreground);
  background: var(--color-muted);
}

[data-theme='just-books'] [data-slot='book-cover'][data-size='large'] {
  border-width: 0.1875rem;
}

[data-theme='just-books'] [data-slot='book-title'] {
  font-family: var(--font-drama);
  font-weight: 400;
  font-size: 1.1875rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

[data-theme='just-books'] [data-slot='book-author'] {
  color: var(--color-foreground);
  font-style: italic;
}

/* Blurbs belong on the book page, not in the grid */
[data-theme='just-books'] [data-slot='book-card'] [data-slot='book-synopsis'] {
  display: none;
}

[data-theme='just-books'] [data-slot='book-synopsis'] {
  color: var(--color-foreground);
  font-size: 1.0625rem;
  line-height: 1.62;
}

[data-theme='just-books'] [data-slot='book-price'] {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.625rem;
  line-height: 1;
  color: var(--color-foreground);
}

/* Book page: price and buy button under one heavy rule, details as a ledger */
[data-theme='just-books'] [data-slot='book-buy'] {
  border-top: 0.25rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='book-buy'] [data-slot='book-price'] {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
}

[data-theme='just-books'] [data-slot='book-details'] {
  border-top: 0.1875rem solid var(--color-foreground);
}

/* Price, stock and the button share one line; the button drops below on a phone */
[data-theme='just-books'] [data-slot='book-buy'] [data-slot='card-content'] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2rem;
}

[data-theme='just-books'] [data-slot='book-stock'] {
  order: 2;
  margin-top: 0;
  text-align: left;
  font-family: var(--font-drama);
  font-size: 1.0625rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-foreground);
}

[data-theme='just-books'] [data-slot='book-buy-action'] {
  order: 3;
  margin-top: 0;
  margin-left: auto;
}

[data-theme='just-books'] [data-slot='book-buy-action']:empty {
  display: none;
}

[data-theme='just-books'] [data-slot='book-buy-action'] :is([data-slot='button'], a) {
  width: auto;
  padding-inline: 2rem;
}

@media (max-width: 40rem) {
  [data-theme='just-books'] [data-slot='book-buy-action'] {
    flex-basis: 100%;
  }

  [data-theme='just-books'] [data-slot='book-buy-action'] :is([data-slot='button'], a) {
    width: 100%;
  }
}

/* On the book page the author is set like a bill's second line */
[data-theme='just-books'] [data-slot='page-title'] + [data-slot='book-author'] {
  font-family: var(--font-drama);
  font-style: normal;
  font-size: 1.75rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Blurb on the left, the ledger in a narrow column on the right */
[data-theme='just-books'] [data-slot='book-lower'] {
  margin-top: 2.5rem;
  column-gap: 4rem;
}

/* ---------- References ---------- */

/* Order numbers and payment references are read out and copied, so they stay
   in a true fixed-width face; the theme's "mono" slot is a slab for prices. */
[data-theme='just-books'] [data-slot='reference'] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- Shop: shelves ---------- */

/* The count of books is the page's second headline */
[data-theme='just-books'] [data-slot='page-lede'] {
  font-family: var(--font-drama);
  font-size: 1.25rem;
  color: var(--color-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme='just-books'] [data-slot='shelf-list-title'] {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 1.125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: 0.25rem solid var(--color-foreground);
  padding-top: 0.75rem;
}

/* A bill of fare: shelf name, dotted leader, count */
[data-theme='just-books'] [data-slot='shelf-link'] {
  font-family: var(--font-drama);
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--color-foreground);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  gap: 0.5rem;
}

[data-theme='just-books'] [data-slot='shelf-name'] {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  /* A name that is one long word ("Unions/Organising/Resources") breaks
     where it must, so it does not run under the count */
  overflow-wrap: anywhere;
}

[data-theme='just-books'] [data-slot='shelf-name']::after {
  content: '';
  flex: 1;
  min-width: 1rem;
  border-bottom: 0.1875rem dotted var(--color-foreground);
  transform: translateY(-0.25em);
}

[data-theme='just-books'] [data-slot='shelf-link']:hover {
  color: var(--jb-oxblood);
}

/* The shelf being viewed is marked by its name alone, set solid */
[data-theme='just-books'] [data-slot='shelf-link'][data-active='true'] {
  text-decoration: underline;
  text-decoration-thickness: 0.1875rem;
  text-underline-offset: 0.2em;
}

[data-theme='just-books'] [data-slot='shelf-picker'] {
  border: 0.125rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='shelf-picker'] summary {
  font-family: var(--font-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Book page: tags and the ledger ---------- */

/* Shelves and subjects read as a line above the title */
[data-theme='just-books'] [data-slot='book-tags'] {
  order: -1;
  margin-bottom: 0.5rem;
  column-gap: 0.5rem;
}

[data-theme='just-books']
  [data-slot='book-tags']
  [data-variant='secondary']
  + [data-variant='secondary']::before {
  content: '\00b7';
  margin-right: 0.5rem;
}

/* Details as a ledger: label, dotted leader, value */
[data-theme='just-books'] [data-slot='detail-row'] {
  align-items: baseline;
  gap: 0.5rem;
}

[data-theme='just-books'] [data-slot='detail-label'] {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--color-foreground);
  font-weight: 600;
  white-space: nowrap;
}

[data-theme='just-books'] [data-slot='detail-label']::after {
  content: '';
  flex: 1;
  min-width: 1rem;
  border-bottom: 0.125rem dotted var(--color-foreground);
  transform: translateY(-0.25em);
}

/* ---------- Events: each one is a bill ---------- */

[data-theme='just-books'] [data-slot='event-grid'] {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
}

/* Oxblood stock, buff ink, centred like a meeting notice */
[data-theme='just-books'] [data-slot='event-card'] {
  background: var(--jb-oxblood);
  color: var(--color-background);
  border: 0;
  padding: 0.75rem 1.5rem 1rem;
  text-align: center;
}

[data-theme='just-books'] [data-slot='event-card']:hover {
  transform: none;
  box-shadow: none;
}

[data-theme='just-books'] [data-slot='event-card'] * {
  color: inherit;
}

[data-theme='just-books'] [data-slot='event-card'] [data-slot='card-header'] > div {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* The kind of event is the bill's headline: PUBLIC MEETING, READING, ... */
[data-theme='just-books'] [data-slot='event-type'] {
  font-family: var(--font-drama);
  font-weight: 400;
  font-size: clamp(2.25rem, 6vw, 3.75rem);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

/* "Upcoming" goes without saying; any other status is stamped on */
[data-theme='just-books'] [data-slot='event-status'] {
  order: -1;
  font-family: var(--font-drama);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: transparent;
  border: 0.125rem solid currentColor;
  border-radius: 0;
}

[data-theme='just-books']
  [data-slot='event-card'][data-status='UPCOMING']
  [data-slot='event-status'] {
  display: none;
}

[data-theme='just-books'] [data-slot='event-title'] {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.1;
  text-wrap: balance;
}

[data-theme='just-books'] [data-slot='event-facts'] {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme='just-books'] [data-slot='event-facts'] > div {
  justify-content: center;
}

[data-theme='just-books'] [data-slot='event-facts'] svg {
  display: none;
}

[data-theme='just-books'] [data-slot='event-card'] [data-slot='button'] {
  background: var(--color-background);
  color: var(--jb-oxblood);
  border: 0;
}

[data-theme='just-books'] [data-slot='event-card'] [data-slot='badge'] {
  background: var(--color-foreground);
  color: var(--color-background);
}

/* Over: black stock. Called off: struck through on plain board. */
[data-theme='just-books'] [data-slot='event-card'][data-status='COMPLETED'] {
  background: var(--color-foreground);
}

[data-theme='just-books'] [data-slot='event-card'][data-status='COMPLETED'] [data-slot='button'] {
  color: var(--color-foreground);
}

[data-theme='just-books'] [data-slot='event-card'][data-status='CANCELLED'] {
  background: transparent;
  color: var(--color-foreground);
  border: 0.1875rem solid var(--color-foreground);
}

[data-theme='just-books']
  [data-slot='event-card'][data-status='CANCELLED']
  [data-slot='event-title'] {
  text-decoration: line-through;
}

[data-theme='just-books'] [data-slot='event-card'][data-status='CANCELLED'] [data-slot='button'] {
  background: var(--color-foreground);
  color: var(--color-background);
}

/* ---------- Empty lists ---------- */

[data-theme='just-books'] [data-slot='empty-state-title'] {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3.4vw, 2.5rem);
  line-height: 1.1;
  color: var(--color-foreground);
  text-wrap: balance;
}

/* ---------- Home: the roundel and the motto ---------- */

/* The motto is set like a handbill: each sentence on its own line, in its own
   face, sized to fill the measure. HeroTitle does the sizing when it sees
   --fit-lines; until it runs, the lines sit at the heading's own size. */
[data-theme='just-books'] [data-slot='hero'] {
  padding-block: 2rem;
}

[data-theme='just-books'] [data-slot='hero'] > div > div {
  align-items: stretch;
  text-align: left;
}

[data-theme='just-books'] [data-slot='hero-icon'] {
  display: none;
}

[data-theme='just-books'] [data-slot='hero-title'] {
  --fit-lines: 1;
  /* Before the lines are fitted a long one can be wider than the column */
  overflow-x: clip;
}

[data-theme='just-books'] [data-slot='hero-title-line'] {
  display: block;
  width: max-content;
  white-space: nowrap;
  line-height: 0.95;
}

[data-theme='just-books'] [data-slot='hero-title-line']:nth-child(3n + 2) {
  font-family: var(--font-mono);
  line-height: 1.1;
}

[data-theme='just-books'] [data-slot='hero-title-line']:nth-child(3n) {
  font-family: var(--font-heading);
  line-height: 1;
}

[data-theme='just-books'] [data-slot='hero-actions'] {
  border-top: 0.25rem solid var(--color-foreground);
  padding-top: 1.25rem;
}

/* Stacked on a narrow screen, the image sits close above the motto */
[data-theme='just-books'] main > [data-slot='media-block']:first-child:has(+ [data-slot='hero']) {
  padding-bottom: 0;
}

/* When the page opens with an image block followed by a hero (the roundel,
   then the motto), wide screens set the two side by side. Any other order of
   blocks leaves them stacked. Later blocks keep the full width. */
@media (min-width: 60rem) {
  [data-theme='just-books'] main:has(> [data-slot='media-block']:first-child + [data-slot='hero']) {
    display: grid;
    grid-template-columns:
      minmax(1rem, 1fr) minmax(0, 32rem) minmax(0, 46rem)
      minmax(1rem, 1fr);
    align-items: center;
    align-content: start;
  }

  [data-theme='just-books']
    main:has(> [data-slot='media-block']:first-child + [data-slot='hero'])
    > * {
    grid-column: 1 / -1;
  }

  [data-theme='just-books'] main > [data-slot='media-block']:first-child:has(+ [data-slot='hero']) {
    grid-column: 2;
    padding-block: 2rem;
  }

  [data-theme='just-books'] main > [data-slot='media-block']:first-child + [data-slot='hero'] {
    grid-column: 3;
  }
}

/* ---------- Basket and checkout ---------- */

/* The quietest pages. The one solid block is the summary with the pay button. */
[data-theme='just-books'] [data-slot='cart-item'] {
  border-bottom: 0.125rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='order-summary'] {
  background: var(--color-foreground);
  color: var(--color-background);
  border: 0;
  padding-inline: 1.5rem;
  /* The page's ink, kept for the button below once the tokens are turned round */
  --jb-summary-ink: var(--color-foreground);
}

/* Inside the block the colour tokens are turned round, so text, quieter text,
   rules and tinted panels all stay readable on the dark ground. The error red
   is lightened, because oxblood on black cannot be read. Set on the children,
   not the block, so the block's own ground still reads the page's ink. */
[data-theme='just-books'] [data-slot='order-summary'] > * {
  --color-foreground: var(--color-background);
  --color-card-foreground: var(--color-background);
  --color-muted-foreground: color-mix(in srgb, var(--color-background) 80%, transparent);
  --color-muted: color-mix(in srgb, var(--color-background) 14%, transparent);
  --color-border: color-mix(in srgb, var(--color-background) 50%, transparent);
  --color-destructive: hsl(358 75% 68%);
}

[data-theme='just-books'] [data-slot='order-summary'] [data-slot='button'] {
  background: var(--color-background);
  color: var(--jb-summary-ink);
  border: 0;
}

[data-theme='just-books'] [data-slot='order-summary'] [data-slot='button']:hover {
  background: color-mix(in srgb, var(--color-background) 85%, transparent);
}

/* ---------- News ---------- */

[data-theme='just-books'] [data-slot='post-card'] {
  background: transparent;
  border: 0;
  border-top: 0.1875rem solid var(--color-foreground);
}

[data-theme='just-books'] [data-slot='post-card'] [data-slot='card-content'] {
  padding-inline: 0;
}

[data-theme='just-books'] [data-slot='post-date'] {
  font-family: var(--font-drama);
  color: var(--color-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme='just-books'] [data-slot='post-title'] {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.625rem;
  line-height: 1.1;
}
