/* =========================================
   Study Center Layout
   ========================================= */

/* Reset for study page */
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
}

.study-layout {
  max-width: 100vw;
  overflow-x: hidden;
}

/* 学习中心绿色主题色规范 */
:root {
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --accent-color: #4CAF50;
  --text-muted: #64748b;
  --text-primary: #334155;
  --color-primary-rgb: 76, 175, 80;
}

:root[data-theme="dark"] {
  --card-bg: #1e293b;
  --border-color: #334155;
  --accent-color: #66BB6A;
  --text-muted: #94a3b8;
  --text-primary: #e2e8f0;
  --color-primary-rgb: 102, 187, 106;
}

:root[data-theme="sepia"] {
  --card-bg: #fdfaf3;
  --border-color: #e0d8c8;
  --accent-color: #a67c52;
  --text-muted: #8a7a5d;
  --text-primary: #5c4d3a;
  --color-primary-rgb: 166, 124, 82;
}

/* ---- Reusable Section Header Component ---- */

/* 区块标题栏 - 包含左侧标题 + 可选右侧内容(如Tab切换) */
.study-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

/* 标题文字 - 带左侧绿色竖条 */
.study-section-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.study-section-header h3::before {
  content: '';
  display: block;
  width: 3px;
  height: 1em;
  background: var(--accent-color);
  border-radius: 2px;
}

/* Pill Tab 切换栏 - 可选右侧组件 */
.study-section-tabs {
  display: inline-flex;
  gap: 3px;
  background: rgba(0, 0, 0, 0.05);
  padding: 5px;
  border-radius: 16px;
}

:root[data-theme="dark"] .study-section-tabs {
  background: rgba(255, 255, 255, 0.1);
}

:root[data-theme="sepia"] .study-section-tabs {
  background: rgba(93, 77, 58, 0.08);
}

.study-section-tab {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 1.03rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.study-section-tab.active {
  background: var(--card-bg);
  color: var(--color-text);
  box-shadow: 0 2px 4px var(--color-shadow);
}

.study-section-tab:hover:not(.active) {
  color: var(--color-text);
}

/* Main layout: side-by-side */
.study-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Content Area ---- */
.study-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg);
  overflow: hidden;
  /* margin-left is controlled by sidebar.css via html.study-sidebar-active */
}

/* ---- Top Bar — Wired-inspired masthead band ---- */
/* Editorial black-on-white duet. Hairline border carries the elevation;
   no drop shadows. Square geometry, sans labels for structure. */
