@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

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

body.hub-kor,
body.hub-math,
body.hub-eng {
  font-family:
    "Pretendard",
    "Noto Sans KR",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #1e293b;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 56px;
  -webkit-font-smoothing: antialiased;
}

body.hub-kor {
  --hub-accent: #8b6f82;
  --hub-accent-strong: #6f5568;
  --hub-accent-soft: #f3edf1;
  --hub-surface: #ffffff;
  --hub-line: #e8e0e5;
  --hub-muted: #64748b;
  background: linear-gradient(165deg, #faf7f9 0%, #f3eef2 42%, #f8f9fb 100%);
}

body.hub-math {
  --hub-accent: #5b7c99;
  --hub-accent-strong: #3f5f7a;
  --hub-accent-soft: #edf2f7;
  --hub-surface: #ffffff;
  --hub-line: #dde5ec;
  --hub-muted: #64748b;
  background: linear-gradient(165deg, #f8fafc 0%, #eef3f8 45%, #f9fafb 100%);
}

body.hub-eng {
  --hub-accent: #4a8fa8;
  --hub-accent-strong: #2f6d86;
  --hub-accent-soft: #eef5f8;
  --hub-surface: #ffffff;
  --hub-line: #d4e4ec;
  --hub-muted: #64748b;
  background: linear-gradient(165deg, #f7fafb 0%, #eaf4f7 45%, #f8fafb 100%);
}

/* 학습지 허브: 80% 축소 + 데스크탑 가로 전폭 활용 (국어·수학·영어 동일) */
body.hub-kor .hub-scale,
body.hub-math .hub-scale,
body.hub-eng .hub-scale {
  zoom: 0.8;
  max-width: none;
  width: calc(100vw - 24px);
  margin: 0 auto;
}

@supports not (zoom: 0.8) {
  body.hub-kor .hub-scale,
  body.hub-math .hub-scale,
  body.hub-eng .hub-scale {
    transform: scale(0.8);
    transform-origin: top center;
    width: calc(125vw - 30px);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
  }
}

body.hub-kor .hub-scale .hub-header,
body.hub-math .hub-scale .hub-header,
body.hub-eng .hub-scale .hub-header {
  position: relative;
  top: auto;
}

body.hub-kor .hub-scale .hub-wrap,
body.hub-math .hub-scale .hub-wrap,
body.hub-eng .hub-scale .hub-wrap {
  max-width: none;
  width: 100%;
  padding: 28px 12px 40px;
}

@media (min-width: 1100px) {
  body.hub-kor .hub-scale .hub-pdf-grid,
  body.hub-math .hub-scale .hub-pdf-grid,
  body.hub-eng .hub-scale .hub-pdf-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
  }

  body.hub-kor .hub-scale .hub-pdf-card,
  body.hub-math .hub-scale .hub-pdf-card,
  body.hub-eng .hub-scale .hub-pdf-card {
    padding: 18px 10px 14px;
    min-height: 124px;
    gap: 14px;
  }

  body.hub-kor .hub-scale .hub-worksheet-card,
  body.hub-math .hub-scale .hub-worksheet-card,
  body.hub-eng .hub-scale .hub-worksheet-card {
    min-height: 136px;
  }

  body.hub-kor .hub-scale .hub-pdf-name,
  body.hub-kor .hub-scale .hub-formula-title,
  body.hub-math .hub-scale .hub-pdf-name,
  body.hub-math .hub-scale .hub-formula-title,
  body.hub-eng .hub-scale .hub-pdf-name,
  body.hub-eng .hub-scale .hub-formula-title {
    font-size: 0.9rem;
  }

  body.hub-kor .hub-scale .hub-pdf-btn,
  body.hub-math .hub-scale .hub-pdf-btn,
  body.hub-eng .hub-scale .hub-pdf-btn {
    max-width: 100%;
    font-size: 0.82rem;
    padding: 9px 8px;
  }

  body.hub-kor .hub-scale .hub-worksheet-desc,
  body.hub-math .hub-scale .hub-worksheet-desc,
  body.hub-eng .hub-scale .hub-worksheet-desc {
    font-size: 0.76rem;
  }

  body.hub-kor .hub-scale .hub-zone-row,
  body.hub-math .hub-scale .hub-zone-row,
  body.hub-eng .hub-scale .hub-zone-row {
    padding: 16px 14px;
    gap: 12px 14px;
  }
}

.hub-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 16px 120px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hub-line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.hub-back {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--hub-line);
  background: var(--hub-surface);
  color: var(--hub-accent-strong);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.hub-back:hover {
  background: var(--hub-accent-soft);
  border-color: color-mix(in srgb, var(--hub-accent) 35%, white);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.hub-title {
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--hub-accent-strong);
  text-align: center;
  line-height: 1.35;
}

.hub-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.hub-pdf-section {
  scroll-margin-top: 88px;
  margin-bottom: 28px;
}

.hub-pdf-section:first-child {
  margin-top: 4px;
}

/* 단계 | 구역 | 카드 3열 레이아웃 */
.hub-stage-layout {
  display: flex;
  align-items: stretch;
  background: var(--hub-surface);
  border: 1px solid var(--hub-line);
  border-radius: 18px;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.hub-stage-label {
  flex-shrink: 0;
  width: 118px;
  padding: 22px 14px;
  border-right: 2px solid var(--hub-line);
  background: var(--hub-accent-soft);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: var(--hub-accent-strong);
  word-break: keep-all;
}

.hub-stage-zones {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hub-zone-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 16px 20px;
  align-items: start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--hub-line);
}

.hub-zone-row:last-child {
  border-bottom: none;
}

.hub-zone-label {
  margin: 0;
  padding-top: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.02em;
  color: #334155;
  word-break: keep-all;
}

.hub-zone-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.hub-zone-desc {
  margin: 0;
  padding: 0 0 2px;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--hub-muted);
  word-break: keep-all;
}

.hub-zone-cards {
  width: 100%;
}

.hub-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hub-muted);
  margin: 36px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hub-line);
}

