/* Custom Terminal & Sysadmin Styling */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700;800&family=Cinzel:wght@600;700;800;900&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Inter', sans-serif;
  --font-serif: 'Cinzel', Georgia, serif;
}

body {
  font-family: var(--font-sans);
  background-color: #030712; /* Tailwind gray-950 */
  color: #f3f4f6;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #1f2937;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #374151;
}

/* Subtle Terminal Scanline Overlay */
.scanlines {
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 255, 0, 0.03)
  );
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
}

/* ========================================================================= */
/* CERTIFICATE STYLING: DIPLOMA & TRANSCRIPT OF RECORDS                      */
/* ========================================================================= */

.cert-container {
  position: relative;
  transition: all 0.3s ease;
}

.cert-border-inner {
  position: absolute;
  inset: 12px;
  border-radius: 1.25rem;
  pointer-events: none;
}

.cert-watermark-seal {
  position: absolute;
  right: -2rem;
  bottom: -2rem;
  pointer-events: none;
  z-index: 1;
}

/* Dark Theme (Sysadmin Prestige Edition) */
.cert-theme-dark {
  background: radial-gradient(circle at 50% 0%, #0f172a 0%, #020617 70%, #000208 100%);
  border-color: rgba(217, 119, 6, 0.5);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(245, 158, 11, 0.12);
}

.cert-theme-dark .cert-border-inner {
  border: 1.5px solid rgba(245, 158, 11, 0.25);
  outline: 1px dashed rgba(245, 158, 11, 0.15);
  outline-offset: -6px;
}

.cert-theme-dark .cert-badge-republic {
  background-color: rgba(15, 23, 42, 0.85);
  color: #fbbf24;
  border: 1px solid rgba(217, 119, 6, 0.4);
}

.cert-theme-dark .cert-subheading {
  color: #d97706;
}

.cert-theme-dark .cert-title {
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.cert-theme-dark .cert-curriculum {
  color: #94a3b8;
}

.cert-theme-dark .cert-italic {
  color: #cbd5e1;
}

.cert-theme-dark .cert-candidate-name {
  color: #fef08a;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.05), rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.05));
  border: 1px solid rgba(245, 158, 11, 0.3);
  text-shadow: 0 0 15px rgba(250, 204, 21, 0.4);
}

.cert-theme-dark .cert-role-pill {
  background-color: rgba(6, 182, 212, 0.1);
  color: #38bdf8;
  border-color: rgba(6, 182, 212, 0.4);
}

.cert-theme-dark .cert-intro-text {
  color: #cbd5e1;
}

.cert-theme-dark .cert-table-title {
  color: #fbbf24;
}

.cert-theme-dark .cert-muted {
  color: #94a3b8;
}

.cert-theme-dark .cert-table-wrapper {
  background-color: rgba(2, 6, 23, 0.9);
  border-color: rgba(217, 119, 6, 0.3);
}

.cert-theme-dark .cert-table-head {
  background-color: rgba(15, 23, 42, 0.95);
  border-color: rgba(217, 119, 6, 0.3);
  color: #cbd5e1;
}

.cert-theme-dark .cert-table-divide {
  border-color: rgba(30, 41, 59, 0.7);
}

.cert-theme-dark .cert-row-title {
  color: #f1f5f9;
}

.cert-theme-dark .cert-time-cell {
  color: #f8fafc;
}

.cert-theme-dark .cert-score-accent {
  color: #38bdf8;
}

.cert-theme-dark .cert-special-row {
  background-color: rgba(15, 23, 42, 0.4);
  border-color: rgba(217, 119, 6, 0.2);
}

.cert-theme-dark .cert-table-footer {
  background-color: rgba(15, 23, 42, 0.95);
  border-color: rgba(217, 119, 6, 0.4);
  color: #ffffff;
}

.cert-theme-dark .cert-footer-heading {
  color: #fbbf24;
}

.cert-theme-dark .cert-kpi-bar {
  background-color: rgba(2, 6, 23, 0.85);
  border-color: rgba(217, 119, 6, 0.3);
}

.cert-theme-dark .cert-seal-stamp {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.15) 0%, rgba(2, 6, 23, 0.9) 70%);
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.cert-theme-dark .cert-sig-name {
  color: #fde047;
}

/* Light / Parchment Theme (Klassische Urkunde) */
.cert-theme-light {
  background: linear-gradient(135deg, #fdfcf7 0%, #f6f1e3 50%, #faf5ea 100%);
  border-color: #b45309;
  color: #1c1917;
  box-shadow: 0 25px 50px -12px rgba(180, 83, 9, 0.2), 0 0 35px rgba(217, 119, 6, 0.15);
}

.cert-theme-light .cert-border-inner {
  border: 2px solid #b45309;
  outline: 1.5px dashed #d97706;
  outline-offset: -8px;
}

.cert-theme-light .cert-badge-republic {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #d97706;
}

.cert-theme-light .cert-subheading {
  color: #92400e;
}

.cert-theme-light .cert-title {
  color: #78350f;
  text-shadow: 0 1px 3px rgba(180, 83, 9, 0.2);
}

.cert-theme-light .cert-curriculum {
  color: #57534e;
}

.cert-theme-light .cert-italic {
  color: #44403c;
}

.cert-theme-light .cert-candidate-name {
  color: #78350f;
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.05), rgba(217, 119, 6, 0.15), rgba(217, 119, 6, 0.05));
  border: 1px solid #d97706;
  text-shadow: 0 1px 2px rgba(180, 83, 9, 0.2);
}

