/* Novanet Levelup — global stylesheet.
 *
 * Tokens mirror the sibling React apps (DeskBooking/src/client/src/index.css). Keep the values in
 * sync when the brand palette changes. Everything is global on purpose: Blazor scoped CSS does not
 * reach NavLink/AuthorizeView output or MarkupString-rendered markdown.
 */

/* ---------------------------------------------------------------------------
 * Tokens
 * ------------------------------------------------------------------------- */
:root {
  --radius: 0.5rem;
  --font-sans: "Nunito Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Zilla Slab", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Novanet brand colors (from novanet.no)
   * Primary: #50E3C2 (teal/mint), #E7F5F2 (light teal)
   * Secondary: #E3C250 (gold), #F5F2E7 (light gold)
   * Neutral: #3B3B3B (text), #F9F8F6 (background), #FFF (highlight)
   * Error: #B94D4D
   */
  --novanet-teal: oklch(0.82 0.12 175);          /* #50E3C2 */
  --novanet-teal-light: oklch(0.96 0.02 175);    /* #E7F5F2 */
  --novanet-gold: oklch(0.82 0.14 85);           /* #E3C250 */
  --novanet-gold-light: oklch(0.96 0.02 85);     /* #F5F2E7 */
  --novanet-neutral: oklch(0.30 0 0);            /* #3B3B3B */
  --novanet-neutral-light: oklch(0.98 0.005 90); /* #F9F8F6 */

  /* Semantic tokens */
  --background: oklch(0.98 0.005 90);
  --foreground: oklch(0.30 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.30 0 0);
  --primary: oklch(0.30 0 0);
  --primary-foreground: oklch(0.98 0 0);
  --secondary: oklch(0.96 0.005 90);
  --secondary-foreground: oklch(0.30 0 0);
  --muted: oklch(0.96 0.005 90);
  --muted-foreground: oklch(0.5 0 0);
  --accent: oklch(0.82 0.12 175);
  --accent-foreground: oklch(0.20 0 0);
  --destructive: oklch(0.55 0.18 25);
  --border: oklch(0.9 0 0);
  --input: oklch(0.9 0 0);
  --ring: oklch(0.82 0.12 175);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ---------------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------------- */
*,
::before,
::after {
  box-sizing: border-box;
  border-color: var(--border);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

/* FocusOnNavigate moves focus to the first h1 after every navigation */
h1:focus {
  outline: none;
}

p {
  margin: 0 0 1em;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

a:hover {
  color: oklch(0.5 0.1 175);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
}

svg.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------- */
.app-header {
  background: var(--novanet-teal-light);
  color: var(--foreground);
}

.app-header-inner,
.container {
  max-width: 80rem;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand svg {
  height: 2rem;
  width: auto;
}

.app-title {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.app-name {
  font-size: 1rem;
  font-weight: 600;
}

.app-version {
  font-size: 0.75rem;
  color: oklch(0.55 0 0);
}

.container {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .app-header-inner,
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .app-header-inner {
    height: 5rem;
  }

  .brand svg {
    height: 2.5rem;
  }

  .app-title {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .app-name {
    font-size: 1.25rem;
  }

  .container {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 1024px) {
  .app-header-inner,
  .container {
    padding-left: 3rem;
    padding-right: 3rem;
  }
}

/* ---------------------------------------------------------------------------
 * Tab navigation (mirrors shadcn Tabs as used in DeskBooking)
 * ------------------------------------------------------------------------- */
.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: 100%;
  padding: 3px;
  background: var(--muted);
  color: var(--muted-foreground);
  border-radius: var(--radius);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
  transition: color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.tab:hover {
  color: var(--foreground);
}

.tab.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------------------
 * User row
 * ------------------------------------------------------------------------- */
.user {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.user a {
  margin-left: 0.5rem;
}

.user-name-full {
  display: none;
}

@media (min-width: 640px) {
  .user-name-full {
    display: inline;
  }

  .user-name-short {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
 * Components
 * ------------------------------------------------------------------------- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-center {
  max-width: 32rem;
  margin: 4rem auto;
  text-align: center;
}

.card-center > :last-child {
  margin-bottom: 0;
}

/* Buttons (same variants and sizes as SkillMatrix's .btn-base set). Also used on anchors. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #2a2a2a;
  color: var(--primary-foreground);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(80 227 194 / 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--muted);
  color: var(--foreground);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.625rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--muted);
  color: var(--foreground);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.text-muted {
  color: var(--muted-foreground);
}

.text-destructive {
  color: var(--destructive);
}

/* ---------------------------------------------------------------------------
 * Sheet (slide-over panel used for topic content)
 * ------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.3);
  opacity: 0;
  visibility: hidden;
  /* Visibility flips instantly on open (so the panel can take focus) and only after the fade on close. */
  transition: opacity 0.25s ease-out, visibility 0s linear 0.25s;
}

.sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease-out, visibility 0s;
}

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  background: var(--card);
  color: var(--card-foreground);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease-out, visibility 0s linear 0.25s;
}

.sheet.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s ease-out, visibility 0s;
}

.sheet:focus {
  outline: none;
}

@media (min-width: 640px) {
  .sheet {
    width: min(50vw, 640px);
  }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

.sheet-body {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

.sheet-body .checkbox {
  margin-bottom: 1.5rem;
}

/* ---------------------------------------------------------------------------
 * Prose (Markdig output)
 * ------------------------------------------------------------------------- */
.prose > :first-child {
  margin-top: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.prose h1 { font-size: 1.75rem; }
.prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.125rem; }

.prose ul,
.prose ol {
  margin: 0 0 1em;
  padding-left: 1.5rem;
}

.prose li {
  margin: 0.25em 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--muted);
}

.prose pre {
  margin: 0 0 1em;
  padding: 1rem;
  border-radius: var(--radius);
  background: oklch(0.22 0 0);
  color: oklch(0.95 0 0);
  overflow-x: auto;
}

.prose pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.prose blockquote {
  margin: 0 0 1em;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted-foreground);
}

.prose table {
  width: 100%;
  margin: 0 0 1em;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.prose th,
.prose td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--muted);
  font-weight: 600;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* ---------------------------------------------------------------------------
 * Mermaid mindmap
 * ------------------------------------------------------------------------- */
.mermaid {
  display: flex;
  justify-content: center;
  min-height: 16rem;
}

/* The raw mindmap definition is prerendered into the div; hide it until Mermaid replaces it. */
.mermaid:not(:has(svg)) {
  visibility: hidden;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

.mermaid .mindmap-node {
  cursor: pointer;
  transition: opacity 0.15s;
}

.mermaid .mindmap-node:hover {
  opacity: 0.8;
}

/* Mermaid injects id-scoped styles into the SVG, so overrides need !important.
 * Nodes get the same 1px edge as cards; translucent so it works on every fill. */
.mermaid .mindmap-node rect,
.mermaid .mindmap-node circle,
.mermaid .mindmap-node path,
.mermaid .mindmap-node polygon {
  stroke: rgb(0 0 0 / 0.12) !important;
  stroke-width: 1px !important;
}

/* Mermaid underlines each node with the inverted section colour, which is off-brand. */
.mermaid .mindmap-node line {
  display: none;
}

.mermaid svg text {
  font-family: var(--font-sans) !important;
}

/* ---------------------------------------------------------------------------
 * Blazor framework UI
 * ------------------------------------------------------------------------- */
#blazor-error-ui {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 0.75rem 1.5rem 0.75rem 1.25rem;
  background: var(--novanet-gold-light);
  border-top: 2px solid var(--novanet-gold);
  color: var(--foreground);
  box-shadow: 0 -1px 2px rgb(0 0 0 / 0.1);
}

#blazor-error-ui .dismiss {
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  cursor: pointer;
}

.blazor-error-boundary {
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--destructive);
  color: #fff;
}

.blazor-error-boundary::after {
  content: "An error has occurred.";
}