.hub-pdf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.hub-pdf-card {
  background: var(--hub-surface);
  border-radius: 16px;
  padding: 22px 18px 18px;
  border: 1px solid var(--hub-line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 132px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.hub-pdf-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--hub-accent) 28%, white);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.hub-pdf-name {
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.02em;
  color: #0f172a;
  word-break: keep-all;
}

.hub-pdf-btn {
  width: 100%;
  max-width: 160px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 11px 16px;
  border-radius: 10px;
  border: none;
  background: var(--hub-accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.hub-pdf-btn:hover {
  background: var(--hub-accent-strong);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--hub-accent) 40%, transparent);
}

.hub-pdf-btn:active {
  transform: scale(0.98);
}

.hub-subsection-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--hub-accent-strong);
  margin: 22px 0 12px;
  padding-left: 2px;
}

.hub-pdf-section:first-child .hub-subsection-title:first-of-type {
  margin-top: 4px;
}

.hub-worksheet-card {
  min-height: 118px;
}

.hub-formula-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.35;
  word-break: keep-all;
}

.hub-title-note {
  display: inline;
  margin-left: 0.4em;
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--hub-muted);
  white-space: nowrap;
}

.hub-worksheet-desc {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--hub-muted);
  letter-spacing: -0.01em;
  margin-top: -6px;
}

.hub-worksheet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.hub-empty {
  text-align: center;
  color: var(--hub-muted);
  padding: 48px 20px;
  font-size: 0.95rem;
}

/* PDF 뷰어: 화면 대부분을 채우도록 */
#pdf-viewer.modal {
  padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px))
    max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  align-items: stretch;
  justify-content: stretch;
  background: rgba(15, 23, 42, 0.72);
}

#pdf-viewer .modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  min-height: 0;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#pdf-viewer .modal-head {
  flex-shrink: 0;
  height: 52px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

#pdf-viewer .modal-head h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

#pdf-viewer .modal-tools .btn {
  font-size: 0.85rem;
  padding: 8px 14px;
}

#pdf-viewer .pdf-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  max-height: none;
  border: 0;
  background: #525659;
}

.pdf-loading {
  position: absolute;
  inset: 52px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.92);
  font-size: 0.95rem;
  font-weight: 500;
  color: #64748b;
  z-index: 2;
}

.pdf-loading[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .hub-stage-layout {
    flex-direction: column;
  }

  .hub-stage-label {
    width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--hub-line);
    padding: 14px 18px;
    text-align: center;
  }

  .hub-zone-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px 16px 18px;
  }

  .hub-zone-label {
    padding-top: 0;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--hub-line);
  }
}

@media (max-width: 640px) {
  .hub-header {
    padding: 14px 16px 14px 88px;
    min-height: 64px;
  }

  .hub-back {
    left: 12px;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .hub-pdf-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
}
