/* Apple-inspired lesson hub */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.1);
  --radius: 18px;
  --radius-sm: 12px;
  --accent: #0071e3;
  --nav-h: 52px;
  --lesson-navy: #1e3a5f;
  --lesson-purple: #c896d8;
  --lesson-border: #c896d8;
  --lesson-label: #386890;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.47059;
  letter-spacing: -0.022em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(245, 245, 247, 0.72);
  border-bottom: 1px solid var(--border);
}

.top-nav__inner {
  width: min(980px, 100%);
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-nav__logo {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.03em;
}

.top-nav__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 980px;
  font-size: 14px;
  color: var(--accent);
  transition: background 0.2s;
}

.top-nav__back:hover {
  background: rgba(0, 113, 227, 0.08);
}

.top-nav__back svg {
  width: 14px;
  height: 14px;
}

.top-nav__spacer {
  flex: 1;
}

.app-main {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 32px 22px 80px;
}

.page-header {
  text-align: center;
  margin-bottom: 40px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.page-header p {
  margin: 0;
  font-size: 19px;
  color: var(--text-secondary);
  max-width: 560px;
  margin-inline: auto;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.course-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.course-card__badge {
  display: inline-block;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 12px;
}

.course-card__name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.course-card__desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  flex: 1;
}

.course-card__meta {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.list-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  color: inherit;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.list-item__title {
  font-size: 17px;
  font-weight: 500;
}

.list-item__sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.list-item__arrow {
  color: var(--text-secondary);
  font-size: 18px;
  flex-shrink: 0;
  margin-left: 12px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--accent);
}

.breadcrumb span.sep {
  opacity: 0.4;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.lesson-chip {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-align: left;
  width: 100%;
}

.lesson-chip:hover {
  border-color: rgba(0, 113, 227, 0.3);
  box-shadow: var(--shadow);
}

.lesson-chip__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.lesson-chip__sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.lesson-viewport {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-bottom: 40px;
  width: 100%;
}

.lesson-viewport__hint {
  width: min(210mm, 100%);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin: -8px 0 0;
}

.lesson-toolbar {
  width: min(210mm, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.lesson-toolbar__group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, opacity 0.2s;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--secondary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.btn--secondary:hover {
  background: rgba(0, 0, 0, 0.1);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.lesson-counter {
  font-size: 13px;
  color: var(--text-secondary);
}

.a4-page {
  width: 210mm;
  height: auto;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  flex-shrink: 0;
  --a4-fs: 16px;
  --a4-lh: 1.66;
  --a4-label-fs: 14px;
  --a4-title-fs: 18px;
}

@media screen and (max-width: 900px) {
  .lesson-viewport {
    overflow-x: auto;
    align-items: flex-start;
    padding-left: max(12px, calc((100% - 210mm) / 2));
    padding-right: 12px;
  }

  .a4-page {
    width: 210mm;
    height: auto;
  }
}

.a4-header {
  display: flex;
  height: 40px;
  flex-shrink: 0;
}

.a4-header__code {
  width: 56px;
  background: var(--lesson-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
}

.a4-header__title {
  flex: 1;
  background: var(--lesson-purple);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: var(--a4-title-fs);
  font-weight: 500;
  line-height: 1.25;
}

.a4-body {
  flex: 0 0 auto;
  padding: 10px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.a4-row {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
  align-items: stretch;
}

.a4-label {
  width: 32px;
  flex-shrink: 0;
  border: 1.5px solid var(--lesson-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: var(--a4-label-fs);
  font-weight: 700;
  color: var(--lesson-label);
  letter-spacing: 0.12em;
  padding: 8px 0;
  background: #fff;
}

.a4-content {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--lesson-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: var(--a4-fs);
  line-height: var(--a4-lh);
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
}

.a4-content--focus {
  line-height: 1.48;
  padding: 9px 13px;
}

.a4-focus-block {
  margin-bottom: 5px;
}

.a4-focus-block:last-child {
  margin-bottom: 0;
}

.a4-content--focus .a4-section-title {
  display: inline;
  margin: 0 2px 0 0;
  white-space: nowrap;
  color: #b45050;
  font-weight: 600;
  font-size: calc(var(--a4-fs) + 0.5px);
}

.a4-inline-items {
  display: inline;
  word-break: break-word;
}

.a4-sep {
  color: #999;
  font-weight: 400;
  padding: 0 1px;
}

.a4-content:not(.a4-content--focus) .a4-section-title {
  display: block;
  color: #b45050;
  font-weight: 600;
  font-size: calc(var(--a4-fs) + 1px);
  margin-top: 8px;
  margin-bottom: 3px;
}

.a4-content .a4-section-title:first-child {
  margin-top: 0;
}

.a4-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--lesson-purple);
}

.a4-footer::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 28px;
  width: 36px;
  height: 36px;
  background: var(--lesson-purple);
  clip-path: polygon(0 100%, 0 0, 100% 100%);
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .top-nav,
  .lesson-toolbar,
  .breadcrumb,
  .lesson-viewport__hint {
    display: none !important;
  }

  .app-main {
    padding: 0;
    max-width: none;
  }

  .lesson-viewport {
    padding: 0;
  }

  .a4-page {
    box-shadow: none;
    border-radius: 0;
    width: 210mm;
    min-height: 297mm;
    height: auto;
    page-break-after: always;
    break-after: page;
  }

  .a4-content {
    font-size: var(--a4-fs);
  }
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.alert-banner {
  padding: 12px 16px;
  background: rgba(255, 149, 0, 0.12);
  border: 1px solid rgba(255, 149, 0, 0.25);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #996300;
  margin-bottom: 20px;
}