.study-topbar {
  /* Wired design tokens scoped to the topbar */
  --wired-canvas: var(--color-bg);
  --wired-ink: #000000;
  --wired-body: #757575;
  --wired-hairline: #e0e0e0;
  --wired-font-sans: "Apercu", "Helvetica Neue", Helvetica, Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;            /* spacing.md spacing.xl */
  background-color: var(--wired-canvas);
  border-bottom: 1px solid var(--wired-hairline);
  font-family: var(--wired-font-sans);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

:root[data-theme="dark"] .study-topbar {
  --wired-ink: #f5f5f5;
  --wired-body: #9a9a9a;
  --wired-hairline: #2a2a2a;
}

:root[data-theme="sepia"] .study-topbar {
  --wired-ink: #3d3327;
  --wired-body: #8a7a5d;
  --wired-hairline: #e0d8c8;
}

.study-topbar-left {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Brand / nav link — body-sm-strong (Apercu 14 / 700 / 0.4px tracking) */
.study-topbar-brand {
  font-family: var(--wired-font-sans);
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: 0.4px;
  color: var(--wired-ink);
  text-decoration: none;
  padding: 4px 0;
  transition: opacity 0.15s ease;
}

.study-topbar-brand:hover {
  opacity: 0.55;
}

.study-topbar-separator {
  color: var(--wired-body);
  font-size: 14px;
  margin: 0 8px;                 /* spacing.sm */
  opacity: 0.45;
  user-select: none;
}

.study-topbar-section {
  font-family: var(--wired-font-sans);
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: 0.4px;
  color: var(--wired-ink);
}

/* Module name reads as secondary metadata — body grey, regular weight */
.study-topbar-module-name {
  font-family: var(--wired-font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 18px;
  letter-spacing: 0.4px;
  color: var(--wired-body);
}

.study-topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;                     /* spacing.lg */
}

/* ---- Module Content Area ---- */
.study-module-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Module loading state */
.study-content-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50vh;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ---- Responsive ---- */

/* Tablet and below: overlay sidebar, simplified topbar */
@media screen and (max-width: 1024px) {

  /* Hide study topbar — mobile-top-bar replaces it */
  .study-topbar {
    display: none;
  }
}

/* Mobile specific padding */
@media screen and (max-width: 768px) {
  .study-topbar {
    padding: 8px 12px;
  }

  .study-module-area {
    padding: 0;
  }

  .review-module,
  .spell-module,
  .vocab-module,
  .hl-module,
  .settings-module {
    padding: 12px 8px 24px;
  }
}

/* =========================================================
   WIRED-INSPIRED STUDY SIDEBAR
   Editorial black-and-white duet — square corners, hairline
   dividers, polarity-flipped active state.
   Scoped to <html class="study-sidebar-active">. Shared sidebar.css
   is left untouched; these overrides only apply on the study page.
   ========================================================= */

html.study-sidebar-active {
  --sb-ink: #1a1a1a;
  --sb-canvas: #ffffff;
  --sb-hairline: #e0e0e0;
  --sb-hover: #f5f5f5;
  --sb-label: #757575;
  --sb-on-ink: #ffffff;
  --sb-scrollbar: #c0c0c0;
  --sb-scrollbar-hover: #757575;
}

html[data-theme="dark"].study-sidebar-active {
  --sb-ink: #ededed;
  --sb-canvas: #0a0a0a;
  --sb-hairline: #1f1f1f;
  --sb-hover: #1a1a1a;
  --sb-label: #8a8a8a;
  --sb-on-ink: #0a0a0a;
  --sb-scrollbar: #4a4a4a;
  --sb-scrollbar-hover: #6e6e6e;
}

html[data-theme="sepia"].study-sidebar-active {
  --sb-ink: #3d3327;
  --sb-canvas: #fdfaf3;
  --sb-hairline: #e0d8c8;
  --sb-hover: #f0e9d8;
  --sb-label: #8a7a5d;
  --sb-on-ink: #fdfaf3;
  --sb-scrollbar: #cfc3a8;
  --sb-scrollbar-hover: #a67c52;
}

/* Surface — pure canvas with a hairline right edge, no shadow */
html.study-sidebar-active .sidebar-container {
  background-color: var(--sb-canvas);
  border-right: 1px solid var(--sb-hairline);
  box-shadow: none;
}

/* Header — balanced padding (no horizontal hairline) */
html.study-sidebar-active .sidebar-header {
  padding: 12px 16px;
}

/* PC toggle & close — square, canvas-soft hover */
html.study-sidebar-active .sidebar-pc-toggle,
html.study-sidebar-active .sidebar-close-btn {
  border-radius: 0;
}

html.study-sidebar-active .sidebar-pc-toggle:hover,
html.study-sidebar-active .sidebar-close-btn:hover {
  background-color: var(--sb-hover);
}

/* Primary nav links — Apercu/Inter sans, 18/400/0.2px tracking, square */
html.study-sidebar-active .sidebar-link {
  margin: 0;
  border-radius: 0;
  padding: 11px 20px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.2px;
  color: var(--sb-ink);
  transition: background-color 0.15s ease, color 0.15s ease;
}

html.study-sidebar-active .sidebar-text {
  font-weight: 400;
}

html.study-sidebar-active .sidebar-link:hover {
  background-color: var(--sb-hover);
  color: var(--sb-ink);
}

/* Active — polarity-flipped (ink fill, canvas text) */
html.study-sidebar-active .sidebar-link.active {
  background-color: var(--sb-ink);
  color: var(--sb-on-ink);
  font-weight: 500;
}

html.study-sidebar-active .sidebar-link.active .sidebar-icon.material-symbols-outlined {
  color: var(--sb-on-ink);
  opacity: 1;
}

/* Icons — inherit current text color */
html.study-sidebar-active .sidebar-icon.material-symbols-outlined {
  font-size: 24px;
  width: 24px;
  height: 24px;
  margin-right: 14px;
  opacity: 1;
  color: inherit;
  transition: color 0.15s ease;
}

/* SVG icons — sized to match, tinted via CSS filter so they follow the
   black/white duet. Source SVGs have black paths, so brightness(0) keeps
   them ink and brightness(0) invert(1) flips them to canvas. */
html.study-sidebar-active .sidebar-icon-svg {
  width: 24px;
  height: 24px;
  min-width: 24px;
  margin-right: 14px;
  filter: brightness(0);
  transition: filter 0.15s ease;
  object-fit: contain;
}

/* Active — flip to white (black bg / white icon in light mode) */
html.study-sidebar-active .sidebar-link.active .sidebar-icon-svg {
  filter: brightness(0) invert(1);
}

/* External-link SVG glyph */
html.study-sidebar-active .sidebar-external-icon-svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin-left: 6px;
  opacity: 0.5;
  filter: brightness(0);
  object-fit: contain;
}

html.study-sidebar-active .sidebar-link.active .sidebar-external-icon-svg {
  filter: brightness(0) invert(1);
}

/* Group label — category-eyebrow: small caps, wide tracking */
html.study-sidebar-active .sidebar-group-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.2px;
  color: var(--sb-label);
  padding: 24px 20px 6px;
  margin: 0;
  text-transform: uppercase;
}

