/*
  NORTH Design System
  ------------------------------------------------------------
  Brand direction: Nordic / cartographic / technical / calm.
  Shared by both the courses (Banläggning) and mapping (Mapper) apps --
  see shared/templates/shell.html, which every page template extends.
  Framework-free by design so either app can load it directly.
*/

:root {
  --north-bg: #f5f4ef;
  --north-bg-elevated: #fbfaf6;
  --north-surface: #ffffff;
  --north-surface-soft: #eeeee8;
  --north-ink: #111513;
  --north-ink-soft: #303733;
  --north-muted: #69716c;
  --north-faint: #8c948e;
  --north-line: #dfe2dc;
  --north-line-strong: #c8cec7;

  --north-blue: #2457d6;
  --north-blue-dark: #1742ad;
  --north-blue-soft: #e8eefc;
  --north-contour: rgba(36, 87, 214, .13);
  --north-success: #287a55;
  --north-warning: #a66b16;
  --north-danger: #b83b48;

  --north-radius-sm: 8px;
  --north-radius-md: 12px;
  --north-radius-lg: 18px;
  --north-radius-xl: 24px;

  --north-shadow-sm: 0 1px 2px rgba(17,21,19,.04), 0 6px 18px rgba(17,21,19,.05);
  --north-shadow: 0 2px 5px rgba(17,21,19,.05), 0 18px 42px rgba(17,21,19,.08);
  --north-shadow-lg: 0 4px 12px rgba(17,21,19,.06), 0 30px 70px rgba(17,21,19,.12);

  --north-content: 1160px;
  --north-gutter: clamp(20px, 4vw, 48px);
  --north-speed: 160ms;
}

:root[data-theme="dark"] {
  --north-bg: #101413;
  --north-bg-elevated: #151a18;
  --north-surface: #171d1a;
  --north-surface-soft: #1d2521;
  --north-ink: #eef2ee;
  --north-ink-soft: #c6cec8;
  --north-muted: #919b94;
  --north-faint: #69736d;
  --north-line: #2a332e;
  --north-line-strong: #3a4640;
  --north-blue: #79a0ff;
  --north-blue-dark: #9db8ff;
  --north-blue-soft: #182642;
  --north-contour: rgba(121,160,255,.12);
  --north-success: #5bc38d;
  --north-warning: #e0aa58;
  --north-danger: #f07884;
}

/* ---------- global foundation ---------- */
.north-app,
.north-scope {
  color: var(--north-ink);
  background: var(--north-bg);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.north-scope *,
.north-scope *::before,
.north-scope *::after { box-sizing: border-box; }

.north-scope button,
.north-scope input,
.north-scope select,
.north-scope textarea { font: inherit; }

.north-scope a { color: var(--north-blue); text-underline-offset: 3px; }

.north-display,
.north-scope h1,
.north-scope h2,
.north-scope h3 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--north-ink);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -.025em;
}

.north-mono,
.north-scope code,
.north-scope kbd,
.north-scope .mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- application shell ---------- */
.north-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--north-bg);
}

.north-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--north-line);
  background: var(--north-bg-elevated);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.north-main { min-width: 0; }

.north-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--north-ink);
  text-decoration: none;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.north-mark {
  width: 28px;
  height: 28px;
  position: relative;
  display: inline-grid;
  place-items: center;
  color: var(--north-ink);
}

.north-mark::before,
.north-mark::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 21px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

.north-mark::after { transform: rotate(-45deg); }

.north-mark > i {
  position: relative;
  z-index: 1;
  width: 7px;
  height: 7px;
  background: var(--north-bg-elevated);
  border: 2px solid currentColor;
  border-radius: 50%;
}

.north-nav { margin-top: 38px; display: grid; gap: 3px; }
.north-nav-label {
  padding: 10px 12px 7px;
  color: var(--north-faint);
  font: 500 10px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.north-nav a {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--north-muted);
  text-decoration: none;
  font-weight: 500;
  transition: background var(--north-speed), color var(--north-speed);
}

.north-nav a:hover { color: var(--north-ink); background: var(--north-surface-soft); }
.north-nav a[aria-current="page"] { color: var(--north-ink); background: var(--north-surface-soft); font-weight: 600; }

.north-sidebar-footer { margin-top: auto; display: grid; gap: 10px; }

.north-topbar {
  height: 68px;
  padding: 0 var(--north-gutter);
  border-bottom: 1px solid var(--north-line);
  background: color-mix(in srgb, var(--north-bg) 88%, transparent);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 15;
}

/* ---------- layout ---------- */
.north-container { width: min(var(--north-content), calc(100% - 2 * var(--north-gutter))); margin-inline: auto; }
.north-page { padding: 38px 0 80px; }
.north-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.north-page-header h1 { margin: 0; font-size: clamp(30px, 4vw, 46px); }
.north-page-header p { max-width: 58ch; margin: 10px 0 0; color: var(--north-muted); }

.north-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--north-blue);
  font: 500 10px/1 "IBM Plex Mono", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.north-eyebrow::before { content: ""; width: 22px; height: 1px; background: currentColor; }

