/* ========================================
   Unfold - 全局样式
   ======================================== */

/* CSS 自定义属性 */
:root {
  --color-primary: #4F46E5;
  --color-primary-hover: #4338CA;
  --color-primary-light: #EEF2FF;
  --color-bg: #F9FAFB;
  --color-surface: #FFFFFF;
  --color-text: #111827;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;
  --color-border: #E5E7EB;
  --color-border-hover: #D1D5DB;
  --color-danger: #EF4444;
  --color-success: #10B981;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --transition: 200ms ease;
  --header-height: 64px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  padding-top: var(--header-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ========================================
   容器
   ======================================== */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ========================================
   头部导航
   ======================================== */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.9);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.header__logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

/* ========================================
   按钮
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn svg {
  flex-shrink: 0;
}

.btn--primary {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn--outline {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--outline:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg);
}

.btn--icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}

.btn--icon:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.btn--full {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
}

/* ========================================
   输入框
   ======================================== */

.input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

.input--textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.5;
}

/* ========================================
   上传面板
   ======================================== */

.upload-panel {
  margin-bottom: 24px;
}

.upload-panel__card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.upload-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.upload-panel__header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

/* 媒体预览 */
.media-preview {
  width: 100%;
  min-height: 200px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--color-bg);
  transition: border-color var(--transition);
}

.media-preview:has(img:not([hidden]), video:not([hidden])) {
  border-style: solid;
  border-color: var(--color-border);
}

.media-preview__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  padding: 40px 20px;
}

.media-preview__image,
.media-preview__video {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
}

/* 操作按钮 */
.upload-panel__actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.upload-panel__actions .btn {
  flex: 1;
}

/* 描述输入 */
.upload-panel__description {
  position: relative;
  margin-bottom: 16px;
}

.upload-panel__char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* 上传进度 */
.upload-progress {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-progress__bar {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.upload-progress__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 300ms ease;
}

.upload-progress__text {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ========================================
   画廊 / 媒体列表
   ======================================== */

.gallery {
  padding-bottom: 40px;
}

.gallery__header {
  margin-bottom: 20px;
}

.gallery__title {
  font-size: 1.25rem;
  font-weight: 600;
}

.gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery__empty,
.gallery__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: var(--color-text-muted);
  text-align: center;
}

/* 媒体卡片 */
.media-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}

.media-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.media-card__thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-bg);
}

.media-card__thumbnail img,
.media-card__thumbnail video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card__type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  color: white;
}

.media-card__body {
  padding: 12px 16px;
}

.media-card__description {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-card__date {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ========================================
   详情页
   ======================================== */

.detail {
  padding-bottom: 40px;
}

.detail__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--color-text-muted);
}

.detail__media {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.detail__image,
.detail__video {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

.detail__info {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.detail__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.detail__type {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.detail__date {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.detail__description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  white-space: pre-wrap;
}

/* ========================================
   评论
   ======================================== */

.comments {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.comments__title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.comments__input {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.comments__input .input--textarea {
  flex: 1;
}

.comments__input .btn {
  align-self: flex-end;
  padding: 10px 20px;
}

.comments__list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comments__empty,
.comments__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  color: var(--color-text-muted);
  text-align: center;
  font-size: 0.875rem;
}

/* 评论项 */
.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.comment-item:last-child {
  border-bottom: none;
}

.comment-item__content {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
}

.comment-item__date {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ========================================
   加载动画
   ======================================== */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner--small {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

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

/* ========================================
   底部
   ======================================== */

.footer {
  border-top: 1px solid var(--color-border);
  padding: 20px 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ========================================
   录制指示器
   ======================================== */

.recording-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #EF4444;
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn--danger {
  background: var(--color-danger);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn--danger:hover {
  background: #DC2626;
  box-shadow: var(--shadow-md);
}

/* ========================================
   工具类
   ======================================== */

[hidden] {
  display: none !important;
}
