/*
Theme Name: The Impossible Bookshop
Theme URI: https://theimpossiblebookshop.co.uk
Author: SJMW
Description: Custom WooCommerce theme for The Impossible Bookshop — secondhand books, CDs & DVDs. Built from the Claude Design mockups (Landing, Search Results, Item Page).
Version: 1.0.2
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: theimpossiblebookshop
Tags: e-commerce, dark, custom-logo
WC requires at least: 8.0
*/

/* ============ Fonts (bundled, latin + latin-ext subsets) ============ */
@font-face { font-family: 'Anton'; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/Anton-400-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Anton'; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/Anton-400-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/SpaceGrotesk-400-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/SpaceGrotesk-400-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("assets/fonts/SpaceGrotesk-500-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url("assets/fonts/SpaceGrotesk-500-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/SpaceGrotesk-600-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/SpaceGrotesk-600-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/SpaceGrotesk-700-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/SpaceGrotesk-700-latin-ext.woff2") format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ============ Design tokens ============ */
:root {
  --ib-bg: oklch(0.16 0.01 260);
  --ib-surface: oklch(0.22 0.015 260);
  --ib-border: oklch(0.3 0.02 260);
  --ib-border-mid: oklch(0.4 0.02 260);
  --ib-text: oklch(0.96 0.01 90);
  --ib-text-soft: oklch(0.85 0.01 90);
  --ib-text-nav: oklch(0.9 0.01 90);
  --ib-dim: oklch(0.75 0.02 260);
  --ib-dimmer: oklch(0.65 0.02 260);
  --ib-faint: oklch(0.6 0.02 260);
  --ib-yellow: oklch(0.78 0.15 90);
  --ib-cyan: oklch(0.7 0.16 200);
  --ib-red: oklch(0.58 0.19 25);
  --ib-red-text: oklch(0.97 0.01 90);
  --ib-ink: oklch(0.16 0.01 260);
  --ib-sans: 'Space Grotesk', sans-serif;
  --ib-display: 'Anton', sans-serif;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { background: var(--ib-bg); }
body {
  margin: 0;
  background: var(--ib-bg);
  color: var(--ib-dim);
  font-family: var(--ib-sans);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--ib-yellow); text-decoration: none; }
a:hover { color: var(--ib-text); }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 {
  font-family: var(--ib-display);
  font-weight: 400;
  color: var(--ib-text);
  text-transform: uppercase;
  line-height: 1.1;
  margin: 0 0 0.5em;
}
.ib-container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%);
  height: 1px; width: 1px; overflow: hidden; position: absolute !important;
}

/* Buttons (shared) */
.ib-btn, .woocommerce #respond input#submit, .woocommerce a.button,
.woocommerce button.button, .woocommerce input.button,
.woocommerce #payment #place_order, .wc-block-components-button {
  display: inline-block;
  background: var(--ib-yellow);
  color: var(--ib-ink) !important;
  font-family: var(--ib-sans);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 0;
  padding: 14px 26px;
  cursor: pointer;
  transition: filter 0.15s;
}
.ib-btn:hover, .woocommerce a.button:hover, .woocommerce button.button:hover,
.woocommerce input.button:hover, .woocommerce #payment #place_order:hover {
  background: var(--ib-yellow);
  filter: brightness(1.1);
  color: var(--ib-ink) !important;
}
.ib-btn--ghost {
  background: transparent;
  border: 2px solid var(--ib-border-mid);
  color: var(--ib-text-soft) !important;
  font-weight: 400;
  text-transform: none;
}

