/* Muzyka z AI — e-book. Motyw: nocna linia autobusowa (granat + światło sodowej latarni). */

:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #f0e9dd;
  --ink: #1d1a16;
  --ink-soft: #5b544a;
  --line: #e2d8c8;
  --accent: #c2410c;        /* sodowa latarnia */
  --accent-soft: #fde7d6;
  --accent-ink: #9a3412;
  --night: #1e2a44;         /* granat nocnego autobusu */
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --code-bg: #1e2a44;
  --code-ink: #f5ede0;
  --ticket: #fff4c2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 26, 22, .06), 0 8px 24px rgba(29, 26, 22, .06);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1525;
    --surface: #161e33;
    --surface-2: #1c2640;
    --ink: #efe8dc;
    --ink-soft: #a9b1c4;
    --line: #2a3554;
    --accent: #fb923c;
    --accent-soft: #3a2416;
    --accent-ink: #fdba74;
    --night: #0a0f1c;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #33270d;
    --code-bg: #0a0f1c;
    --code-ink: #f5ede0;
    --ticket: #2b2714;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1525;
  --surface: #161e33;
  --surface-2: #1c2640;
  --ink: #efe8dc;
  --ink-soft: #a9b1c4;
  --line: #2a3554;
  --accent: #fb923c;
  --accent-soft: #3a2416;
  --accent-ink: #fdba74;
  --night: #0a0f1c;
  --ok: #4ade80;
  --ok-soft: #12301f;
  --warn: #fbbf24;
  --warn-soft: #33270d;
  --code-bg: #0a0f1c;
  --code-ink: #f5ede0;
  --ticket: #2b2714;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
}
img { max-width: 100%; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--night);
  color: #e7e2d8;
  padding: 28px 18px 24px;
}
.brand {
  display: block;
  text-decoration: none;
  color: #fff;
  margin: 0 8px 22px;
}
.brand .route {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  background: #fb923c;
  color: #1a1206;
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 600;
}
.brand span.sub { display: block; font-size: 13px; color: #a9b1c4; margin-top: 4px; }

#toc ol { list-style: none; margin: 0; padding: 0; }
#toc li { margin: 0; }
#toc a {
  display: grid;
  grid-template-columns: 34px 1fr 16px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: #d8d2c6;
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.3;
}
#toc a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#toc a[aria-current="page"] { background: rgba(251, 146, 60, .16); color: #fff; }
#toc .stop {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  border: 1.5px solid #4a5675;
  border-radius: 999px;
  padding: 2px 0;
  color: #c9cfdd;
}
#toc a[aria-current="page"] .stop { border-color: #fb923c; color: #fb923c; }
#toc .done-dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; justify-self: end; }
#toc .done-dot.partial { background: #fb923c; opacity: .55; }
#toc .done-dot.full { background: #4ade80; }
#toc .group {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7c87a3;
  margin: 18px 10px 6px;
}
.sidebar-foot { margin: 22px 10px 0; font-size: 12px; color: #7c87a3; }
.theme-toggle {
  margin-top: 10px;
  background: transparent;
  color: #c9cfdd;
  border: 1px solid #4a5675;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.theme-toggle:hover { border-color: #fb923c; color: #fff; }

.menu-btn { display: none; }

.content {
  width: 100%;
  min-width: 0;
  max-width: 820px;
  padding: 56px 48px 80px;
  margin: 0 auto;
}

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(32px, 5vw, 46px); margin: 6px 0 14px; }
h2 { font-size: 28px; margin: 56px 0 14px; padding-top: 8px; }
h3 { font-size: 21px; margin: 30px 0 10px; }
p { margin: 0 0 14px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--accent-ink);
  margin: 0;
}
.lead { font-size: 20px; color: var(--ink-soft); line-height: 1.55; }
small, .muted { color: var(--ink-soft); }
strong { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
ul, ol { padding-left: 1.3em; }
li { margin: 4px 0; }
kbd {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}
code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------- Module header ---------- */
.mod-head { margin-bottom: 26px; }
.outcome {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-top: 18px;
}
.outcome b { white-space: nowrap; color: var(--accent-ink); }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill {
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 3px 12px;
  color: var(--ink-soft);
}

/* ---------- Steps ---------- */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 18px 0; }
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 22px 56px;
  margin: 0;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--night);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 15px;
}
:root[data-theme="dark"] ol.steps > li::before { background: var(--accent); color: #1a1206; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) ol.steps > li::before { background: var(--accent); color: #1a1206; } }
ol.steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 42px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}
ol.steps > li > strong:first-child { display: block; font-size: 18px; margin-bottom: 4px; padding-top: 6px; }
.expect {
  display: block;
  font-size: 15px;
  color: var(--ok);
  margin-top: 6px;
}
.expect::before { content: "✓ Powinieneś zobaczyć: "; font-weight: 700; }