.cert-theme-light .cert-role-pill {
  background-color: #e0f2fe;
  color: #0369a1;
  border-color: #0284c7;
}

.cert-theme-light .cert-intro-text {
  color: #292524;
}

.cert-theme-light .cert-table-title {
  color: #92400e;
}

.cert-theme-light .cert-muted {
  color: #78716c;
}

.cert-theme-light .cert-table-wrapper {
  background-color: #ffffff;
  border-color: #d97706;
}

.cert-theme-light .cert-table-head {
  background-color: #fef3c7;
  border-color: #d97706;
  color: #78350f;
}

.cert-theme-light .cert-table-divide {
  border-color: #e7e5e4;
}

.cert-theme-light .cert-row-title {
  color: #1c1917;
}

.cert-theme-light .cert-time-cell {
  color: #0f172a;
}

.cert-theme-light .cert-score-accent {
  color: #0369a1;
}

.cert-theme-light .cert-special-row {
  background-color: #fbf7ee;
  border-color: #d97706;
}

.cert-theme-light .cert-table-footer {
  background-color: #fef3c7;
  border-color: #d97706;
  color: #1c1917;
}

.cert-theme-light .cert-footer-heading {
  color: #92400e;
}

.cert-theme-light .cert-kpi-bar {
  background-color: #ffffff;
  border-color: #d97706;
}

.cert-theme-light .cert-time-total {
  color: #0f172a;
}

.cert-theme-light .cert-date {
  color: #b45309;
}