/* ============ Header ============ */
.ib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 22px 40px;
  background: var(--ib-bg);
  border-bottom: 2px solid var(--ib-yellow);
}
.ib-header__brand { display: flex; align-items: center; gap: 12px; }
.ib-header__brand img, .ib-header__logo { width: 36px !important; height: auto !important; max-width: 36px; }
.ib-header__title {
  font-family: var(--ib-sans);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.01em;
  color: var(--ib-text);
}
.ib-header__title:hover { color: var(--ib-yellow); }
.ib-nav { display: flex; align-items: center; gap: 26px; }
.ib-nav ul { display: flex; gap: 26px; list-style: none; margin: 0; padding: 0; }
.ib-nav a {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ib-text-nav);
}
.ib-nav a:hover { color: var(--ib-yellow); }
.ib-cart {
  background: var(--ib-red);
  color: var(--ib-red-text) !important;
  border-radius: 3px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ib-cart:hover { filter: brightness(1.15); }

/* ============ Hero (front page) ============ */
.ib-hero { padding: 60px 48px; position: relative; }
.ib-hero h1 {
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.05;
  max-width: 560px;
  margin: 0;
}
.ib-hero h1 .ib-accent { color: var(--ib-yellow); }
.ib-hero__sub { font-size: 15px; color: var(--ib-dim); margin-top: 14px; max-width: 440px; }

/* Search bar */
.ib-search { display: flex; margin-top: 26px; max-width: 520px; }
.ib-search input[type="search"] {
  flex: 1;
  min-width: 0;
  background: var(--ib-surface);
  border: 2px solid var(--ib-yellow);
  border-right: none;
  border-radius: 0;
  padding: 14px 18px;
  color: var(--ib-text-soft);
  font-family: var(--ib-sans);
  font-size: 14px;
  outline: none;
}
.ib-search input[type="search"]::placeholder { color: var(--ib-text-soft); opacity: 0.8; }
.ib-search button {
  background: var(--ib-yellow);
  color: var(--ib-ink);
  border: none;
  border-radius: 0;
  padding: 14px 26px;
  font-family: var(--ib-sans);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  cursor: pointer;
}

/* ============ Category tiles ============ */
.ib-tiles {
  padding: 0 48px 40px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.ib-tile { border-radius: 4px; padding: 22px; display: block; }
.ib-tile__name { font-family: var(--ib-display); font-size: 20px; text-transform: uppercase; }
.ib-tile__count { font-size: 12px; margin-top: 4px; }
.ib-tile--yellow { background: var(--ib-yellow); }
.ib-tile--yellow .ib-tile__name { color: var(--ib-ink); }
.ib-tile--yellow .ib-tile__count { color: oklch(0.16 0.01 260 / 0.7); }
.ib-tile--cyan { background: var(--ib-cyan); }
.ib-tile--cyan .ib-tile__name { color: var(--ib-ink); }
.ib-tile--cyan .ib-tile__count { color: oklch(0.16 0.01 260 / 0.7); }
.ib-tile--red { background: var(--ib-red); }
.ib-tile--red .ib-tile__name { color: var(--ib-red-text); }
.ib-tile--red .ib-tile__count { color: oklch(0.97 0.01 90 / 0.7); }
.ib-tile:hover { filter: brightness(1.08); }

/* ============ Sections ============ */
.ib-section { padding: 0 48px 48px; }
.ib-section__title { font-size: 22px; margin-bottom: 18px; }

/* ============ Product cards ============ */
.ib-grid, ul.products {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  list-style: none;
  margin: 0 !important;
  padding: 0;
}
ul.products::before, ul.products::after { display: none; }
.woocommerce ul.products li.product, .ib-card {
  background: var(--ib-surface);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 !important;
  width: auto !important;
  float: none !important;
  display: flex;
  flex-direction: column;
}
.ib-card__media { height: 170px; position: relative; display: block; }
.ib-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ib-card__body { padding: 14px; }
.ib-badge {
  display: inline-block;
  background: var(--ib-yellow);
  color: var(--ib-ink);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ib-badge--cds, .ib-badge--cd { background: var(--ib-cyan); color: var(--ib-ink); }
.ib-badge--dvds, .ib-badge--dvd { background: var(--ib-red); color: var(--ib-red-text); }
.ib-card__title { font-weight: 700; color: var(--ib-text); font-size: 14px; margin: 0; font-family: var(--ib-sans); text-transform: none; }
.ib-card__title a { color: var(--ib-text); }
.ib-card__title a:hover { color: var(--ib-yellow); }
.ib-card__sub { font-size: 12px; color: var(--ib-dimmer); }
.ib-card__price, .woocommerce ul.products li.product .price {
  font-size: 15px;
  color: var(--ib-yellow) !important;
  font-weight: 700;
  margin-top: 6px;
  font-family: var(--ib-sans);
}
.woocommerce ul.products li.product .price del { opacity: 0.5; }

/* Cover placeholder (striped) */
.ib-placeholder {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(45deg, var(--ib-border) 0px, var(--ib-border) 12px, var(--ib-surface) 12px, var(--ib-surface) 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
}
.ib-placeholder span {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ib-yellow);
  background: oklch(0.16 0.01 260 / 0.75);
  padding: 4px 8px;
  text-transform: uppercase;
}

/* ============ Shop / search results ============ */
.ib-results-head { padding: 32px 48px 0; }
.ib-results-head .ib-search { margin-top: 0; max-width: none; }
.ib-filters { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.ib-chip, .woocommerce .woocommerce-ordering select {
  border: 1px solid var(--ib-border-mid);
  border-radius: 3px;
  padding: 5px 14px;
  font-family: var(--ib-sans);
  font-size: 12px;
  color: var(--ib-dim);
  text-transform: uppercase;
  background: transparent;
}
.woocommerce .woocommerce-ordering { margin: 0; float: none; }
.woocommerce .woocommerce-ordering select { cursor: pointer; }
.ib-result-count, .woocommerce .woocommerce-result-count {
  font-size: 13px;
  color: var(--ib-dimmer);
  margin: 16px 0 0;
  float: none;
}
.ib-shop-grid { padding: 20px 48px 48px; }
.ib-shop-grid ul.products { grid-template-columns: repeat(4, 1fr); gap: 16px; }
.ib-shop-grid .ib-card__media { height: 150px; }
.ib-shop-grid .ib-card__body { padding: 12px; }
.ib-shop-grid .ib-card__title { font-size: 13px; }
.ib-shop-grid .ib-card__sub { font-size: 11px; }

/* Pagination */
.woocommerce nav.woocommerce-pagination { margin: 24px 0 0; }
.woocommerce nav.woocommerce-pagination ul { border: none; display: flex; gap: 8px; justify-content: center; }
.woocommerce nav.woocommerce-pagination ul li {
  border: 1px solid var(--ib-border-mid); border-radius: 3px; overflow: hidden;
}
.woocommerce nav.woocommerce-pagination ul li a,
.woocommerce nav.woocommerce-pagination ul li span {
  color: var(--ib-dim); padding: 6px 12px; font-size: 13px;
}
.woocommerce nav.woocommerce-pagination ul li span.current { background: var(--ib-yellow); color: var(--ib-ink); }

/* ============ Single product (Item page) ============ */
.ib-breadcrumb, .woocommerce .woocommerce-breadcrumb {
  padding: 16px 48px 0;
  font-size: 12px;
  color: var(--ib-faint);
  text-transform: uppercase;
  margin: 0;
  font-family: var(--ib-sans);
}
.woocommerce .woocommerce-breadcrumb a { color: var(--ib-faint); }
.woocommerce .woocommerce-breadcrumb a:hover { color: var(--ib-yellow); }
.ib-product { padding: 24px 48px 48px; display: grid; grid-template-columns: 340px 1fr; gap: 40px; }
.ib-product__media { height: 340px; border-radius: 4px; overflow: hidden; position: relative; }
.ib-product__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ib-price-tag {
  position: absolute;
  top: 14px;
  right: -8px;
  background: var(--ib-red);
  color: var(--ib-red-text);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  transform: rotate(6deg);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  z-index: 2;
}
.ib-price-tag .amount, .ib-price-tag bdi { color: var(--ib-red-text); }
.ib-product__info .ib-badge { font-size: 12px; padding: 4px 10px; margin-bottom: 10px; }
.ib-product__title { font-size: 34px; margin: 0; }
.ib-product__author { font-size: 15px; color: oklch(0.7 0.02 260); margin-top: 4px; }
.ib-product__condition { font-size: 13px; color: var(--ib-faint); margin-top: 18px; }
.ib-product__buy { margin-top: 20px; }
.ib-product__buy form.cart { display: flex; gap: 0; align-items: stretch; }
.ib-product__buy .quantity { display: none; }
.ib-product__buy .single_add_to_cart_button { border-radius: 0; }
.ib-seller { margin-top: 28px; padding-top: 20px; border-top: 2px solid var(--ib-border); }
.ib-seller__title { font-size: 15px; margin-bottom: 6px; }
.ib-seller__text { font-size: 13px; color: var(--ib-dimmer); line-height: 1.6; }
.ib-seller__text p { margin: 0 0 0.8em; }

/* Related products */
.ib-related { padding: 0 48px 48px; }
.ib-related > h2, .related.products > h2, .up-sells > h2 {
  font-size: 19px; margin-bottom: 14px;
}
.related.products, .up-sells { padding: 0 48px 48px; }
.related.products ul.products, .up-sells ul.products { grid-template-columns: repeat(3, 1fr); gap: 16px; }
.related.products .ib-card__media, .up-sells .ib-card__media { height: 130px; }

/* ============ Cart / checkout / account (palette pass) ============ */
.ib-page { padding: 40px 48px 60px; }
.ib-page h1 { font-size: 30px; }
.woocommerce table.shop_table {
  border: 1px solid var(--ib-border);
  border-radius: 4px;
  background: var(--ib-surface);
  color: var(--ib-dim);
}
.woocommerce table.shop_table th, .woocommerce table.shop_table td {
  border-color: var(--ib-border);
  color: var(--ib-text-soft);
}
.woocommerce table.shop_table th { color: var(--ib-text); text-transform: uppercase; font-size: 12px; letter-spacing: 0.05em; }
.woocommerce .cart_totals h2, .woocommerce-billing-fields h3, #order_review_heading { font-size: 20px; }
.woocommerce form .form-row input.input-text, .woocommerce form .form-row textarea,
.woocommerce form .form-row select, .woocommerce form .form-row .select2-selection {
  background: var(--ib-surface);
  border: 1px solid var(--ib-border-mid);
  border-radius: 3px;
  color: var(--ib-text-soft);
  padding: 10px 12px;
}
.woocommerce form .form-row label { color: var(--ib-dim); font-size: 13px; }
.woocommerce-message, .woocommerce-info, .woocommerce-error {
  background: var(--ib-surface);
  color: var(--ib-text-soft);
  border-top-color: var(--ib-yellow);
}
.woocommerce-error { border-top-color: var(--ib-red); }
.woocommerce-message::before, .woocommerce-info::before { color: var(--ib-yellow); }
.woocommerce-error::before { color: var(--ib-red); }
.woocommerce #payment { background: var(--ib-surface); border-radius: 4px; }
.woocommerce #payment div.payment_box { background: var(--ib-bg); color: var(--ib-dim); }
.woocommerce #payment div.payment_box::before { border-bottom-color: var(--ib-bg); }
.woocommerce-account .woocommerce-MyAccount-navigation ul { list-style: none; padding: 0; }
.woocommerce-account .woocommerce-MyAccount-navigation li { margin-bottom: 8px; }
.price .amount, .price bdi { color: var(--ib-yellow); }

/* ============ Footer ============ */
.ib-footer {
  border-top: 2px solid var(--ib-yellow);
  padding: 28px 40px 40px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ib-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ib-footer a { color: var(--ib-dim); }
.ib-footer a:hover { color: var(--ib-yellow); }

/* ============ Generic content (posts/pages) ============ */
.ib-page .entry-content a { text-decoration: underline; }
.ib-page .entry-content { color: var(--ib-dim); max-width: 720px; }

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .ib-hero, .ib-tiles, .ib-section, .ib-results-head, .ib-shop-grid,
  .ib-product, .ib-related, .related.products, .up-sells, .ib-page,
  .woocommerce .woocommerce-breadcrumb, .ib-breadcrumb { padding-left: 24px; padding-right: 24px; }
  .ib-header, .ib-footer { padding-left: 24px; padding-right: 24px; }
  .ib-tiles { grid-template-columns: 1fr 1fr; }
  .ib-grid, ul.products, .ib-shop-grid ul.products { grid-template-columns: repeat(2, 1fr) !important; }
  .ib-product { grid-template-columns: 1fr; }
  .ib-product__media { max-width: 340px; }
}
@media (max-width: 520px) {
  .ib-tiles { grid-template-columns: 1fr; }
  .ib-grid, ul.products, .ib-shop-grid ul.products { grid-template-columns: 1fr !important; }
  .ib-nav ul { gap: 14px; flex-wrap: wrap; }
}
