/* ============================================================
   Self-hosted Monospace Font (box-drawing glyphs)
   ============================================================ */
@font-face {
  font-family: "Fira Mono";
  src: url("/fonts/FiraMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/* ============================================================
   SKILL PACKER — Design Tokens & Theme
   ============================================================ */

:root {
  /* Colors — dark terminal aesthetic */
  --color-bg: #000000;
  --color-text-primary: #ededed;
  --color-text-secondary: rgb(180, 180, 180);
  --color-text-tertiary: rgb(155, 155, 155);
  --color-text-muted: rgb(150, 150, 150);
  --color-border: rgb(42, 42, 42);
  --color-border-strong: rgb(72, 72, 72);
  --color-error: #f87171;
  --color-success: #4ade80;

  /* Typography — cross-platform CJK stacks */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Fira Mono", "SF Mono", "Noto Sans Mono SC", "Sarasa Mono SC", Menlo, Consolas, monospace;

  /* Font sizes */
  --text-body: 1.00rem;
  --text-small: 0.88rem;
  --text-caption: 0.75rem;
  --text-tiny: 0.63rem;

  /* Spacing — 8px scale */
  --space-1: 2px;
  --space-2: 4px;
  --space-3: 8px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 6px;
  --border-default: 1px solid var(--color-border);
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   Container
   ============================================================ */

.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-7);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-6);
}

/* ============================================================
   ASCII Art Header
   ============================================================ */

.header {
  position: relative;
}

.ascii-art {
  font-family: "Fira Mono", var(--font-mono);
  font-size: clamp(0.52rem, 1.4vw, 0.70rem);
  line-height: 1.15;
  color: var(--color-text-primary);
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  padding: var(--space-3) var(--space-2);
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.ascii-tagline {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  margin-top: var(--space-2);
  padding-left: var(--space-2);
}

/* Language Switcher */
#lang-switcher {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1;
}

.lang-switch-btn {
  font-family: var(--font-mono);
  font-size: var(--text-tiny);
  color: var(--color-text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  letter-spacing: 0.06em;
  font-weight: 500;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.lang-switch-btn:hover {
  color: var(--color-text-primary);
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--color-text-tertiary);
  box-shadow: 0 0 12px rgba(237, 237, 237, 0.08);
}

/* ============================================================
   Input Section
   ============================================================ */

.input-section {
  display: flex;
  flex-direction: column;
}

.input-label {
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.input-label a {
  color: var(--color-text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.input-label a:hover {
  color: var(--color-text-primary);
}

.repo-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  line-height: 1.7;
  border: 1px solid var(--color-border-strong);
  padding: 14px 16px;
  resize: vertical;
  min-height: 160px;
  outline: none;
  transition: border-color 200ms ease, background-color 200ms ease, box-shadow 200ms ease;
  border-radius: var(--radius-md);
}

.repo-input::placeholder {
  color: var(--color-text-tertiary);
  opacity: 0.65;
}

.repo-input:hover {
  border-color: var(--color-text-tertiary);
}

.repo-input:focus {
  border-color: var(--color-text-primary);
  background-color: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px var(--color-text-primary), 0 0 24px rgba(237, 237, 237, 0.06);
}

.repo-input:focus::placeholder {
  opacity: 0.35;
}

/* Input meta line */
.input-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.meta-text {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

.meta-divider {
  font-size: var(--text-caption);
  color: var(--color-border-strong);
}

/* hCaptcha disclosure — inside footer, inherits footer text styles */
.hcaptcha-disclosure {
  margin-bottom: var(--space-2);
}

.hcaptcha-disclosure a {
  color: var(--color-text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 200ms ease;
}

.hcaptcha-disclosure a:hover {
  color: var(--color-text-primary);
}

/* ============================================================
   Pack Button
   ============================================================ */

.button-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: var(--space-5);
}

.pack-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-bg);
  background-color: var(--color-text-primary);
  border: 2px solid var(--color-text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
  text-transform: uppercase;
  overflow: hidden;
  min-width: 220px;
}

.pack-button:hover:not(:disabled) {
  background-color: transparent;
  color: var(--color-text-primary);
  box-shadow: 0 0 24px rgba(237, 237, 237, 0.15);
}

.pack-button:active:not(:disabled) {
  transform: scale(0.98);
  transition: transform 100ms ease;
}

.pack-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Loading state */
.pack-button.is-loading {
  pointer-events: none;
}

.pack-button.is-loading .button-label {
  opacity: 0;
}

.pack-button.is-loading .button-loader {
  opacity: 1;
}

.button-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms ease;
}

.button-loader::after {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-bg);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

/* When hovering in loading state (hover state shows transparent bg) */
.pack-button.is-loading:hover {
  background-color: transparent;
}

.pack-button.is-loading:hover .button-loader::after {
  border-color: var(--color-text-primary);
  border-top-color: transparent;
}

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

/* ============================================================
   Status Area
   ============================================================ */

.status-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.status-message {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-small);
  color: var(--color-text-secondary);
  padding: var(--space-4) var(--space-6);
  border: var(--border-default);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

/* Pulse dot for waiting state */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-text-secondary);
  flex-shrink: 0;
}

