/* =============================================
   BundID × HISinOne Checkliste — Stylesheet
   Design: Clean / Technical / Institutional
   ============================================= */

/* --- Fonts --- */
/* DM Serif Display (headings) + DM Sans (body) — loaded via HTML */

/* --- Design Tokens --- */
:root,
[data-theme='light'] {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content: 860px;

  /* Fonts */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Colors — Institutional blue-slate palette */
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fb;
  --color-surface-offset: #eef0f4;
  --color-border: #d8dce6;
  --color-divider: #e4e7ef;

  --color-text: #1a1f2e;
  --color-text-muted: #5a6272;
  --color-text-faint: #9aa0b0;

  /* Primary: Deep blue (institutional) */
  --color-primary: #1a4b8c;
  --color-primary-hover: #133a6e;
  --color-primary-highlight: #dde8f7;

  /* Accent: BundID Brand teal */
  --color-accent: #006b7a;
  --color-accent-hover: #00525e;
  --color-accent-highlight: #d0eaed;

  /* Semantic */
  --color-success: #2d7a3e;
  --color-success-bg: #e8f5ec;
  --color-success-border: #a8d9b2;
  --color-warning: #8a5a00;
  --color-warning-bg: #fff7e0;
  --color-warning-border: #f5d070;
  --color-error: #9b2828;
  --color-error-bg: #fef0f0;
  --color-new: #5c3da8;
  --color-new-bg: #f0ecfa;

  /* Phase colors */
  --phase-1: #1a4b8c;
  --phase-2: #006b7a;
  --phase-3: #2d6e4e;
  --phase-4: #7a3d00;
  --phase-5: #5c3da8;
  --phase-6: #8a2040;

  --shadow-sm: 0 1px 3px rgba(26, 31, 46, 0.07);
  --shadow-md: 0 4px 16px rgba(26, 31, 46, 0.09);
  --shadow-lg: 0 12px 40px rgba(26, 31, 46, 0.12);
}

[data-theme='dark'] {
  --color-bg: #111318;
  --color-surface: #191c23;
  --color-surface-2: #1e2229;
  --color-surface-offset: #22262f;
  --color-border: #30343f;
  --color-divider: #282c36;

  --color-text: #d4d8e4;
  --color-text-muted: #7a8094;
  --color-text-faint: #4a5060;

  --color-primary: #6a9fd8;
  --color-primary-hover: #8ab5e6;
  --color-primary-highlight: #1e2d42;

  --color-accent: #3ab8c6;
  --color-accent-hover: #5ecad6;
  --color-accent-highlight: #142830;

  --color-success: #5cac70;
  --color-success-bg: #162419;
  --color-success-border: #2d5a36;
  --color-warning: #d4a030;
  --color-warning-bg: #211a08;
  --color-warning-border: #5a4010;
  --color-error: #e06060;
  --color-error-bg: #1e1010;
  --color-new: #9d80e0;
  --color-new-bg: #1e1832;

  --phase-1: #6a9fd8;
  --phase-2: #3ab8c6;
  --phase-3: #5cac70;
  --phase-4: #d4a030;
  --phase-5: #9d80e0;
  --phase-6: #e06080;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #111318;
    --color-surface: #191c23;
    --color-surface-2: #1e2229;
    --color-surface-offset: #22262f;
    --color-border: #30343f;
    --color-divider: #282c36;
    --color-text: #d4d8e4;
    --color-text-muted: #7a8094;
    --color-text-faint: #4a5060;
    --color-primary: #6a9fd8;
    --color-primary-hover: #8ab5e6;
    --color-primary-highlight: #1e2d42;
    --color-accent: #3ab8c6;
    --color-accent-hover: #5ecad6;
    --color-accent-highlight: #142830;
    --color-success: #5cac70;
    --color-success-bg: #162419;
    --color-success-border: #2d5a36;
    --color-warning: #d4a030;
    --color-warning-bg: #211a08;
    --color-warning-border: #5a4010;
    --color-error: #e06060;
    --color-error-bg: #1e1010;
    --color-new: #9d80e0;
    --color-new-bg: #1e1832;
    --phase-1: #6a9fd8;
    --phase-2: #3ab8c6;
    --phase-3: #5cac70;
    --phase-4: #d4a030;
    --phase-5: #9d80e0;
    --phase-6: #e06080;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-20);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-offset);
  color: var(--color-accent);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================
   HEADER
   ============================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  color: var(--color-primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.1;
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.2;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.overall-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  min-width: 120px;
}

.progress-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.progress-bar-track {
  width: 100%;
  height: 4px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.btn-secondary {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-secondary:hover {
  background: var(--color-divider);
  color: var(--color-text);
}

.btn-primary {
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  border: 1px solid transparent;
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--color-primary-hover); }

/* =============================================
   HERO
   ============================================= */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  padding: clamp(var(--space-10), 6vw, var(--space-20)) var(--space-6);
  color: #fff;
}

.hero-inner {
  max-width: var(--content);
  margin: 0 auto;
}

.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.9);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-5);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  line-height: 1.1;
  color: #fff;
  margin-bottom: var(--space-5);
}

.hero h1 em {
  font-style: italic;
  opacity: 0.85;
}

.hero-desc {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.85);
  max-width: 60ch;
  margin-bottom: var(--space-8);
}