html.study-sidebar-active .sidebar-menu > .sidebar-group-label:first-child {
  padding-top: 14px;
}

/* Bottom area — no top hairline */
html.study-sidebar-active .sidebar-bottom {
  padding: 4px 0;
  background-color: var(--sb-canvas);
}

/* External-link glyph keeps a quiet opacity */
html.study-sidebar-active .sidebar-external-icon {
  color: currentColor;
  opacity: 0.5;
}

/* Collapsed desktop — remove icon margin so icon sits cleanly */
html.study-sidebar-active.study-sidebar-collapsed .sidebar-link {
  padding: 11px 0;
}

html.study-sidebar-active.study-sidebar-collapsed .sidebar-icon.material-symbols-outlined,
html.study-sidebar-active.study-sidebar-collapsed .sidebar-icon-svg {
  margin-right: 0;
}

/* Collapsed: hide external-link glyph so only the main icon shows */
html.study-sidebar-active.study-sidebar-collapsed .sidebar-external-icon {
  display: none;
}

/* ---- Dark theme: SVG/Material icon filters (colors follow --sb-* tokens) ---- */
html[data-theme="dark"].study-sidebar-active .sidebar-icon.material-symbols-outlined {
  color: inherit;
  opacity: 1;
  filter: none;
}

/* SVG icons — dark mode inverts the tint (default = white, active = black) */
html[data-theme="dark"].study-sidebar-active .sidebar-icon-svg,
html[data-theme="dark"].study-sidebar-active .sidebar-external-icon-svg {
  filter: brightness(0) invert(1);
}

html[data-theme="dark"].study-sidebar-active .sidebar-link.active .sidebar-icon-svg,
html[data-theme="dark"].study-sidebar-active .sidebar-link.active .sidebar-external-icon-svg {
  filter: brightness(0);
}

