/* Desktop-specific overrides — native macOS feel.
 *
 * Goal: make the Tauri window look like a real macOS app (Mail/Notes/Finder
 * style) instead of a web page wrapper. Key techniques:
 *
 *   1. Transparent body background so the NSVisualEffectView vibrancy
 *      applied in lib.rs shows through.
 *   2. System font (-apple-system) instead of Nunito.
 *   3. Title bar overlay: pad the top bar so content clears the traffic
 *      lights, and let the vibrancy tint the toolbar area.
 *   4. Tighter native spacing — macOS apps use ~4-8px gaps, not 16-24px.
 *   5. No box shadows on cards; rely on subtle background separation.
 */

:root {
  --desktop-sidebar-width: 240px;
  /* macOS system colors (light mode approximations; the OS handles dark
     mode automatically via the vibrancy layer). */
  --mac-text-primary: rgba(0, 0, 0, 0.92);
  --mac-text-secondary: rgba(0, 0, 0, 0.55);
  --mac-text-tertiary: rgba(0, 0, 0, 0.40);
  --mac-separator: rgba(0, 0, 0, 0.10);
  --mac-hover: rgba(0, 0, 0, 0.06);
  --mac-active: rgba(0, 0, 0, 0.10);
  --mac-accent: rgba(255, 149, 0, 0.85);
}

/* ── Body / window background ──
 * Transparent so the NSVisualEffectView shows through. The vibrancy
 * material is "Sidebar" which is appropriately subtle. */
body.kid {
  --kid-page-margin: 0px !important;
  --kid-page-height: 100vh !important;
  --kid-topbar-height: 52px !important;
  background: transparent !important;
  color: var(--mac-text-primary) !important;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "SF Pro Display", "PingFang SC", "Hiragino Sans GB", sans-serif !important;
  padding: 0 !important;
  padding-bottom: 0 !important;
}

body.kid .kid-app-root {
  height: 100vh !important;
  min-height: 100vh !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  overflow: visible !important;
}

body.kid .kid-topbar {
  top: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
}

/* Override the Nunito font variable set in styles.css */
body.kid {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "SF Pro Display", "PingFang SC", "Hiragino Sans GB", sans-serif !important;
}

/* ── Top bar (title bar overlay region) ──
 * macOS traffic lights sit at (16, 18) and are ~14px tall, so the
 * interactive area extends to roughly x=78. Pad the header so brand
 * identity and controls never collide with the lights. */
body.kid header.sticky {
  background: rgba(246, 246, 246, 0.6) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--mac-separator) !important;
  box-shadow: none !important;
}

body.kid header.sticky > div {
  padding-left: 84px !important;
  height: 52px !important;
}

/* Drag region: Tauri v2 handles `data-tauri-drag-region` natively in the
 * webview. Interactive elements (button, a, input) automatically opt out
 * per Tauri's drag region spec, so no extra CSS is needed. */

/* Tighten header content */
body.kid header.sticky .kid-top-identity {
  height: 28px !important;
  font-size: 13px !important;
}

/* Brand mark removed — the toolbar now leads with the current identity
 * (learner name) instead of a redundant app name. */

/* Segmented control — native macOS style */
body.kid .segmented {
  background: rgba(0, 0, 0, 0.06) !important;
  border-radius: 6px !important;
  padding: 2px !important;
  border: none !important;
  box-shadow: none !important;
}

body.kid .segmented-option {
  padding: 4px 10px !important;
  font-size: 13px !important;
  border-radius: 4px !important;
  border: none !important;
  background: transparent !important;
  color: var(--mac-text-secondary) !important;
}

body.kid .segmented-option[data-active="true"] {
  background: #fff !important;
  color: var(--mac-text-primary) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04) !important;
}

/* ── Sidebar ── */
.kid-reader-aside {
  width: var(--desktop-sidebar-width) !important;
  flex-shrink: 0;
  background: transparent !important;
  border-right: 1px solid var(--mac-separator) !important;
}

