/* ════════════════════════════════════════════════════════════════
   Penworthy — base layer
   Resets, typography, layout shells, buttons, pills, cards, forms,
   utilities and responsive helpers.
   Ported from design-reference/styles.css (tokens live in tokens.css).
   ════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background: var(--pw-bg);
  color: var(--pw-ink);
  font-family: var(--pw-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }

h1, h2, h3, h4 { font-family: var(--pw-display); color: var(--pw-blue); margin: 0; font-weight: 700; letter-spacing: -0.01em; }

/* ── App layout ── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-main { flex: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  font-size: 17px;
  font-family: var(--pw-display);
  font-weight: 500;
  border-radius: var(--pw-r-lg);
  cursor: pointer;
  transition: filter .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pw-blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-yellow { background: var(--pw-yellow); color: var(--pw-blue); font-weight: 600; }
.btn-yellow:hover { filter: brightness(.96); }
.btn-orange {
  background: var(--pw-orange); color: var(--pw-orange-btn-ink); font-weight: 600;
  box-shadow: 0 4px 14px rgba(224,160,64,.35);
}
.btn-orange:hover { background: var(--pw-orange-hover); }
.btn-ghost { background: transparent; color: var(--pw-blue); }
.btn-ghost:hover { background: var(--pw-blue-tint); }
.btn-outline-blue { background: transparent; color: var(--pw-blue); border: 1.5px solid var(--pw-blue); }
.btn-outline-blue:hover { background: var(--pw-blue-tint); }
.btn-sm { padding: 8px 16px; font-size: 14px; border-radius: var(--pw-r); }

/* ── Page shells ──
   Scoped to elements: WordPress's body_class() outputs `page` on static-page
   views, which would otherwise frame the entire <body>. */
:where(div, section, main, article).page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 50px 80px;
}
:where(div, section, main, article).page-wide { max-width: 1540px; padding: 32px 50px 80px; }

/* ── Cards / pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--pw-pill);
  font-size: 14px;
  background: var(--pw-line-2);
  color: var(--pw-ink-2);
}
.pill-blue { background: var(--pw-blue-tint); color: var(--pw-blue); }
.pill-yellow { background: var(--pw-yellow-light); color: var(--pw-blue); font-weight: 600; }
.pill-green { background: var(--pw-green-light); color: #2C7A52; }
.pill-coral { background: var(--pw-coral-light); color: #C4471F; }

.card {
  background: #fff;
  border: 1px solid var(--pw-line);
  border-radius: var(--pw-r-md);
}
.card-soft { background: #fff; border-radius: var(--pw-r-md); box-shadow: var(--pw-shadow); }

/* ── Item-tag icons (the colored badges on book cards) ── */
.tag-icons { display: flex; gap: 6px; align-items: center; }
.tag-icon {
  width: 22px; height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}
.tag-low    { background: var(--pw-coral-light); color: var(--pw-coral); }
.tag-prev   { background: #FFF6CC; color: #B58B00; }
.tag-dw     { background: var(--pw-yellow-light); color: var(--pw-tan-text); }
.tag-series { background: var(--pw-blue-tint); color: var(--pw-blue); }
.tag-char   { background: var(--pw-blue-tint); color: var(--pw-blue); }

/* ── Forms ── */
.input {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--pw-r-md);
  border: 1.5px solid var(--pw-line);
  font-size: 15px;
  background: #fff;
  outline: none;
  transition: border .15s;
}
.input:focus { border-color: var(--pw-blue); }
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--pw-ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Utility ── */
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.text-blue { color: var(--pw-blue); }
.text-mute { color: var(--pw-ink-3); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 13px; }
.text-bold { font-weight: 700; }
.text-display { font-family: var(--pw-display); }
.flex-1 { flex: 1; }

/* item cover — default kit (landscape 4:3); BookCover overrides per kind */
.cover {
  display: block; /* covers are often <a> elements — inline would void the aspect-ratio */
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--pw-r);
  overflow: hidden;
  position: relative;
  background: var(--pw-blue-tint);
}
/* The photo always fills the 4:3 tile (BookCover in components.jsx). */
.cover img, .pw-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fff;
  border-radius: var(--pw-r-sm);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--pw-blue);
}
.cover-tag.is-new { background: var(--pw-coral-light); color: #B2402E; } /* 4.82:1 on coral-light (was --pw-coral #F75940 = 2.74:1) */
.cover-tag.is-popular { background: var(--pw-yellow-light); color: #8D6300; } /* 4.70:1 on yellow-light (was #A07000 = 3.83:1) */

/* Section eyebrow (reused across home) */
.pw-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--pw-tan-text);
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.25); }

/* ════════════════════════════════════════════════════════════════
   Responsive layer — global optimization
   Inline grids keep their desktop columns; the .rc-* utilities
   override them (via !important) below each breakpoint.
   ════════════════════════════════════════════════════════════════ */

/* ── Collapse utilities for inline-styled grids ── */
@media (max-width: 1080px) {
  .rc2-1080 { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 980px) {
  .rc-980 { grid-template-columns: 1fr !important; }
  .rc-980 > * { grid-column: auto !important; }
  .rc-980.rc-flip > aside { order: -1; } /* order summary above the form/list on small screens */
}
@media (max-width: 900px) {
  .rc-900 { grid-template-columns: 1fr !important; }
  .rc-900 > * { grid-column: auto !important; }
}
@media (max-width: 640px) {
  .rc-640 { grid-template-columns: 1fr !important; }
  .rc-640 > * { grid-column: auto !important; }
}

/* ── Page gutters scale down ── */
@media (max-width: 1080px) {
  :where(div, section, main, article).page { padding: 32px 32px 64px; }
  .page-wide { padding: 28px 32px 64px; }
}
@media (max-width: 640px) {
  :where(div, section, main, article).page { padding: 24px 18px 56px; }
  .page-wide { padding: 20px 18px 56px; }
}

/* ── Phone: touch-friendly small buttons + content never hides under
      the floating cart pill (.pw-cart-fab, see components.css) ── */
@media (max-width: 860px) {
  .app-main { padding-bottom: 84px; }
  .btn-sm { padding: 10px 16px; }
}
