/* ==========================================================================
   books.blue-way.net — one stylesheet, no frameworks, no external fonts.
   Colours are defined once below; dark mode follows the visitor's system.
   ========================================================================== */

:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --ink: #1d2230;
  --muted: #5d6474;
  --line: #e2ddd2;
  --accent: #1f4d7a;          /* blue-way blue */
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --gold: #e8d66c;            /* the yellow of the cover titles */
  --notice-bg: #fbf5d9;
  --notice-line: #e9dc98;
  --shadow: 0 1px 2px rgba(29, 34, 48, .06), 0 8px 24px rgba(29, 34, 48, .08);
  --radius: 10px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", "Songti SC", "SimSun", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171f;
    --surface: #1b1f29;
    --ink: #e9e6de;
    --muted: #a3a9b6;
    --line: #2c3240;
    --accent: #8fb8e3;
    --accent-ink: #0f1622;
    --accent-soft: #1f2a3a;
    --notice-bg: #2a2716;
    --notice-line: #4a4320;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; padding-block: 2.5rem 4rem; }

.wrap { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 640px) { .wrap { padding-inline: 1.5rem; } }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); letter-spacing: -.01em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }
p  { margin: 0 0 1rem; }

a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

img { max-width: 100%; height: auto; display: block; }
code { font-size: .9em; background: var(--accent-soft); padding: .05em .35em; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: .5rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: .5rem; }

/* ---------- Header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.25rem; flex-wrap: wrap; padding-block: .5rem; }

.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand-sub { font-size: .78rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav > a { color: var(--ink); text-decoration: none; padding: .45rem .7rem; border-radius: 6px; font-size: .97rem; }
.site-nav > a:hover { background: var(--accent-soft); }
.site-nav > a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Language menu (no JavaScript: <details>) */
.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .4rem;
  padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 999px; font-size: .95rem;
  background: var(--bg);
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.lang-menu summary::after { content: ""; width: .4em; height: .4em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg) translateY(-2px); margin-left: .1rem; }
.lang-menu[open] summary { border-color: var(--accent); }
.lang-menu ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); z-index: 5;
  list-style: none; margin: 0; padding: .35rem; min-width: 11rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.lang-menu li a { display: block; padding: .45rem .75rem; border-radius: 6px; color: var(--ink); text-decoration: none; }
.lang-menu li a:hover { background: var(--accent-soft); }
.lang-menu li a[aria-current] { font-weight: 600; color: var(--accent); }
.lang-menu li a[aria-current]::after { content: " ✓"; }

/* ---------- Home ---------- */
.hero { max-width: 44rem; margin-bottom: 2.25rem; }
.hero h1 { margin-bottom: .75rem; }
.lead { font-size: 1.2rem; color: var(--muted); }

.notice {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--notice-bg); border: 1px solid var(--notice-line); border-radius: var(--radius);
  padding: .85rem 1rem; margin-bottom: 2rem; font-size: .98rem;
}
.notice svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; margin-top: .1rem; }
.notice span { flex: 1; }