/* ---------- surfaces ---------- */
.north-card {
  background: var(--north-surface);
  border: 1px solid var(--north-line);
  border-radius: var(--north-radius-lg);
  box-shadow: var(--north-shadow-sm);
}

.north-card:hover { border-color: var(--north-line-strong); }
.north-card-pad { padding: 22px; }
.north-card-compact { border-radius: var(--north-radius-md); }
.north-card-flat { box-shadow: none; }

.north-grid { display: grid; gap: 16px; }
.north-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.north-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.north-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- buttons ---------- */
.north-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--north-speed), background var(--north-speed), border-color var(--north-speed), color var(--north-speed), box-shadow var(--north-speed);
}
.north-btn:hover { transform: translateY(-1px); }
.north-btn:active { transform: translateY(0); }
.north-btn-primary { background: var(--north-ink); color: var(--north-bg-elevated); box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.north-btn-primary:hover { background: #27302b; }
.north-btn-accent { background: var(--north-blue); color: white; }
.north-btn-accent:hover { background: var(--north-blue-dark); }
.north-btn-secondary { background: var(--north-surface); color: var(--north-ink); border-color: var(--north-line-strong); }
.north-btn-ghost { background: transparent; color: var(--north-muted); }
.north-btn-danger { background: var(--north-danger); color: white; }
.north-btn-sm { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.north-btn-lg { min-height: 44px; padding: 10px 18px; }

/* ---------- forms ---------- */
.north-label { display: block; margin-bottom: 7px; color: var(--north-ink-soft); font-size: 12px; font-weight: 600; }
.north-help { margin-top: 6px; color: var(--north-faint); font-size: 12px; }
.north-input,
.north-select,
.north-textarea {
  width: 100%;
  border: 1px solid var(--north-line-strong);
  border-radius: 9px;
  background: var(--north-surface);
  color: var(--north-ink);
  padding: 9px 11px;
  outline: none;
  transition: border-color var(--north-speed), box-shadow var(--north-speed);
}
.north-input:focus,
.north-select:focus,
.north-textarea:focus { border-color: var(--north-blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--north-blue) 15%, transparent); }
.north-textarea { min-height: 120px; resize: vertical; }
.north-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.north-field-full { grid-column: 1 / -1; }

/* ---------- status / metadata ---------- */
.north-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font: 500 11px/1 "IBM Plex Mono", monospace;
  border: 1px solid var(--north-line);
  background: var(--north-surface-soft);
  color: var(--north-muted);
}
.north-badge-blue { color: var(--north-blue); background: var(--north-blue-soft); border-color: color-mix(in srgb, var(--north-blue) 25%, var(--north-line)); }
.north-badge-success { color: var(--north-success); background: color-mix(in srgb, var(--north-success) 10%, var(--north-surface)); }
.north-badge-warning { color: var(--north-warning); background: color-mix(in srgb, var(--north-warning) 10%, var(--north-surface)); }
.north-badge-danger { color: var(--north-danger); background: color-mix(in srgb, var(--north-danger) 10%, var(--north-surface)); }

.north-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.north-meta { color: var(--north-faint); font: 11px/1.4 "IBM Plex Mono", monospace; }

/* ---------- tables / lists ---------- */
.north-table { width: 100%; border-collapse: collapse; }
.north-table th {
  padding: 10px 14px;
  color: var(--north-faint);
  font: 500 10px/1.2 "IBM Plex Mono", monospace;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--north-line);
}
.north-table td { padding: 13px 14px; border-bottom: 1px solid var(--north-line); vertical-align: middle; }
.north-table tr:last-child td { border-bottom: 0; }
.north-table tbody tr:hover { background: var(--north-surface-soft); }

.north-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.north-list li { display: flex; align-items: flex-start; gap: 9px; color: var(--north-ink-soft); }
.north-list li::before { content: "✓"; color: var(--north-success); font-family: "IBM Plex Mono", monospace; }

/* ---------- map / version visual language ---------- */
.north-map {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  border: 1px solid var(--north-line);
  border-radius: var(--north-radius-lg);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--north-blue) 7%, transparent) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(color-mix(in srgb, var(--north-blue) 7%, transparent) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--north-surface);
}

.north-map::before {
  content: "";
  position: absolute;
  inset: -10% -5%;
  opacity: .7;
  background:
    radial-gradient(ellipse 24% 17% at 26% 48%, transparent 48%, var(--north-contour) 49% 50%, transparent 51% 58%, var(--north-contour) 59% 60%, transparent 61% 68%, var(--north-contour) 69% 70%, transparent 71%),
    radial-gradient(ellipse 20% 14% at 68% 34%, transparent 48%, var(--north-contour) 49% 50%, transparent 51% 58%, var(--north-contour) 59% 60%, transparent 61% 68%, var(--north-contour) 69% 70%, transparent 71%);
  pointer-events: none;
}