.cert-theme-light .cert-seal-stamp {
  background: radial-gradient(circle, #fef3c7 0%, #fef9c3 60%, #fffbeb 100%);
  border-color: #b45309;
  box-shadow: 0 0 15px rgba(217, 119, 6, 0.25);
}

.cert-theme-light .cert-sig-name {
  color: #78350f;
}

/* ========================================================================= */
/* PRINT OPTIMIZATION (HIGH-PRECISION A4 DIPLOMA / PDF)                      */
/* ========================================================================= */

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 6mm;
  }

  *, *:before, *:after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #ffffff !important;
    color: #1c1917 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 11pt !important;
  }

  /* Hide entire UI navigation, modals, and screen-only controls */
  header, nav, footer, #app-navigation,
  .print\\:hidden, #btn-print-certificate, #btn-toggle-cert-theme,
  #btn-open-glossary, #btn-sound-toggle, #reset-modal, #glossary-modal,
  .certificate-page > div:first-child,
  .certificate-page > div:nth-child(2) {
    display: none !important;
  }

  .certificate-page {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  /* Force pristine certificate printing format */
  #printable-certificate {
    background: #ffffff !important;
    color: #1c1917 !important;
    border: 3px double #b45309 !important;
    border-radius: 0.75rem !important;
    padding: 12mm 14mm !important;
    box-shadow: none !important;
    width: 100% !important;
    margin: 0 auto !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #printable-certificate .cert-border-inner {
    border: 1.5px solid #b45309 !important;
    outline: 1px dashed #d97706 !important;
    outline-offset: -5px !important;
    inset: 6px !important;
  }

  #printable-certificate .cert-badge-republic {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #d97706 !important;
  }

  #printable-certificate .cert-title {
    color: #78350f !important;
    font-size: 26pt !important;
    text-shadow: none !important;
  }

  #printable-certificate .cert-candidate-name {
    color: #78350f !important;
    background: #fffbeb !important;
    border: 1.5px solid #d97706 !important;
    font-size: 22pt !important;
    text-shadow: none !important;
    padding: 4px 16px !important;
  }

  #printable-certificate .cert-role-pill {
    background: #f0f9ff !important;
    color: #0369a1 !important;
    border: 1px solid #0284c7 !important;
  }

  #printable-certificate .cert-table-wrapper {
    background: #ffffff !important;
    border: 1.5px solid #b45309 !important;
  }

  #printable-certificate .cert-table-head {
    background: #fef3c7 !important;
    color: #78350f !important;
    border-bottom: 1.5px solid #b45309 !important;
  }

  #printable-certificate .cert-row-title {
    color: #1c1917 !important;
  }

  #printable-certificate .cert-time-cell {
    color: #0f172a !important;
  }

  #printable-certificate .cert-score-accent {
    color: #0369a1 !important;
  }

  #printable-certificate .cert-table-divide {
    border-color: #e2e8f0 !important;
  }

  #printable-certificate .cert-special-row {
    background: #f8fafc !important;
  }

  #printable-certificate .cert-table-footer {
    background: #fef3c7 !important;
    color: #1c1917 !important;
    border-top: 2px solid #b45309 !important;
  }

  #printable-certificate .cert-kpi-bar {
    background: #fefce8 !important;
    border: 1px solid #d97706 !important;
  }

  #printable-certificate .cert-seal-stamp {
    background: #fffbeb !important;
    border: 2px double #b45309 !important;
    box-shadow: none !important;
  }

  #printable-certificate .cert-sig-name {
    color: #78350f !important;
    border-bottom-color: #78350f !important;
  }

  #printable-certificate .cert-time-total {
    color: #0f172a !important;
  }
}

/* ========================================================================= */
/* EINSTEIGER-HILFEN: Begriffs-Erklärungen, Popover, Simulationen            */
/* ========================================================================= */

