:root {
  --blue: #4e97cc;
  --blue-dark: #24658f;
  --ink: #27333c;
  --paper: #fffef9;
  --line: #c8ddeb;
  --shadow: 0 8px 24px rgb(24 55 75 / 16%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: #f3f5f6;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.65;
}

.site-header {
  background: #4d4f52;
  color: white;
  text-align: center;
  border-bottom: 4px solid var(--blue);
}

.site-name {
  display: block;
  padding: 1rem 1rem .55rem;
  color: white;
  font-size: clamp(1.45rem, 4vw, 2.2rem);
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .04em;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .25rem;
  padding: 0 .75rem .8rem;
}

nav a {
  color: white;
  padding: .42rem .75rem;
  border-radius: 999px;
  text-decoration: none;
}

nav a:hover, nav a:focus-visible, nav a[aria-current="page"] { background: var(--blue); }

main {
  width: min(1120px, calc(100% - 2rem));
  margin: 2rem auto;
  padding: clamp(1rem, 3vw, 2.5rem);
  background: white;
  box-shadow: var(--shadow);
  border-radius: 4px;
}

.page-heading { text-align: center; max-width: 850px; margin: 0 auto 2.5rem; }
.section-label { color: var(--blue-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
h1, h2 { color: var(--blue-dark); line-height: 1.2; }
h1 { margin: .15rem 0; font-size: clamp(2rem, 6vw, 3.5rem); }
h2 { margin-top: 0; font-size: clamp(1.45rem, 4vw, 2rem); }
.ornament { margin: .25rem 0; color: var(--blue); font-size: 1.5rem; }
.intro { font-size: 1.13rem; }

.book-cover {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 340px);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  margin-bottom: 3rem;
  padding: clamp(1rem, 3vw, 2rem);
  background: #eef7fc;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }
.source-details { margin: 1.25rem 0 0; font-size: .96rem; }
.source-details div { margin-bottom: .35rem; }
.source-details dt { display: inline; color: var(--blue-dark); font-weight: 700; }
.source-details dt::after { content: " : "; }
.source-details dd { display: inline; margin: 0; }
.button, .secondary-button {
  display: inline-block;
  padding: .7rem 1rem;
  border: 2px solid var(--blue-dark);
  border-radius: 4px;
  font-family: Arial, sans-serif;
  font-weight: 700;
  text-decoration: none;
}
.button { color: white; background: var(--blue-dark); }
.secondary-button { color: var(--blue-dark); background: white; }
.button:hover, .button:focus-visible { background: #194c6d; }
.secondary-button:hover, .secondary-button:focus-visible { background: #e3f2fb; }

.reading-help { margin-top: -.75rem; }
.page-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.page-button {
  display: block;
  width: 100%;
  padding: .65rem;
  color: var(--blue-dark);
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 3px 12px rgb(24 55 75 / 12%);
  font: 700 1rem Arial, sans-serif;
  cursor: zoom-in;
}
.page-button:hover, .page-button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.page-button img { display: block; width: 100%; height: auto; margin-bottom: .6rem; }
.cover-button img { margin-bottom: 0; }
.back-link { margin: 2.5rem 0 0; text-align: center; }
.back-link a { color: var(--blue-dark); font-weight: 700; }

footer { padding: 1.5rem; color: #e8e8e8; background: #4d4f52; text-align: center; }

dialog {
  width: min(1100px, 96vw);
  height: 96vh;
  padding: 0;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 12px 45px rgb(0 0 0 / 45%);
}
dialog::backdrop { background: rgb(0 0 0 / 78%); }
.reader-bar, .reader-controls {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem;
  color: white;
  background: #333;
  font-family: Arial, sans-serif;
}
.reader-bar { top: 0; }
.reader-bar p { margin: 0; }
.reader-controls { bottom: 0; }
.reader-bar button, .reader-controls button { padding: .55rem .75rem; cursor: pointer; }
.reader-image-wrap { padding: 1rem; background: #1e1e1e; text-align: center; }
#reader-image { max-width: 100%; height: auto; vertical-align: middle; }

@media (max-width: 760px) {
  main { width: min(100% - 1rem, 1120px); margin: .5rem auto; }
  .book-cover { grid-template-columns: 1fr; }
  .cover-button { max-width: 340px; margin: 0 auto; }
  .page-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .reader-controls span { display: none; }
}

@media (max-width: 430px) {
  .page-grid { grid-template-columns: 1fr; }
  .page-button { max-width: 320px; margin: 0 auto; }
}
