/* Lekcje Krzewiny: large type and strong contrast for kids and a classroom projector. */

:root {
  --bg: #fff8ee;
  --surface: #ffffff;
  --ink: #1d2540;
  --ink-soft: #55607d;
  --line: #e7dccb;
  --accent: #2f6ae0;
  --accent-ink: #ffffff;
  --go: #16834d;
  --warn-bg: #fff1c2;
  --warn-line: #e8c34d;
  --danger: #c43131;
  --code-bg: #f6f8fc;
  --code-line: #d9e0ee;
  --console-bg: #1d2540;
  --console-ink: #e9f0ff;
  --radius: 14px;
  --shadow: 0 2px 0 rgba(29, 37, 64, 0.08), 0 6px 18px rgba(29, 37, 64, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.55 var(--font);
}

a { color: var(--accent); }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

/* --- header ------------------------------------------------------------ */

.site-header {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.35rem;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ink);
  color: #ffd43b;
  font: 700 1.1rem var(--mono);
}

.adminbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
  padding: 8px 16px;
  background: var(--ink);
  color: #fff;
  font-size: 0.95rem;
}
.adminbar span { font-weight: 700; color: #ffd43b; }
.adminbar a, .adminbar .link-button { color: #fff; }
.adminbar form { margin: 0; }

.link-button {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* --- headings and text --------------------------------------------------- */

.page-title {
  margin: 16px 0 8px;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lead { margin: 0 0 28px; color: var(--ink-soft); font-size: 1.2rem; }

.eyebrow {
  margin: 20px 0 0;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
}

.intro {
  margin: 8px 0 0;
  font-size: 1.25rem;
}

.empty {
  padding: 28px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-align: center;
}

.back {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
  text-decoration: none;
}
.back:hover { text-decoration: underline; }

.flash, .hidden-note, .admin-note, .error {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 10px;
}
.flash { background: #dff5e8; border: 1px solid #9fd8b6; }
.hidden-note { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.admin-note { padding: 0; }
.error { background: #fde3e3; border: 1px solid #f0a8a8; color: #8a1c1c; }

/* --- lesson list --------------------------------------------------------- */

.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.lesson-card:hover, .lesson-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.lesson-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2f6ae0;
  color: #fff;
  font-weight: 800;
  font-size: 1.4rem;
}
.lesson-list li:nth-child(4n + 2) .lesson-num { background: #16834d; }
.lesson-list li:nth-child(4n + 3) .lesson-num { background: #d9480f; }
.lesson-list li:nth-child(4n + 4) .lesson-num { background: #7a3fc4; }

.lesson-name { flex: 1; font-size: 1.3rem; font-weight: 700; }
.lesson-arrow { font-size: 1.5rem; color: var(--ink-soft); }

/* --- code blocks --------------------------------------------------------- */


.code-box {
  background: var(--code-bg);
  border: 2px solid var(--code-line);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border-bottom: 2px solid var(--code-line);
  background: #eef2fa;
}

.code-lang { color: var(--ink-soft); font-weight: 700; font-size: 0.95rem; }

/* Deliberately quiet: the teacher wants students to type the code
   themselves, so copying is a small grey icon, the colour of the label. */
.copy-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.copy-button svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.copy-button:hover { background: #e2e8f4; color: var(--ink); }
.copy-button:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }
.copy-button .icon-done { visibility: hidden; }
.copy-button.copied .icon-copy { visibility: hidden; }
.copy-button.copied .icon-done { visibility: visible; }
.copy-button.copied { color: var(--go); }
.copy-button.failed { color: var(--danger); }

pre.code {
  margin: 0;
  padding: 16px 16px 16px 0;
  background: transparent;
  overflow-x: auto;
  font: 500 1rem/1.6 var(--mono);
  counter-reset: line;
  tab-size: 4;
}

pre.code .line { counter-increment: line; }
pre.code .line::before {
  content: counter(line);
  display: inline-block;
  width: 3.2em;
  padding-right: 1em;
  color: #9aa5bf;
  text-align: right;
  user-select: none;
}

.copy-source { display: none; }

.example-head { margin: 0 0 6px; font-weight: 700; color: var(--ink-soft); }
.example pre {
  margin: 0;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--console-bg);
  color: var(--console-ink);
  font: 0.95rem/1.55 var(--mono);
  overflow-x: auto;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 48px;
}
.pager a {
  padding: 14px 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 700;
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager-next { margin-left: auto; }

/* --- lesson blocks -------------------------------------------------------- */

/* Scoped to .block: the editor's boxes reuse the block-<kind> class names. */
.block { margin-top: 28px; }
.block.block-heading { margin-top: 40px; margin-bottom: 0; font-size: 1.45rem; line-height: 1.25; }
/* A heading belongs to what follows it, and output to the code above it. */
.block.block-heading + .block,
.block.block-code + .block.block-output { margin-top: 12px; }

/* --- forms and admin ----------------------------------------------------- */

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

label {
  display: block;
  margin-bottom: 16px;
  font-weight: 700;
}

.optional { color: var(--ink-soft); font-weight: 400; font-size: 0.95rem; }

input[type="text"], input[type="password"], textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 400 1.05rem/1.5 var(--font);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

textarea.code-input { font: 1rem/1.5 var(--mono); tab-size: 4; resize: vertical; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 700 1rem var(--font);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { color: var(--danger); border-color: #f0b4b4; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--accent); }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.icon-button.danger { color: var(--danger); }

.login-form { max-width: 420px; margin: 40px auto; }
.login-form .page-title { font-size: 1.6rem; margin-top: 0; }
.login-form input { margin-bottom: 16px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.admin-row.is-hidden { background: #fbf6ec; }

.order { display: flex; gap: 6px; }
.order form, .admin-row-actions form { margin: 0; }

.admin-row-main { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.admin-row-title { font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.meta { display: flex; gap: 10px; align-items: center; color: var(--ink-soft); font-size: 0.95rem; }

.admin-row-actions { display: flex; gap: 8px; }

.badge { padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; }
.badge-on { background: #dff5e8; color: #11653b; }
.badge-off { background: var(--warn-bg); color: #7a5a00; }

.edit-form { margin-top: 16px; }

/* No gap: the "+" inserters between blocks provide the spacing. */
#blocks { display: grid; margin: 4px 0 16px; }

.inserter {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0;
}
/* A dashed line through the "+" on hover shows where the block will go. */
.inserter::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px dashed transparent;
}
.inserter:hover::before, .inserter.is-open::before { border-color: var(--accent); }
.inserter-toggle {
  position: relative;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink-soft);
  font: 700 1.15rem/1 var(--font);
  cursor: pointer;
}
.inserter-toggle:hover, .inserter-toggle:focus-visible, .inserter.is-open .inserter-toggle {
  border-color: var(--accent);
  color: var(--accent);
}
.inserter-menu {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--bg);
}
.inserter-menu[hidden] { display: none; }
.inserter-menu .button { min-height: 36px; padding: 4px 12px; font-size: 0.95rem; }

.block-editor {
  padding: 16px 20px 4px;
  background: var(--surface);
  border: 2px solid var(--code-line);
  border-radius: var(--radius);
}

.block-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.block-label { font-weight: 800; font-size: 1.15rem; }
.block-tools { display: flex; gap: 6px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.danger-zone { margin-top: 40px; }

/* --- courses ------------------------------------------------------------ */

.course-list { margin-top: 24px; }
.course-main { flex: 1; display: grid; gap: 2px; }
.course-card .lesson-name { flex: none; }
.course-meta { color: var(--ink-soft); font-size: 1rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.lock { font-weight: 700; color: #7a5a00; }
.lock-big { margin: 0; font-size: 2.4rem; }
.badge-lock { background: var(--warn-bg); color: #7a5a00; }

/* --- Markdown text ------------------------------------------------------- */


.prose { font-size: 1.15rem; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table { margin: 0 0 14px; }
.prose h1, .prose h2, .prose h3 { margin: 24px 0 10px; line-height: 1.25; }
.prose h1 { font-size: 1.6rem; }
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.2rem; }
.prose ul, .prose ol { padding-left: 1.6em; }
.prose li { margin: 4px 0; }
.prose code {
  padding: 1px 6px;
  border-radius: 6px;
  background: #eef2fa;
  font: 0.95em var(--mono);
}
.prose pre {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--code-bg);
  border: 2px solid var(--code-line);
  overflow-x: auto;
}
.prose pre code { padding: 0; background: none; }
.prose blockquote {
  padding: 12px 18px;
  border-left: 6px solid #ffd43b;
  border-radius: 0 10px 10px 0;
  background: var(--warn-bg);
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; border-radius: 10px; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 12px; border: 1px solid var(--line); text-align: left; }
.prose th { background: #f6efe2; }
.lead.prose { color: var(--ink); margin-bottom: 12px; }

/* --- block editor -------------------------------------------------------- */

.block-editor.block-text { border-color: #f0dca8; background: #fffdf6; }
.block-editor.block-heading input { font-size: 1.25rem; font-weight: 700; }
.block-editor.block-output { border-color: #b9c2d8; }
.lang-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lang-picker select { margin-top: 0; padding: 6px 10px; }
.add-label { align-self: center; font-weight: 700; color: var(--ink-soft); }
textarea.text-input { font-size: 1.05rem; }
.add-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

.md-field { display: grid; gap: 0 20px; margin-bottom: 16px; }
.md-input { display: grid; grid-template-rows: auto 1fr; margin-bottom: 0; }
.md-preview-wrap { display: grid; grid-template-rows: auto 1fr; margin-top: 12px; }
.md-preview-label { font-weight: 700; color: var(--ink-soft); }
.md-preview {
  margin-top: 6px;
  padding: 10px 14px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}
.md-preview:empty::before { content: "Tu zobaczysz, jak tekst wygląda dla uczniów."; color: var(--ink-soft); font-style: italic; }
.md-preview-error { border-color: var(--danger); }
@media (min-width: 860px) {
  .md-field { grid-template-columns: 1fr 1fr; }
  .md-preview-wrap { margin-top: 0; }
}

.md-help { margin: -6px 0 16px; color: var(--ink-soft); }
.md-help summary { cursor: pointer; font-weight: 600; }
.md-help table { margin-top: 8px; border-collapse: collapse; font-size: 0.95rem; }
.md-help td { padding: 4px 14px 4px 0; vertical-align: top; }
.md-help code { font-family: var(--mono); }

.hint { margin: -6px 0 0; color: var(--ink-soft); font-size: 0.95rem; }

select {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 400 1.05rem var(--font);
}

.offscreen { position: fixed; top: -1000px; left: -1000px; }

@media (max-width: 560px) {
  body { font-size: 1.05rem; }
  .lesson-card { padding: 14px; gap: 14px; }
  .lesson-num { width: 44px; height: 44px; font-size: 1.2rem; }
  pre.code { font-size: 0.9rem; }
  .example pre { font-size: 0.875rem; }
  pre.code .line::before { width: 2.6em; padding-right: 0.8em; }
}

@media (prefers-reduced-motion: reduce) {
  .lesson-card { transition: none; }
}
