/* =====================================================================
   A könyvek háttere – spoilerzáras univerzumtérkép
   A common.css témaváltozóiból dolgozik.
   ===================================================================== */

body.hatter-page {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  color: var(--text);
}

/* ===== Fejléc ===== */
.hk-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.hk-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
}

.hk-titles { flex: 1; min-width: 0; }
/* Az oldal címe a közös fejléc alatt (lib/site-header.php). */
.hk-pagehead { margin: 4px 0 18px; }
.hk-titles.hk-pagehead h1 { font-size: clamp(26px, 4vw, 34px); }
.hk-titles h1 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.15; }

.hk-eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ===== Bevezető, haladás, tippek ===== */
.hk-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.hk-intro { max-width: 760px; }
.hk-lead { margin: 0 0 14px; font-size: 16px; line-height: 1.65; color: var(--muted); }
.hk-lead b { color: var(--text); }

.hk-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 14px;
  color: var(--muted);
}

.hk-stat b { color: var(--text); font-variant-numeric: tabular-nums; }

.hk-bar {
  flex: 1 1 160px;
  max-width: 260px;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.hk-bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s ease; }

.hk-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

.hk-preview-flag {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--warn-soft, var(--accent-soft));
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hk-tips {
  max-width: 760px;
  margin: 22px 0 0;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.hk-tips summary { cursor: pointer; font-size: 19px; font-weight: 600; }
.hk-tips-body { margin-top: 10px; }
.hk-tips-body p, .hk-tips-body li { line-height: 1.6; }

/* ===== Admin előnézet ===== */
.hk-admin {
  max-width: 760px;
  margin: 16px 0 0;
  padding: 12px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
}

.hk-admin summary { cursor: pointer; font-weight: 600; }
.hk-admin-hint { margin: 8px 0 10px; font-size: 13px; color: var(--muted); }
.hk-admin-books { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.hk-admin-books label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.hk-admin-books input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ===== Térkép ===== */
.hk-map {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 28px 72px;
  align-items: start;
  margin-top: 30px;
}

.hk-edges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
  /* A nyilak a keretek háttere fölött, a kártyák alatt futnak. */
  z-index: 1;
}

.hk-edge {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  opacity: .75;
}

.hk-edge.is-dashed { stroke-dasharray: 6 5; }

.hk-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; position: relative; }

.hk-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.hk-group.is-open {
  padding: 34px 22px 22px;
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
  animation: hk-reveal .5s ease-out;
}

.hk-group .hk-group.is-open { background: color-mix(in srgb, var(--surface) 55%, transparent); padding-top: 30px; }

.hk-group-label {
  position: absolute;
  top: -11px;
  left: 18px;
  right: 18px;
  margin: 0;
  padding: 2px 10px;
  width: fit-content;
  max-width: calc(100% - 36px);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--accent);
  background: var(--bg);
  border-radius: 6px;
  z-index: 3; /* a nyilak fölött */
}

.hk-group-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}

.hk-group-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* A többoszlopos sor lejjebb kezdődik, hogy a szétágazó nyilak jól látsszanak. */
@media (min-width: 900px) {
  .hk-group-grid { margin-top: 26px; }
  .hk-group-col > .hk-group.is-open { margin-top: 6px; }
}

/* ===== Kártyák ===== */
.hk-node {
  position: relative;
  z-index: 2; /* a nyilak fölött */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 92px;
  padding: 16px 16px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  animation: hk-reveal .45s ease-out;
}

.hk-node:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.hk-node:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.hk-node-era {
  padding: 1px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 999px;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 2px;
}

.hk-node-title { font-size: 18px; font-weight: 600; line-height: 1.25; }
.hk-node-sub { font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.hk-node-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; }

