/* ═══════════════════════════════════════════════════════════════
 *   DEIN ERSTER QM · AFTERSALES — Brand v1.0
 *   Token-basiertes System (siehe /css/tokens.css)
 * ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
@import url('/css/tokens.css');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════
 *   LOGO (Compass-SVG via <use>)
 * ═══════════════════════════════════════════════════════════════ */
.logo-compass { color: var(--terra); flex-shrink: 0; }
.logo-compass-sec { color: var(--ink-3); }

/* ═══════════════════════════════════════════════════════════════
 *   HEADER
 * ═══════════════════════════════════════════════════════════════ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.header-logo span {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.header-progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--ink-3);
}

.header-progress .progress-text {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.progress-bar-wrap {
  width: 120px;
  height: 6px;
  background: var(--canvas-dark);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--terra);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ═══════════════════════════════════════════════════════════════
 *   MAIN
 * ═══════════════════════════════════════════════════════════════ */
.main { flex: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ═══════════════════════════════════════════════════════════════
 *   WELCOME
 * ═══════════════════════════════════════════════════════════════ */
.welcome {
  text-align: center;
  margin-bottom: 2.5rem;
}

.welcome h1 {
  font-family: var(--font-body);
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.welcome p {
  color: var(--ink-2);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════
 *   CATEGORY SECTIONS
 * ═══════════════════════════════════════════════════════════════ */
.category-section { margin-bottom: 2.5rem; }

.category-title {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-title .cat-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--terra);
}

/* ═══════════════════════════════════════════════════════════════
 *   VIDEO CARDS
 * ═══════════════════════════════════════════════════════════════ */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.video-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-terra);
  border-color: var(--border-strong);
}

.video-card.completed { border-color: var(--success); }