.book-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
.book-card {
  display: grid; grid-template-columns: 140px 1fr; gap: 1.5rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
@media (min-width: 720px) { .book-card { grid-template-columns: 190px 1fr; padding: 1.75rem; gap: 2rem; } }
@media (max-width: 479px) { .book-card { grid-template-columns: 1fr; } .book-card-cover { max-width: 180px; } }

.book-card > *, .edition > *, .book > *, .about-grid > * { min-width: 0; }
.book-card-cover { text-decoration: none; }
.book-card h2 { font-size: 1.75rem; margin-bottom: .2rem; }
.book-card h2 a { color: var(--ink); text-decoration: none; }
.book-card h2 a:hover { color: var(--accent); }
.subtitle { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1.1rem; margin-bottom: .75rem; }
.tagline { margin-bottom: .9rem; }
.title-hint { font-size: .95rem; color: var(--muted); margin-bottom: .75rem; }
.title-hint span { font-weight: 600; }

.avail { font-size: .9rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .85rem; }

.more { font-weight: 600; text-decoration: none; }
.more:hover { text-decoration: underline; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .2rem .6rem; border-radius: 4px; background: var(--gold); color: #2a2510; margin-bottom: .6rem;
}

/* ---------- Covers ---------- */
.cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 3px; box-shadow: 0 2px 4px rgba(0,0,0,.18), 0 10px 28px rgba(0,0,0,.22); }
.cover--placeholder {
  display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center;
  padding: 18% 8% 12%; background: linear-gradient(160deg, #23324a, #121822); color: var(--gold);
  container-type: inline-size;
}
.ph-title { font-family: var(--serif); font-weight: 700; font-size: clamp(1rem, 16cqi, 2.4rem); line-height: 1.1; }
.ph-author { color: #f2efe6; font-family: var(--serif); font-size: clamp(.7rem, 8cqi, 1.2rem); }
.is-coming .cover--placeholder { opacity: .92; }

/* ---------- Book page ---------- */
.back { margin-bottom: 1.5rem; font-size: .95rem; }
.back a { text-decoration: none; }

.book { display: grid; gap: 2rem; margin-bottom: 3rem; }
@media (min-width: 760px) { .book { grid-template-columns: 300px 1fr; gap: 3rem; } }
.book-cover { max-width: 300px; }
@media (min-width: 760px) { .book-cover { position: sticky; top: 1.5rem; align-self: start; } }
.byline { color: var(--muted); margin-bottom: 1rem; }
.book-info .avail { margin-bottom: 1.5rem; }
.blurb { max-width: 40rem; font-size: 1.08rem; }
.blurb p:first-of-type::first-letter { font-family: var(--serif); }

.fallback-note { font-size: .9rem; color: var(--muted); font-style: italic; }

.editions { border-top: 1px solid var(--line); padding-top: 2.5rem; }
.editions > h2 { margin-bottom: 1.25rem; }
.edition-list { display: grid; gap: 1.25rem; }
@media (min-width: 900px) { .edition-list { grid-template-columns: 1fr 1fr; } }

.edition {
  display: grid; grid-template-columns: 96px 1fr; gap: 1.25rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
@media (min-width: 640px) { .edition { grid-template-columns: 120px 1fr; } }
.edition h3 { margin-bottom: .1rem; }
.edition .subtitle { font-size: 1rem; margin-bottom: .9rem; }
.edition-lang { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .95rem; margin-bottom: .35rem; }
.lang-code { display: inline-grid; place-items: center; min-width: 2.1rem; height: 1.5rem; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; letter-spacing: .05em; }
.coming-text { color: var(--muted); font-size: .95rem; }

.buy { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: .05rem;
  padding: .6rem 1rem; border-radius: 8px; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(31, 77, 122, .25); text-decoration: none; }
.btn-fmt { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.btn-store { font-size: .85rem; opacity: .9; line-height: 1.3; }
.btn.is-disabled { background: transparent; color: var(--muted); border: 1px dashed var(--line); cursor: not-allowed; }
.btn.is-disabled:hover { transform: none; box-shadow: none; }

.buy-note { margin-top: 1.25rem; font-size: .9rem; color: var(--muted); max-width: 44rem; }

/* ---------- Text pages ---------- */
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.3rem; margin-top: 2rem; }
.about.prose { max-width: 60rem; }
.about-grid { display: grid; gap: 2rem; margin-top: 1.5rem; }
@media (min-width: 720px) { .about-grid { grid-template-columns: 240px 1fr; gap: 2.5rem; } }
.author-photo { margin: 0; max-width: 240px; }
.author-photo img { border-radius: var(--radius); }
.photo-placeholder { aspect-ratio: 4 / 5; border-radius: var(--radius); background: var(--accent-soft); display: grid; place-items: center; color: var(--accent); }
.photo-placeholder svg { width: 35%; opacity: .5; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); font-size: .9rem; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding-block: 1.25rem; }
.site-footer nav { display: flex; gap: 1.25rem; }
.site-footer a { color: var(--muted); }

/* Right-to-left languages (Arabic, Hebrew …) mostly work through logical properties;
   arrows are flipped here. */
[dir="rtl"] .more span, [dir="rtl"] .back span { display: inline-block; transform: scaleX(-1); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
