/* ============================================================
   AI-kørekort for undervisere, Aabenraa Kommune / PUC Aabenraa
   Designsystem
   ============================================================ */

:root {
  --blue: #096fb7;
  --blue-dark: #075591;
  --blue-darker: #06426f;
  --yellow: #f3cb13;
  --orange: #dc911a;
  --green: #a2c138;
  --red: #c0392b;

  --ink: #1c2733;
  --ink-soft: #445064;
  --paper: #ffffff;
  --bg: #f4f7fa;
  --bg-soft: #eaf1f8;
  --border: #d9e3ec;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(9, 40, 70, 0.07), 0 1px 2px rgba(9, 40, 70, 0.06);
  --shadow-lg: 0 12px 32px rgba(9, 40, 70, 0.14), 0 2px 8px rgba(9, 40, 70, 0.08);

  --maxw: 880px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

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

.wrap-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */
.site-header {
  background: linear-gradient(135deg, var(--blue-darker) 0%, var(--blue) 100%);
  color: #fff;
  padding: 18px 0;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 5;
}

.site-header .header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 46px;
  width: 46px;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text .title {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.brand-text .subtitle {
  font-size: 0.8rem;
  color: #d7e8f8;
  font-weight: 500;
}

.header-nav {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 0.92rem;
  font-weight: 600;
}

.header-nav a {
  color: #eaf3fc;
}
.header-nav a:hover { color: #fff; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1100px 420px at 15% -10%, rgba(243,203,19,0.18), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(9,111,183,0.12), transparent 55%),
    var(--paper);
  border-bottom: 1px solid var(--border);
  padding: 56px 0 44px;
}

.hero h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  margin: 0 0 14px;
  font-weight: 800;
  color: var(--blue-darker);
  letter-spacing: -0.3px;
}

.hero .lead {
  font-size: 1.08rem;
  color: var(--ink-soft);
  max-width: 700px;
  margin: 0 0 22px;
}

.badge-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.badge {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--blue-darker);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 16px rgba(9,111,183,0.3);
}
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.btn-primary:disabled, .btn-primary[aria-disabled="true"] {
  background: #b9c4cf;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-gold {
  background: var(--yellow);
  color: #4a3900;
  box-shadow: 0 6px 16px rgba(243,203,19,0.35);
}
.btn-gold:hover { background: #ffd633; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--blue-darker);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-soft); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.45;
  box-shadow: none;
}

/* ---------- Progress overview (index) ---------- */
.progress-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 34px;
}

.progress-summary .track {
  flex: 1;
  height: 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-summary .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 999px;
  transition: width .4s ease;
  width: 0%;
}

.progress-summary .count {
  font-weight: 800;
  color: var(--blue-darker);
  white-space: nowrap;
  font-size: 0.95rem;
}

/* ---------- Chapter grid (index) ---------- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  padding: 40px 0 60px;
}

.chapter-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s ease, transform .15s ease;
}

.chapter-card.is-unlocked:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.chapter-card.is-locked {
  opacity: 0.6;
}

.chapter-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--blue-darker);
  font-weight: 800;
  font-size: 0.95rem;
}

.chapter-card.is-done .chapter-num {
  background: var(--green);
  color: #fff;
}

.chapter-title {
  font-weight: 750;
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0;
}

.chapter-desc {
  font-size: 0.87rem;
  color: var(--ink-soft);
  flex: 1;
  margin: 0;
}

.chapter-status {
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chapter-status.done { color: #2f7d3a; }
.chapter-status.locked { color: #8a94a3; }
.chapter-status.open { color: var(--blue); }

.chapter-card-link {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.cert-card {
  background: linear-gradient(135deg, var(--blue-darker), var(--blue));
  color: #fff;
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.cert-card h3 { margin: 0 0 6px; font-size: 1.2rem; }
.cert-card p { margin: 0; color: #d7e8f8; font-size: 0.92rem; max-width: 480px; }

/* ---------- Stepper (chapter pages) ---------- */
.stepper {
  display: flex;
  gap: 6px;
  padding: 16px 0;
  overflow-x: auto;
}

.step-dot {
  flex: 1;
  min-width: 30px;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  position: relative;
}

.step-dot.done { background: var(--green); }
.step-dot.current { background: var(--blue); }