.kid-reader-aside .kid-aside-header {
  padding: 10px 12px 6px 12px !important;
  gap: 6px !important;
}

.kid-reader-aside .kid-aside-header .heading-17 {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase !important;
  color: var(--mac-text-tertiary) !important;
}

/* Sidebar list container — override the outer padding wrapper. */
.kid-reader-aside > .p-4 {
  padding: 4px 6px !important;
}

/* ── News list items ──
 * Native macOS sidebar list rows: tight, transparent, with a subtle
 * rounded hover/active state (like Mail/Finder). */
.kid-news-item {
  display: block;
  width: 100%;
  margin-top: 1px !important;
  padding: 5px 8px 5px 12px !important;
  border-radius: 5px !important;
  background: transparent !important;
  border: none !important;
}
.kid-news-item:first-child {
  margin-top: 0 !important;
}

/* Active indicator bar — keep the warm accent but tighter */
.kid-news-item[data-active="true"] {
  background: var(--mac-active) !important;
}
.kid-news-item[data-active="true"]::before {
  top: 7px !important;
  bottom: 7px !important;
  left: 3px !important;
  width: 3px !important;
  border-radius: 2px !important;
  background: var(--mac-accent) !important;
}

/* Mastered badge */
.kid-news-item[data-read="mastered"]::after {
  top: 3px !important;
  right: 6px !important;
  padding: 1px 5px !important;
  font-size: 9px !important;
  font-weight: 600 !important;
  border-radius: 3px !important;
  background: rgba(0, 0, 0, 0.08) !important;
  color: var(--mac-text-secondary) !important;
}

/* Internal layout of each news item */
.kid-news-item > * {
  margin: 0 !important;
}
.kid-news-item > *:first-child {
  margin-bottom: 2px !important;
  font-size: 10px !important;
  line-height: 1.3 !important;
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  color: var(--mac-text-tertiary) !important;
}
.kid-news-item > *:first-child span {
  font-size: 10px !important;
}
.kid-news-item > *:first-child span.font-semibold {
  color: var(--mac-text-secondary) !important;
  font-weight: 600 !important;
}

/* Title */
.kid-news-title {
  font-size: 13px !important;
  line-height: 1.35 !important;
  color: var(--mac-text-primary) !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}
.kid-news-item[data-read="unread"] .kid-news-title {
  font-weight: 700 !important;
}
.kid-news-item[data-active="true"] .kid-news-title {
  color: var(--mac-accent) !important;
}

/* Summary */
.kid-news-item > *:last-child {
  margin-top: 1px !important;
  font-size: 11px !important;
  line-height: 1.3 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: var(--mac-text-tertiary) !important;
}

/* Infinite-scroll footer */
.kid-news-sentinel { height: 1px !important; }
.kid-news-loading-more,
.kid-news-end {
  padding: 8px 10px !important;
  font-size: 10px !important;
  color: var(--mac-text-tertiary) !important;
}

/* ── Article body ── */
.kid-paragraph {
  margin-bottom: 1rem !important;
  line-height: 1.65 !important;
  color: var(--mac-text-primary) !important;
}

/* ── Hero / header ── */
.kid-reader-main > header {
  padding: 10px 16px !important;
}
.kid-reader-main > header .heading-24 {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: var(--mac-text-primary) !important;
}
.kid-reader-main > header .copy-13 {
  font-size: 12px !important;
  color: var(--mac-text-secondary) !important;
}

/* ── Tab bar ── */
.kid-tabs {
  padding: 4px 16px !important;
  border-bottom: 1px solid var(--mac-separator) !important;
}
.kid-tabs button {
  padding: 6px 12px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--mac-text-secondary) !important;
  border: none !important;
  background: transparent !important;
  border-radius: 4px !important;
}
.kid-tabs button[data-active="true"],
.kid-tabs button.active {
  color: var(--mac-accent) !important;
  background: rgba(255, 149, 0, 0.10) !important;
}