.north-map-grid { position: absolute; inset: 0; background: linear-gradient(135deg, transparent 49.7%, color-mix(in srgb, var(--north-blue) 20%, transparent) 50%, transparent 50.3%); opacity: .25; }
.north-map-label { position: absolute; left: 18px; top: 16px; color: var(--north-faint); font: 10px "IBM Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.north-map-north { position: absolute; right: 20px; top: 18px; display: grid; gap: 4px; justify-items: center; color: var(--north-ink); font: 600 11px "IBM Plex Mono", monospace; }
.north-map-north::after { content: "↑"; font-size: 22px; line-height: .8; }

.north-version {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--north-line);
}
.north-version:last-child { border-bottom: 0; }
.north-version-node { width: 10px; height: 10px; margin: auto; border-radius: 50%; background: var(--north-surface); border: 2px solid var(--north-blue); position: relative; }
.north-version-node::after { content: ""; position: absolute; top: 8px; left: 2px; width: 2px; height: 36px; background: var(--north-line-strong); }
.north-version:last-child .north-version-node::after { display: none; }
.north-version-current .north-version-node { background: var(--north-blue); }
.north-version-title { color: var(--north-ink); font-weight: 600; }
.north-version-desc { margin-top: 2px; color: var(--north-muted); font-size: 13px; }

/* ---------- drop zone ---------- */
.north-dropzone {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--north-line-strong);
  border-radius: var(--north-radius-lg);
  background: var(--north-bg-elevated);
  color: var(--north-muted);
  transition: border-color var(--north-speed), background var(--north-speed), color var(--north-speed);
}
.north-dropzone:hover,
.north-dropzone.is-dragover { border-color: var(--north-blue); background: var(--north-blue-soft); color: var(--north-ink); }
.north-dropzone strong { color: var(--north-ink); }

/* ---------- command/search ---------- */
.north-search {
  position: relative;
  display: flex;
  align-items: center;
}
.north-search input { padding-left: 36px; }
.north-search svg { position: absolute; left: 12px; color: var(--north-faint); pointer-events: none; }

/* ---------- empty state ---------- */
.north-empty { padding: 64px 24px; text-align: center; }
.north-empty h2 { margin: 10px 0 8px; font-size: 26px; }
.north-empty p { max-width: 48ch; margin: 0 auto 20px; color: var(--north-muted); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .north-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .north-sidebar { padding-inline: 10px; }
  .north-brand span:not(.north-mark) { display: none; }
  .north-nav-label { display: none; }
  .north-nav a { justify-content: center; font-size: 0; }
  .north-nav a svg { width: 20px; height: 20px; }
  .north-grid-3,
  .north-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .north-shell { display: block; }
  .north-sidebar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 62px; padding: 6px 10px; border-right: 0; border-top: 1px solid var(--north-line); flex-direction: row; align-items: center; }
  .north-sidebar > .north-brand,
  .north-sidebar-footer,
  .north-nav-label { display: none; }
  .north-nav { margin: 0; display: flex; flex: 1; justify-content: space-around; }
  .north-nav a { min-width: 48px; }
  .north-main { padding-bottom: 62px; }
  .north-grid-2,
  .north-grid-3,
  .north-grid-4,
  .north-form-grid { grid-template-columns: 1fr; }
  .north-field-full { grid-column: auto; }
  .north-page-header { display: block; }
}

/* ---------- modal (release notes, etc.) ---------- */
.north-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 21, 19, .45);
}
.north-modal-overlay[hidden] { display: none; }
.north-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  overflow: auto;
  padding: 26px 26px 22px;
  background: var(--north-surface);
  border-radius: var(--north-radius-lg);
  box-shadow: var(--north-shadow-lg);
}
.north-modal-close { position: absolute; top: 14px; right: 14px; }
.north-modal-entry { margin-top: 18px; }
.north-modal-entry:first-of-type { margin-top: 14px; }
.north-modal-entry h3 { margin: 0 0 6px; font-size: 15px; }
.north-modal-entry p { margin: 0 0 8px; color: var(--north-ink-soft); }
.north-modal-entry ul { margin: 0 0 8px; padding-left: 20px; color: var(--north-ink-soft); }
.north-modal-entry li { margin: 4px 0; }
.north-modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; }

/* ---------- shell adapter (gitmap-specific, not part of upstream north.css) ---------- */
/* Legacy per-app markup (.appbar/.brand/.glyph, badge-draft/training/released)
   is being retired page by page in favour of shell.html -- these bridge
   rules keep any not-yet-converted page and the version-status vocabulary
   readable under the new tokens without a second parallel stylesheet. */
.badge-draft, .badge-training, .badge-released {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 8px;
  border-radius: 999px; font: 500 11px/1 "IBM Plex Mono", monospace; border: 1px solid var(--north-line);
}
.badge-draft { color: var(--north-muted); background: var(--north-surface-soft); }
.badge-training { color: var(--north-warning); background: color-mix(in srgb, var(--north-warning) 10%, var(--north-surface)); }
.badge-released { color: var(--north-success); background: color-mix(in srgb, var(--north-success) 10%, var(--north-surface)); }