.hero-desc a {
  color: rgba(255,255,255,0.9);
  text-decoration: underline;
}

.hero-stats {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.stat-card {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 90px;
  backdrop-filter: blur(8px);
  transition: background var(--transition);
}

.stat-num {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1;
  color: #fff;
  font-weight: 400;
}

.stat-lbl {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* =============================================
   ENV SWITCHER
   ============================================= */
.env-switcher-wrapper {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-6);
}

.env-switcher {
  max-width: var(--content);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.env-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}

.env-btn {
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.env-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.env-btn:not(.active):hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* =============================================
   MAIN / PHASES
   ============================================= */
.main-content {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.phase {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.phase:hover {
  box-shadow: var(--shadow-md);
}

/* Phase color accents via CSS custom property on each */
#phase-1 { --phase-color: var(--phase-1); }
#phase-2 { --phase-color: var(--phase-2); }
#phase-3 { --phase-color: var(--phase-3); }
#phase-4 { --phase-color: var(--phase-4); }
#phase-5 { --phase-color: var(--phase-5); }
#phase-6 { --phase-color: var(--phase-6); }

.phase-header {
  padding: var(--space-6) var(--space-8);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--phase-color, var(--color-primary));
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.phase-header h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--color-text);
  flex: 1;
}

.phase-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.phase-progress-track {
  width: 80px;
  height: 5px;
  background: var(--color-divider);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.phase-progress-fill {
  height: 100%;
  background: var(--phase-color, var(--color-primary));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.phase-progress-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.phase-desc {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
}

.wiki-link {
  display: inline-block;
  margin-top: var(--space-1);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--phase-color, var(--color-primary)) !important;
  text-decoration: none;
}
.wiki-link:hover { text-decoration: underline; }

/* =============================================
   TASK LIST
   ============================================= */
.task-list {
  padding: var(--space-4) var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
  transition: all var(--transition);
  cursor: default;
}

.task-item:hover {
  background: var(--color-surface-2);
  border-color: var(--color-border);
}

.task-item.task-warn {
  border-left: 3px solid var(--color-warning);
  background: var(--color-warning-bg);
}

.task-item.task-warn:hover {
  background: var(--color-warning-bg);
}

.task-item.task-new {
  border-left: 3px solid var(--color-new);
  background: var(--color-new-bg);
}

.task-item.done {
  opacity: 0.6;
  background: var(--color-success-bg) !important;
  border-color: var(--color-success-border) !important;
}

.task-item.done .task-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Custom Checkbox */
.task-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

input.task-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cb-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  margin-top: 2px;
  transition: all var(--transition);
  position: relative;
}

.cb-custom::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid transparent;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: border-color var(--transition);
}

input.task-cb:checked + .cb-custom {
  background: var(--color-success);
  border-color: var(--color-success);
}

input.task-cb:checked + .cb-custom::after {
  border-color: #fff;
}

.task-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.task-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.3;
}

.task-detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.task-detail a {
  font-size: inherit;
}

.task-meta {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: flex-start;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Tags */
.task-tag {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tag-admin { background: var(--color-primary-highlight); color: var(--color-primary); }
.tag-tech { background: var(--color-accent-highlight); color: var(--color-accent); }
.tag-warn { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning-border); }
.tag-new { background: var(--color-new-bg); color: var(--color-new); }
.tag-extern { background: var(--color-surface-offset); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.tag-test { background: var(--color-success-bg); color: var(--color-success); }
.tag-optional { background: var(--color-surface-offset); color: var(--color-text-faint); border: 1px solid var(--color-border); }
.tag-ops { background: var(--color-primary-highlight); color: var(--color-primary); }

/* =============================================
   SUCCESS BOX
   ============================================= */
.success-box {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--color-success);
  line-height: 1.6;
}

.success-box strong { font-weight: 600; }

.success-final {
  font-size: var(--text-base);
}

.final-links {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

.final-links a {
  color: var(--color-success);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: underline;
}

/* =============================================
   PHASE DONE STATE
   ============================================= */
.phase.phase-complete .phase-header {
  background: var(--color-success-bg);
}

.phase.phase-complete .phase-badge::after {
  content: ' ✓';
}

/* =============================================
   FOOTER
   ============================================= */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-6);
  margin-top: var(--space-10);
}

.footer-inner {
  max-width: var(--content);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.site-footer p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 100%;
}

.footer-links {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* =============================================
   EXPORT TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 640px) {
  .header-inner {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .overall-progress {
    min-width: 80px;
  }

  .hero { padding: var(--space-8) var(--space-4); }

  .hero-stats {
    gap: var(--space-3);
  }

  .stat-card {
    padding: var(--space-3) var(--space-4);
    min-width: 70px;
  }

  .main-content {
    padding: var(--space-6) var(--space-4);
    gap: var(--space-6);
  }

  .phase-header {
    padding: var(--space-4) var(--space-5);
    gap: var(--space-2);
  }

  .phase-desc {
    padding: var(--space-3) var(--space-5);
  }

  .task-list {
    padding: var(--space-3) var(--space-4) var(--space-4);
  }

  .task-item {
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }

  .task-meta {
    padding-top: 0;
  }

  .phase-progress {
    margin-left: 0;
    width: 100%;
  }

  .phase-progress-track {
    flex: 1;
  }
}