.term-help,
.term-help-demo {
  text-decoration: underline dotted rgba(251, 191, 36, 0.85);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: help;
  border-radius: 3px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.term-help:hover,
.term-help:focus-visible {
  background-color: rgba(251, 191, 36, 0.15);
  color: #fde68a;
  outline: none;
}

.term-help::after {
  content: '?';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.95em;
  height: 0.95em;
  margin-left: 2px;
  font-size: 0.65em;
  font-weight: 800;
  vertical-align: super;
  border-radius: 9999px;
  color: #030712;
  background: rgba(251, 191, 36, 0.85);
}

body.beginner-off .term-help {
  text-decoration: none;
  cursor: inherit;
  background: none;
  color: inherit;
}

body.beginner-off .term-help::after {
  display: none;
}

.term-popover {
  position: fixed;
  z-index: 60;
  width: min(380px, calc(100vw - 24px));
  max-height: 70vh;
  overflow-y: auto;
  padding: 14px 16px;
  background: #0b1220;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: termPopIn 0.15s ease-out;
}

.term-popover.term-popover-sheet {
  left: 12px !important;
  right: 12px;
  bottom: 12px;
  top: auto !important;
  width: auto;
}

@keyframes termPopIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.lexicon-entry summary::-webkit-details-marker,
.beginner-sim summary::-webkit-details-marker {
  display: none;
}

.briefing-slide {
  animation: termPopIn 0.25s ease-out;
}

/* Paket-Reise (Netzwerk-Simulation) */
.sim-packet {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 9999px;
  background: #fbbf24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.9);
  transition: left 0.55s ease-in-out, top 0.55s ease-in-out, opacity 0.3s;
  z-index: 5;
  pointer-events: none;
}

.sim-node {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  transition: transform 0.2s, filter 0.2s, opacity 0.2s;
}

.sim-node.sim-node-active {
  transform: translate(-50%, -50%) scale(1.12);
  filter: drop-shadow(0 0 10px rgba(52, 211, 153, 0.7));
}

.sim-row-out {
  opacity: 0.3;
  text-decoration: line-through;
}

.sim-col-out {
  opacity: 0.25;
}

@media print {
  .term-popover, #briefing-modal, .beginner-card { display: none !important; }
  .term-help { text-decoration: none; }
  .term-help::after { display: none; }
}

/* ========================================================================= */
/* MODUL-DESIGN: LINUX ALS KONSOLE                                           */
/* ========================================================================= */

body.theme-linux {
  --tty-green: #4ade80;
  --tty-bright: #d1fae5;
  --tty-text: #a7f3d0;
  --tty-dim: #5f9a71;
  --tty-line: #14532d;
  --tty-bg: #000000;
  --tty-panel: #020a04;
  background-color: var(--tty-bg);
}

body.theme-linux #app-main-content,
body.theme-linux #app-main-content * {
  font-family: var(--font-mono);
}

/* Bildzeilen & leichtes Leuchten wie bei einem Röhrenmonitor */
body.theme-linux::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.22) 3px),
    radial-gradient(ellipse at center, rgba(74, 222, 128, 0.04) 0%, rgba(0, 0, 0, 0.35) 100%);
}

body.theme-linux.fx-off::after {
  display: none;
}

/* Flächen: schwarz statt grau-blau */
body.theme-linux #app-main-content [class*="bg-slate-"],
body.theme-linux #app-main-content [class*="bg-gradient-"],
body.theme-linux #app-main-content [class*="bg-black"] {
  background-color: var(--tty-panel);
  background-image: none;
}

body.theme-linux #app-main-content [class*="border-slate-"] {
  border-color: var(--tty-line);
}

/* Eckig statt abgerundet (außer runde LEDs/Punkte) */
body.theme-linux #app-main-content [class*="rounded"]:not(.rounded-full) {
  border-radius: 2px;
}

body.theme-linux #app-main-content [class*="shadow"] {
  box-shadow: none;
}

/* Schrift: Phosphor-Grün */
body.theme-linux #app-main-content .text-white,
body.theme-linux #app-main-content h2,
body.theme-linux #app-main-content h3 {
  color: var(--tty-bright);
}

body.theme-linux #app-main-content h2,
body.theme-linux #app-main-content h3 {
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.45);
}

body.theme-linux #app-main-content [class*="text-slate-1"],
body.theme-linux #app-main-content [class*="text-slate-2"],
body.theme-linux #app-main-content [class*="text-slate-3"] {
  color: var(--tty-text);
}

body.theme-linux #app-main-content [class*="text-slate-4"],
body.theme-linux #app-main-content [class*="text-slate-5"],
body.theme-linux #app-main-content [class*="text-slate-6"] {
  color: var(--tty-dim);
}

body.theme-linux.fx-off #app-main-content h2,
body.theme-linux.fx-off #app-main-content h3 {
  text-shadow: none;
}

/* Abschnitte als Terminal-Fenster mit Titel im Rahmen */
body.theme-linux .tty-frame {
  position: relative;
  border: 1px solid var(--tty-green) !important;
  padding-top: 2.6rem !important;
}