/* Mobile overlay sidebar — keep the square aesthetic, drop the right border */
@media screen and (max-width: 1024px) {
  html.study-sidebar-active .sidebar-container {
    border-right: none;
  }
}

/* Sidebar scrollbar — thin track, square thumb, hairline hover.
   Applied globally to every scrollable surface inside the study page
   (sidebar menu, module content area, module-internal panels). */
html.study-sidebar-active *,
html.study-sidebar-active *::before,
html.study-sidebar-active *::after {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-scrollbar) transparent;
}

html.study-sidebar-active ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html.study-sidebar-active ::-webkit-scrollbar-track,
html.study-sidebar-active ::-webkit-scrollbar-corner {
  background: transparent;
}

html.study-sidebar-active ::-webkit-scrollbar-thumb {
  background-color: var(--sb-scrollbar);
  border-radius: 0;
  border: 2px solid transparent;
  background-clip: padding-box;
}

html.study-sidebar-active ::-webkit-scrollbar-thumb:hover {
  background-color: var(--sb-scrollbar-hover);
}

/* ---- Article List Module (shared by checkin, bookmarks, history) ---- */

.study-article-list {
  padding: 2rem 0;
  position: relative;
  overflow: hidden;
}

.study-article-list > .study-article-container,
.study-article-list > .study-show-more-btn {
  position: relative;
  z-index: 1;
}

.study-show-more-btn {
  margin-top: 2rem;
  padding: 1rem;
  font-size: 17px;
  box-shadow: 0 4px 19px var(--color-shadow);
  background-color: var(--show-more-btn-background, #000409);
  color: var(--show-more-btn-text-color, #ffffff);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color var(--transition-duration, 0.3s);
  max-width: 350px;
  margin-left: auto;
  margin-right: auto;
}

:root[data-theme="dark"] .study-show-more-btn {
  --show-more-btn-background: #f9f9fa;
  --show-more-btn-text-color: #040404;
}

.study-show-more-btn:hover {
  background-color: var(--show-more-btn-hover-background, #5a5b5d);
}

:root[data-theme="dark"] .study-show-more-btn:hover {
  background-color: #656566;
}

:root[data-theme="sepia"] .study-show-more-btn {
  --show-more-btn-background: #3d3327;
  --show-more-btn-text-color: #fdfaf3;
}

:root[data-theme="sepia"] .study-show-more-btn:hover {
  background-color: #5c4d3a;
}
/* =========================================
   Module Nav — bottom prev/next navigation
   Rendered at the end of every study module
   ========================================= */

.study-module-nav {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
  padding: 24px 16px 40px;
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  flex-shrink: 0;
}

.module-nav-btn {
  flex: 0 1 320px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  box-shadow: 0 1px 2px var(--color-shadow);
}

.module-nav-prev {
  justify-content: flex-start;
}

.module-nav-next {
  justify-content: flex-end;
  text-align: right;
}

.module-nav-btn:hover {
  border-color: var(--color-text-muted);
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] .module-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

:root[data-theme="sepia"] .module-nav-btn:hover {
  background: rgba(93, 77, 58, 0.06);
}

.module-nav-btn:active {
  transform: translateY(1px);
}

.module-nav-icon {
  font-size: 22px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.module-nav-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.module-nav-label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.module-nav-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Responsive ---- */
@media screen and (max-width: 768px) {
  .study-module-nav {
    padding: 16px 8px 24px;
    gap: 8px;
  }

  .module-nav-btn {
    padding: 10px 12px;
    gap: 6px;
    min-width: 0;
  }

  .module-nav-icon {
    font-size: 20px;
  }

  .module-nav-label {
    font-size: 0.7rem;
  }

  .module-nav-name {
    font-size: 0.82rem;
  }
}

@media screen and (max-width: 420px) {
  /* On very narrow screens, allow the name to wrap so it stays readable
     instead of being truncated to nothing */
  .module-nav-name {
    white-space: normal;
    line-height: 1.2;
  }
}