.hk-chip {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.hk-chip-read { background: var(--success-soft); color: var(--success); }

.hk-meter { display: inline-flex; gap: 3px; }
.hk-meter i { width: 14px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.hk-meter i.on { background: var(--accent); }
.hk-meter i.peek { background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 5px); }

.hk-node.is-book { border-top: 3px solid var(--accent); }
.hk-node.is-read { background: color-mix(in srgb, var(--success-soft) 40%, var(--surface)); }
.hk-node.is-planned { border-style: dashed; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.hk-node.is-peeked { border-style: dashed; }

.hk-node.is-hidden {
  min-height: 86px;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  background:
    repeating-linear-gradient(135deg, transparent 0 9px, color-mix(in srgb, var(--muted) 9%, transparent) 9px 10px),
    color-mix(in srgb, var(--surface-2) 75%, transparent);
  color: var(--muted);
  box-shadow: none;
}

.hk-node.is-hidden:hover { border-color: var(--border-strong); }
.hk-node-fog { font-size: 14px; font-weight: 600; letter-spacing: .03em; }
.hk-node-need { font-size: 12px; line-height: 1.35; }

.hk-lock { width: 20px; height: 20px; opacity: .8; }

.hk-new {
  position: absolute;
  top: -9px;
  right: 12px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.hk-new.is-inline { position: static; display: inline-block; margin-bottom: 6px; }

@keyframes hk-reveal { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .hk-node, .hk-group.is-open { animation: none; }
}

/* ===== Kártyaablak ===== */
.hk-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  overscroll-behavior: contain;
}

.hk-dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

.hk-dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hk-dialog-head h2 { margin: 2px 0 0; font-size: 24px; font-weight: 600; line-height: 1.2; }
.hk-dialog-body { padding: 18px 22px 24px; }

.hk-intro-text { font-size: 16.5px; }
.hk-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.hk-section h3:first-child, .hk-section .hk-new + h3, .hk-section .hk-peek-badge + h3 { margin-top: 0; }
.hk-section.is-peeked { border-top-style: dashed; }

.hk-peek-badge, .hk-peeked-note {
  display: inline-block;
  margin-bottom: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.hk-peeked-note { display: block; border-radius: 10px; padding: 8px 12px; font-weight: 500; }

.hk-locked {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: repeating-linear-gradient(135deg, transparent 0 9px, color-mix(in srgb, var(--muted) 7%, transparent) 9px 10px), var(--surface-2);
  color: var(--muted);
}

.hk-locked.is-card { margin-top: 0; text-align: center; }
.hk-locked .hk-lock { width: 22px; height: 22px; }
.hk-locked p { margin: 6px 0; }
.hk-locked b { color: var(--text); }

.hk-need { list-style: none; margin: 6px 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.hk-locked.is-card .hk-need { justify-content: center; }
.hk-need li { padding: 2px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text); }
.hk-need li.is-done { background: var(--success-soft); color: var(--success); border-color: transparent; }

.hk-warn { margin: 0 0 10px; color: var(--text); }
.hk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hk-locked.is-card .hk-actions { justify-content: center; }

.hk-links { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; }
.hk-links-title { flex-basis: 100%; margin: 0 0 2px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.hk-link-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.hk-link-chip small { font-size: 12px; font-weight: 400; color: var(--muted); }
.hk-link-chip:hover { border-color: var(--accent); }
.hk-book-actions { margin-top: 22px; }
.hk-book-actions .btn { min-height: 44px; }

.hk-footnote { max-width: 760px; margin: 34px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }

/* ===== Mobil: függőleges idővonal, alulról felcsúszó kártya ===== */
@media (max-width: 899px) {
  .hk-map { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .hk-edges { display: none; }
  .hk-group-grid { grid-template-columns: minmax(0, 1fr); }
  .hk-col { gap: 16px; }
  .hk-group, .hk-group-col { gap: 16px; }
  /* A függőleges sorrendet egy vékony vonal köti össze. */
  .hk-col::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    transform: translateX(-1px);
    background: linear-gradient(var(--border-strong), transparent);
    z-index: -1;
  }
  .hk-group.is-open { padding: 30px 14px 16px; }
}

@media (max-width: 560px) {
  .hk-titles h1 { font-size: 20px; }
  .hk-main { padding-top: 18px; }
  .hk-tips { padding: 12px 16px; }
  .hk-node { min-height: 84px; padding: 14px 14px 12px; }
  .hk-node-title { font-size: 17px; }
  .hk-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    animation: hk-sheet .24s ease-out;
  }
  .hk-dialog-head, .hk-dialog-body { padding-left: 18px; padding-right: 18px; }
  .hk-dialog-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .hk-book-actions .btn { flex: 1 1 0; }
}

@keyframes hk-sheet { from { transform: translateY(24px); opacity: .4; } }

/* ===== Szöveg a kártyákon (a book.css prózastílusával egyező) ===== */
.hatter-page .book-prose { line-height: 1.75; font-size: 1.02rem; }
.hatter-page .book-prose h3, .hatter-page .book-prose h4 { font-family: "Noto Serif", Georgia, serif; font-size: 18px; line-height: 1.3; margin: 1.2em 0 .45em; }
.hatter-page .book-prose p { margin: 0 0 1em; }
.hatter-page .book-prose p:last-child { margin-bottom: 0; }
.hatter-page .book-prose ul { margin: 0 0 1em; padding-left: 1.3em; }
.hatter-page .book-prose li { margin-bottom: .3em; }
.hatter-page .book-prose blockquote { border-left: 3px solid var(--accent); padding: 8px 18px; margin: 14px 0; background: var(--accent-soft); }
.hatter-page .book-prose a { color: var(--accent); }