/* ---------- Prompt box ---------- */
.prompt {
  position: relative;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  margin: 18px 0 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.prompt .prompt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  background: rgba(255, 255, 255, .05);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
  font-family: var(--font-mono);
  color: #fdba74;
}
.prompt pre {
  margin: 0;
  padding: 16px 18px 18px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow: auto;
}
.copy-btn {
  background: #fb923c;
  color: #1a1206;
  border: 0;
  border-radius: 8px;
  padding: 5px 12px;
  font: 700 13px var(--font-body);
  cursor: pointer;
  flex-shrink: 0;
}
.copy-btn:hover { background: #fdba74; }
.copy-btn.copied { background: #4ade80; }

/* ---------- Example (bus ticket) ---------- */
.example {
  background: var(--ticket);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  margin: 22px 0;
  position: relative;
}
.example .ticket-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.example .ticket-label::before {
  content: "N";
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0 6px;
}
.example p:last-child { margin-bottom: 0; }
.lyrics {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.6;
  white-space: pre-line;
}
.lyrics .tag { font-family: var(--font-mono); font-size: 13px; color: var(--accent-ink); display: block; margin-top: 10px; }

/* ---------- Callouts ---------- */
.note, .warn, .tip {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px 0;
  font-size: 16px;
}
.note { background: var(--surface-2); }
.tip { background: var(--ok-soft); }
.warn { background: var(--warn-soft); }
.note > b:first-child, .tip > b:first-child, .warn > b:first-child { display: block; margin-bottom: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 18px 0 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
td.bad { color: #b91c1c; }
:root[data-theme="dark"] td.bad { color: #fca5a5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) td.bad { color: #fca5a5; } }
td.good { color: var(--ok); }

/* ---------- Compare (before / after) ---------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0 24px; }
.compare > div { border-radius: var(--radius); padding: 16px 18px; border: 1px solid var(--line); background: var(--surface); }
.compare .before { border-top: 4px solid #dc2626; }
.compare .after { border-top: 4px solid var(--ok); }
.compare h4 { margin: 0 0 8px; font-size: 14px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Checklist ---------- */
.checklist {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 26px 0;
  box-shadow: var(--shadow);
}
.checklist h3 { margin-top: 0; }
.checklist label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.checklist label:last-of-type { border-bottom: 0; }
.checklist input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ok); flex-shrink: 0; }
.checklist input:checked + span { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--ok); }
.checklist .progress { font-size: 14px; color: var(--ink-soft); margin-top: 10px; }
.checklist.complete { border-color: var(--ok); }
.checklist.complete .progress { color: var(--ok); font-weight: 700; }

/* ---------- Cards (index) ---------- */
.hero {
  background: var(--night);
  color: #f5ede0;
  border-radius: 22px;
  padding: 44px 40px;
  margin-bottom: 34px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 146, 60, .55), rgba(251, 146, 60, 0) 70%);
}
.hero h1 { color: #fff; margin-top: 10px; position: relative; }
.hero .lead { color: #c9cfdd; position: relative; }
.hero .eyebrow { color: #fdba74; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 18px 0; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--ink); }
.card .stop { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--accent-ink); }
.card strong { display: block; font-family: var(--font-display); font-size: 19px; margin: 4px 0; }
.card span.d { font-size: 14.5px; color: var(--ink-soft); }

/* ---------- Pager ---------- */
#pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 60px; padding-top: 24px; border-top: 1px solid var(--line); }
#pager a {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
}
#pager a:hover { border-color: var(--accent); }
#pager a.next { text-align: right; }
#pager small { display: block; font-size: 12.5px; color: var(--ink-soft); }

.edition { font-size: 13px; color: var(--ink-soft); margin-top: 40px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .menu-btn {
    display: inline-flex;
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    align-items: center;
    gap: 10px;
    background: var(--night);
    color: #fff;
    border: 0;
    padding: 12px 16px;
    font: 700 15px var(--font-body);
    cursor: pointer;
  }
  .content { padding: 28px 16px 60px; }
  .hero { padding: 30px 22px; }
  .compare { grid-template-columns: 1fr; }
  h2 { font-size: 24px; }
  .lead { font-size: 18px; }
  #pager { flex-direction: column; }
  #pager a.next { text-align: left; }
}

/* ---------- ScrollArea ---------- */
.sa-native-hidden { scrollbar-width: none; -ms-overflow-style: none; }
.sa-native-hidden::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sa-wrap { position: relative; }  /* sidebar ma własne sticky/fixed, body używa toru fixed */
.sidebar.sa-enhanced { overflow: hidden; padding: 0; }
.sidebar-scroll { height: 100%; overflow-y: auto; padding: 28px 18px 24px; overscroll-behavior: contain; }
.sa-track {
  --sa-thumb: color-mix(in srgb, var(--ink) 34%, transparent);
  --sa-thumb-hover: color-mix(in srgb, var(--ink) 55%, transparent);
  position: absolute;
  z-index: 15;
  opacity: 0;
  transition: opacity .25s ease;
  touch-action: none;
}
.sa-track.sa-v { top: 4px; bottom: 4px; right: 2px; width: 12px; }
.sa-track.sa-h { left: 4px; right: 4px; bottom: 2px; height: 12px; }
.sa-track.sa-fixed { position: fixed; z-index: 60; }
.sidebar > .sa-track, .sa-dark > .sa-track {
  --sa-thumb: rgba(255, 255, 255, .28);
  --sa-thumb-hover: rgba(255, 255, 255, .5);
}
.sa-thumb {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 999px;
  background: var(--sa-thumb);
  transition: background-color .15s ease, width .15s ease, height .15s ease, left .15s ease, top .15s ease;
}
.sa-v .sa-thumb { left: 3px; width: 6px; }
.sa-h .sa-thumb { top: 3px; height: 6px; }
.sa-track:hover .sa-thumb, .sa-dragging .sa-thumb { background: var(--sa-thumb-hover); }
.sa-v:hover .sa-thumb, .sa-v.sa-dragging .sa-thumb { left: 1.5px; width: 9px; }
.sa-h:hover .sa-thumb, .sa-h.sa-dragging .sa-thumb { top: 1.5px; height: 9px; }
.sa-host:hover > .sa-track:not(.sa-fixed),
.sa-track:hover, .sa-track.sa-visible, .sa-track.sa-dragging { opacity: 1; }
.sa-dragging { user-select: none; }
@media (hover: none) { .sa-host:hover > .sa-track:not(.sa-fixed) { opacity: 0; } .sa-track.sa-visible { opacity: 1; } }

/* ---------- Bramka hasła ---------- */
body.locked { background: #141c33; min-height: 100vh; }
body.locked #gate { visibility: hidden; }
body.locked.gate-ready #gate { visibility: visible; }
#gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  color: #efe8dc;
  background:
    radial-gradient(900px 600px at 85% 10%, rgba(251, 146, 60, .18), transparent 60%),
    linear-gradient(180deg, #070b17, #141c33);
}
.gate-card {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 44px;
  align-items: center;
}
.gate-cover svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
  transform: rotate(-1.5deg);
}
.gate-body .eyebrow { color: #fdba74; }
.gate-body h1 { color: #fff; font-size: clamp(30px, 4vw, 42px); margin: 8px 0 6px; }
.gate-author { color: #a9b1c4; font-size: 15px; margin-bottom: 16px; }
.gate-desc { color: #d5dbea; font-size: 17px; line-height: 1.6; }
.gate-incl { list-style: none; padding: 0; margin: 14px 0 20px; display: grid; gap: 6px; }
.gate-incl li { padding-left: 26px; position: relative; font-size: 15.5px; color: #e7e2d8; }
.gate-incl li::before { content: "✓"; position: absolute; left: 0; color: #4ade80; font-weight: 700; }
.gate-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid rgba(251, 146, 60, .35);
  background: rgba(251, 146, 60, .08);
  border-radius: 14px;
  margin-bottom: 20px;
  width: fit-content;
}
.gate-amount { font-family: var(--font-display); font-size: 40px; font-weight: 600; color: #fb923c; line-height: 1; }
.gate-tax { font-size: 15px; color: #fdba74; text-transform: uppercase; letter-spacing: .08em; }
#gate-form label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; color: #efe8dc; }
.gate-row { display: flex; gap: 10px; }
#gate-pass {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  color: #fff;
  background: #0b1222;
  border: 1.5px solid #2a3554;
  border-radius: 12px;
  padding: 12px 14px;
}
#gate-pass:focus { outline: none; border-color: #fb923c; box-shadow: 0 0 0 3px rgba(251, 146, 60, .25); }
#gate-submit {
  font: 700 16px var(--font-body);
  background: #fb923c;
  color: #1a1206;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  white-space: nowrap;
}
#gate-submit:hover { background: #fdba74; }
#gate-submit:disabled { opacity: .7; cursor: progress; }
#gate-error { min-height: 22px; margin: 8px 0 0; color: #fca5a5; font-size: 14.5px; }
.gate-small { font-size: 13.5px; color: #7c87a3; margin-top: 6px; }
.gate-card.shake { animation: gate-shake .4s ease; }
@keyframes gate-shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
@media (max-width: 800px) {
  .gate-card { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .gate-cover { max-width: 300px; margin: 0 auto; }
  .gate-row { flex-direction: column; }
  .gate-amount { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .gate-card.shake { animation: none; }
  .gate-cover svg { transform: none; }
}

@media print {
  .sa-track { display: none !important; }
  .sidebar, .menu-btn, #pager, .copy-btn, .theme-toggle { display: none !important; }
  .layout { display: block; }
  .content { max-width: none; padding: 0; }
}