/* ── Cards / panels ──
 * Native macOS apps don't use heavy card shadows. Use a subtle
 * background tint + 1px border instead. */
.card {
  padding: 14px !important;
  background: rgba(255, 255, 255, 0.55) !important;
  border: 1px solid var(--mac-separator) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

/* AI tutor panel */
.kid-tutor-panel {
  padding: 14px !important;
  gap: 10px !important;
  background: rgba(255, 255, 255, 0.55) !important;
  border: 1px solid var(--mac-separator) !important;
}
.kid-tutor-panel header {
  padding-bottom: 8px !important;
  border-bottom: 1px solid var(--mac-separator) !important;
}
.kid-tutor-panel section {
  gap: 8px !important;
}
.kid-tutor-panel .btn {
  padding: 7px 12px !important;
  font-size: 13px !important;
  border-radius: 6px !important;
}

/* Bottom dock */
.kid-dock {
  padding: 8px 16px !important;
  gap: 12px !important;
  background: transparent !important;
  border-top: 1px solid var(--mac-separator) !important;
}
.kid-dock .btn {
  padding: 7px 14px !important;
  font-size: 13px !important;
  border-radius: 6px !important;
}

/* ── Buttons ──
 * Native macOS button style: rounded, subtle. */
.btn {
  font-weight: 500 !important;
  border-radius: 6px !important;
  transition: background 0.15s ease, color 0.15s ease !important;
}
.btn-primary {
  background: var(--mac-accent) !important;
  color: #fff !important;
  box-shadow: none !important;
}
.btn-primary:hover {
  background: rgba(255, 149, 0, 1) !important;
}
.btn-secondary,
.btn-tertiary {
  background: rgba(0, 0, 0, 0.05) !important;
  color: var(--mac-text-primary) !important;
  border: none !important;
  box-shadow: none !important;
}
.btn-secondary:hover,
.btn-tertiary:hover {
  background: rgba(0, 0, 0, 0.10) !important;
}

/* ── Font sizes ── */
.copy-14 { font-size: 13px !important; }
.copy-15 { font-size: 14px !important; }
.prose-19 { font-size: 15px !important; line-height: 1.65 !important; }
.prose-20 { font-size: 16px !important; line-height: 1.65 !important; }
.heading-17 { font-size: 13px !important; }
.heading-18 { font-size: 15px !important; }

/* ── Scrollbar ──
 * macOS native overlay scrollbar: thin, only visible on hover. */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
  background-clip: content-box;
}

/* ── Subviews: text colors ──
 * Use macOS-style text colors everywhere. */
.text-gray-1000 { color: var(--mac-text-primary) !important; }
.text-gray-900  { color: var(--mac-text-primary) !important; }
.text-gray-800  { color: var(--mac-text-primary) !important; }
.text-gray-700  { color: var(--mac-text-secondary) !important; }
.text-gray-600  { color: var(--mac-text-secondary) !important; }
.text-gray-500  { color: var(--mac-text-tertiary) !important; }

/* Borders */
.kid-reader-aside,
.kid-tabs,
.kid-dock,
.kid-tutor-panel header {
  border-color: var(--mac-separator) !important;
}

/* ── AI 小老师 docked layout ──
 * In the Tauri desktop window (≥1024px) the chat panel docks to the right
 * and the reading shell reserves space for it via padding-right. Use
 * macOS-native styling: translucent panel, subtle border, no heavy shadow. */
.kid-reading-shell[data-chat-docked="true"] {
  padding-right: 360px !important;
}

.kid-chat-aside {
  background: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
  border-left: 1px solid var(--mac-separator) !important;
  overflow: hidden !important;
  box-shadow: none !important;
}

.kid-chat-aside[data-docked="true"] {
  right: 12px !important;
  top: 60px !important;
  height: calc(100dvh - 60px - 12px) !important;
  width: min(348px, calc(100vw - 260px - 24px)) !important;
  border: 1px solid var(--mac-separator) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}