.status-dot.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50%      { opacity: 1.0;  transform: scale(1.2); }
}

/* Loading dots for processing */
.loading-dots::after {
  content: "...";
  animation: dotsPulse 1.4s ease-in-out infinite;
}

@keyframes dotsPulse {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1.0; }
}

/* Error state */
.status-message.is-error {
  color: var(--color-error);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.06);
}

.status-message.is-error .status-dot {
  background-color: var(--color-error);
}

/* Success state */
.status-message.is-success {
  color: var(--color-success);
  border-color: rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.05);
}

.status-message.is-success .status-dot {
  background-color: var(--color-success);
}

/* ============================================================
   Download Area
   ============================================================ */

.download-area {
  animation: fadeSlideIn 400ms ease both;
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border: var(--border-default);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.download-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.download-icon {
  font-family: var(--font-mono);
  font-size: 1.88rem;
  color: var(--color-text-muted);
  line-height: 1;
}

.download-filename {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--color-text-primary);
  word-break: break-all;
}

.download-size {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.download-button {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--color-text-primary);
  background: transparent;
  border: var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.download-button:hover {
  background-color: var(--color-text-primary);
  color: var(--color-bg);
  border-color: var(--color-text-primary);
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5) var(--space-6);
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

.footer-accent {
  font-family: var(--font-mono);
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: color 200ms ease;
}

.footer-accent:hover {
  color: var(--color-text-primary);
}

/* ============================================================
   Animations
   ============================================================ */

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

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 600px) {
  .container {
    padding: var(--space-7) var(--space-5) var(--space-6);
    gap: var(--space-5);
  }

  .ascii-art {
    font-size: 0.40rem;
    line-height: 1.12;
    padding: var(--space-2);
  }

  #lang-switcher {
    top: var(--space-1);
    right: var(--space-1);
  }

  .lang-switch-btn {
    font-size: 0.55rem;
    padding: 2px 6px;
  }

  .repo-input {
    padding: 12px 14px;
    font-size: var(--text-caption);
    min-height: 140px;
  }

  .pack-button {
    min-width: 180px;
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-small);
  }

  .download-card {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .download-button {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .ascii-art {
    font-size: 0.32rem;
    padding: var(--space-1);
    line-height: 1.1;
  }

  .container {
    padding: var(--space-6) var(--space-4) var(--space-5);
    gap: var(--space-4);
  }

  #lang-switcher {
    top: 0;
    right: 0;
  }

  .lang-switch-btn {
    font-size: 0.5rem;
    padding: 1px 4px;
  }

  .input-label {
    font-size: var(--text-caption);
  }
}
