/* ==========================================================================
   Awesome Java Books — design tokens & base
   ========================================================================== */

:root {
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --color-bg: #fbf8f3;
  --color-bg-alt: #f2ecdf;
  --color-surface: #ffffff;
  --color-border: #e6ddc9;
  --color-text: #1e1a14;
  --color-text-muted: #5c5546;
  --color-primary: #c1440e;
  --color-primary-dark: #9c3609;
  --color-primary-contrast: #fff8ef;
  --color-accent: #2c5f6f;
  --color-tag-bg: #f4e3d3;
  --color-tag-text: #8a4008;
  --shadow-sm: 0 1px 2px rgba(30, 26, 20, 0.06), 0 1px 1px rgba(30, 26, 20, 0.04);
  --shadow-md: 0 8px 24px rgba(30, 26, 20, 0.10), 0 2px 6px rgba(30, 26, 20, 0.06);
  --shadow-lg: 0 20px 50px rgba(30, 26, 20, 0.16);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --max-width: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14110d;
    --color-bg-alt: #1c1812;
    --color-surface: #201b15;
    --color-border: #332c22;
    --color-text: #f3ede0;
    --color-text-muted: #b7ac97;
    --color-primary: #ef7f3d;
    --color-primary-dark: #f39a63;
    --color-primary-contrast: #1c1108;
    --color-accent: #7fb8cc;
    --color-tag-bg: #3a2a1a;
    --color-tag-text: #f0b47c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.3rem; }

p { margin: 0 0 1em; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   Header / Nav
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-text);
}
.brand:hover { text-decoration: none; opacity: 0.85; }
.brand .cup { font-size: 1.4rem; }

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 26px;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}
.main-nav a:hover,
.main-nav a.active { color: var(--color-primary); text-decoration: none; }

.has-dropdown { position: relative; }

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
}
.dropdown-toggle:hover,
.dropdown-toggle[aria-expanded="true"] { color: var(--color-primary); }
.dropdown-toggle .caret { font-size: 0.7rem; transition: transform 0.15s ease; }
.dropdown-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 18px);
  left: -16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  min-width: 300px;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.dropdown-menu.open { display: grid; }

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--color-text);
  font-weight: 500;
  line-height: 1.3;
}
.dropdown-menu a:hover,
.dropdown-menu a.active { background: var(--color-bg-alt); color: var(--color-primary); text-decoration: none; }
.dropdown-menu .dm-icon { font-size: 1.1rem; flex-shrink: 0; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--color-text);
  font-size: 1.1rem;
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .main-nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0; right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
  }
  .main-nav.open { display: block; }
  .main-nav ul {
    flex-direction: column;
    gap: 0;
    padding: 8px 24px 18px;
  }
  .main-nav li { border-top: 1px solid var(--color-border); }
  .main-nav a { display: block; padding: 14px 4px; }
  .dropdown-toggle { padding: 14px 4px; width: 100%; justify-content: space-between; }
  .dropdown-menu {
    position: static;
    display: none;
    grid-template-columns: 1fr;
    box-shadow: none;
    border: none;
    padding: 0 0 10px;
  }
  .dropdown-menu.open { display: grid; }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  padding: 72px 0 56px;
  text-align: center;
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--color-primary) 14%, transparent), transparent 45%),
    radial-gradient(circle at 85% 0%, color-mix(in srgb, var(--color-accent) 12%, transparent), transparent 40%);
}

.hero .kicker {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--color-tag-bg);
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 22px;
}

.hero h1 { max-width: 780px; margin-inline: auto; }

.hero .lede {
  max-width: 680px;
  margin: 18px auto 0;
  font-size: 1.15rem;
  color: var(--color-text-muted);
}

.hero .lede a {
  color: var(--color-primary-dark);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-primary) 40%, transparent);
  text-underline-offset: 3px;
}
.hero .lede a:hover { text-decoration-color: var(--color-primary); }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.hero-stats .stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--color-primary);
}
.hero-stats .stat span {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Category nav cards (home page)
   ========================================================================== */

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  margin: 40px 0 64px;
}

.category-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 26px 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  color: var(--color-text);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  text-decoration: none;
}

.category-card .icon { font-size: 1.8rem; margin-bottom: 12px; display: block; }
.category-card h3 { margin-bottom: 6px; font-size: 1.1rem; }
.category-card p { color: var(--color-text-muted); font-size: 0.92rem; margin-bottom: 8px; }
.category-card .count { font-size: 0.8rem; color: var(--color-primary); font-weight: 600; }

/* ==========================================================================
   Section
   ========================================================================== */

.section { padding: 56px 0; }
.section-alt { background: var(--color-bg-alt); }
.section-head { max-width: 680px; margin: 0 auto 40px; text-align: center; }
.section-head p { color: var(--color-text-muted); }

/* ==========================================================================
   Book cards
   ========================================================================== */

.book-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.book-card {
  display: flex;
  gap: 26px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 26px 30px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.book-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.book-card .cover {
  flex: 0 0 120px;
}
.book-card .cover img {
  width: 120px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--color-bg-alt);
}

@media (max-width: 640px) {
  .book-card { flex-direction: column; padding: 22px; gap: 16px; }
  .book-card .cover { flex: 0 0 auto; }
  .book-card .cover img { width: 96px; }
}

.book-card .body { flex: 1; min-width: 0; }

.book-card .rank {
  font-family: var(--font-display);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.book-card h3 {
  font-size: 1.08rem;
  margin: 2px 0 2px;
}

.book-card .byline {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.book-card .best-for {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  padding: 3px 10px;
  border-radius: 100px;
  margin-bottom: 10px;
}

.book-card .blurb {
  font-size: 0.93rem;
  color: var(--color-text);
  margin-bottom: 12px;
}

.book-card .links {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  flex-wrap: wrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-primary);
  color: var(--color-primary-contrast) !important;
  padding: 12px 22px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; background: var(--color-primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border);
  box-shadow: none;
}
.btn-ghost:hover { border-color: var(--color-primary); color: var(--color-primary) !important; }

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 30px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Breadcrumbs
   ========================================================================== */

.breadcrumbs {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding: 18px 0 0;
}
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs .sep { margin: 0 6px; opacity: 0.6; }

/* ==========================================================================
   Page header (category pages)
   ========================================================================== */

.page-header {
  padding: 32px 0 44px;
}
.page-header h1 { margin-bottom: 10px; }
.page-header .lede { max-width: 720px; color: var(--color-text-muted); font-size: 1.05rem; }
.level-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  margin-bottom: 14px;
}

/* ==========================================================================
   FAQ
   ========================================================================== */

.faq {
  max-width: 780px;
  margin: 0 auto;
}
.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.02rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--color-primary);
  flex-shrink: 0;
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p { margin-top: 12px; color: var(--color-text-muted); }

/* ==========================================================================
   Callout / methodology
   ========================================================================== */

.callout {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 22px 24px;
  margin: 32px 0;
}
.callout h3 { margin-bottom: 8px; font-size: 1.05rem; }
.callout p:last-child { margin-bottom: 0; }

.meta-line {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: -6px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 48px 0 32px;
  margin-top: 40px;
  background: var(--color-bg-alt);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-grid h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 14px;
}

.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--color-text); font-size: 0.92rem; }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 24px;
}

@media (max-width: 700px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   404
   ========================================================================== */

.not-found {
  text-align: center;
  padding: 100px 0;
}