/* Titelleiste des "Terminal-Fensters" */
body.theme-linux .tty-frame::before {
  content: '── ' attr(data-frame-title) ' ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.3rem 0.75rem;
  font-size: 11px;
  line-height: 1.2rem;
  color: #000;
  background: var(--tty-green);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  z-index: 1;
}

body.theme-linux .tty-prompt {
  color: var(--tty-green);
  font-weight: 700;
  margin-right: 0.5rem;
  font-size: 0.85em;
  white-space: nowrap;
}

/* Buttons im Stil [ Befehl ] */
body.theme-linux #app-main-content button {
  background: transparent;
  background-image: none;
  border: 1px solid var(--tty-green);
  color: var(--tty-green);
  box-shadow: none;
  transition: background-color 0.1s, color 0.1s;
}

body.theme-linux #app-main-content button:hover:not(:disabled),
body.theme-linux #app-main-content button:focus-visible {
  background: var(--tty-green);
  color: #000;
  outline: none;
}

body.theme-linux #app-main-content button *,
body.theme-linux #app-main-content button:hover * {
  color: inherit;
}

/* Eingabefelder */
body.theme-linux #app-main-content input,
body.theme-linux #app-main-content select,
body.theme-linux #app-main-content textarea {
  background: #000;
  color: var(--tty-bright);
  caret-color: var(--tty-green);
  border-color: var(--tty-line);
}

body.theme-linux #app-main-content input:focus,
body.theme-linux #app-main-content select:focus,
body.theme-linux #app-main-content textarea:focus {
  border-color: var(--tty-green);
  outline: none;
}

body.theme-linux #app-main-content ::selection {
  background: var(--tty-green);
  color: #000;
}

/* Unterstrichene Fachbegriffe passend einfärben */
body.theme-linux .term-help {
  text-decoration-color: var(--tty-green);
}

body.theme-linux .term-help::after {
  background: var(--tty-green);
}

/* Statuszeile wie in tmux */
.tty-statusbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #000;
  background: var(--tty-green, #4ade80);
}

.tty-status-tab {
  font-weight: 800;
}

.tty-status-mid {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.theme-linux #app-main-content .tty-statusbar button.tty-status-fx {
  border: none;
  padding: 0;
  color: #000;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

body.theme-linux #app-main-content .tty-statusbar button.tty-status-fx:hover {
  text-decoration: underline;
}

.tty-cursor {
  animation: ttyBlink 1s steps(1) infinite;
}

@keyframes ttyBlink {
  50% { opacity: 0; }
}

/* Start-Einblendung */
.tty-boot {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #000;
  color: #a7f3d0;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2rem 1.25rem;
  cursor: pointer;
  transition: opacity 0.25s;
}

.tty-boot-lines {
  max-width: 48rem;
  margin: 0 auto;
  line-height: 1.7;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.tty-ok {
  color: #4ade80;
  font-weight: 700;
}

.tty-bright {
  color: #fff;
}

.tty-boot-skip {
  position: absolute;
  bottom: 1.25rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: #5f9a71;
}

.tty-boot-out {
  opacity: 0;
}

body.fx-off .tty-cursor {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .tty-cursor { animation: none; }
}

@media print {
  .tty-statusbar, .tty-boot { display: none !important; }
  body.theme-linux::after { display: none; }
}

/* Aktive/ausgewählte Buttons bleiben als gefüllte Fläche erkennbar */
body.theme-linux #app-main-content button.bg-amber-500,
body.theme-linux #app-main-content button.bg-cyan-600.font-bold,
body.theme-linux #app-main-content button.bg-emerald-600.font-bold {
  background: var(--tty-green);
  color: #000;
}

body.theme-linux #app-main-content input[type="checkbox"],
body.theme-linux #app-main-content input[type="range"] {
  accent-color: var(--tty-green);
}

/* Kopfzeile: Beschriftungen nicht umbrechen */
header button,
header nav span,
#hud-total-score {
  white-space: nowrap;
}

body.theme-linux #app-main-content h2,
body.theme-linux #app-main-content h3 {
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