/* Skeleton-Shimmer waehrend Thumbnail laedt */
.video-card.is-loading .video-thumb-overlay,
.video-card.is-loading .play-icon,
.video-card.is-loading .video-check { opacity: 0; }
.video-card.is-loading .video-info h3,
.video-card.is-loading .video-info p { color: transparent; background: var(--canvas-dark); border-radius: 4px; }
.video-card.is-loading .video-info p { margin-top: 0.4rem; }
.video-card.is-loading .video-thumb {
  background: linear-gradient(90deg, var(--canvas-dark) 0%, var(--surface) 50%, var(--canvas-dark) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.video-card.is-loading .video-thumb img { opacity: 0; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.video-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--canvas-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.video-thumb-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(20, 17, 14, 0.92));
  padding: 28px 12px 10px;
  color: var(--canvas);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.3;
  z-index: 1;
  pointer-events: none;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-thumb .play-icon {
  position: absolute;
  width: 56px;
  height: 56px;
  background: var(--terra-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(20, 17, 14, 0.25);
  transition: transform 0.2s, background 0.2s;
}

.video-card:hover .play-icon {
  transform: scale(1.08);
  background: var(--terra);
}

.play-icon svg { width: 24px; height: 24px; fill: #fff; margin-left: 3px; }

.video-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(45, 140, 91, 0.3);
}

.video-info { padding: 1rem; }

.video-info h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.video-info p {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-progress-bar {
  height: 3px;
  background: var(--canvas-dark);
}

.video-progress-bar .fill {
  height: 100%;
  background: var(--terra);
  transition: width 0.3s;
}

/* ═══════════════════════════════════════════════════════════════
 *   VIDEO PLAYER VIEW
 * ═══════════════════════════════════════════════════════════════ */
.player-view { display: none; }
.player-view.active { display: block; }
.overview-view.hidden { display: none; }

.player-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--terra);
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 1.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.15s;
}

.player-back:hover { color: var(--terra-dark); }

.player-container {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.player-embed {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
}

.player-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.player-meta { padding: 1.5rem; }

.player-meta h2 {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.player-meta p { color: var(--ink-2); line-height: 1.6; }

.player-nav {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

/* ═══════════════════════════════════════════════════════════════
 *   BUTTONS
 * ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  min-height: 44px;
}

.btn-gold,
.btn-terra {
  background: var(--terra);
  color: var(--ink-inverse);
}

.btn-gold:hover,
.btn-terra:hover { background: var(--terra-dark); }

.btn-sec {
  background: var(--canvas-dark);
  color: var(--ink);
}

.btn-sec:hover { background: var(--ink-4); color: var(--canvas); }

/* ═══════════════════════════════════════════════════════════════
 *   ERROR VIEW
 * ═══════════════════════════════════════════════════════════════ */
.error-view {
  display: none;
  text-align: center;
  padding: 4rem 2rem;
}

.error-view.active { display: block; }

.error-icon {
  width: 80px;
  height: 80px;
  background: var(--terra-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  color: var(--terra);
  font-size: 2rem;
}

.error-view h2 {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.error-view p {
  color: var(--ink-2);
  max-width: 400px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════════
 *   LOADING
 * ═══════════════════════════════════════════════════════════════ */
.loading-view {
  text-align: center;
  padding: 6rem 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--canvas-dark);
  border-top-color: var(--terra);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════
 *   ENTRANCE-ANIMATION (nur erster Render)
 * ═══════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.first-render .category-section {
  opacity: 0;
  animation: fadeSlideUp 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
body.first-render .category-section:nth-of-type(1) { animation-delay: 0ms; }
body.first-render .category-section:nth-of-type(2) { animation-delay: 100ms; }
body.first-render .category-section:nth-of-type(3) { animation-delay: 200ms; }
body.first-render .category-section:nth-of-type(4) { animation-delay: 300ms; }

body.first-render .video-card {
  opacity: 0;
  animation: fadeSlideUp 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
body.first-render .video-card:nth-child(1)  { animation-delay: 50ms; }
body.first-render .video-card:nth-child(2)  { animation-delay: 100ms; }
body.first-render .video-card:nth-child(3)  { animation-delay: 150ms; }
body.first-render .video-card:nth-child(4)  { animation-delay: 200ms; }
body.first-render .video-card:nth-child(5)  { animation-delay: 250ms; }
body.first-render .video-card:nth-child(6)  { animation-delay: 300ms; }
body.first-render .video-card:nth-child(7)  { animation-delay: 350ms; }
body.first-render .video-card:nth-child(8)  { animation-delay: 400ms; }
body.first-render .video-card:nth-child(9)  { animation-delay: 450ms; }
body.first-render .video-card:nth-child(10) { animation-delay: 500ms; }
body.first-render .video-card:nth-child(n+11) { animation-delay: 550ms; }

/* ═══════════════════════════════════════════════════════════════
 *   CSS-ARROWS (statt Unicode &#8592; / &#8594;)
 * ═══════════════════════════════════════════════════════════════ */
.arrow {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  border-style: solid;
  border-color: currentColor;
  vertical-align: -0.04em;
  flex-shrink: 0;
}
.arrow-left  { border-width: 2px 0 0 2px; transform: rotate(-45deg); margin-right: 0.5em; }
.arrow-right { border-width: 2px 2px 0 0; transform: rotate(45deg);  margin-left:  0.5em; }

.loading-view p { color: var(--ink-3); }

/* ═══════════════════════════════════════════════════════════════
 *   FOOTER
 * ═══════════════════════════════════════════════════════════════ */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-top: auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--terra); }

.footer-company { font-size: 0.75rem; color: var(--ink-3); }

/* ═══════════════════════════════════════════════════════════════
 *   LOGIN
 * ═══════════════════════════════════════════════════════════════ */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
}

.login-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-terra);
  border: 1px solid var(--border);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.login-logo span {
  font-family: var(--font-body);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-subtitle {
  color: var(--ink-3);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.login-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--canvas);
  color: var(--ink);
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 44px;
}

.login-input:focus {
  outline: none;
  border-color: var(--terra);
  box-shadow: 0 0 0 3px var(--terra-subtle);
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}

.login-submit {
  width: 100%;
  padding: 0.85rem;
  background: var(--terra);
  color: var(--ink-inverse);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 48px;
}

.login-submit:hover { background: var(--terra-dark); }
.login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════
 *   LOGOUT
 * ═══════════════════════════════════════════════════════════════ */
.logout-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 40px;
}

.logout-btn:hover {
  border-color: var(--border-strong);
  color: var(--terra);
}

/* ═══════════════════════════════════════════════════════════════
 *   RESPONSIVE
 * ═══════════════════════════════════════════════════════════════ */

/* Tablet — 2-spaltiges Video-Grid */
@media (max-width: 900px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 1.75rem; }
}

/* Mobile — 1-spaltig */
@media (max-width: 768px) {
  .header { padding: 0.75rem 1rem; }
  .header-logo span { font-size: 1.05rem; }
  .main { padding: 1.25rem; }
  .welcome h1 { font-size: 1.5rem; }
  .video-grid { grid-template-columns: 1fr; }
  .player-meta h2 { font-size: 1.2rem; }
  .player-nav { flex-direction: column; }
}

/* Small Mobile */
@media (max-width: 480px) {
  .header { padding: 0.5rem 0.75rem; }
  .header-logo span { font-size: 0.95rem; }
  .header-progress { flex-direction: column; gap: 0.25rem; align-items: flex-end; }
  .progress-bar-wrap { width: 80px; }
  .welcome h1 { font-size: 1.3rem; }
  .login-box { padding: 1.75rem 1.5rem; }
}