/* ---------- Chapter content ---------- */
.chapter-header {
  padding: 40px 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}

.kicker {
  color: var(--orange);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.chapter-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0 0 12px;
  color: var(--blue-darker);
  font-weight: 800;
}

.purpose-box {
  background: var(--bg-soft);
  border-left: 4px solid var(--blue);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.96rem;
  color: var(--ink-soft);
}

.content {
  background: var(--paper);
  padding: 36px 0 10px;
}

.content h2 {
  font-size: 1.32rem;
  color: var(--blue-darker);
  margin: 40px 0 12px;
  font-weight: 800;
}
.content h2:first-child { margin-top: 0; }

.content h3 {
  font-size: 1.06rem;
  color: var(--ink);
  margin: 22px 0 8px;
  font-weight: 750;
}

.content p { margin: 0 0 14px; color: var(--ink); }
.content ul, .content ol { margin: 0 0 16px; padding-left: 22px; }
.content li { margin-bottom: 7px; }

.fact-box {
  background: linear-gradient(135deg, #fff8e1, #fff);
  border: 1px solid #f0dfa0;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 20px 0;
}
.fact-box .fact-label {
  font-weight: 800;
  color: var(--orange);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.fact-box ul { margin: 0; padding-left: 20px; }
.fact-box li { margin-bottom: 6px; }

.quote-box {
  border-left: 4px solid var(--orange);
  background: var(--bg-soft);
  padding: 14px 18px;
  margin: 18px 0;
  font-style: italic;
  color: var(--ink-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.example-box {
  background: #eef7ee;
  border: 1px solid #cfe8cf;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 16px 0;
}
.example-box .example-label {
  font-weight: 800;
  color: #2f7d3a;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ---------- Story box (fx "Eventyret om Ilt, Brint og Vand") ---------- */
.story-box {
  background: linear-gradient(135deg, #eaf6f2, #f8fdfc);
  border: 1px solid #cfe8df;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 20px 0;
  overflow: hidden;
}
.story-box .story-image {
  float: right;
  width: 300px;
  max-width: 45%;
  margin: 0 0 14px 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.story-box .story-image img { width: 100%; display: block; }
.story-box .story-text p { margin: 0 0 12px; }
.story-box .story-audio {
  width: 100%;
  margin: 8px 0 6px;
  clear: both;
}
.story-box .story-credit {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 6px 0 0;
  clear: both;
}

/* ---------- Media-left block: image left, text wraps to the right ---------- */
.media-left-block {
  overflow: hidden;
  margin: 20px 0;
}
.media-left-block .media-left-figure {
  float: left;
  width: 260px;
  max-width: 42%;
  margin: 4px 24px 14px 0;
}
.media-left-block p:first-of-type { margin-top: 0; }
@media (max-width: 640px) {
  .media-left-block .media-left-figure { float: none; width: 100%; max-width: 100%; margin: 0 0 14px; }
}
@media (max-width: 640px) {
  .story-box .story-image { float: none; width: 100%; max-width: 100%; margin: 0 0 14px; }
}

table.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 24px;
  font-size: 0.9rem;
}
table.compare th, table.compare td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
table.compare th {
  background: var(--bg-soft);
  color: var(--blue-darker);
  font-weight: 750;
}
table.compare tr:nth-child(even) td { background: #fafcfe; }

.timeline {
  list-style: none;
  margin: 18px 0;
  padding: 0;
  border-left: 3px solid var(--border);
}
.timeline li {
  position: relative;
  padding: 0 0 14px 20px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--blue);
}
.timeline .yr { font-weight: 800; color: var(--blue-darker); margin-right: 6px; }

/* ---------- Videnstige (staircase) ---------- */
.ladder {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 24px 0 30px;
  padding-top: 10px;
}
.ladder-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.ladder-step .bar {
  width: 100%;
  height: var(--h, 60px);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--blue), var(--blue-darker));
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
}
.ladder-step:nth-child(5) .bar { background: linear-gradient(180deg, var(--green), #6f8f22); }
.ladder-step .step-num {
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.22);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ladder-step .label {
  margin-top: 8px;
  font-weight: 800;
  color: var(--blue-darker);
  font-size: 0.85rem;
  text-align: center;
}
.ladder-step .sub {
  font-size: 0.74rem;
  color: var(--ink-soft);
  text-align: center;
}
@media (max-width: 640px) {
  .ladder-step .label { font-size: 0.72rem; }
  .ladder-step .sub { font-size: 0.64rem; }
}

/* ---------- Kapitel-illustrationer ---------- */
.chapter-image {
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
}
.chapter-image img { width: 100%; display: block; }
.chapter-image figcaption {
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}

.image-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.image-row .chapter-image { flex: 1 1 260px; margin: 0; }

.chapter-image.chapter-image-wide img { aspect-ratio: 16 / 9; object-fit: cover; }

/* ---------- Reflection block ---------- */
.reflection {
  background: linear-gradient(135deg, #eaf3fc, #f4f9ff);
  border: 1px solid #cfe1f4;
  border-radius: var(--radius);
  padding: 26px 26px 22px;
  margin: 36px 0;
}

.reflection h2 {
  margin-top: 0 !important;
  color: var(--blue-darker);
  display: flex;
  align-items: center;
  gap: 10px;
}

.reflection .reflection-goal {
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 14px;
}

.reflection ol, .reflection ul { margin: 0 0 14px; padding-left: 22px; }

.reflection textarea {
  width: 100%;
  min-height: 110px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.94rem;
  resize: vertical;
  margin: 6px 0 18px;
}
.reflection textarea:focus {
  outline: none;
  border-color: var(--blue);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--blue);
  flex-shrink: 0;
  cursor: pointer;
}
.check-row label { font-weight: 600; font-size: 0.94rem; cursor: pointer; }

.complete-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.saved-note {
  font-size: 0.8rem;
  color: #2f7d3a;
  font-weight: 700;
  display: none;
  align-items: center;
  gap: 6px;
}
.saved-note.show { display: inline-flex; }

/* ---------- Chapter nav footer ---------- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 30px 0 60px;
  gap: 14px;
  flex-wrap: wrap;
}

.locked-banner {
  max-width: var(--maxw);
  margin: 40px auto;
  padding: 24px;
  background: #fff4e6;
  border: 1px solid #f2d4a8;
  border-radius: var(--radius);
  text-align: center;
}
.locked-banner h2 { color: var(--orange); margin-top: 0; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  background: var(--paper);
}
.site-footer a { color: var(--blue-darker); font-weight: 600; }
.footer-inner { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center;}
.footer-credit {
  font-size: 0.76rem;
  color: var(--ink-soft);
  opacity: 0.75;
  margin-top: 4px;
}

/* ---------- Certificate page ---------- */
.cert-form {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  margin: 30px 0;
}
.cert-form label {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}
.cert-form label:first-of-type { margin-top: 0; }
.cert-form input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}
.cert-form input[type="text"]:focus { outline: none; border-color: var(--blue); }

#cert-preview-wrap {
  margin: 30px 0;
  text-align: center;
}
#cert-canvas {
  width: 100%;
  max-width: 900px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.cert-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ---------- Auth widget (login/signup) ---------- */
.auth-widget {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-hello {
  color: #eaf3fc;
  font-size: 0.86rem;
  font-weight: 600;
}

.auth-open-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.auth-link-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s ease;
}
.auth-link-btn:hover { background: rgba(255,255,255,0.28); }

.auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 20, 34, 0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal-box {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px 26px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px;
}
.auth-modal-close:hover { color: var(--ink); }

.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1.5px solid var(--border);
}

.auth-tabs .tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 6px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
}

.auth-tabs .tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.auth-form label {
  display: block;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}
.auth-form label:first-of-type { margin-top: 0; }

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.96rem;
  font-family: inherit;
}
.auth-form input[type="text"]:focus,
.auth-form input[type="password"]:focus {
  outline: none;
  border-color: var(--blue);
}

.auth-form .btn {
  width: 100%;
  justify-content: center;
  margin-top: 18px;
}

.auth-error {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 12px;
}

.auth-note {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin: 14px 0 0;
}

@media (max-width: 640px) {
  .header-nav { display: none; }
  .cert-card { flex-direction: column; align-items: flex-start; }
  .progress-summary { flex-direction: column; align-items: stretch; }
  .auth-widget { margin-left: auto; }
}
